Skip to content

Commit

Permalink
Removal of vector copies, as per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
VourMa committed Jul 24, 2024
1 parent 375a06c commit 77e6b9a
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 120 deletions.
3 changes: 2 additions & 1 deletion RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
30 changes: 15 additions & 15 deletions RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/interface/EndcapGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
46 changes: 23 additions & 23 deletions RecoTracker/LSTCore/interface/LST.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,31 @@ namespace lst {
const std::vector<float> ph2_z,
bool no_pls_dupclean,
bool tc_pls_triplets);
std::vector<std::vector<unsigned int>> hits() { return out_tc_hitIdxs_; }
std::vector<unsigned int> len() { return out_tc_len_; }
std::vector<int> seedIdx() { return out_tc_seedIdx_; }
std::vector<short> trackCandidateType() { return out_tc_trackCandidateType_; }
const std::vector<std::vector<unsigned int>>& hits() const { return out_tc_hitIdxs_; }
const std::vector<unsigned int>& len() const { return out_tc_len_; }
const std::vector<int>& seedIdx() const { return out_tc_seedIdx_; }
const std::vector<short>& trackCandidateType() const { return out_tc_trackCandidateType_; }

private:
void prepareInput(const std::vector<float> see_px,
const std::vector<float> see_py,
const std::vector<float> see_pz,
const std::vector<float> see_dxy,
const std::vector<float> see_dz,
const std::vector<float> see_ptErr,
const std::vector<float> see_etaErr,
const std::vector<float> see_stateTrajGlbX,
const std::vector<float> see_stateTrajGlbY,
const std::vector<float> see_stateTrajGlbZ,
const std::vector<float> see_stateTrajGlbPx,
const std::vector<float> see_stateTrajGlbPy,
const std::vector<float> see_stateTrajGlbPz,
const std::vector<int> see_q,
const std::vector<std::vector<int>> see_hitIdx,
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z);
void prepareInput(std::vector<float> const& see_px,
std::vector<float> const& see_py,
std::vector<float> const& see_pz,
std::vector<float> const& see_dxy,
std::vector<float> const& see_dz,
std::vector<float> const& see_ptErr,
std::vector<float> const& see_etaErr,
std::vector<float> const& see_stateTrajGlbX,
std::vector<float> const& see_stateTrajGlbY,
std::vector<float> const& see_stateTrajGlbZ,
std::vector<float> const& see_stateTrajGlbPx,
std::vector<float> const& see_stateTrajGlbPy,
std::vector<float> const& see_stateTrajGlbPz,
std::vector<int> const& see_q,
std::vector<std::vector<int>> const& see_hitIdx,
std::vector<unsigned int> const& ph2_detId,
std::vector<float> const& ph2_x,
std::vector<float> const& ph2_y,
std::vector<float> const& ph2_z);

void getOutput(lst::Event<TAcc>& event);
std::vector<unsigned int> getHitIdxs(const short trackCandidateType,
Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/LSTCore/interface/ModuleConnectionMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>& getConnectedModuleDetIds(unsigned int detid) const;
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/interface/TiltedGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/EndcapGeometry.cc
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
2 changes: 1 addition & 1 deletion RecoTracker/LSTCore/src/LSTESData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/LSTCore/src/ModuleConnectionMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions RecoTracker/LSTCore/src/TiltedGeometry.cc
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
46 changes: 23 additions & 23 deletions RecoTracker/LSTCore/src/alpaka/Event.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ void lst::Event<Acc3D>::resetEvent() {
}
}

