Skip to content

Commit

Permalink
Merge pull request #66 from SegmentLinking/CMSSW_14_1_0_pre3_LST_X_LS…
Browse files Browse the repository at this point in the history
…TCore_realfiles_batch4

Batch 4 for updates to LST integration in cms-sw
  • Loading branch information
slava77 authored Aug 2, 2024
2 parents 1d9b396 + ecd8e3e commit 4cd5974
Show file tree
Hide file tree
Showing 76 changed files with 5,441 additions and 6,169 deletions.
6 changes: 3 additions & 3 deletions Configuration/PyReleaseValidation/python/relval_2026.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
numWFIB.extend([30834.0]) #2026D113
numWFIB.extend([31234.0]) #2026D114

# Temporary placement for LST workflow to workaround PR conflicts - to be formatted and placed in an upcoming PR
numWFIB.extend([24834.703,24834.704]) #2026D98 LST tracking (initialStep+HighPtTripletStep only): CPU, GPU

#Additional sample for short matrix and IB
#Default Phase-2 Det NoPU
numWFIB.extend([prefixDet+34.911]) #DD4hep XML
Expand All @@ -62,8 +65,5 @@
numWFIB.extend([prefixDet+234.9921]) #prodlike premix stage1+stage2
numWFIB.extend([prefixDet+234.114]) #PU, with 10% OT inefficiency

# Temporary placement for LST workflow to workaround PR conflicts - to be formatted and placed in an upcoming PR
numWFIB.extend([24834.703,24834.704]) #2026D98 LST tracking (initialStep+HighPtTripletStep only): CPU, GPU

for numWF in numWFIB:
workflows[numWF] = _upgrade_workflows[numWF]
2 changes: 1 addition & 1 deletion RecoTracker/FinalTrackSelectors/plugins/TrackListMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void TrackListMerger::produce(edm::Event& e, const edm::EventSetup& es) {
}

//DL here
if LIKELY (ngood > 0 && collsSize > 0)
if LIKELY (ngood > 1 && collsSize > 1)
for (unsigned int ltm = 0; ltm < listsToMerge_.size(); ltm++) {
int saveSelected[rSize];
bool notActive[collsSize];
Expand Down
1 change: 0 additions & 1 deletion RecoTracker/LST/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<use name="DataFormats/TrackerRecHit2D"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<use name="RecoTracker/LSTCore"/>
<flags CXXFLAGS="-DLST_IS_CMSSW_PACKAGE"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
Expand Down
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
8 changes: 4 additions & 4 deletions RecoTracker/LST/plugins/alpaka/LSTModulesDevESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"

// LST includes
#include "RecoTracker/LSTCore/interface/alpaka/Module.h"
#include "RecoTracker/LSTCore/interface/alpaka/LST.h"
#include "RecoTracker/LSTCore/interface/Module.h"
#include "RecoTracker/LSTCore/interface/LST.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

Expand All @@ -22,8 +22,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
descriptions.addWithDefaultLabel(desc);
}

std::unique_ptr<SDL::LSTESData<SDL::DevHost>> produce(TrackerRecoGeometryRecord const& iRecord) {
return SDL::loadAndFillESHost();
std::unique_ptr<lst::LSTESData<DevHost>> produce(TrackerRecoGeometryRecord const& iRecord) {
return lst::loadAndFillESHost();
}
};

Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/LST/plugins/alpaka/LSTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"

#include "RecoTracker/LSTCore/interface/alpaka/LST.h"
#include "RecoTracker/LSTCore/interface/LST.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

Expand Down Expand Up @@ -87,11 +87,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
private:
edm::EDGetTokenT<LSTPixelSeedInput> lstPixelSeedInputToken_;
edm::EDGetTokenT<LSTPhase2OTHitsInput> lstPhase2OTHitsInputToken_;
device::ESGetToken<SDL::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
device::ESGetToken<lst::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
const bool verbose_, nopLSDupClean_, tcpLSTriplets_;
edm::EDPutTokenT<LSTOutput> lstOutputToken_;

SDL::LST<SDL::Acc> lst_;
lst::LST<Acc3D> lst_;
};

} // namespace ALPAKA_ACCELERATOR_NAMESPACE
Expand Down
5 changes: 5 additions & 0 deletions RecoTracker/LST/src/ES_ModulesDev.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "RecoTracker/LSTCore/interface/LSTESData.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(lst::LSTESData<alpaka_common::DevHost>);
7 changes: 2 additions & 5 deletions RecoTracker/LST/src/alpaka/ES_ModulesDev.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include "RecoTracker/LSTCore/interface/alpaka/LST.h"
#include "RecoTracker/LSTCore/interface/LSTESData.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/typelookup.h"

