Skip to content

Commit

Permalink
Merge pull request #71 from SegmentLinking/renameClassesRemoveCopies
Browse files Browse the repository at this point in the history
More work on Constants and removal of vector copies
  • Loading branch information
slava77 authored Jul 30, 2024
2 parents 3fc9904 + 944e1b4 commit 24aa3a2
Show file tree
Hide file tree
Showing 31 changed files with 2,045 additions and 2,803 deletions.
13 changes: 9 additions & 4 deletions RecoTracker/LST/interface/LSTOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
class LSTOutput {
public:
LSTOutput() = default;
LSTOutput(std::vector<std::vector<unsigned int>> hitIdx,
std::vector<unsigned int> len,
std::vector<int> seedIdx,
std::vector<short> trackCandidateType) {
LSTOutput(std::vector<std::vector<unsigned int>> const& hitIdx,
std::vector<unsigned int> const& len,
std::vector<int> const& seedIdx,
std::vector<short> const& trackCandidateType) {
hitIdx_ = std::move(hitIdx);
len_ = std::move(len);
seedIdx_ = std::move(seedIdx);
Expand All @@ -21,9 +21,14 @@ class LSTOutput {

enum LSTTCType { T5 = 4, pT3 = 5, pT5 = 7, pLS = 8 };

// Hit indices of each of the LST track candidates.
std::vector<std::vector<unsigned int>> const& hitIdx() const { return hitIdx_; }
// Number of hits of each of the LST track candidates.
std::vector<unsigned int> const& len() const { return len_; }
// Index of the pixel track associated to each of the LST track candidates.
// If not associated to a pixel track, which is the case for T5s, it defaults to -1.
std::vector<int> const& seedIdx() const { return seedIdx_; }
// LSTTCType as per the enum above.
std::vector<short> const& trackCandidateType() const { return trackCandidateType_; }

private:
Expand Down
10 changes: 5 additions & 5 deletions RecoTracker/LST/interface/LSTPhase2OTHitsInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
class LSTPhase2OTHitsInput {
public:
LSTPhase2OTHitsInput() = default;
LSTPhase2OTHitsInput(std::vector<unsigned int> detId,
std::vector<float> x,
std::vector<float> y,
std::vector<float> z,
std::vector<TrackingRecHit const*> hits) {
LSTPhase2OTHitsInput(std::vector<unsigned int> const& detId,
std::vector<float> const& x,
std::vector<float> const& y,
std::vector<float> const& z,
std::vector<TrackingRecHit const*> const& hits) {
detId_ = std::move(detId);
x_ = std::move(x);
y_ = std::move(y);
Expand Down
30 changes: 15 additions & 15 deletions RecoTracker/LST/interface/LSTPixelSeedInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
class LSTPixelSeedInput {
public:
LSTPixelSeedInput() = default;
LSTPixelSeedInput(std::vector<float> px,
std::vector<float> py,
std::vector<float> pz,
std::vector<float> dxy,
std::vector<float> dz,
std::vector<float> ptErr,
std::vector<float> etaErr,
std::vector<float> stateTrajGlbX,
std::vector<float> stateTrajGlbY,
std::vector<float> stateTrajGlbZ,
std::vector<float> stateTrajGlbPx,
std::vector<float> stateTrajGlbPy,
std::vector<float> stateTrajGlbPz,
std::vector<int> q,
std::vector<std::vector<int>> hitIdx) {
LSTPixelSeedInput(std::vector<float> const& px,
std::vector<float> const& py,
std::vector<float> const& pz,
std::vector<float> const& dxy,
std::vector<float> const& dz,
std::vector<float> const& ptErr,
std::vector<float> const& etaErr,
std::vector<float> const& stateTrajGlbX,
std::vector<float> const& stateTrajGlbY,
std::vector<float> const& stateTrajGlbZ,
std::vector<float> const& stateTrajGlbPx,
std::vector<float> const& stateTrajGlbPy,
std::vector<float> const& stateTrajGlbPz,
std::vector<int> const& q,
std::vector<std::vector<int>> const& hitIdx) {
px_ = std::move(px);
py_ = std::move(py);
pz_ = std::move(pz);
Expand Down
8 changes: 4 additions & 4 deletions RecoTracker/LST/plugins/LSTOutputConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ void LSTOutputConverter::produce(edm::StreamID, edm::Event& iEvent, const edm::E
auto const& lstOutput = iEvent.get(lstOutputToken_);
auto const& phase2OTRecHits = iEvent.get(lstPhase2OTHitsInputToken_);
auto const& pixelSeeds = iEvent.get(lstPixelSeedToken_);
const auto& mf = iSetup.getData(mfToken_);
const auto& propAlo = iSetup.getData(propagatorAlongToken_);
const auto& propOppo = iSetup.getData(propagatorOppositeToken_);
const auto& tracker = iSetup.getData(tGeomToken_);
auto const& mf = iSetup.getData(mfToken_);
auto const& propAlo = iSetup.getData(propagatorAlongToken_);
auto const& propOppo = iSetup.getData(propagatorOppositeToken_);
auto const& tracker = iSetup.getData(tGeomToken_);

// Vector definitions
std::vector<std::vector<unsigned int>> const& lstTC_hitIdx = lstOutput.hitIdx();
Expand Down
22 changes: 14 additions & 8 deletions RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,29 @@ void LSTPhase2OTHitsInputProducer::produce(edm::StreamID iID, edm::Event& iEvent

// Vector definitions
std::vector<unsigned int> ph2_detId;
ph2_detId.reserve(phase2OTHits.dataSize());
std::vector<float> ph2_x;
ph2_x.reserve(phase2OTHits.dataSize());
std::vector<float> ph2_y;
ph2_y.reserve(phase2OTHits.dataSize());
std::vector<float> ph2_z;
ph2_z.reserve(phase2OTHits.dataSize());
std::vector<TrackingRecHit const*> ph2_hits;
ph2_hits.reserve(phase2OTHits.dataSize());

for (auto it = phase2OTHits.begin(); it != phase2OTHits.end(); it++) {
const DetId hitId = it->detId();
for (auto hit = it->begin(); hit != it->end(); hit++) {
for (auto const& it : phase2OTHits) {
const DetId hitId = it.detId();
for (auto const& hit : it) {
ph2_detId.push_back(hitId.rawId());
ph2_x.push_back(hit->globalPosition().x());
ph2_y.push_back(hit->globalPosition().y());
ph2_z.push_back(hit->globalPosition().z());
ph2_hits.push_back(hit);
ph2_x.push_back(hit.globalPosition().x());
ph2_y.push_back(hit.globalPosition().y());
ph2_z.push_back(hit.globalPosition().z());
ph2_hits.push_back(&hit);
}
}

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
42 changes: 21 additions & 21 deletions RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void LSTPixelSeedInputProducer::fillDescriptions(edm::ConfigurationDescriptions&

void LSTPixelSeedInputProducer::produce(edm::StreamID iID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
// Setup
const auto& mf = iSetup.getData(mfToken_);
auto const& mf = iSetup.getData(mfToken_);
auto const& bs = iEvent.get(beamSpotToken_);

// Vector definitions
Expand All @@ -83,7 +83,7 @@ void LSTPixelSeedInputProducer::produce(edm::StreamID iID, edm::Event& iEvent, c

for (size_t iColl = 0; iColl < seedTokens_.size(); ++iColl) {
// Get seed tokens
const auto& seedToken = seedTokens_[iColl];
auto const& seedToken = seedTokens_[iColl];
auto const& seedTracks = iEvent.get(seedToken);

if (seedTracks.empty())
Expand All @@ -98,10 +98,10 @@ void LSTPixelSeedInputProducer::produce(edm::StreamID iID, edm::Event& iEvent, c
edm::ProductID id = seedTracks[0].seedRef().id();

for (size_t iSeed = 0; iSeed < seedTrackRefs.size(); ++iSeed) {
const auto& seedTrackRef = seedTrackRefs[iSeed];
const auto& seedTrack = *seedTrackRef;
const auto& seedRef = seedTrack.seedRef();
const auto& seed = *seedRef;
auto const& seedTrackRef = seedTrackRefs[iSeed];
auto const& seedTrack = *seedTrackRef;
auto const& seedRef = seedTrack.seedRef();
auto const& seed = *seedRef;

if (seedRef.id() != id)
throw cms::Exception("LogicError")
Expand Down 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
6 changes: 3 additions & 3 deletions RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace lst {
const float* geoMapPhi;

template <typename TBuff>
void setData(const TBuff& buf) {
void setData(TBuff const& buf) {
geoMapDetId = alpaka::getPtrNative(buf.geoMapDetId_buf);
geoMapPhi = alpaka::getPtrNative(buf.geoMapPhi_buf);
}
Expand All @@ -37,13 +37,13 @@ namespace lst {
}

template <typename TQueue, typename TDevSrc>
inline void copyFromSrc(TQueue queue, const EndcapGeometryBuffer<TDevSrc>& src) {
inline void copyFromSrc(TQueue queue, EndcapGeometryBuffer<TDevSrc> const& src) {
alpaka::memcpy(queue, geoMapDetId_buf, src.geoMapDetId_buf);
alpaka::memcpy(queue, geoMapPhi_buf, src.geoMapPhi_buf);
}

template <typename TQueue, typename TDevSrc>
EndcapGeometryBuffer(TQueue queue, const EndcapGeometryBuffer<TDevSrc>& src, unsigned int nEndCapMap)
EndcapGeometryBuffer(TQueue queue, EndcapGeometryBuffer<TDevSrc> const& src, unsigned int nEndCapMap)
: EndcapGeometryBuffer(alpaka::getDev(queue), nEndCapMap) {
copyFromSrc(queue, src);
}
Expand Down
94 changes: 47 additions & 47 deletions RecoTracker/LSTCore/interface/LST.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,59 +23,59 @@ namespace lst {
template <typename TQueue>
void run(TQueue& queue,
bool verbose,
const LSTESData<alpaka::Dev<TAcc>>* deviceESData,
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,
LSTESData<alpaka::Dev<TAcc>> const* deviceESData,
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,
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_; }
std::vector<std::vector<unsigned int>> const& hits() const { return out_tc_hitIdxs_; }
std::vector<unsigned int> const& len() const { return out_tc_len_; }
std::vector<int> const& seedIdx() const { return out_tc_seedIdx_; }
std::vector<short> const& 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,
const unsigned int TCIdx,
const unsigned int* TCHitIndices,
const unsigned int* hitIndices);
std::vector<unsigned int> getHitIdxs(short trackCandidateType,
unsigned int TCIdx,
unsigned int const* TCHitIndices,
unsigned int const* hitIndices);

// Input and output vectors
std::vector<float> in_trkX_;
Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/LSTCore/interface/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace lst {
};

template <typename TBuff>
void setData(const TBuff& buf) {
void setData(TBuff const& buf) {
detIds = alpaka::getPtrNative(buf.detIds_buf);
moduleMap = alpaka::getPtrNative(buf.moduleMap_buf);
mapdetId = alpaka::getPtrNative(buf.mapdetId_buf);
Expand Down Expand Up @@ -175,7 +175,7 @@ namespace lst {
}

template <typename TQueue, typename TDevSrc>
inline void copyFromSrc(TQueue queue, const ModulesBuffer<TDevSrc>& src, bool isFull = true) {
inline void copyFromSrc(TQueue queue, ModulesBuffer<TDevSrc> const& src, bool isFull = true) {
alpaka::memcpy(queue, detIds_buf, src.detIds_buf);
if (isFull) {
alpaka::memcpy(queue, moduleMap_buf, src.moduleMap_buf);
Expand Down Expand Up @@ -216,7 +216,7 @@ namespace lst {
}

template <typename TQueue, typename TDevSrc>
ModulesBuffer(TQueue queue, const ModulesBuffer<TDevSrc>& src, unsigned int nMod, unsigned int nPixs)
ModulesBuffer(TQueue queue, ModulesBuffer<TDevSrc> const& src, unsigned int nMod, unsigned int nPixs)
: ModulesBuffer(alpaka::getDev(queue), nMod, nPixs) {
copyFromSrc(queue, src);
}
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
Loading

0 comments on commit 24aa3a2

Please sign in to comment.