void lst::Event<Acc3D>::addHitToEvent(std::vector<float> x,
std::vector<float> y,
std::vector<float> z,
std::vector<unsigned int> detId,
std::vector<unsigned int> idxInNtuple) {
void lst::Event<Acc3D>::addHitToEvent(std::vector<float> const& x,
std::vector<float> const& y,
std::vector<float> const& z,
std::vector<unsigned int> const& detId,
std::vector<unsigned int> const& idxInNtuple) {
// Use the actual number of hits instead of a max.
unsigned int nHits = x.size();

Expand Down Expand Up @@ -217,24 +217,24 @@ void lst::Event<Acc3D>::addHitToEvent(std::vector<float> x,
alpaka::enqueue(queue, module_ranges_task);
}

void lst::Event<Acc3D>::addPixelSegmentToEvent(std::vector<unsigned int> hitIndices0,
std::vector<unsigned int> hitIndices1,
std::vector<unsigned int> hitIndices2,
std::vector<unsigned int> hitIndices3,
std::vector<float> dPhiChange,
std::vector<float> ptIn,
std::vector<float> ptErr,
std::vector<float> px,
std::vector<float> py,
std::vector<float> pz,
std::vector<float> eta,
std::vector<float> etaErr,
std::vector<float> phi,
std::vector<int> charge,
std::vector<unsigned int> seedIdx,
std::vector<int> superbin,
std::vector<int8_t> pixelType,
std::vector<char> isQuad) {
void lst::Event<Acc3D>::addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
std::vector<unsigned int> const& hitIndices1,
std::vector<unsigned int> const& hitIndices2,
std::vector<unsigned int> const& hitIndices3,
std::vector<float> const& dPhiChange,
std::vector<float> const& ptIn,
std::vector<float> const& ptErr,
std::vector<float> const& px,
std::vector<float> const& py,
std::vector<float> const& pz,
std::vector<float> const& eta,
std::vector<float> const& etaErr,
std::vector<float> const& phi,
std::vector<int> const& charge,
std::vector<unsigned int> const& seedIdx,
std::vector<int> const& superbin,
std::vector<int8_t> const& pixelType,
std::vector<char> const& isQuad) {
unsigned int size = ptIn.size();

if (size > n_max_pixel_segments_per_module) {
Expand Down
48 changes: 24 additions & 24 deletions RecoTracker/LSTCore/src/alpaka/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,30 @@ namespace lst {
}
void resetEvent();

void addHitToEvent(
std::vector<float> x,
std::vector<float> y,
std::vector<float> z,
std::vector<unsigned int> detId,
std::vector<unsigned int> idxInNtuple); //call the appropriate hit function, then increment the counter here
void addPixelSegmentToEvent(std::vector<unsigned int> hitIndices0,
std::vector<unsigned int> hitIndices1,
std::vector<unsigned int> hitIndices2,
std::vector<unsigned int> hitIndices3,
std::vector<float> dPhiChange,
std::vector<float> ptIn,
std::vector<float> ptErr,
std::vector<float> px,
std::vector<float> py,
std::vector<float> pz,
std::vector<float> eta,
std::vector<float> etaErr,
std::vector<float> phi,
std::vector<int> charge,
std::vector<unsigned int> seedIdx,
std::vector<int> superbin,
std::vector<int8_t> pixelType,
std::vector<char> isQuad);
void addHitToEvent(std::vector<float> const& x,
std::vector<float> const& y,
std::vector<float> const& z,
std::vector<unsigned int> const& detId,
std::vector<unsigned int> const&
idxInNtuple); //call the appropriate hit function, then increment the counter here
void addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
std::vector<unsigned int> const& hitIndices1,
std::vector<unsigned int> const& hitIndices2,
std::vector<unsigned int> const& hitIndices3,
std::vector<float> const& dPhiChange,
std::vector<float> const& ptIn,
std::vector<float> const& ptErr,
std::vector<float> const& px,
std::vector<float> const& py,
std::vector<float> const& pz,
std::vector<float> const& eta,
std::vector<float> const& etaErr,
std::vector<float> const& phi,
std::vector<int> const& charge,
std::vector<unsigned int> const& seedIdx,
std::vector<int> const& superbin,
std::vector<int8_t> const& pixelType,
std::vector<char> const& isQuad);

// functions that map the objects to the appropriate modules
void addMiniDoubletsToEventExplicit();
Expand Down
38 changes: 19 additions & 19 deletions RecoTracker/LSTCore/src/alpaka/LST.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ namespace {
} // namespace

template <>
void lst::LST<Acc3D>::prepareInput(const std::vector<float> see_px,
const std::vector<float> see_py,
const std::vector<float> see_pz,
const std::vector<float> see_dxy,
const std::vector<float> see_dz,
const std::vector<float> see_ptErr,
const std::vector<float> see_etaErr,
const std::vector<float> see_stateTrajGlbX,
const std::vector<float> see_stateTrajGlbY,
const std::vector<float> see_stateTrajGlbZ,
const std::vector<float> see_stateTrajGlbPx,
const std::vector<float> see_stateTrajGlbPy,
const std::vector<float> see_stateTrajGlbPz,
const std::vector<int> see_q,
const std::vector<std::vector<int>> see_hitIdx,
const std::vector<unsigned int> ph2_detId,
const std::vector<float> ph2_x,
const std::vector<float> ph2_y,
const std::vector<float> ph2_z) {
void lst::LST<Acc3D>::prepareInput(std::vector<float> const& see_px,
std::vector<float> const& see_py,
std::vector<float> const& see_pz,
std::vector<float> const& see_dxy,
std::vector<float> const& see_dz,
std::vector<float> const& see_ptErr,
std::vector<float> const& see_etaErr,
std::vector<float> const& see_stateTrajGlbX,
std::vector<float> const& see_stateTrajGlbY,
std::vector<float> const& see_stateTrajGlbZ,
std::vector<float> const& see_stateTrajGlbPx,
std::vector<float> const& see_stateTrajGlbPy,
std::vector<float> const& see_stateTrajGlbPz,
std::vector<int> const& see_q,
std::vector<std::vector<int>> const& see_hitIdx,
std::vector<unsigned int> const& ph2_detId,
std::vector<float> const& ph2_x,
std::vector<float> const& ph2_y,
std::vector<float> const& ph2_z) {
unsigned int count = 0;
auto n_see = see_stateTrajGlbPx.size();
std::vector<float> px_vec;
Expand Down

0 comments on commit 77e6b9a

Please sign in to comment.