Skip to content

Commit eba46b5

Browse files
authored
Merge pull request #49328 from alexandertuna/ClusterSizeRequirementRevived
Add cluster size requirement to LST
2 parents e8875c3 + 1963f67 commit eba46b5

File tree

14 files changed

+80
-12
lines changed

14 files changed

+80
-12
lines changed

RecoTracker/LST/plugins/alpaka/LSTInputProducer.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
8181

8282
std::vector<unsigned int> ph2_detId;
8383
ph2_detId.reserve(phase2OTHits.dataSize());
84+
std::vector<uint16_t> ph2_clustSize;
85+
ph2_clustSize.reserve(phase2OTHits.dataSize());
8486
std::vector<float> ph2_x;
8587
ph2_x.reserve(phase2OTHits.dataSize());
8688
std::vector<float> ph2_y;
@@ -94,6 +96,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
9496
const DetId hitId = it.detId();
9597
for (auto const& hit : it) {
9698
ph2_detId.push_back(hitId.rawId());
99+
ph2_clustSize.push_back(hit.cluster()->size());
97100
ph2_x.push_back(hit.globalPosition().x());
98101
ph2_y.push_back(hit.globalPosition().y());
99102
ph2_z.push_back(hit.globalPosition().z());
@@ -213,6 +216,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
213216
see_hitIdx,
214217
{},
215218
ph2_detId,
219+
ph2_clustSize,
216220
ph2_x,
217221
ph2_y,
218222
ph2_z,

RecoTracker/LST/plugins/alpaka/LSTProducer.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
2929
lstESToken_{esConsumes(edm::ESInputTag("", config.getParameter<std::string>("ptCutLabel")))},
3030
verbose_(config.getParameter<bool>("verbose")),
3131
ptCut_(config.getParameter<double>("ptCut")),
32+
clustSizeCut_(static_cast<uint16_t>(config.getParameter<uint32_t>("clustSizeCut"))),
3233
nopLSDupClean_(config.getParameter<bool>("nopLSDupClean")),
3334
tcpLSTriplets_(config.getParameter<bool>("tcpLSTriplets")),
3435
lstOutputToken_{produces()} {}
@@ -42,6 +43,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
4243
lst.run(iEvent.queue(),
4344
verbose_,
4445
static_cast<float>(ptCut_),
46+
clustSizeCut_,
4547
&lstESDeviceData,
4648
&lstInputDC,
4749
nopLSDupClean_,
@@ -57,6 +59,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
5759
desc.add<edm::InputTag>("lstInput", edm::InputTag{"lstInputProducer"});
5860
desc.add<bool>("verbose", false);
5961
desc.add<double>("ptCut", 0.8);
62+
desc.add<uint32_t>("clustSizeCut", 16);
6063
desc.add<std::string>("ptCutLabel", "0.8");
6164
desc.add<bool>("nopLSDupClean", false);
6265
desc.add<bool>("tcpLSTriplets", false);
@@ -68,6 +71,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
6871
const device::ESGetToken<lst::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
6972
const bool verbose_;
7073
const double ptCut_;
74+
const uint16_t clustSizeCut_;
7175
const bool nopLSDupClean_;
7276
const bool tcpLSTriplets_;
7377
const device::EDPutToken<lst::TrackCandidatesBaseDeviceCollection> lstOutputToken_;

RecoTracker/LSTCore/interface/LSTInputSoA.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ namespace lst {
1717
SOA_COLUMN(float, ys),
1818
SOA_COLUMN(float, zs),
1919
SOA_COLUMN(unsigned int, idxs),
20-
SOA_COLUMN(unsigned int, detid)
20+
SOA_COLUMN(unsigned int, detid),
21+
SOA_COLUMN(uint16_t, clustsize)
2122
#ifndef LST_STANDALONE
2223
,
2324
SOA_COLUMN(TrackingRecHit const*, hits)

RecoTracker/LSTCore/interface/LSTPrepareInput.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace lst {
3838
std::vector<std::vector<int>> const& see_hitIdx,
3939
std::vector<unsigned int> const& see_algo,
4040
std::vector<unsigned int> const& ph2_detId,
41+
std::vector<uint16_t> const& ph2_clustSize,
4142
std::vector<float> const& ph2_x,
4243
std::vector<float> const& ph2_y,
4344
std::vector<float> const& ph2_z,
@@ -49,6 +50,7 @@ namespace lst {
4950
std::vector<float> trkX;
5051
std::vector<float> trkY;
5152
std::vector<float> trkZ;
53+
std::vector<uint16_t> hitClustSize;
5254
std::vector<unsigned int> hitId;
5355
std::vector<unsigned int> hitIdxs;
5456
std::vector<Params_pLS::ArrayUxHits> hitIndices_vec;
@@ -86,6 +88,7 @@ namespace lst {
8688
trkX.reserve(4 * n_see);
8789
trkY.reserve(4 * n_see);
8890
trkZ.reserve(4 * n_see);
91+
hitClustSize.reserve(4 * n_see);
8992
hitId.reserve(4 * n_see);
9093
hitIdxs.reserve(hit_size + 4 * n_see);
9194
hitIdxs.resize(hit_size);
@@ -156,11 +159,15 @@ namespace lst {
156159
hitId.push_back(1);
157160
hitId.push_back(1);
158161
hitId.push_back(1);
162+
hitClustSize.push_back(1);
163+
hitClustSize.push_back(1);
164+
hitClustSize.push_back(1);
159165
if (see_hitIdx[iSeed].size() > 3) {
160166
trkX.push_back(r3LH.x());
161167
trkY.push_back(see_dxy[iSeed]);
162168
trkZ.push_back(see_dz[iSeed]);
163169
hitId.push_back(1);
170+
hitClustSize.push_back(1);
164171
}
165172
px_vec.push_back(px);
166173
py_vec.push_back(py);
@@ -214,6 +221,7 @@ namespace lst {
214221
std::memcpy(hits.ys().data(), ph2_y.data(), nHitsOT * sizeof(float));
215222
std::memcpy(hits.zs().data(), ph2_z.data(), nHitsOT * sizeof(float));
216223
std::memcpy(hits.detid().data(), ph2_detId.data(), nHitsOT * sizeof(unsigned int));
224+
std::memcpy(hits.clustsize().data(), ph2_clustSize.data(), nHitsOT * sizeof(uint16_t));
217225
#ifndef LST_STANDALONE
218226
std::memcpy(hits.hits().data(), ph2_hits.data(), nHitsOT * sizeof(TrackingRecHit const*));
219227
#endif
@@ -222,6 +230,7 @@ namespace lst {
222230
std::memcpy(hits.ys().data() + nHitsOT, trkY.data(), nHitsIT * sizeof(float));
223231
std::memcpy(hits.zs().data() + nHitsOT, trkZ.data(), nHitsIT * sizeof(float));
224232
std::memcpy(hits.detid().data() + nHitsOT, hitId.data(), nHitsIT * sizeof(unsigned int));
233+
std::memcpy(hits.clustsize().data() + nHitsOT, hitClustSize.data(), nHitsIT * sizeof(uint16_t));
225234
#ifndef LST_STANDALONE
226235
std::memset(hits.hits().data() + nHitsOT, 0, nHitsIT * sizeof(TrackingRecHit const*));
227236
#endif

RecoTracker/LSTCore/interface/alpaka/LST.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
2020
void run(Queue& queue,
2121
bool verbose,
2222
const float ptCut,
23+
const uint16_t clustSizeCut,
2324
LSTESData<Device> const* deviceESData,
2425
LSTInputDeviceCollection const* lstInputDC,
2526
bool no_pls_dupclean,

RecoTracker/LSTCore/src/alpaka/LST.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ using XYZVector = ROOT::Math::XYZVector;
1111
void LST::run(Queue& queue,
1212
bool verbose,
1313
float const ptCut,
14+
uint16_t const clustSizeCut,
1415
LSTESData<Device> const* deviceESData,
1516
LSTInputDeviceCollection const* lstInputDC,
1617
bool no_pls_dupclean,
1718
bool tc_pls_triplets) {
18-
auto event = LSTEvent(verbose, ptCut, queue, deviceESData);
19+
auto event = LSTEvent(verbose, ptCut, clustSizeCut, queue, deviceESData);
1920

2021
event.addInputToEvent(lstInputDC);
2122
event.addHitToEvent();

RecoTracker/LSTCore/src/alpaka/LSTEvent.dev.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ void LSTEvent::createMiniDoublets() {
239239
miniDoubletsDC_->view<MiniDoubletsSoA>(),
240240
miniDoubletsDC_->view<MiniDoubletsOccupancySoA>(),
241241
rangesDC_->const_view(),
242-
ptCut_);
242+
ptCut_,
243+
clustSizeCut_);
243244

244245
auto const addMiniDoubletRangesToEventExplicit_workDiv = cms::alpakatools::make_workdiv<Acc1D>(1, 1024);
245246

RecoTracker/LSTCore/src/alpaka/LSTEvent.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
4040
private:
4141
Queue& queue_;
4242
const float ptCut_;
43+
const uint16_t clustSizeCut_;
4344

4445
std::array<unsigned int, 6> n_minidoublets_by_layer_barrel_{};
4546
std::array<unsigned int, 5> n_minidoublets_by_layer_endcap_{};
@@ -93,9 +94,11 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
9394

9495
public:
9596
// Constructor used for CMSSW integration. Uses an external queue.
96-
LSTEvent(bool verbose, const float pt_cut, Queue& q, const LSTESData<Device>* deviceESData)
97+
LSTEvent(
98+
bool verbose, const float ptCut, const uint16_t clustSizeCut, Queue& q, const LSTESData<Device>* deviceESData)
9799
: queue_(q),
98-
ptCut_(pt_cut),
100+
ptCut_(ptCut),
101+
clustSizeCut_(clustSizeCut),
99102
nModules_(deviceESData->nModules),
100103
nLowerModules_(deviceESData->nLowerModules),
101104
nPixels_(deviceESData->nPixels),
@@ -104,9 +107,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
104107
pixelMapping_(*deviceESData->pixelMapping),
105108
endcapGeometry_(*deviceESData->endcapGeometry),
106109
addObjects_(verbose) {
107-
if (pt_cut < 0.6f) {
110+
if (ptCut < 0.6f) {
108111
throw std::invalid_argument("Minimum pT cut must be at least 0.6 GeV. Provided value: " +
109-
std::to_string(pt_cut));
112+
std::to_string(ptCut));
110113
}
111114
}
112115
void initSync(); // synchronizes, for standalone usage

RecoTracker/LSTCore/src/alpaka/MiniDoublet.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
622622
float yUpper,
623623
float zUpper,
624624
float rtUpper,
625-
const float ptCut) {
625+
const float ptCut,
626+
uint16_t clustSizeLower,
627+
uint16_t clustSizeUpper,
628+
const uint16_t clustSizeCut) {
629+
if (clustSizeLower > clustSizeCut or clustSizeUpper > clustSizeCut) {
630+
return false;
631+
}
626632
if (modules.subdets()[lowerModuleIndex] == Barrel) {
627633
return runMiniDoubletDefaultAlgoBarrel(acc,
628634
modules,
@@ -683,7 +689,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
683689
MiniDoublets mds,
684690
MiniDoubletsOccupancy mdsOccupancy,
685691
ObjectRangesConst ranges,
686-
const float ptCut) const {
692+
const float ptCut,
693+
const uint16_t clustSizeCut) const {
687694
for (uint16_t lowerModuleIndex : cms::alpakatools::uniform_elements_y(acc, modules.nLowerModules())) {
688695
uint16_t upperModuleIndex = modules.partnerModuleIndices()[lowerModuleIndex];
689696
int nLowerHits = hitsRanges.hitRangesnLower()[lowerModuleIndex];
@@ -711,6 +718,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
711718
float yUpper = hitsBase.ys()[upperHitArrayIndex];
712719
float zUpper = hitsBase.zs()[upperHitArrayIndex];
713720
float rtUpper = hitsExtended.rts()[upperHitArrayIndex];
721+
uint16_t clustSizeLower = hitsBase.clustsize()[lowerHitArrayIndex];
722+
uint16_t clustSizeUpper = hitsBase.clustsize()[upperHitArrayIndex];
714723

715724
float dz, dphi, dphichange, shiftedX, shiftedY, shiftedZ, noShiftedDphi, noShiftedDphiChange;
716725
bool success = runMiniDoubletDefaultAlgo(acc,
@@ -735,7 +744,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
735744
yUpper,
736745
zUpper,
737746
rtUpper,
738-
ptCut);
747+
ptCut,
748+
clustSizeLower,
749+
clustSizeUpper,
750+
clustSizeCut);
739751
if (success) {
740752
int totOccupancyMDs = alpaka::atomicAdd(
741753
acc, &mdsOccupancy.totOccupancyMDs()[lowerModuleIndex], 1u, alpaka::hierarchy::Threads{});

RecoTracker/LSTCore/standalone/bin/lst.cc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int main(int argc, char **argv) {
5656
"o,output", "Output file name", cxxopts::value<std::string>())(
5757
"N,nmatch", "N match for MTV-like matching", cxxopts::value<int>()->default_value("9"))(
5858
"p,ptCut", "Min pT cut In GeV", cxxopts::value<float>()->default_value("0.8"))(
59+
"c,clustSizeCut", "Max cluster size cut", cxxopts::value<uint16_t>()->default_value("16"))(
5960
"n,nevents", "N events to loop over", cxxopts::value<int>()->default_value("-1"))(
6061
"x,event_index", "specific event index to process", cxxopts::value<int>()->default_value("-1"))(
6162
"g,pdg_id", "The simhit pdgId match option", cxxopts::value<int>()->default_value("0"))(
@@ -161,6 +162,10 @@ int main(int argc, char **argv) {
161162
// --ptCut
162163
ana.ptCut = result["ptCut"].as<float>();
163164

165+
//_______________________________________________________________________________
166+
// --clustSizeCut
167+
ana.clustSizeCut = result["clustSizeCut"].as<uint16_t>();
168+
164169
//_______________________________________________________________________________
165170
// --nmatch
166171
ana.nmatch_threshold = result["nmatch"].as<int>();
@@ -312,6 +317,8 @@ int main(int argc, char **argv) {
312317
std::cout << " ana.input_file_list_tstring: " << ana.input_file_list_tstring << std::endl;
313318
std::cout << " ana.output_tfile: " << ana.output_tfile->GetName() << std::endl;
314319
std::cout << " ana.n_events: " << ana.n_events << std::endl;
320+
std::cout << " ana.ptCut: " << ana.ptCut << std::endl;
321+
std::cout << " ana.clustSizeCut: " << ana.clustSizeCut << std::endl;
315322
std::cout << " ana.nsplit_jobs: " << ana.nsplit_jobs << std::endl;
316323
std::cout << " ana.job_index: " << ana.job_index << std::endl;
317324
std::cout << " ana.specific_event_index: " << ana.specific_event_index << std::endl;
@@ -373,6 +380,12 @@ void run_lst() {
373380
std::vector<int> evt_num;
374381
std::vector<TString> file_name;
375382

383+
// Backwards compatibility
384+
const auto hasClustSize = trk.contains("ph2_clustSize");
385+
if (ana.verbose >= 1) {
386+
std::cout << "hasClustSize = " << hasClustSize << std::endl;
387+
}
388+
376389
// Looping input file
377390
full_timer.Reset();
378391
full_timer.Start();
@@ -383,6 +396,10 @@ void run_lst() {
383396
if (not goodEvent())
384397
continue;
385398

399+
// Backwards compatibility
400+
const auto trk_ph2_clustSize =
401+
hasClustSize ? trk.getVUS("ph2_clustSize") : std::vector<uint16_t>(trk.getVF("ph2_x").size());
402+
386403
auto lstInputHC = prepareInput(trk.getVF("see_px"),
387404
trk.getVF("see_py"),
388405
trk.getVF("see_pz"),
@@ -400,6 +417,7 @@ void run_lst() {
400417
trk.getVVI("see_hitIdx"),
401418
trk.getVU("see_algo"),
402419
trk.getVU("ph2_detId"),
420+
trk_ph2_clustSize,
403421
trk.getVF("ph2_x"),
404422
trk.getVF("ph2_y"),
405423
trk.getVF("ph2_z"),
@@ -418,7 +436,7 @@ void run_lst() {
418436
std::vector<LSTEvent *> events;
419437
std::vector<ALPAKA_ACCELERATOR_NAMESPACE::Queue *> event_queues;
420438
for (int s = 0; s < ana.streams; s++) {
421-
LSTEvent *event = new LSTEvent(ana.verbose >= 2, ana.ptCut, queues[s], &deviceESData);
439+
LSTEvent *event = new LSTEvent(ana.verbose >= 2, ana.ptCut, ana.clustSizeCut, queues[s], &deviceESData);
422440
events.push_back(event);
423441
event_queues.push_back(&queues[s]);
424442
}

0 commit comments

Comments
 (0)