From 77e6b9a450853457ea6e351da5ac39ae94350ff3 Mon Sep 17 00:00:00 2001 From: Manos Vourliotis Date: Wed, 24 Jul 2024 09:44:52 -0700 Subject: [PATCH] Removal of vector copies, as per comments --- .../plugins/LSTPhase2OTHitsInputProducer.cc | 3 +- .../LST/plugins/LSTPixelSeedInputProducer.cc | 30 ++++++------ .../LSTCore/interface/EndcapGeometry.h | 4 +- RecoTracker/LSTCore/interface/LST.h | 46 +++++++++--------- .../LSTCore/interface/ModuleConnectionMap.h | 6 +-- .../LSTCore/interface/TiltedGeometry.h | 4 +- RecoTracker/LSTCore/src/EndcapGeometry.cc | 4 +- RecoTracker/LSTCore/src/LSTESData.cc | 2 +- .../LSTCore/src/ModuleConnectionMap.cc | 6 +-- RecoTracker/LSTCore/src/TiltedGeometry.cc | 4 +- RecoTracker/LSTCore/src/alpaka/Event.dev.cc | 46 +++++++++--------- RecoTracker/LSTCore/src/alpaka/Event.h | 48 +++++++++---------- RecoTracker/LSTCore/src/alpaka/LST.dev.cc | 38 +++++++-------- 13 files changed, 121 insertions(+), 120 deletions(-) diff --git a/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc b/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc index 4b0d797db0d4f..02d6e76018cca 100644 --- a/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc +++ b/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc @@ -55,7 +55,8 @@ void LSTPhase2OTHitsInputProducer::produce(edm::StreamID iID, edm::Event& iEvent } } - LSTPhase2OTHitsInput phase2OTHitsInput(ph2_detId, ph2_x, ph2_y, ph2_z, ph2_hits); + LSTPhase2OTHitsInput phase2OTHitsInput( + std::move(ph2_detId), std::move(ph2_x), std::move(ph2_y), std::move(ph2_z), std::move(ph2_hits)); iEvent.emplace(lstPhase2OTHitsInputPutToken_, std::move(phase2OTHitsInput)); } diff --git a/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc b/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc index b4f42476b1ce9..2839270c9b59e 100644 --- a/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc +++ b/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc @@ -149,21 +149,21 @@ void LSTPixelSeedInputProducer::produce(edm::StreamID iID, edm::Event& iEvent, c } } - LSTPixelSeedInput pixelSeedInput(see_px, - see_py, - see_pz, - see_dxy, - see_dz, - see_ptErr, - see_etaErr, - see_stateTrajGlbX, - see_stateTrajGlbY, - see_stateTrajGlbZ, - see_stateTrajGlbPx, - see_stateTrajGlbPy, - see_stateTrajGlbPz, - see_q, - see_hitIdx); + LSTPixelSeedInput pixelSeedInput(std::move(see_px), + std::move(see_py), + std::move(see_pz), + std::move(see_dxy), + std::move(see_dz), + std::move(see_ptErr), + std::move(see_etaErr), + std::move(see_stateTrajGlbX), + std::move(see_stateTrajGlbY), + std::move(see_stateTrajGlbZ), + std::move(see_stateTrajGlbPx), + std::move(see_stateTrajGlbPy), + std::move(see_stateTrajGlbPz), + std::move(see_q), + std::move(see_hitIdx)); iEvent.emplace(lstPixelSeedInputPutToken_, std::move(pixelSeedInput)); iEvent.emplace(lstPixelSeedsPutToken_, std::move(see_seeds)); } diff --git a/RecoTracker/LSTCore/interface/EndcapGeometry.h b/RecoTracker/LSTCore/interface/EndcapGeometry.h index 09bab83238754..555955d83941c 100644 --- a/RecoTracker/LSTCore/interface/EndcapGeometry.h +++ b/RecoTracker/LSTCore/interface/EndcapGeometry.h @@ -22,10 +22,10 @@ namespace lst { unsigned int nEndCapMap; EndcapGeometry() = default; - EndcapGeometry(std::string filename); + EndcapGeometry(std::string const& filename); ~EndcapGeometry() = default; - void load(std::string); + void load(std::string const&); void fillGeoMapArraysExplicit(); float getdxdy_slope(unsigned int detid) const; }; diff --git a/RecoTracker/LSTCore/interface/LST.h b/RecoTracker/LSTCore/interface/LST.h index cb5d8c912166c..f5b32b295c17c 100644 --- a/RecoTracker/LSTCore/interface/LST.h +++ b/RecoTracker/LSTCore/interface/LST.h @@ -45,31 +45,31 @@ namespace lst { const std::vector ph2_z, bool no_pls_dupclean, bool tc_pls_triplets); - std::vector> hits() { return out_tc_hitIdxs_; } - std::vector len() { return out_tc_len_; } - std::vector seedIdx() { return out_tc_seedIdx_; } - std::vector trackCandidateType() { return out_tc_trackCandidateType_; } + const std::vector>& hits() const { return out_tc_hitIdxs_; } + const std::vector& len() const { return out_tc_len_; } + const std::vector& seedIdx() const { return out_tc_seedIdx_; } + const std::vector& trackCandidateType() const { return out_tc_trackCandidateType_; } private: - void prepareInput(const std::vector see_px, - const std::vector see_py, - const std::vector see_pz, - const std::vector see_dxy, - const std::vector see_dz, - const std::vector see_ptErr, - const std::vector see_etaErr, - const std::vector see_stateTrajGlbX, - const std::vector see_stateTrajGlbY, - const std::vector see_stateTrajGlbZ, - const std::vector see_stateTrajGlbPx, - const std::vector see_stateTrajGlbPy, - const std::vector see_stateTrajGlbPz, - const std::vector see_q, - const std::vector> see_hitIdx, - const std::vector ph2_detId, - const std::vector ph2_x, - const std::vector ph2_y, - const std::vector ph2_z); + void prepareInput(std::vector const& see_px, + std::vector const& see_py, + std::vector const& see_pz, + std::vector const& see_dxy, + std::vector const& see_dz, + std::vector const& see_ptErr, + std::vector const& see_etaErr, + std::vector const& see_stateTrajGlbX, + std::vector const& see_stateTrajGlbY, + std::vector const& see_stateTrajGlbZ, + std::vector const& see_stateTrajGlbPx, + std::vector const& see_stateTrajGlbPy, + std::vector const& see_stateTrajGlbPz, + std::vector const& see_q, + std::vector> const& see_hitIdx, + std::vector const& ph2_detId, + std::vector const& ph2_x, + std::vector const& ph2_y, + std::vector const& ph2_z); void getOutput(lst::Event& event); std::vector getHitIdxs(const short trackCandidateType, diff --git a/RecoTracker/LSTCore/interface/ModuleConnectionMap.h b/RecoTracker/LSTCore/interface/ModuleConnectionMap.h index 99600faeece13..b3a931345b3a5 100644 --- a/RecoTracker/LSTCore/interface/ModuleConnectionMap.h +++ b/RecoTracker/LSTCore/interface/ModuleConnectionMap.h @@ -15,11 +15,11 @@ namespace lst { public: ModuleConnectionMap(); - ModuleConnectionMap(std::string filename); + ModuleConnectionMap(std::string const& filename); ~ModuleConnectionMap(); - void load(std::string); - void add(std::string); + void load(std::string const&); + void add(std::string const&); void print(); const std::vector& getConnectedModuleDetIds(unsigned int detid) const; diff --git a/RecoTracker/LSTCore/interface/TiltedGeometry.h b/RecoTracker/LSTCore/interface/TiltedGeometry.h index 6a8c6bab902b8..b70a1d95a357b 100644 --- a/RecoTracker/LSTCore/interface/TiltedGeometry.h +++ b/RecoTracker/LSTCore/interface/TiltedGeometry.h @@ -17,10 +17,10 @@ namespace lst { public: TiltedGeometry() = default; - TiltedGeometry(std::string filename); + TiltedGeometry(std::string const& filename); ~TiltedGeometry() = default; - void load(std::string); + void load(std::string const&); float getDrDz(unsigned int detid) const; float getDxDy(unsigned int detid) const; diff --git a/RecoTracker/LSTCore/src/EndcapGeometry.cc b/RecoTracker/LSTCore/src/EndcapGeometry.cc index cf659f38246b8..a95e8c34de248 100644 --- a/RecoTracker/LSTCore/src/EndcapGeometry.cc +++ b/RecoTracker/LSTCore/src/EndcapGeometry.cc @@ -1,8 +1,8 @@ #include "RecoTracker/LSTCore/interface/EndcapGeometry.h" -lst::EndcapGeometry::EndcapGeometry(std::string filename) { load(filename); } +lst::EndcapGeometry::EndcapGeometry(std::string const& filename) { load(filename); } -void lst::EndcapGeometry::load(std::string filename) { +void lst::EndcapGeometry::load(std::string const& filename) { dxdy_slope_.clear(); centroid_phis_.clear(); diff --git a/RecoTracker/LSTCore/src/LSTESData.cc b/RecoTracker/LSTCore/src/LSTESData.cc index 414834e78c70c..c4a255f61f8cc 100644 --- a/RecoTracker/LSTCore/src/LSTESData.cc +++ b/RecoTracker/LSTCore/src/LSTESData.cc @@ -30,7 +30,7 @@ namespace { return path_str; } - std::string get_absolute_path_after_check_file_exists(const std::string name) { + std::string get_absolute_path_after_check_file_exists(std::string const& name) { std::filesystem::path fullpath = std::filesystem::absolute(name.c_str()); if (not std::filesystem::exists(fullpath)) { std::cout << "ERROR: Could not find the file = " << fullpath << std::endl; diff --git a/RecoTracker/LSTCore/src/ModuleConnectionMap.cc b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc index 3049399b92386..732b8e155fb4e 100644 --- a/RecoTracker/LSTCore/src/ModuleConnectionMap.cc +++ b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc @@ -2,11 +2,11 @@ lst::ModuleConnectionMap::ModuleConnectionMap() {} -lst::ModuleConnectionMap::ModuleConnectionMap(std::string filename) { load(filename); } +lst::ModuleConnectionMap::ModuleConnectionMap(std::string const& filename) { load(filename); } lst::ModuleConnectionMap::~ModuleConnectionMap() {} -void lst::ModuleConnectionMap::load(std::string filename) { +void lst::ModuleConnectionMap::load(std::string const& filename) { moduleConnections_.clear(); std::ifstream ifile(filename, std::ios::binary); @@ -49,7 +49,7 @@ void lst::ModuleConnectionMap::load(std::string filename) { } } -void lst::ModuleConnectionMap::add(std::string filename) { +void lst::ModuleConnectionMap::add(std::string const& filename) { std::ifstream ifile; ifile.open(filename.c_str()); std::string line; diff --git a/RecoTracker/LSTCore/src/TiltedGeometry.cc b/RecoTracker/LSTCore/src/TiltedGeometry.cc index a68a9e223f45b..96db807240f69 100644 --- a/RecoTracker/LSTCore/src/TiltedGeometry.cc +++ b/RecoTracker/LSTCore/src/TiltedGeometry.cc @@ -1,8 +1,8 @@ #include "RecoTracker/LSTCore/interface/TiltedGeometry.h" -lst::TiltedGeometry::TiltedGeometry(std::string filename) { load(filename); } +lst::TiltedGeometry::TiltedGeometry(std::string const& filename) { load(filename); } -void lst::TiltedGeometry::load(std::string filename) { +void lst::TiltedGeometry::load(std::string const& filename) { drdzs_.clear(); dxdys_.clear(); diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc index 1ac2cc9cf0487..b2fa20e03fae9 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc @@ -150,11 +150,11 @@ void lst::Event::resetEvent() { } } -void lst::Event::addHitToEvent(std::vector x, - std::vector y, - std::vector z, - std::vector detId, - std::vector idxInNtuple) { +void lst::Event::addHitToEvent(std::vector const& x, + std::vector const& y, + std::vector const& z, + std::vector const& detId, + std::vector const& idxInNtuple) { // Use the actual number of hits instead of a max. unsigned int nHits = x.size(); @@ -217,24 +217,24 @@ void lst::Event::addHitToEvent(std::vector x, alpaka::enqueue(queue, module_ranges_task); } -void lst::Event::addPixelSegmentToEvent(std::vector hitIndices0, - std::vector hitIndices1, - std::vector hitIndices2, - std::vector hitIndices3, - std::vector dPhiChange, - std::vector ptIn, - std::vector ptErr, - std::vector px, - std::vector py, - std::vector pz, - std::vector eta, - std::vector etaErr, - std::vector phi, - std::vector charge, - std::vector seedIdx, - std::vector superbin, - std::vector pixelType, - std::vector isQuad) { +void lst::Event::addPixelSegmentToEvent(std::vector const& hitIndices0, + std::vector const& hitIndices1, + std::vector const& hitIndices2, + std::vector const& hitIndices3, + std::vector const& dPhiChange, + std::vector const& ptIn, + std::vector const& ptErr, + std::vector const& px, + std::vector const& py, + std::vector const& pz, + std::vector const& eta, + std::vector const& etaErr, + std::vector const& phi, + std::vector const& charge, + std::vector const& seedIdx, + std::vector const& superbin, + std::vector const& pixelType, + std::vector const& isQuad) { unsigned int size = ptIn.size(); if (size > n_max_pixel_segments_per_module) { diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/Event.h index 57c99123e2ee1..e947d40dd0d56 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/Event.h @@ -109,30 +109,30 @@ namespace lst { } void resetEvent(); - void addHitToEvent( - std::vector x, - std::vector y, - std::vector z, - std::vector detId, - std::vector idxInNtuple); //call the appropriate hit function, then increment the counter here - void addPixelSegmentToEvent(std::vector hitIndices0, - std::vector hitIndices1, - std::vector hitIndices2, - std::vector hitIndices3, - std::vector dPhiChange, - std::vector ptIn, - std::vector ptErr, - std::vector px, - std::vector py, - std::vector pz, - std::vector eta, - std::vector etaErr, - std::vector phi, - std::vector charge, - std::vector seedIdx, - std::vector superbin, - std::vector pixelType, - std::vector isQuad); + void addHitToEvent(std::vector const& x, + std::vector const& y, + std::vector const& z, + std::vector const& detId, + std::vector const& + idxInNtuple); //call the appropriate hit function, then increment the counter here + void addPixelSegmentToEvent(std::vector const& hitIndices0, + std::vector const& hitIndices1, + std::vector const& hitIndices2, + std::vector const& hitIndices3, + std::vector const& dPhiChange, + std::vector const& ptIn, + std::vector const& ptErr, + std::vector const& px, + std::vector const& py, + std::vector const& pz, + std::vector const& eta, + std::vector const& etaErr, + std::vector const& phi, + std::vector const& charge, + std::vector const& seedIdx, + std::vector const& superbin, + std::vector const& pixelType, + std::vector const& isQuad); // functions that map the objects to the appropriate modules void addMiniDoubletsToEventExplicit(); diff --git a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc b/RecoTracker/LSTCore/src/alpaka/LST.dev.cc index c03007b3d273c..6c3f2f5f34945 100644 --- a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/LST.dev.cc @@ -20,25 +20,25 @@ namespace { } // namespace template <> -void lst::LST::prepareInput(const std::vector see_px, - const std::vector see_py, - const std::vector see_pz, - const std::vector see_dxy, - const std::vector see_dz, - const std::vector see_ptErr, - const std::vector see_etaErr, - const std::vector see_stateTrajGlbX, - const std::vector see_stateTrajGlbY, - const std::vector see_stateTrajGlbZ, - const std::vector see_stateTrajGlbPx, - const std::vector see_stateTrajGlbPy, - const std::vector see_stateTrajGlbPz, - const std::vector see_q, - const std::vector> see_hitIdx, - const std::vector ph2_detId, - const std::vector ph2_x, - const std::vector ph2_y, - const std::vector ph2_z) { +void lst::LST::prepareInput(std::vector const& see_px, + std::vector const& see_py, + std::vector const& see_pz, + std::vector const& see_dxy, + std::vector const& see_dz, + std::vector const& see_ptErr, + std::vector const& see_etaErr, + std::vector const& see_stateTrajGlbX, + std::vector const& see_stateTrajGlbY, + std::vector const& see_stateTrajGlbZ, + std::vector const& see_stateTrajGlbPx, + std::vector const& see_stateTrajGlbPy, + std::vector const& see_stateTrajGlbPz, + std::vector const& see_q, + std::vector> const& see_hitIdx, + std::vector const& ph2_detId, + std::vector const& ph2_x, + std::vector const& ph2_y, + std::vector const& ph2_z) { unsigned int count = 0; auto n_see = see_stateTrajGlbPx.size(); std::vector px_vec;