// Temporary hack: The DevHost instantiation is needed in both CPU and GPU plugins,
// whereas the (non-host-)Device instantiation only in the GPU plugin
TYPELOOKUP_DATA_REG(SDL::LSTESData<SDL::DevHost>);
TYPELOOKUP_ALPAKA_TEMPLATED_DATA_REG(SDL::LSTESData);
TYPELOOKUP_ALPAKA_TEMPLATED_DATA_REG(lst::LSTESData);
1 change: 1 addition & 0 deletions RecoTracker/LSTCore/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<use name="root"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<flags CXXFLAGS="-DCACHE_ALLOC -DT4FromT3 -DUSE_RZCHI2 -DUSE_T5_DNN -DPT_CUT=0.8 -DDUP_pLS -DDUP_T5 -DDUP_pT5 -DDUP_pT3 -DCrossclean_T5 -DCrossclean_pT3"/>
<use name="1" for="alpaka"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
Expand Down
80 changes: 80 additions & 0 deletions RecoTracker/LSTCore/interface/Constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#ifndef RecoTracker_LSTCore_interface_Constants_h
#define RecoTracker_LSTCore_interface_Constants_h

#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

#ifdef CACHE_ALLOC
#include "HeterogeneousCore/AlpakaInterface/interface/CachedBufAlloc.h"
#endif

namespace lst {

// Buffer type for allocations where auto type can't be used.
template <typename TDev, typename TData>
using Buf = alpaka::Buf<TDev, TData, alpaka_common::Dim1D, alpaka_common::Idx>;

// Allocation wrapper function to make integration of the caching allocator easier and reduce code boilerplate.
template <typename T, typename TAcc, typename TSize, typename TQueue>
ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf<alpaka::Dev<TAcc>, T> allocBufWrapper(TAcc const& devAccIn,
TSize nElements,
TQueue queue) {
#ifdef CACHE_ALLOC
return cms::alpakatools::allocCachedBuf<T, alpaka_common::Idx>(
devAccIn, queue, alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
#else
return alpaka::allocBuf<T, alpaka_common::Idx>(devAccIn,
alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
#endif
}

// Second allocation wrapper function when queue is not given. Reduces code boilerplate.
template <typename T, typename TAcc, typename TSize>
ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf<alpaka::Dev<TAcc>, T> allocBufWrapper(TAcc const& devAccIn, TSize nElements) {
return alpaka::allocBuf<T, alpaka_common::Idx>(devAccIn,
alpaka_common::Vec1D(static_cast<alpaka_common::Idx>(nElements)));
}

// If a compile time flag does not define PT_CUT, default to 0.8 (GeV)
#ifndef PT_CUT
constexpr float PT_CUT = 0.8f;
#endif

constexpr unsigned int max_blocks = 80;
constexpr unsigned int max_connected_modules = 40;

constexpr unsigned int n_max_pixel_segments_per_module = 50000;

constexpr unsigned int n_max_pixel_md_per_modules = 2 * n_max_pixel_segments_per_module;

constexpr unsigned int n_max_pixel_triplets = 5000;
constexpr unsigned int n_max_pixel_quintuplets = 15000;

constexpr unsigned int n_max_pixel_track_candidates = 30000;
constexpr unsigned int n_max_nonpixel_track_candidates = 1000;

constexpr unsigned int size_superbins = 45000;

//defining the constant host device variables right up here
// Currently pixel tracks treated as LSs with 2 double layers (IT layers 1+2 and 3+4) and 4 hits. To be potentially handled better in the future.
struct Params_pLS {
static constexpr int kLayers = 2, kHits = 4;
};
struct Params_LS {
static constexpr int kLayers = 2, kHits = 4;
};
struct Params_T3 {
static constexpr int kLayers = 3, kHits = 6;
};
struct Params_pT3 {
static constexpr int kLayers = 5, kHits = 10;
};
struct Params_T5 {
static constexpr int kLayers = 5, kHits = 10;
};
struct Params_pT5 {
static constexpr int kLayers = 7, kHits = 14;
};

} //namespace lst

#endif
Loading

0 comments on commit 4cd5974

Please sign in to comment.