File indexing completed on 2024-11-19 23:20:26
0001 #include "AccessHelper.h"
0002
0003 using namespace ALPAKA_ACCELERATOR_NAMESPACE::lst;
0004
0005
0006
0007
0008
0009
0010 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> convertHitsToHitIdxsAndHitTypes(
0011 LSTEvent* event, std::vector<unsigned int> hits) {
0012 auto hitsEvt = event->getHits<HitsSoA>();
0013 std::vector<unsigned int> hitidxs;
0014 std::vector<unsigned int> hittypes;
0015 for (auto& hit : hits) {
0016 hitidxs.push_back(hitsEvt.idxs()[hit]);
0017 if (hitsEvt.detid()[hit] == 1)
0018 hittypes.push_back(0);
0019 else
0020 hittypes.push_back(4);
0021 }
0022 return std::make_tuple(hitidxs, hittypes);
0023 }
0024
0025
0026
0027
0028
0029
0030 std::vector<unsigned int> getPixelHitsFrompLS(LSTEvent* event, unsigned int pLS) {
0031 SegmentsConst segments = event->getSegments<SegmentsSoA>();
0032 MiniDoubletsConst miniDoublets = event->getMiniDoublets<MiniDoubletsSoA>();
0033 auto ranges = event->getRanges();
0034 auto modulesEvt = event->getModules<ModulesSoA>();
0035 const unsigned int pLS_offset = ranges.segmentModuleIndices()[modulesEvt.nLowerModules()];
0036 unsigned int MD_1 = segments.mdIndices()[pLS + pLS_offset][0];
0037 unsigned int MD_2 = segments.mdIndices()[pLS + pLS_offset][1];
0038 unsigned int hit_1 = miniDoublets.anchorHitIndices()[MD_1];
0039 unsigned int hit_2 = miniDoublets.outerHitIndices()[MD_1];
0040 unsigned int hit_3 = miniDoublets.anchorHitIndices()[MD_2];
0041 unsigned int hit_4 = miniDoublets.outerHitIndices()[MD_2];
0042 if (hit_3 == hit_4)
0043 return {hit_1, hit_2, hit_3};
0044 else
0045 return {hit_1, hit_2, hit_3, hit_4};
0046 }
0047
0048
0049 std::vector<unsigned int> getPixelHitIdxsFrompLS(LSTEvent* event, unsigned int pLS) {
0050 auto hitsEvt = event->getHits<HitsSoA>();
0051 std::vector<unsigned int> hits = getPixelHitsFrompLS(event, pLS);
0052 std::vector<unsigned int> hitidxs;
0053 for (auto& hit : hits)
0054 hitidxs.push_back(hitsEvt.idxs()[hit]);
0055 return hitidxs;
0056 }
0057
0058
0059 std::vector<unsigned int> getPixelHitTypesFrompLS(LSTEvent* event, unsigned int pLS) {
0060 std::vector<unsigned int> hits = getPixelHitsFrompLS(event, pLS);
0061 std::vector<unsigned int> hittypes(hits.size(), 0);
0062 return hittypes;
0063 }
0064
0065
0066 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompLS(LSTEvent* event,
0067 unsigned pLS) {
0068 return convertHitsToHitIdxsAndHitTypes(event, getPixelHitsFrompLS(event, pLS));
0069 }
0070
0071
0072
0073
0074
0075
0076 std::vector<unsigned int> getHitsFromMD(LSTEvent* event, unsigned int MD) {
0077 MiniDoubletsConst miniDoublets = event->getMiniDoublets<MiniDoubletsSoA>();
0078 unsigned int hit_1 = miniDoublets.anchorHitIndices()[MD];
0079 unsigned int hit_2 = miniDoublets.outerHitIndices()[MD];
0080 return {hit_1, hit_2};
0081 }
0082
0083
0084 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromMD(LSTEvent* event,
0085 unsigned MD) {
0086 return convertHitsToHitIdxsAndHitTypes(event, getHitsFromMD(event, MD));
0087 }
0088
0089
0090
0091
0092
0093
0094 std::vector<unsigned int> getMDsFromLS(LSTEvent* event, unsigned int LS) {
0095 SegmentsConst segments = event->getSegments<SegmentsSoA>();
0096 unsigned int MD_1 = segments.mdIndices()[LS][0];
0097 unsigned int MD_2 = segments.mdIndices()[LS][1];
0098 return {MD_1, MD_2};
0099 }
0100
0101
0102 std::vector<unsigned int> getHitsFromLS(LSTEvent* event, unsigned int LS) {
0103 std::vector<unsigned int> MDs = getMDsFromLS(event, LS);
0104 std::vector<unsigned int> hits_0 = getHitsFromMD(event, MDs[0]);
0105 std::vector<unsigned int> hits_1 = getHitsFromMD(event, MDs[1]);
0106 return {hits_0[0], hits_0[1], hits_1[0], hits_1[1]};
0107 }
0108
0109
0110 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromLS(LSTEvent* event,
0111 unsigned LS) {
0112 return convertHitsToHitIdxsAndHitTypes(event, getHitsFromLS(event, LS));
0113 }
0114
0115
0116
0117
0118
0119
0120 std::vector<unsigned int> getLSsFromT3(LSTEvent* event, unsigned int t3) {
0121 auto const triplets = event->getTriplets<TripletsSoA>();
0122 unsigned int ls_1 = triplets.segmentIndices()[t3][0];
0123 unsigned int ls_2 = triplets.segmentIndices()[t3][1];
0124 return {ls_1, ls_2};
0125 }
0126
0127
0128 std::vector<unsigned int> getMDsFromT3(LSTEvent* event, unsigned int T3) {
0129 std::vector<unsigned int> LSs = getLSsFromT3(event, T3);
0130 std::vector<unsigned int> MDs_0 = getMDsFromLS(event, LSs[0]);
0131 std::vector<unsigned int> MDs_1 = getMDsFromLS(event, LSs[1]);
0132 return {MDs_0[0], MDs_0[1], MDs_1[1]};
0133 }
0134
0135
0136 std::vector<unsigned int> getHitsFromT3(LSTEvent* event, unsigned int T3) {
0137 std::vector<unsigned int> MDs = getMDsFromT3(event, T3);
0138 std::vector<unsigned int> hits_0 = getHitsFromMD(event, MDs[0]);
0139 std::vector<unsigned int> hits_1 = getHitsFromMD(event, MDs[1]);
0140 std::vector<unsigned int> hits_2 = getHitsFromMD(event, MDs[2]);
0141 return {hits_0[0], hits_0[1], hits_1[0], hits_1[1], hits_2[0], hits_2[1]};
0142 }
0143
0144
0145 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromT3(LSTEvent* event,
0146 unsigned T3) {
0147 return convertHitsToHitIdxsAndHitTypes(event, getHitsFromT3(event, T3));
0148 }
0149
0150
0151
0152
0153
0154
0155 std::vector<unsigned int> getT3sFromT5(LSTEvent* event, unsigned int t5) {
0156 auto const quintuplets = event->getQuintuplets<QuintupletsSoA>();
0157 unsigned int t3_1 = quintuplets.tripletIndices()[t5][0];
0158 unsigned int t3_2 = quintuplets.tripletIndices()[t5][1];
0159 return {t3_1, t3_2};
0160 }
0161
0162
0163 std::vector<unsigned int> getLSsFromT5(LSTEvent* event, unsigned int T5) {
0164 std::vector<unsigned int> T3s = getT3sFromT5(event, T5);
0165 std::vector<unsigned int> LSs_0 = getLSsFromT3(event, T3s[0]);
0166 std::vector<unsigned int> LSs_1 = getLSsFromT3(event, T3s[1]);
0167 return {LSs_0[0], LSs_0[1], LSs_1[0], LSs_1[1]};
0168 }
0169
0170
0171 std::vector<unsigned int> getMDsFromT5(LSTEvent* event, unsigned int T5) {
0172 std::vector<unsigned int> LSs = getLSsFromT5(event, T5);
0173 std::vector<unsigned int> MDs_0 = getMDsFromLS(event, LSs[0]);
0174 std::vector<unsigned int> MDs_1 = getMDsFromLS(event, LSs[1]);
0175 std::vector<unsigned int> MDs_2 = getMDsFromLS(event, LSs[2]);
0176 std::vector<unsigned int> MDs_3 = getMDsFromLS(event, LSs[3]);
0177 return {MDs_0[0], MDs_0[1], MDs_1[1], MDs_2[1], MDs_3[1]};
0178 }
0179
0180
0181 std::vector<unsigned int> getHitsFromT5(LSTEvent* event, unsigned int T5) {
0182 std::vector<unsigned int> MDs = getMDsFromT5(event, T5);
0183 std::vector<unsigned int> hits_0 = getHitsFromMD(event, MDs[0]);
0184 std::vector<unsigned int> hits_1 = getHitsFromMD(event, MDs[1]);
0185 std::vector<unsigned int> hits_2 = getHitsFromMD(event, MDs[2]);
0186 std::vector<unsigned int> hits_3 = getHitsFromMD(event, MDs[3]);
0187 std::vector<unsigned int> hits_4 = getHitsFromMD(event, MDs[4]);
0188 return {hits_0[0], hits_0[1], hits_1[0], hits_1[1], hits_2[0], hits_2[1], hits_3[0], hits_3[1], hits_4[0], hits_4[1]};
0189 }
0190
0191
0192 std::vector<unsigned int> getHitIdxsFromT5(LSTEvent* event, unsigned int T5) {
0193 auto hitsEvt = event->getHits<HitsSoA>();
0194 std::vector<unsigned int> hits = getHitsFromT5(event, T5);
0195 std::vector<unsigned int> hitidxs;
0196 for (auto& hit : hits)
0197 hitidxs.push_back(hitsEvt.idxs()[hit]);
0198 return hitidxs;
0199 }
0200
0201 std::vector<unsigned int> getModuleIdxsFromT5(LSTEvent* event, unsigned int T5) {
0202 std::vector<unsigned int> hits = getHitsFromT5(event, T5);
0203 std::vector<unsigned int> module_idxs;
0204 auto hitsEvt = event->getHits<HitsSoA>();
0205 for (auto& hitIdx : hits) {
0206 module_idxs.push_back(hitsEvt.moduleIndices()[hitIdx]);
0207 }
0208 return module_idxs;
0209 }
0210
0211 std::vector<unsigned int> getHitTypesFromT5(LSTEvent* event, unsigned int T5) {
0212 return {4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
0213 ;
0214 }
0215
0216
0217 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromT5(LSTEvent* event,
0218 unsigned T5) {
0219 return convertHitsToHitIdxsAndHitTypes(event, getHitsFromT5(event, T5));
0220 }
0221
0222
0223
0224
0225
0226
0227 unsigned int getPixelLSFrompT3(LSTEvent* event, unsigned int pT3) {
0228 auto const pixelTriplets = event->getPixelTriplets();
0229 auto ranges = event->getRanges();
0230 auto modulesEvt = event->getModules<ModulesSoA>();
0231 const unsigned int pLS_offset = ranges.segmentModuleIndices()[modulesEvt.nLowerModules()];
0232 return pixelTriplets.pixelSegmentIndices()[pT3] - pLS_offset;
0233 }
0234
0235
0236 unsigned int getT3FrompT3(LSTEvent* event, unsigned int pT3) {
0237 auto const pixelTriplets = event->getPixelTriplets();
0238 return pixelTriplets.tripletIndices()[pT3];
0239 }
0240
0241
0242 std::vector<unsigned int> getLSsFrompT3(LSTEvent* event, unsigned int pT3) {
0243 unsigned int T3 = getT3FrompT3(event, pT3);
0244 return getLSsFromT3(event, T3);
0245 }
0246
0247
0248 std::vector<unsigned int> getMDsFrompT3(LSTEvent* event, unsigned int pT3) {
0249 unsigned int T3 = getT3FrompT3(event, pT3);
0250 return getMDsFromT3(event, T3);
0251 }
0252
0253
0254 std::vector<unsigned int> getOuterTrackerHitsFrompT3(LSTEvent* event, unsigned int pT3) {
0255 unsigned int T3 = getT3FrompT3(event, pT3);
0256 return getHitsFromT3(event, T3);
0257 }
0258
0259
0260 std::vector<unsigned int> getPixelHitsFrompT3(LSTEvent* event, unsigned int pT3) {
0261 unsigned int pLS = getPixelLSFrompT3(event, pT3);
0262 return getPixelHitsFrompLS(event, pLS);
0263 }
0264
0265
0266 std::vector<unsigned int> getHitsFrompT3(LSTEvent* event, unsigned int pT3) {
0267 unsigned int pLS = getPixelLSFrompT3(event, pT3);
0268 unsigned int T3 = getT3FrompT3(event, pT3);
0269 std::vector<unsigned int> pixelHits = getPixelHitsFrompLS(event, pLS);
0270 std::vector<unsigned int> outerTrackerHits = getHitsFromT3(event, T3);
0271 pixelHits.insert(pixelHits.end(), outerTrackerHits.begin(), outerTrackerHits.end());
0272 return pixelHits;
0273 }
0274
0275
0276 std::vector<unsigned int> getHitIdxsFrompT3(LSTEvent* event, unsigned int pT3) {
0277 auto hitsEvt = event->getHits<HitsSoA>();
0278 std::vector<unsigned int> hits = getHitsFrompT3(event, pT3);
0279 std::vector<unsigned int> hitidxs;
0280 for (auto& hit : hits)
0281 hitidxs.push_back(hitsEvt.idxs()[hit]);
0282 return hitidxs;
0283 }
0284
0285 std::vector<unsigned int> getModuleIdxsFrompT3(LSTEvent* event, unsigned int pT3) {
0286 std::vector<unsigned int> hits = getOuterTrackerHitsFrompT3(event, pT3);
0287 std::vector<unsigned int> module_idxs;
0288 auto hitsEvt = event->getHits<HitsSoA>();
0289 for (auto& hitIdx : hits) {
0290 module_idxs.push_back(hitsEvt.moduleIndices()[hitIdx]);
0291 }
0292 return module_idxs;
0293 }
0294
0295 std::vector<unsigned int> getHitTypesFrompT3(LSTEvent* event, unsigned int pT3) {
0296 unsigned int pLS = getPixelLSFrompT3(event, pT3);
0297 std::vector<unsigned int> pixelHits = getPixelHitsFrompLS(event, pLS);
0298
0299 if (pixelHits.size() == 3)
0300 return {0, 0, 0, 4, 4, 4, 4, 4, 4};
0301 else
0302 return {0, 0, 0, 0, 4, 4, 4, 4, 4, 4};
0303 }
0304
0305
0306 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompT3(LSTEvent* event,
0307 unsigned pT3) {
0308 return convertHitsToHitIdxsAndHitTypes(event, getHitsFrompT3(event, pT3));
0309 }
0310
0311
0312
0313
0314
0315
0316 unsigned int getPixelLSFrompT5(LSTEvent* event, unsigned int pT5) {
0317 auto const pixelQuintuplets = event->getPixelQuintuplets();
0318 auto ranges = event->getRanges();
0319 auto modulesEvt = event->getModules<ModulesSoA>();
0320 const unsigned int pLS_offset = ranges.segmentModuleIndices()[modulesEvt.nLowerModules()];
0321 return pixelQuintuplets.pixelSegmentIndices()[pT5] - pLS_offset;
0322 }
0323
0324
0325 unsigned int getT5FrompT5(LSTEvent* event, unsigned int pT5) {
0326 auto const pixelQuintuplets = event->getPixelQuintuplets();
0327 return pixelQuintuplets.quintupletIndices()[pT5];
0328 }
0329
0330
0331 std::vector<unsigned int> getT3sFrompT5(LSTEvent* event, unsigned int pT5) {
0332 unsigned int T5 = getT5FrompT5(event, pT5);
0333 return getT3sFromT5(event, T5);
0334 }
0335
0336
0337 std::vector<unsigned int> getLSsFrompT5(LSTEvent* event, unsigned int pT5) {
0338 unsigned int T5 = getT5FrompT5(event, pT5);
0339 return getLSsFromT5(event, T5);
0340 }
0341
0342
0343 std::vector<unsigned int> getMDsFrompT5(LSTEvent* event, unsigned int pT5) {
0344 unsigned int T5 = getT5FrompT5(event, pT5);
0345 return getMDsFromT5(event, T5);
0346 }
0347
0348
0349 std::vector<unsigned int> getOuterTrackerHitsFrompT5(LSTEvent* event, unsigned int pT5) {
0350 unsigned int T5 = getT5FrompT5(event, pT5);
0351 return getHitsFromT5(event, T5);
0352 }
0353
0354
0355 std::vector<unsigned int> getPixelHitsFrompT5(LSTEvent* event, unsigned int pT5) {
0356 unsigned int pLS = getPixelLSFrompT5(event, pT5);
0357 return getPixelHitsFrompLS(event, pLS);
0358 }
0359
0360
0361 std::vector<unsigned int> getHitsFrompT5(LSTEvent* event, unsigned int pT5) {
0362 unsigned int pLS = getPixelLSFrompT5(event, pT5);
0363 unsigned int T5 = getT5FrompT5(event, pT5);
0364 std::vector<unsigned int> pixelHits = getPixelHitsFrompLS(event, pLS);
0365 std::vector<unsigned int> outerTrackerHits = getHitsFromT5(event, T5);
0366 pixelHits.insert(pixelHits.end(), outerTrackerHits.begin(), outerTrackerHits.end());
0367 return pixelHits;
0368 }
0369
0370
0371 std::vector<unsigned int> getHitIdxsFrompT5(LSTEvent* event, unsigned int pT5) {
0372 auto hitsEvt = event->getHits<HitsSoA>();
0373 std::vector<unsigned int> hits = getHitsFrompT5(event, pT5);
0374 std::vector<unsigned int> hitidxs;
0375 for (auto& hit : hits)
0376 hitidxs.push_back(hitsEvt.idxs()[hit]);
0377 return hitidxs;
0378 }
0379
0380
0381 std::vector<unsigned int> getModuleIdxsFrompT5(LSTEvent* event, unsigned int pT5) {
0382 std::vector<unsigned int> hits = getOuterTrackerHitsFrompT5(event, pT5);
0383 std::vector<unsigned int> module_idxs;
0384 auto hitsEvt = event->getHits<HitsSoA>();
0385 for (auto& hitIdx : hits) {
0386 module_idxs.push_back(hitsEvt.moduleIndices()[hitIdx]);
0387 }
0388 return module_idxs;
0389 }
0390
0391
0392 std::vector<unsigned int> getHitTypesFrompT5(LSTEvent* event, unsigned int pT5) {
0393 unsigned int pLS = getPixelLSFrompT5(event, pT5);
0394 std::vector<unsigned int> pixelHits = getPixelHitsFrompLS(event, pLS);
0395
0396 if (pixelHits.size() == 3)
0397 return {0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
0398 else
0399 return {0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
0400 }
0401
0402
0403 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFrompT5(LSTEvent* event,
0404 unsigned pT5) {
0405 return convertHitsToHitIdxsAndHitTypes(event, getHitsFrompT5(event, pT5));
0406 }
0407
0408
0409
0410
0411
0412
0413 std::vector<unsigned int> getLSsFromTC(LSTEvent* event, unsigned int iTC) {
0414
0415 auto const& trackCandidates = event->getTrackCandidates();
0416 short type = trackCandidates.trackCandidateType()[iTC];
0417 unsigned int objidx = trackCandidates.directObjectIndices()[iTC];
0418 switch (type) {
0419 case lst::LSTObjType::pT5:
0420 return getLSsFrompT5(event, objidx);
0421 break;
0422 case lst::LSTObjType::pT3:
0423 return getLSsFrompT3(event, objidx);
0424 break;
0425 case lst::LSTObjType::T5:
0426 return getLSsFromT5(event, objidx);
0427 break;
0428 case lst::LSTObjType::pLS:
0429 return std::vector<unsigned int>();
0430 break;
0431 }
0432 }
0433
0434
0435 std::tuple<std::vector<unsigned int>, std::vector<unsigned int>> getHitIdxsAndHitTypesFromTC(LSTEvent* event,
0436 unsigned iTC) {
0437
0438 auto const& trackCandidates = event->getTrackCandidates();
0439 short type = trackCandidates.trackCandidateType()[iTC];
0440 unsigned int objidx = trackCandidates.directObjectIndices()[iTC];
0441 switch (type) {
0442 case lst::LSTObjType::pT5:
0443 return getHitIdxsAndHitTypesFrompT5(event, objidx);
0444 break;
0445 case lst::LSTObjType::pT3:
0446 return getHitIdxsAndHitTypesFrompT3(event, objidx);
0447 break;
0448 case lst::LSTObjType::T5:
0449 return getHitIdxsAndHitTypesFromT5(event, objidx);
0450 break;
0451 case lst::LSTObjType::pLS:
0452 return getHitIdxsAndHitTypesFrompLS(event, objidx);
0453 break;
0454 }
0455 }