diff --git a/RecoTracker/LST/interface/LSTOutput.h b/RecoTracker/LST/interface/LSTOutput.h index 7a581cc3299f9..a337f107e35ba 100644 --- a/RecoTracker/LST/interface/LSTOutput.h +++ b/RecoTracker/LST/interface/LSTOutput.h @@ -7,10 +7,10 @@ class LSTOutput { public: LSTOutput() = default; - LSTOutput(std::vector> hitIdx, - std::vector len, - std::vector seedIdx, - std::vector trackCandidateType) { + LSTOutput(std::vector> const& hitIdx, + std::vector const& len, + std::vector const& seedIdx, + std::vector const& trackCandidateType) { hitIdx_ = std::move(hitIdx); len_ = std::move(len); seedIdx_ = std::move(seedIdx); @@ -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> const& hitIdx() const { return hitIdx_; } + // Number of hits of each of the LST track candidates. std::vector 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 const& seedIdx() const { return seedIdx_; } + // LSTTCType as per the enum above. std::vector const& trackCandidateType() const { return trackCandidateType_; } private: diff --git a/RecoTracker/LST/interface/LSTPhase2OTHitsInput.h b/RecoTracker/LST/interface/LSTPhase2OTHitsInput.h index 6a65d09dd30d7..40b265db3edb7 100644 --- a/RecoTracker/LST/interface/LSTPhase2OTHitsInput.h +++ b/RecoTracker/LST/interface/LSTPhase2OTHitsInput.h @@ -9,11 +9,11 @@ class LSTPhase2OTHitsInput { public: LSTPhase2OTHitsInput() = default; - LSTPhase2OTHitsInput(std::vector detId, - std::vector x, - std::vector y, - std::vector z, - std::vector hits) { + LSTPhase2OTHitsInput(std::vector const& detId, + std::vector const& x, + std::vector const& y, + std::vector const& z, + std::vector const& hits) { detId_ = std::move(detId); x_ = std::move(x); y_ = std::move(y); diff --git a/RecoTracker/LST/interface/LSTPixelSeedInput.h b/RecoTracker/LST/interface/LSTPixelSeedInput.h index 69fa1ed0d4ece..2fb6a244a5648 100644 --- a/RecoTracker/LST/interface/LSTPixelSeedInput.h +++ b/RecoTracker/LST/interface/LSTPixelSeedInput.h @@ -7,21 +7,21 @@ class LSTPixelSeedInput { public: LSTPixelSeedInput() = default; - LSTPixelSeedInput(std::vector px, - std::vector py, - std::vector pz, - std::vector dxy, - std::vector dz, - std::vector ptErr, - std::vector etaErr, - std::vector stateTrajGlbX, - std::vector stateTrajGlbY, - std::vector stateTrajGlbZ, - std::vector stateTrajGlbPx, - std::vector stateTrajGlbPy, - std::vector stateTrajGlbPz, - std::vector q, - std::vector> hitIdx) { + LSTPixelSeedInput(std::vector const& px, + std::vector const& py, + std::vector const& pz, + std::vector const& dxy, + std::vector const& dz, + std::vector const& ptErr, + std::vector const& etaErr, + std::vector const& stateTrajGlbX, + std::vector const& stateTrajGlbY, + std::vector const& stateTrajGlbZ, + std::vector const& stateTrajGlbPx, + std::vector const& stateTrajGlbPy, + std::vector const& stateTrajGlbPz, + std::vector const& q, + std::vector> const& hitIdx) { px_ = std::move(px); py_ = std::move(py); pz_ = std::move(pz); diff --git a/RecoTracker/LST/plugins/LSTOutputConverter.cc b/RecoTracker/LST/plugins/LSTOutputConverter.cc index de528395d7c46..e21b456962b84 100644 --- a/RecoTracker/LST/plugins/LSTOutputConverter.cc +++ b/RecoTracker/LST/plugins/LSTOutputConverter.cc @@ -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> const& lstTC_hitIdx = lstOutput.hitIdx(); diff --git a/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc b/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc index 4b0d797db0d4f..3fd0a76770e56 100644 --- a/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc +++ b/RecoTracker/LST/plugins/LSTPhase2OTHitsInputProducer.cc @@ -39,23 +39,29 @@ void LSTPhase2OTHitsInputProducer::produce(edm::StreamID iID, edm::Event& iEvent // Vector definitions std::vector ph2_detId; + ph2_detId.reserve(phase2OTHits.dataSize()); std::vector ph2_x; + ph2_x.reserve(phase2OTHits.dataSize()); std::vector ph2_y; + ph2_y.reserve(phase2OTHits.dataSize()); std::vector ph2_z; + ph2_z.reserve(phase2OTHits.dataSize()); std::vector 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)); } diff --git a/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc b/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc index b4f42476b1ce9..098d8731d62c8 100644 --- a/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc +++ b/RecoTracker/LST/plugins/LSTPixelSeedInputProducer.cc @@ -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 @@ -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()) @@ -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") @@ -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)); } diff --git a/RecoTracker/LSTCore/interface/EndcapGeometry.h b/RecoTracker/LSTCore/interface/EndcapGeometry.h index 09bab83238754..555955d83941c 100644 --- a/RecoTracker/LSTCore/interface/EndcapGeometry.h +++ b/RecoTracker/LSTCore/interface/EndcapGeometry.h @@ -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; }; diff --git a/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h b/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h index 1f1333d89f002..6a787a5ed95eb 100644 --- a/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h +++ b/RecoTracker/LSTCore/interface/EndcapGeometryBuffer.h @@ -18,7 +18,7 @@ namespace lst { const float* geoMapPhi; template - void setData(const TBuff& buf) { + void setData(TBuff const& buf) { geoMapDetId = alpaka::getPtrNative(buf.geoMapDetId_buf); geoMapPhi = alpaka::getPtrNative(buf.geoMapPhi_buf); } @@ -37,13 +37,13 @@ namespace lst { } template - inline void copyFromSrc(TQueue queue, const EndcapGeometryBuffer& src) { + inline void copyFromSrc(TQueue queue, EndcapGeometryBuffer const& src) { alpaka::memcpy(queue, geoMapDetId_buf, src.geoMapDetId_buf); alpaka::memcpy(queue, geoMapPhi_buf, src.geoMapPhi_buf); } template - EndcapGeometryBuffer(TQueue queue, const EndcapGeometryBuffer& src, unsigned int nEndCapMap) + EndcapGeometryBuffer(TQueue queue, EndcapGeometryBuffer const& src, unsigned int nEndCapMap) : EndcapGeometryBuffer(alpaka::getDev(queue), nEndCapMap) { copyFromSrc(queue, src); } diff --git a/RecoTracker/LSTCore/interface/LST.h b/RecoTracker/LSTCore/interface/LST.h index cb5d8c912166c..ac23bd09a7ecf 100644 --- a/RecoTracker/LSTCore/interface/LST.h +++ b/RecoTracker/LSTCore/interface/LST.h @@ -23,59 +23,59 @@ namespace lst { template void run(TQueue& queue, bool verbose, - const LSTESData>* deviceESData, - const std::vector see_px, - const std::vector see_py, - const std::vector see_pz, - const std::vector see_dxy, - const std::vector see_dz, - const std::vector see_ptErr, - const std::vector see_etaErr, - const std::vector see_stateTrajGlbX, - const std::vector see_stateTrajGlbY, - const std::vector see_stateTrajGlbZ, - const std::vector see_stateTrajGlbPx, - const std::vector see_stateTrajGlbPy, - const std::vector see_stateTrajGlbPz, - const std::vector see_q, - const std::vector> see_hitIdx, - const std::vector ph2_detId, - const std::vector ph2_x, - const std::vector ph2_y, - const std::vector ph2_z, + LSTESData> const* deviceESData, + std::vector const& see_px, + std::vector const& see_py, + std::vector const& see_pz, + std::vector const& see_dxy, + std::vector const& see_dz, + std::vector const& see_ptErr, + std::vector const& see_etaErr, + std::vector const& see_stateTrajGlbX, + std::vector const& see_stateTrajGlbY, + std::vector const& see_stateTrajGlbZ, + std::vector const& see_stateTrajGlbPx, + std::vector const& see_stateTrajGlbPy, + std::vector const& see_stateTrajGlbPz, + std::vector const& see_q, + std::vector> const& see_hitIdx, + std::vector const& ph2_detId, + std::vector const& ph2_x, + std::vector const& ph2_y, + std::vector const& ph2_z, bool no_pls_dupclean, bool tc_pls_triplets); - std::vector> hits() { return out_tc_hitIdxs_; } - std::vector len() { return out_tc_len_; } - std::vector seedIdx() { return out_tc_seedIdx_; } - std::vector trackCandidateType() { return out_tc_trackCandidateType_; } + std::vector> const& hits() const { return out_tc_hitIdxs_; } + std::vector const& len() const { return out_tc_len_; } + std::vector const& seedIdx() const { return out_tc_seedIdx_; } + std::vector const& trackCandidateType() const { return out_tc_trackCandidateType_; } private: - void prepareInput(const std::vector see_px, - const std::vector see_py, - const std::vector see_pz, - const std::vector see_dxy, - const std::vector see_dz, - const std::vector see_ptErr, - const std::vector see_etaErr, - const std::vector see_stateTrajGlbX, - const std::vector see_stateTrajGlbY, - const std::vector see_stateTrajGlbZ, - const std::vector see_stateTrajGlbPx, - const std::vector see_stateTrajGlbPy, - const std::vector see_stateTrajGlbPz, - const std::vector see_q, - const std::vector> see_hitIdx, - const std::vector ph2_detId, - const std::vector ph2_x, - const std::vector ph2_y, - const std::vector ph2_z); + void prepareInput(std::vector const& see_px, + std::vector const& see_py, + std::vector const& see_pz, + std::vector const& see_dxy, + std::vector const& see_dz, + std::vector const& see_ptErr, + std::vector const& see_etaErr, + std::vector const& see_stateTrajGlbX, + std::vector const& see_stateTrajGlbY, + std::vector const& see_stateTrajGlbZ, + std::vector const& see_stateTrajGlbPx, + std::vector const& see_stateTrajGlbPy, + std::vector const& see_stateTrajGlbPz, + std::vector const& see_q, + std::vector> const& see_hitIdx, + std::vector const& ph2_detId, + std::vector const& ph2_x, + std::vector const& ph2_y, + std::vector const& ph2_z); void getOutput(lst::Event& event); - std::vector getHitIdxs(const short trackCandidateType, - const unsigned int TCIdx, - const unsigned int* TCHitIndices, - const unsigned int* hitIndices); + std::vector getHitIdxs(short trackCandidateType, + unsigned int TCIdx, + unsigned int const* TCHitIndices, + unsigned int const* hitIndices); // Input and output vectors std::vector in_trkX_; diff --git a/RecoTracker/LSTCore/interface/Module.h b/RecoTracker/LSTCore/interface/Module.h index c50e5c4c6c2a5..56c560eaba04c 100644 --- a/RecoTracker/LSTCore/interface/Module.h +++ b/RecoTracker/LSTCore/interface/Module.h @@ -83,7 +83,7 @@ namespace lst { }; template - 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); @@ -175,7 +175,7 @@ namespace lst { } template - inline void copyFromSrc(TQueue queue, const ModulesBuffer& src, bool isFull = true) { + inline void copyFromSrc(TQueue queue, ModulesBuffer const& src, bool isFull = true) { alpaka::memcpy(queue, detIds_buf, src.detIds_buf); if (isFull) { alpaka::memcpy(queue, moduleMap_buf, src.moduleMap_buf); @@ -216,7 +216,7 @@ namespace lst { } template - ModulesBuffer(TQueue queue, const ModulesBuffer& src, unsigned int nMod, unsigned int nPixs) + ModulesBuffer(TQueue queue, ModulesBuffer const& src, unsigned int nMod, unsigned int nPixs) : ModulesBuffer(alpaka::getDev(queue), nMod, nPixs) { copyFromSrc(queue, src); } diff --git a/RecoTracker/LSTCore/interface/ModuleConnectionMap.h b/RecoTracker/LSTCore/interface/ModuleConnectionMap.h index 99600faeece13..b3a931345b3a5 100644 --- a/RecoTracker/LSTCore/interface/ModuleConnectionMap.h +++ b/RecoTracker/LSTCore/interface/ModuleConnectionMap.h @@ -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& getConnectedModuleDetIds(unsigned int detid) const; diff --git a/RecoTracker/LSTCore/interface/TiltedGeometry.h b/RecoTracker/LSTCore/interface/TiltedGeometry.h index 6a8c6bab902b8..b70a1d95a357b 100644 --- a/RecoTracker/LSTCore/interface/TiltedGeometry.h +++ b/RecoTracker/LSTCore/interface/TiltedGeometry.h @@ -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; diff --git a/RecoTracker/LSTCore/interface/alpaka/Constants.h b/RecoTracker/LSTCore/interface/alpaka/Constants.h index 218d0f5552c02..e2ebd979a59a3 100644 --- a/RecoTracker/LSTCore/interface/alpaka/Constants.h +++ b/RecoTracker/LSTCore/interface/alpaka/Constants.h @@ -57,45 +57,48 @@ namespace lst { return WorkDiv3D(adjustedBlocks, adjustedThreads, elementsPerThreadArg); } + // The constants below are usually used in functions like alpaka::math::min(), + // expecting a reference (T const&) in the arguments. Hence, + // ALPAKA_STATIC_ACC_MEM_GLOBAL needs to be used in addition to constexpr. + // 15 MeV constant from the approximate Bethe-Bloch formula ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMulsInGeV = 0.015; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniMulsPtScaleBarrel[6] = { + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniMulsPtScaleBarrel[6] = { 0.0052, 0.0038, 0.0034, 0.0034, 0.0032, 0.0034}; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniMulsPtScaleEndcap[5] = {0.006, 0.006, 0.006, 0.006, 0.006}; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniRminMeanBarrel[6] = { + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniMulsPtScaleEndcap[5] = {0.006, 0.006, 0.006, 0.006, 0.006}; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniRminMeanBarrel[6] = { 25.007152356, 37.2186993757, 52.3104270826, 68.6658656666, 85.9770373007, 108.301772384}; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float miniRminMeanEndcap[5] = { + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kMiniRminMeanEndcap[5] = { 130.992832231, 154.813883559, 185.352604327, 221.635123002, 265.022076742}; ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float k2Rinv1GeVf = (2.99792458e-3 * 3.8) / 2; ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kR1GeVf = 1. / (2.99792458e-3 * 3.8); - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float sinAlphaMax = 0.95; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kSinAlphaMax = 0.95; ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float ptCut = PT_CUT; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float deltaZLum = 15.0; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float pixelPSZpitch = 0.15; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float stripPSZpitch = 2.4; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float strip2SZpitch = 5.0; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float width2S = 0.009; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float widthPS = 0.01; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float pt_betaMax = 7.0; - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float magnetic_field = 3.8112; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kDeltaZLum = 15.0; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPixelPSZpitch = 0.15; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kStripPSZpitch = 2.4; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kStrip2SZpitch = 5.0; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWidth2S = 0.009; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWidthPS = 0.01; + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kPt_betaMax = 7.0; // Since C++ can't represent infinity, lst_INF = 123456789 was used to represent infinity in the data table ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float lst_INF = 123456789.0; namespace t5dnn { // Working points matching LST fake rate (43.9%) or signal acceptance (82.0%) - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float lstwp1 = 0.3418833f; // 94.0% TPR, 43.9% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float lstwp2 = 0.6177366f; // 82.0% TPR, 20.0% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kLSTWp1 = 0.3418833f; // 94.0% TPR, 43.9% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kLSTWp2 = 0.6177366f; // 82.0% TPR, 20.0% FPR // Other working points - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp70 = 0.7776195f; // 70.0% TPR, 10.0% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp75 = 0.7181118f; // 75.0% TPR, 13.5% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp80 = 0.6492643f; // 80.0% TPR, 17.9% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp85 = 0.5655319f; // 85.0% TPR, 23.8% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp90 = 0.4592205f; // 90.0% TPR, 32.6% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp95 = 0.3073708f; // 95.0% TPR, 47.7% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp97p5 = 0.2001348f; // 97.5% TPR, 61.2% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp99 = 0.1120605f; // 99.0% TPR, 75.9% FPR - ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float wp99p9 = 0.0218196f; // 99.9% TPR, 95.4% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp70 = 0.7776195f; // 70.0% TPR, 10.0% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp75 = 0.7181118f; // 75.0% TPR, 13.5% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp80 = 0.6492643f; // 80.0% TPR, 17.9% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp85 = 0.5655319f; // 85.0% TPR, 23.8% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp90 = 0.4592205f; // 90.0% TPR, 32.6% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp95 = 0.3073708f; // 95.0% TPR, 47.7% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp97p5 = 0.2001348f; // 97.5% TPR, 61.2% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp99 = 0.1120605f; // 99.0% TPR, 75.9% FPR + ALPAKA_STATIC_ACC_MEM_GLOBAL constexpr float kWp99p9 = 0.0218196f; // 99.9% TPR, 95.4% FPR } // namespace t5dnn diff --git a/RecoTracker/LSTCore/src/EndcapGeometry.cc b/RecoTracker/LSTCore/src/EndcapGeometry.cc index 3b0041086b040..d35b2520022ce 100644 --- a/RecoTracker/LSTCore/src/EndcapGeometry.cc +++ b/RecoTracker/LSTCore/src/EndcapGeometry.cc @@ -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(); diff --git a/RecoTracker/LSTCore/src/LSTESData.cc b/RecoTracker/LSTCore/src/LSTESData.cc index 414834e78c70c..482d97d34249c 100644 --- a/RecoTracker/LSTCore/src/LSTESData.cc +++ b/RecoTracker/LSTCore/src/LSTESData.cc @@ -30,11 +30,10 @@ 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; - exit(2); + throw std::runtime_error("Could not find the file = " + fullpath.string()); } return fullpath.string(); } diff --git a/RecoTracker/LSTCore/src/ModuleConnectionMap.cc b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc index 3049399b92386..732b8e155fb4e 100644 --- a/RecoTracker/LSTCore/src/ModuleConnectionMap.cc +++ b/RecoTracker/LSTCore/src/ModuleConnectionMap.cc @@ -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); @@ -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; diff --git a/RecoTracker/LSTCore/src/ModuleMethods.h b/RecoTracker/LSTCore/src/ModuleMethods.h index 80389a67e7081..4faf61ac0048b 100644 --- a/RecoTracker/LSTCore/src/ModuleMethods.h +++ b/RecoTracker/LSTCore/src/ModuleMethods.h @@ -30,7 +30,7 @@ namespace lst { PixelMap& pixelMapping, TQueue queue, const MapPLStoLayer& pLStoLayer, - struct ModuleMetaData& mmd) { + ModuleMetaData& mmd) { pixelMapping.pixelModuleIndex = mmd.detIdToIndex[1]; std::vector connectedModuleDetIds; @@ -105,10 +105,10 @@ namespace lst { }; template - inline void fillConnectedModuleArrayExplicit(struct ModulesBuffer* modulesBuf, + inline void fillConnectedModuleArrayExplicit(ModulesBuffer* modulesBuf, unsigned int nMod, TQueue queue, - struct ModuleMetaData& mmd, + ModuleMetaData& mmd, const ModuleConnectionMap* moduleConnectionMap) { alpaka_common::DevHost const& devHost = cms::alpakatools::host(); auto moduleMap_buf = allocBufWrapper(devHost, nMod * max_connected_modules); @@ -133,10 +133,10 @@ namespace lst { }; template - inline void fillMapArraysExplicit(struct ModulesBuffer* modulesBuf, + inline void fillMapArraysExplicit(ModulesBuffer* modulesBuf, unsigned int nMod, TQueue queue, - struct ModuleMetaData& mmd) { + ModuleMetaData& mmd) { alpaka_common::DevHost const& devHost = cms::alpakatools::host(); auto mapIdx_buf = allocBufWrapper(devHost, nMod); uint16_t* mapIdx = alpaka::getPtrNative(mapIdx_buf); diff --git a/RecoTracker/LSTCore/src/TiltedGeometry.cc b/RecoTracker/LSTCore/src/TiltedGeometry.cc index a288409c2a9e8..a3442147939c3 100644 --- a/RecoTracker/LSTCore/src/TiltedGeometry.cc +++ b/RecoTracker/LSTCore/src/TiltedGeometry.cc @@ -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(); diff --git a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc index 862e6e355b694..c78e7732fe249 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/Event.dev.cc @@ -150,11 +150,11 @@ void lst::Event::resetEvent() { } } -void lst::Event::addHitToEvent(std::vector x, - std::vector y, - std::vector z, - std::vector detId, - std::vector idxInNtuple) { +void lst::Event::addHitToEvent(std::vector const& x, + std::vector const& y, + std::vector const& z, + std::vector const& detId, + std::vector const& idxInNtuple) { // Use the actual number of hits instead of a max. unsigned int nHits = x.size(); @@ -217,24 +217,24 @@ void lst::Event::addHitToEvent(std::vector x, alpaka::enqueue(queue, module_ranges_task); } -void lst::Event::addPixelSegmentToEvent(std::vector hitIndices0, - std::vector hitIndices1, - std::vector hitIndices2, - std::vector hitIndices3, - std::vector dPhiChange, - std::vector ptIn, - std::vector ptErr, - std::vector px, - std::vector py, - std::vector pz, - std::vector eta, - std::vector etaErr, - std::vector phi, - std::vector charge, - std::vector seedIdx, - std::vector superbin, - std::vector pixelType, - std::vector isQuad) { +void lst::Event::addPixelSegmentToEvent(std::vector const& hitIndices0, + std::vector const& hitIndices1, + std::vector const& hitIndices2, + std::vector const& hitIndices3, + std::vector const& dPhiChange, + std::vector const& ptIn, + std::vector const& ptErr, + std::vector const& px, + std::vector const& py, + std::vector const& pz, + std::vector const& eta, + std::vector const& etaErr, + std::vector const& phi, + std::vector const& charge, + std::vector const& seedIdx, + std::vector const& superbin, + std::vector const& pixelType, + std::vector const& isQuad) { unsigned int size = ptIn.size(); if (size > n_max_pixel_segments_per_module) { diff --git a/RecoTracker/LSTCore/src/alpaka/Event.h b/RecoTracker/LSTCore/src/alpaka/Event.h index 57c99123e2ee1..01abacba7dc74 100644 --- a/RecoTracker/LSTCore/src/alpaka/Event.h +++ b/RecoTracker/LSTCore/src/alpaka/Event.h @@ -11,6 +11,7 @@ #include "Kernels.h" #include "Quintuplet.h" #include "MiniDoublet.h" +#include "PixelQuintuplet.h" #include "PixelTriplet.h" #include "TrackCandidate.h" @@ -82,7 +83,6 @@ namespace lst { int* superbinCPU; int8_t* pixelTypeCPU; - // Stuff that used to be global const uint16_t nModules_; const uint16_t nLowerModules_; const unsigned int nPixels_; @@ -109,30 +109,30 @@ namespace lst { } void resetEvent(); - void addHitToEvent( - std::vector x, - std::vector y, - std::vector z, - std::vector detId, - std::vector idxInNtuple); //call the appropriate hit function, then increment the counter here - void addPixelSegmentToEvent(std::vector hitIndices0, - std::vector hitIndices1, - std::vector hitIndices2, - std::vector hitIndices3, - std::vector dPhiChange, - std::vector ptIn, - std::vector ptErr, - std::vector px, - std::vector py, - std::vector pz, - std::vector eta, - std::vector etaErr, - std::vector phi, - std::vector charge, - std::vector seedIdx, - std::vector superbin, - std::vector pixelType, - std::vector isQuad); + // Calls the appropriate hit function, then increments the counter + void addHitToEvent(std::vector const& x, + std::vector const& y, + std::vector const& z, + std::vector const& detId, + std::vector const& idxInNtuple); + void addPixelSegmentToEvent(std::vector const& hitIndices0, + std::vector const& hitIndices1, + std::vector const& hitIndices2, + std::vector const& hitIndices3, + std::vector const& dPhiChange, + std::vector const& ptIn, + std::vector const& ptErr, + std::vector const& px, + std::vector const& py, + std::vector const& pz, + std::vector const& eta, + std::vector const& etaErr, + std::vector const& phi, + std::vector const& charge, + std::vector const& seedIdx, + std::vector const& superbin, + std::vector const& pixelType, + std::vector const& isQuad); // functions that map the objects to the appropriate modules void addMiniDoubletsToEventExplicit(); diff --git a/RecoTracker/LSTCore/src/alpaka/Hit.h b/RecoTracker/LSTCore/src/alpaka/Hit.h index 493eefd71f057..c14ac26124e6d 100644 --- a/RecoTracker/LSTCore/src/alpaka/Hit.h +++ b/RecoTracker/LSTCore/src/alpaka/Hit.h @@ -107,13 +107,6 @@ namespace lst { inline void setData(HitsBuffer& buf) { data_.setData(buf); } }; - // Alpaka does not support log10 natively right now. - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE float temp_log10(TAcc const& acc, float val) { - constexpr float ln10 = 2.302585093f; // precomputed ln(10) - return alpaka::math::log(acc, val) / ln10; - }; - template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float eta(TAcc const& acc, float x, float y, float z) { float r3 = alpaka::math::sqrt(acc, x * x + y * y + z * z); @@ -149,13 +142,6 @@ namespace lst { return deltaPhi(acc, x1, y1, x2 - x1, y2 - y1); }; - // Alpaka: This function is not yet implemented directly in Alpaka. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float copysignf(float a, float b) { - int sign_a = (a < 0) ? -1 : 1; - int sign_b = (b < 0) ? -1 : 1; - return sign_a * sign_b * a; - }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float calculate_dPhi(float phi1, float phi2) { // Calculate dPhi float dPhi = phi1 - phi2; @@ -194,9 +180,9 @@ namespace lst { struct moduleRangesKernel { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Hits hitsInGPU, - int const& nLowerModules) const { + lst::Modules modulesInGPU, + lst::Hits hitsInGPU, + int nLowerModules) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -223,9 +209,9 @@ namespace lst { unsigned int nEndCapMap, // Number of elements in endcap map const unsigned int* geoMapDetId, // DetId's from endcap map const float* geoMapPhi, // Phi values from endcap map - struct lst::Modules modulesInGPU, - struct lst::Hits hitsInGPU, - unsigned int const& nHits) const // Total number of hits in event + lst::Modules modulesInGPU, + lst::Hits hitsInGPU, + unsigned int nHits) const // Total number of hits in event { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/Kernels.h b/RecoTracker/LSTCore/src/alpaka/Kernels.h index b95d4ce24055f..8e3fa46c3ab6f 100644 --- a/RecoTracker/LSTCore/src/alpaka/Kernels.h +++ b/RecoTracker/LSTCore/src/alpaka/Kernels.h @@ -10,26 +10,27 @@ #include "Segment.h" #include "Triplet.h" #include "Quintuplet.h" +#include "PixelQuintuplet.h" #include "PixelTriplet.h" namespace lst { - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmQuintupletFromMemory(struct lst::Quintuplets& quintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmQuintupletFromMemory(lst::Quintuplets& quintupletsInGPU, unsigned int quintupletIndex, bool secondpass = false) { quintupletsInGPU.isDup[quintupletIndex] |= 1 + secondpass; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelTripletFromMemory(struct lst::PixelTriplets& pixelTripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelTripletFromMemory(lst::PixelTriplets& pixelTripletsInGPU, unsigned int pixelTripletIndex) { pixelTripletsInGPU.isDup[pixelTripletIndex] = true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelQuintupletFromMemory(struct lst::PixelQuintuplets& pixelQuintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelQuintupletFromMemory(lst::PixelQuintuplets& pixelQuintupletsInGPU, unsigned int pixelQuintupletIndex) { pixelQuintupletsInGPU.isDup[pixelQuintupletIndex] = true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelSegmentFromMemory(struct lst::Segments& segmentsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void rmPixelSegmentFromMemory(lst::Segments& segmentsInGPU, unsigned int pixelSegmentArrayIndex, bool secondpass = false) { segmentsInGPU.isDup[pixelSegmentArrayIndex] |= 1 + secondpass; @@ -37,7 +38,7 @@ namespace lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkHitsT5(unsigned int ix, unsigned int jx, - struct lst::Quintuplets& quintupletsInGPU) { + lst::Quintuplets const& quintupletsInGPU) { unsigned int hits1[Params_T5::kHits]; unsigned int hits2[Params_T5::kHits]; @@ -64,7 +65,7 @@ namespace lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkHitspT5(unsigned int ix, unsigned int jx, - struct lst::PixelQuintuplets& pixelQuintupletsInGPU) { + lst::PixelQuintuplets const& pixelQuintupletsInGPU) { unsigned int hits1[Params_pT5::kHits]; unsigned int hits2[Params_pT5::kHits]; @@ -91,7 +92,7 @@ namespace lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE void checkHitspT3(unsigned int ix, unsigned int jx, - struct lst::PixelTriplets& pixelTripletsInGPU, + lst::PixelTriplets const& pixelTripletsInGPU, int* matched) { int phits1[Params_pLS::kHits]; int phits2[Params_pLS::kHits]; @@ -144,9 +145,9 @@ namespace lst { struct removeDupQuintupletsInGPUAfterBuild { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Quintuplets quintupletsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Modules modulesInGPU, + lst::Quintuplets quintupletsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -194,8 +195,8 @@ namespace lst { struct removeDupQuintupletsInGPUBeforeTC { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Quintuplets quintupletsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Quintuplets quintupletsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -268,7 +269,7 @@ namespace lst { struct removeDupPixelTripletsInGPUFromMap { template - ALPAKA_FN_ACC void operator()(TAcc const& acc, struct lst::PixelTriplets pixelTripletsInGPU) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, lst::PixelTriplets pixelTripletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -305,7 +306,7 @@ namespace lst { struct removeDupPixelQuintupletsInGPUFromMap { template - ALPAKA_FN_ACC void operator()(TAcc const& acc, struct lst::PixelQuintuplets pixelQuintupletsInGPU) const { + ALPAKA_FN_ACC void operator()(TAcc const& acc, lst::PixelQuintuplets pixelQuintupletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -333,8 +334,8 @@ namespace lst { struct checkHitspLS { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Segments segmentsInGPU, + lst::Modules modulesInGPU, + lst::Segments segmentsInGPU, bool secondpass) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc b/RecoTracker/LSTCore/src/alpaka/LST.dev.cc index c03007b3d273c..940469e8682a2 100644 --- a/RecoTracker/LSTCore/src/alpaka/LST.dev.cc +++ b/RecoTracker/LSTCore/src/alpaka/LST.dev.cc @@ -8,7 +8,7 @@ using namespace ALPAKA_ACCELERATOR_NAMESPACE; using XYZVector = ROOT::Math::XYZVector; namespace { - XYZVector calculateR3FromPCA(const XYZVector& p3, const float dxy, const float dz) { + XYZVector calculateR3FromPCA(const XYZVector& p3, float dxy, float dz) { const float pt = p3.rho(); const float p = p3.r(); const float vz = dz * pt * pt / p / p; @@ -20,25 +20,25 @@ namespace { } // namespace template <> -void lst::LST::prepareInput(const std::vector see_px, - const std::vector see_py, - const std::vector see_pz, - const std::vector see_dxy, - const std::vector see_dz, - const std::vector see_ptErr, - const std::vector see_etaErr, - const std::vector see_stateTrajGlbX, - const std::vector see_stateTrajGlbY, - const std::vector see_stateTrajGlbZ, - const std::vector see_stateTrajGlbPx, - const std::vector see_stateTrajGlbPy, - const std::vector see_stateTrajGlbPz, - const std::vector see_q, - const std::vector> see_hitIdx, - const std::vector ph2_detId, - const std::vector ph2_x, - const std::vector ph2_y, - const std::vector ph2_z) { +void lst::LST::prepareInput(std::vector const& see_px, + std::vector const& see_py, + std::vector const& see_pz, + std::vector const& see_dxy, + std::vector const& see_dz, + std::vector const& see_ptErr, + std::vector const& see_etaErr, + std::vector const& see_stateTrajGlbX, + std::vector const& see_stateTrajGlbY, + std::vector const& see_stateTrajGlbZ, + std::vector const& see_stateTrajGlbPx, + std::vector const& see_stateTrajGlbPy, + std::vector const& see_stateTrajGlbPz, + std::vector const& see_q, + std::vector> const& see_hitIdx, + std::vector const& ph2_detId, + std::vector const& ph2_x, + std::vector const& ph2_y, + std::vector const& ph2_z) { unsigned int count = 0; auto n_see = see_stateTrajGlbPx.size(); std::vector px_vec; @@ -213,10 +213,10 @@ void lst::LST::prepareInput(const std::vector see_px, } template <> -std::vector lst::LST::getHitIdxs(const short trackCandidateType, - const unsigned int TCIdx, - const unsigned int* TCHitIndices, - const unsigned int* hitIndices) { +std::vector lst::LST::getHitIdxs(short trackCandidateType, + unsigned int TCIdx, + unsigned int const* TCHitIndices, + unsigned int const* hitIndices) { std::vector hits; unsigned int maxNHits = 0; @@ -280,26 +280,26 @@ template <> template <> void lst::LST::run(Queue& queue, bool verbose, - const LSTESData* deviceESData, - const std::vector see_px, - const std::vector see_py, - const std::vector see_pz, - const std::vector see_dxy, - const std::vector see_dz, - const std::vector see_ptErr, - const std::vector see_etaErr, - const std::vector see_stateTrajGlbX, - const std::vector see_stateTrajGlbY, - const std::vector see_stateTrajGlbZ, - const std::vector see_stateTrajGlbPx, - const std::vector see_stateTrajGlbPy, - const std::vector see_stateTrajGlbPz, - const std::vector see_q, - const std::vector> see_hitIdx, - const std::vector ph2_detId, - const std::vector ph2_x, - const std::vector ph2_y, - const std::vector ph2_z, + LSTESData const* deviceESData, + std::vector const& see_px, + std::vector const& see_py, + std::vector const& see_pz, + std::vector const& see_dxy, + std::vector const& see_dz, + std::vector const& see_ptErr, + std::vector const& see_etaErr, + std::vector const& see_stateTrajGlbX, + std::vector const& see_stateTrajGlbY, + std::vector const& see_stateTrajGlbZ, + std::vector const& see_stateTrajGlbPx, + std::vector const& see_stateTrajGlbPy, + std::vector const& see_stateTrajGlbPz, + std::vector const& see_q, + std::vector> const& see_hitIdx, + std::vector const& ph2_detId, + std::vector const& ph2_x, + std::vector const& ph2_y, + std::vector const& ph2_z, bool no_pls_dupclean, bool tc_pls_triplets) { auto event = lst::Event(verbose, queue, deviceESData); diff --git a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h index 28c525a68a218..86a22d943c33f 100644 --- a/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h +++ b/RecoTracker/LSTCore/src/alpaka/MiniDoublet.h @@ -27,7 +27,6 @@ namespace lst { float* shiftedXs; float* shiftedYs; float* shiftedZs; - float* noShiftedDzs; //if shifted module float* noShiftedDphis; //if shifted module float* noShiftedDphiChanges; //if shifted module @@ -69,7 +68,6 @@ namespace lst { shiftedXs = alpaka::getPtrNative(buf.shiftedXs_buf); shiftedYs = alpaka::getPtrNative(buf.shiftedYs_buf); shiftedZs = alpaka::getPtrNative(buf.shiftedZs_buf); - noShiftedDzs = alpaka::getPtrNative(buf.noShiftedDzs_buf); noShiftedDphis = alpaka::getPtrNative(buf.noShiftedDphis_buf); noShiftedDphiChanges = alpaka::getPtrNative(buf.noShiftedDphiChanges_buf); anchorX = alpaka::getPtrNative(buf.anchorX_buf); @@ -114,7 +112,6 @@ namespace lst { Buf shiftedXs_buf; Buf shiftedYs_buf; Buf shiftedZs_buf; - Buf noShiftedDzs_buf; Buf noShiftedDphis_buf; Buf noShiftedDphiChanges_buf; @@ -158,7 +155,6 @@ namespace lst { shiftedXs_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), shiftedYs_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), shiftedZs_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), - noShiftedDzs_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), noShiftedDphis_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), noShiftedDphiChanges_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), anchorX_buf(allocBufWrapper(devAccIn, nMemoryLoc, queue)), @@ -194,19 +190,18 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void addMDToMemory(TAcc const& acc, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Hits& hitsInGPU, - struct lst::Modules& modulesInGPU, + lst::MiniDoublets& mdsInGPU, + lst::Hits const& hitsInGPU, + lst::Modules const& modulesInGPU, unsigned int lowerHitIdx, unsigned int upperHitIdx, - uint16_t& lowerModuleIdx, + uint16_t lowerModuleIdx, float dz, float dPhi, float dPhiChange, float shiftedX, float shiftedY, float shiftedZ, - float noShiftedDz, float noShiftedDphi, float noShiftedDPhiChange, unsigned int idx) { @@ -237,7 +232,6 @@ namespace lst { mdsInGPU.shiftedYs[idx] = shiftedY; mdsInGPU.shiftedZs[idx] = shiftedZ; - mdsInGPU.noShiftedDzs[idx] = noShiftedDz; mdsInGPU.noShiftedDphis[idx] = noShiftedDphi; mdsInGPU.noShiftedDphiChanges[idx] = noShiftedDPhiChange; @@ -268,8 +262,7 @@ namespace lst { mdsInGPU.outerLowEdgeY[idx] = hitsInGPU.lowEdgeYs[outerHitIndex]; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules(struct lst::Modules& modulesInGPU, - uint16_t& moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules(lst::Modules const& modulesInGPU, uint16_t moduleIndex) { // The "tighter" tilted modules are the subset of tilted modules that have smaller spacing // This is the same as what was previously considered as"isNormalTiltedModules" // See Figure 9.1 of https://cds.cern.ch/record/2272264/files/CMS-TDR-014.pdf @@ -289,7 +282,7 @@ namespace lst { return false; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize(struct lst::Modules& modulesInGPU, uint16_t& moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize(struct lst::Modules const& modulesInGPU, uint16_t moduleIndex) { float miniDeltaTilted[3] = {0.26f, 0.26f, 0.26f}; float miniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f}; float miniDeltaLooseTilted[3] = {0.4f, 0.4f, 0.4f}; @@ -341,12 +334,8 @@ namespace lst { }; template - ALPAKA_FN_ACC ALPAKA_FN_INLINE float dPhiThreshold(TAcc const& acc, - float rt, - struct lst::Modules& modulesInGPU, - uint16_t& moduleIndex, - float dPhi = 0, - float dz = 0) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float dPhiThreshold( + TAcc const& acc, float rt, lst::Modules const& modulesInGPU, uint16_t moduleIndex, float dPhi = 0, float dz = 0) { // ================================================================= // Various constants // ================================================================= @@ -357,12 +346,12 @@ namespace lst { // ================================================================= unsigned int iL = modulesInGPU.layers[moduleIndex] - 1; - const float miniSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rt * k2Rinv1GeVf / ptCut, sinAlphaMax)); + const float miniSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rt * k2Rinv1GeVf / ptCut, kSinAlphaMax)); const float rLayNominal = - ((modulesInGPU.subdets[moduleIndex] == Barrel) ? miniRminMeanBarrel[iL] : miniRminMeanEndcap[iL]); + ((modulesInGPU.subdets[moduleIndex] == Barrel) ? kMiniRminMeanBarrel[iL] : kMiniRminMeanEndcap[iL]); const float miniPVoff = 0.1f / rLayNominal; - const float miniMuls = ((modulesInGPU.subdets[moduleIndex] == Barrel) ? miniMulsPtScaleBarrel[iL] * 3.f / ptCut - : miniMulsPtScaleEndcap[iL] * 3.f / ptCut); + const float miniMuls = ((modulesInGPU.subdets[moduleIndex] == Barrel) ? kMiniMulsPtScaleBarrel[iL] * 3.f / ptCut + : kMiniMulsPtScaleEndcap[iL] * 3.f / ptCut); const bool isTilted = modulesInGPU.subdets[moduleIndex] == Barrel and modulesInGPU.sides[moduleIndex] != Center; //the lower module is sent in irrespective of its layer type. We need to fetch the drdz properly @@ -376,12 +365,12 @@ namespace lst { } else { drdz = 0; } - const float miniTilt2 = ((isTilted) ? (0.5f * 0.5f) * (pixelPSZpitch * pixelPSZpitch) * (drdz * drdz) / + const float miniTilt2 = ((isTilted) ? (0.5f * 0.5f) * (kPixelPSZpitch * kPixelPSZpitch) * (drdz * drdz) / (1.f + drdz * drdz) / moduleGapSize(modulesInGPU, moduleIndex) : 0); // Compute luminous region requirement for endcap - const float miniLum = alpaka::math::abs(acc, dPhi * deltaZLum / dz); // Balaji's new error + const float miniLum = alpaka::math::abs(acc, dPhi * kDeltaZLum / dz); // Balaji's new error // ================================================================= // Return the threshold value @@ -405,9 +394,9 @@ namespace lst { template ALPAKA_FN_INLINE ALPAKA_FN_ACC void shiftStripHits(TAcc const& acc, - struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex, - uint16_t& upperModuleIndex, + lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex, + uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float* shiftedCoords, @@ -571,9 +560,9 @@ namespace lst { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgo(TAcc const& acc, - struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex, - uint16_t& upperModuleIndex, + lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex, + uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float& dz, @@ -582,7 +571,6 @@ namespace lst { float& shiftedX, float& shiftedY, float& shiftedZ, - float& noShiftedDz, float& noShiftedDphi, float& noShiftedDphiChange, float xLower, @@ -606,7 +594,6 @@ namespace lst { shiftedX, shiftedY, shiftedZ, - noShiftedDz, noShiftedDphi, noShiftedDphiChange, xLower, @@ -630,7 +617,6 @@ namespace lst { shiftedX, shiftedY, shiftedZ, - noShiftedDz, noShiftedDphi, noShiftedDphiChange, xLower, @@ -646,9 +632,9 @@ namespace lst { template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoBarrel(TAcc const& acc, - struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex, - uint16_t& upperModuleIndex, + lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex, + uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float& dz, @@ -657,7 +643,6 @@ namespace lst { float& shiftedX, float& shiftedY, float& shiftedZ, - float& noShiftedDz, float& noShiftedDphi, float& noShiftedDphiChange, float xLower, @@ -670,7 +655,6 @@ namespace lst { float rtUpper) { dz = zLower - zUpper; const float dzCut = modulesInGPU.moduleType[lowerModuleIndex] == lst::PS ? 2.f : 10.f; - //const float sign = ((dz > 0) - (dz < 0)) * ((hitsInGPU.zs[lowerHitIndex] > 0) - (hitsInGPU.zs[lowerHitIndex] < 0)); const float sign = ((dz > 0) - (dz < 0)) * ((zLower > 0) - (zLower < 0)); const float invertedcrossercut = (alpaka::math::abs(acc, dz) > 2) * sign; @@ -770,16 +754,14 @@ namespace lst { noShiftedDphiChange = dPhiChange; } - noShiftedDz = 0; // not used anywhere - return alpaka::math::abs(acc, dPhiChange) < miniCut; }; template ALPAKA_FN_ACC bool runMiniDoubletDefaultAlgoEndcap(TAcc const& acc, - struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex, - uint16_t& upperModuleIndex, + lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex, + uint16_t upperModuleIndex, unsigned int lowerHitIndex, unsigned int upperHitIndex, float& drt, @@ -788,7 +770,6 @@ namespace lst { float& shiftedX, float& shiftedY, float& shiftedZ, - float& noShiftedDz, float& noShiftedDphi, float& noShiftedDphichange, float xLower, @@ -883,7 +864,6 @@ namespace lst { float dzFrac = alpaka::math::abs(acc, dz) / alpaka::math::abs(acc, zLower); dPhiChange = dPhi / dzFrac * (1.f + dzFrac); noShiftedDphichange = noShiftedDphi / dzFrac * (1.f + dzFrac); - noShiftedDz = 0; // not used anywhere return alpaka::math::abs(acc, dPhiChange) < miniCut; }; @@ -927,7 +907,7 @@ namespace lst { float zUpper = hitsInGPU.zs[upperHitArrayIndex]; float rtUpper = hitsInGPU.rts[upperHitArrayIndex]; - float dz, dphi, dphichange, shiftedX, shiftedY, shiftedZ, noShiftedDz, noShiftedDphi, noShiftedDphiChange; + float dz, dphi, dphichange, shiftedX, shiftedY, shiftedZ, noShiftedDphi, noShiftedDphiChange; bool success = runMiniDoubletDefaultAlgo(acc, modulesInGPU, lowerModuleIndex, @@ -940,7 +920,6 @@ namespace lst { shiftedX, shiftedY, shiftedZ, - noShiftedDz, noShiftedDphi, noShiftedDphiChange, xLower, @@ -975,7 +954,6 @@ namespace lst { shiftedX, shiftedY, shiftedZ, - noShiftedDz, noShiftedDphi, noShiftedDphiChange, mdIndex); diff --git a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h index bcfa914fbfe80..b337b5f83f8ba 100644 --- a/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h +++ b/RecoTracker/LSTCore/src/alpaka/NeuralNetwork.h @@ -14,19 +14,19 @@ namespace lst::t5dnn { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float runInference(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Triplets& tripletsInGPU, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Triplets const& tripletsInGPU, const float* xVec, const float* yVec, const unsigned int* mdIndices, const uint16_t* lowerModuleIndices, - const unsigned int& innerTripletIndex, - const unsigned int& outerTripletIndex, - const float& innerRadius, - const float& outerRadius, - const float& bridgeRadius) { + unsigned int innerTripletIndex, + unsigned int outerTripletIndex, + float innerRadius, + float outerRadius, + float bridgeRadius) { // Unpack x-coordinates of hits float x1 = xVec[0]; float x2 = xVec[1]; @@ -66,7 +66,7 @@ namespace lst::t5dnn { // Build DNN input vector (corresponding output N-tuple branch noted in parenthetical in comment) float x[38] = { - lst::temp_log10(acc, 2 * lst::k2Rinv1GeVf * innerRadius), // inner T3 pT (t3_pt) + alpaka::math::log10(acc, 2 * lst::k2Rinv1GeVf * innerRadius), // inner T3 pT (t3_pt) mdsInGPU.anchorEta[mdIndex1], // inner T3 anchor hit 1 eta (t3_0_eta) mdsInGPU.anchorPhi[mdIndex1], // inner T3 anchor hit 1 phi (t3_0_phi) mdsInGPU.anchorZ[mdIndex1], // inner T3 anchor hit 1 z (t3_0_z) @@ -82,7 +82,7 @@ namespace lst::t5dnn { mdsInGPU.anchorZ[mdIndex3], // inner T3 anchor hit 3 z (t3_4_z) alpaka::math::sqrt(acc, x3 * x3 + y3 * y3), // inner T3 anchor hit 3 r (t3_4_r) float(modulesInGPU.layers[lowerModuleIndex3] + 6 * is_endcap3), // inner T3 anchor hit 3 layer (t3_4_layer) - lst::temp_log10(acc, 2 * lst::k2Rinv1GeVf * outerRadius), // outer T3 pT (t3_pt) + alpaka::math::log10(acc, 2 * lst::k2Rinv1GeVf * outerRadius), // outer T3 pT (t3_pt) mdsInGPU.anchorEta[mdIndex3], // outer T3 anchor hit 4 eta (t3_0_eta) mdsInGPU.anchorPhi[mdIndex3], // outer T3 anchor hit 4 phi (t3_0_phi) mdsInGPU.anchorZ[mdIndex3], // outer T3 anchor hit 3 eta (t3_0_z) @@ -98,12 +98,12 @@ namespace lst::t5dnn { mdsInGPU.anchorZ[mdIndex5], // outer T3 anchor hit 5 z (t3_4_z) alpaka::math::sqrt(acc, x5 * x5 + y5 * y5), // outer T3 anchor hit 5 r (t3_4_r) float(modulesInGPU.layers[lowerModuleIndex5] + 6 * is_endcap5), // outer T3 anchor hit 5 layer (t3_4_layer) - lst::temp_log10(acc, (innerRadius + outerRadius) * lst::k2Rinv1GeVf), // T5 pT (t5_pt) - mdsInGPU.anchorEta[md_idx_for_t5_eta_phi], // T5 eta (t5_eta) - mdsInGPU.anchorPhi[md_idx_for_t5_eta_phi], // T5 phi (t5_phi) - lst::temp_log10(acc, innerRadius), // T5 inner radius (t5_innerRadius) - lst::temp_log10(acc, bridgeRadius), // T5 bridge radius (t5_bridgeRadius) - lst::temp_log10(acc, outerRadius) // T5 outer radius (t5_outerRadius) + alpaka::math::log10(acc, (innerRadius + outerRadius) * lst::k2Rinv1GeVf), // T5 pT (t5_pt) + mdsInGPU.anchorEta[md_idx_for_t5_eta_phi], // T5 eta (t5_eta) + mdsInGPU.anchorPhi[md_idx_for_t5_eta_phi], // T5 phi (t5_phi) + alpaka::math::log10(acc, innerRadius), // T5 inner radius (t5_innerRadius) + alpaka::math::log10(acc, bridgeRadius), // T5 bridge radius (t5_bridgeRadius) + alpaka::math::log10(acc, outerRadius) // T5 outer radius (t5_outerRadius) }; // (0): Linear(in_features=38, out_features=32, bias=True) => x = x*W_T + b diff --git a/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h new file mode 100644 index 0000000000000..ee172f9e05f6e --- /dev/null +++ b/RecoTracker/LSTCore/src/alpaka/PixelQuintuplet.h @@ -0,0 +1,947 @@ +#ifndef RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h +#define RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h + +#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" +#include "RecoTracker/LSTCore/interface/Module.h" + +#include "Segment.h" +#include "MiniDoublet.h" +#include "Hit.h" +#include "Triplet.h" +#include "Quintuplet.h" +#include "PixelTriplet.h" + +namespace lst { + struct PixelQuintuplets { + unsigned int* pixelIndices; + unsigned int* T5Indices; + unsigned int* nPixelQuintuplets; + unsigned int* totOccupancyPixelQuintuplets; + bool* isDup; + FPX* score; + FPX* eta; + FPX* phi; + uint8_t* logicalLayers; + unsigned int* hitIndices; + uint16_t* lowerModuleIndices; + FPX* pixelRadius; + FPX* quintupletRadius; + FPX* centerX; + FPX* centerY; + float* rzChiSquared; + float* rPhiChiSquared; + float* rPhiChiSquaredInwards; + + template + void setData(TBuff& buf) { + pixelIndices = alpaka::getPtrNative(buf.pixelIndices_buf); + T5Indices = alpaka::getPtrNative(buf.T5Indices_buf); + nPixelQuintuplets = alpaka::getPtrNative(buf.nPixelQuintuplets_buf); + totOccupancyPixelQuintuplets = alpaka::getPtrNative(buf.totOccupancyPixelQuintuplets_buf); + isDup = alpaka::getPtrNative(buf.isDup_buf); + score = alpaka::getPtrNative(buf.score_buf); + eta = alpaka::getPtrNative(buf.eta_buf); + phi = alpaka::getPtrNative(buf.phi_buf); + logicalLayers = alpaka::getPtrNative(buf.logicalLayers_buf); + hitIndices = alpaka::getPtrNative(buf.hitIndices_buf); + lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); + pixelRadius = alpaka::getPtrNative(buf.pixelRadius_buf); + quintupletRadius = alpaka::getPtrNative(buf.quintupletRadius_buf); + centerX = alpaka::getPtrNative(buf.centerX_buf); + centerY = alpaka::getPtrNative(buf.centerY_buf); + rzChiSquared = alpaka::getPtrNative(buf.rzChiSquared_buf); + rPhiChiSquared = alpaka::getPtrNative(buf.rPhiChiSquared_buf); + rPhiChiSquaredInwards = alpaka::getPtrNative(buf.rPhiChiSquaredInwards_buf); + } + }; + + template + struct PixelQuintupletsBuffer { + Buf pixelIndices_buf; + Buf T5Indices_buf; + Buf nPixelQuintuplets_buf; + Buf totOccupancyPixelQuintuplets_buf; + Buf isDup_buf; + Buf score_buf; + Buf eta_buf; + Buf phi_buf; + Buf logicalLayers_buf; + Buf hitIndices_buf; + Buf lowerModuleIndices_buf; + Buf pixelRadius_buf; + Buf quintupletRadius_buf; + Buf centerX_buf; + Buf centerY_buf; + Buf rzChiSquared_buf; + Buf rPhiChiSquared_buf; + Buf rPhiChiSquaredInwards_buf; + + PixelQuintuplets data_; + + template + PixelQuintupletsBuffer(unsigned int maxPixelQuintuplets, TDevAcc const& devAccIn, TQueue& queue) + : pixelIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + T5Indices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + nPixelQuintuplets_buf(allocBufWrapper(devAccIn, 1, queue)), + totOccupancyPixelQuintuplets_buf(allocBufWrapper(devAccIn, 1, queue)), + isDup_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + score_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + eta_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + phi_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + logicalLayers_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kLayers, queue)), + hitIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kHits, queue)), + lowerModuleIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kLayers, queue)), + pixelRadius_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + quintupletRadius_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + centerX_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + centerY_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + rzChiSquared_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + rPhiChiSquared_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), + rPhiChiSquaredInwards_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)) { + alpaka::memset(queue, nPixelQuintuplets_buf, 0u); + alpaka::memset(queue, totOccupancyPixelQuintuplets_buf, 0u); + alpaka::wait(queue); + } + + inline PixelQuintuplets const* data() const { return &data_; } + inline void setData(PixelQuintupletsBuffer& buf) { data_.setData(buf); } + }; + + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelQuintupletToMemory(lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Quintuplets const& quintupletsInGPU, + lst::PixelQuintuplets& pixelQuintupletsInGPU, + unsigned int pixelIndex, + unsigned int T5Index, + unsigned int pixelQuintupletIndex, + float rzChiSquared, + float rPhiChiSquared, + float rPhiChiSquaredInwards, + float score, + float eta, + float phi, + float pixelRadius, + float quintupletRadius, + float centerX, + float centerY) { + pixelQuintupletsInGPU.pixelIndices[pixelQuintupletIndex] = pixelIndex; + pixelQuintupletsInGPU.T5Indices[pixelQuintupletIndex] = T5Index; + pixelQuintupletsInGPU.isDup[pixelQuintupletIndex] = false; + pixelQuintupletsInGPU.score[pixelQuintupletIndex] = __F2H(score); + pixelQuintupletsInGPU.eta[pixelQuintupletIndex] = __F2H(eta); + pixelQuintupletsInGPU.phi[pixelQuintupletIndex] = __F2H(phi); + + pixelQuintupletsInGPU.pixelRadius[pixelQuintupletIndex] = __F2H(pixelRadius); + pixelQuintupletsInGPU.quintupletRadius[pixelQuintupletIndex] = __F2H(quintupletRadius); + pixelQuintupletsInGPU.centerX[pixelQuintupletIndex] = __F2H(centerX); + pixelQuintupletsInGPU.centerY[pixelQuintupletIndex] = __F2H(centerY); + + pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex] = 0; + pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 1] = 0; + pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 2] = + quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers]; + pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 3] = + quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 1]; + pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 4] = + quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 2]; + pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 5] = + quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 3]; + pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 6] = + quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 4]; + + pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex] = + segmentsInGPU.innerLowerModuleIndices[pixelIndex]; + pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 1] = + segmentsInGPU.outerLowerModuleIndices[pixelIndex]; + pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 2] = + quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers]; + pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 3] = + quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 1]; + pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 4] = + quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 2]; + pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 5] = + quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 3]; + pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 6] = + quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 4]; + + unsigned int pixelInnerMD = segmentsInGPU.mdIndices[Params_pLS::kLayers * pixelIndex]; + unsigned int pixelOuterMD = segmentsInGPU.mdIndices[Params_pLS::kLayers * pixelIndex + 1]; + + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex] = + mdsInGPU.anchorHitIndices[pixelInnerMD]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 1] = + mdsInGPU.outerHitIndices[pixelInnerMD]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 2] = + mdsInGPU.anchorHitIndices[pixelOuterMD]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 3] = + mdsInGPU.outerHitIndices[pixelOuterMD]; + + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 4] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 5] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 1]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 6] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 2]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 7] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 3]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 8] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 4]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 9] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 5]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 10] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 6]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 11] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 7]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 12] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 8]; + pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 13] = + quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 9]; + + pixelQuintupletsInGPU.rzChiSquared[pixelQuintupletIndex] = rzChiSquared; + pixelQuintupletsInGPU.rPhiChiSquared[pixelQuintupletIndex] = rPhiChiSquared; + pixelQuintupletsInGPU.rPhiChiSquaredInwards[pixelQuintupletIndex] = rPhiChiSquaredInwards; + }; + + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RZChiSquaredCuts(lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + uint16_t lowerModuleIndex4, + uint16_t lowerModuleIndex5, + float rzChiSquared) { + const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex1] == lst::TwoS); + const int layer2 = modulesInGPU.layers[lowerModuleIndex2] + + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex2] == lst::TwoS); + const int layer3 = modulesInGPU.layers[lowerModuleIndex3] + + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex3] == lst::TwoS); + const int layer4 = modulesInGPU.layers[lowerModuleIndex4] + + 6 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex4] == lst::TwoS); + const int layer5 = modulesInGPU.layers[lowerModuleIndex5] + + 6 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex5] == lst::TwoS); + + if (layer1 == 1 and layer2 == 2 and layer3 == 3) { + if (layer4 == 12 and layer5 == 13) { + return rzChiSquared < 451.141f; + } else if (layer4 == 4 and layer5 == 12) { + return rzChiSquared < 392.654f; + } else if (layer4 == 4 and layer5 == 5) { + return rzChiSquared < 225.322f; + } else if (layer4 == 7 and layer5 == 13) { + return rzChiSquared < 595.546f; + } else if (layer4 == 7 and layer5 == 8) { + return rzChiSquared < 196.111f; + } + } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { + if (layer4 == 13 and layer5 == 14) { + return rzChiSquared < 297.446f; + } else if (layer4 == 8 and layer5 == 14) { + return rzChiSquared < 451.141f; + } else if (layer4 == 8 and layer5 == 9) { + return rzChiSquared < 518.339f; + } + } else if (layer1 == 1 and layer2 == 7 and layer3 == 8) { + if (layer4 == 9 and layer5 == 10) { + return rzChiSquared < 341.75f; + } else if (layer4 == 9 and layer5 == 15) { + return rzChiSquared < 341.75f; + } + } else if (layer1 == 2 and layer2 == 3 and layer3 == 4) { + if (layer4 == 12 and layer5 == 13) { + return rzChiSquared < 392.655f; + } else if (layer4 == 5 and layer5 == 12) { + return rzChiSquared < 341.75f; + } else if (layer4 == 5 and layer5 == 6) { + return rzChiSquared < 112.537f; + } + } else if (layer1 == 2 and layer2 == 3 and layer4 == 7) { + if (layer4 == 13 and layer5 == 14) { + return rzChiSquared < 595.545f; + } else if (layer4 == 8 and layer5 == 14) { + return rzChiSquared < 74.198f; + } + } else if (layer1 == 2 and layer2 == 7 and layer3 == 8) { + if (layer4 == 14 and layer5 == 15) { + return rzChiSquared < 518.339f; + } else if (layer4 == 9 and layer5 == 10) { + return rzChiSquared < 8.046f; + } else if (layer4 == 9 and layer5 == 15) { + return rzChiSquared < 451.141f; + } + } else if (layer1 == 3 and layer2 == 7 and layer3 == 8 and layer4 == 14 and layer5 == 15) { + return rzChiSquared < 56.207f; + } else if (layer1 == 7 and layer2 == 8 and layer3 == 9) { + if (layer4 == 10 and layer5 == 11) { + return rzChiSquared < 64.578f; + } else if (layer4 == 10 and layer5 == 16) { + return rzChiSquared < 85.250f; + } else if (layer4 == 15 and layer5 == 16) { + return rzChiSquared < 85.250f; + } + } + return true; + }; + + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredCuts(lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + uint16_t lowerModuleIndex4, + uint16_t lowerModuleIndex5, + float rPhiChiSquared) { + const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex1] == lst::TwoS); + const int layer2 = modulesInGPU.layers[lowerModuleIndex2] + + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex2] == lst::TwoS); + const int layer3 = modulesInGPU.layers[lowerModuleIndex3] + + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex3] == lst::TwoS); + const int layer4 = modulesInGPU.layers[lowerModuleIndex4] + + 6 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex4] == lst::TwoS); + const int layer5 = modulesInGPU.layers[lowerModuleIndex5] + + 6 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex5] == lst::TwoS); + + if (layer1 == 1 and layer2 == 2 and layer3 == 3) { + if (layer4 == 12 and layer5 == 13) { + return rPhiChiSquared < 48.921f; + } else if (layer4 == 4 and layer5 == 12) { + return rPhiChiSquared < 97.948f; + } else if (layer4 == 4 and layer5 == 5) { + return rPhiChiSquared < 129.3f; + } else if (layer4 == 7 and layer5 == 13) { + return rPhiChiSquared < 56.21f; + } else if (layer4 == 7 and layer5 == 8) { + return rPhiChiSquared < 74.198f; + } + } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { + if (layer4 == 13 and layer5 == 14) { + return rPhiChiSquared < 21.265f; + } else if (layer4 == 8 and layer5 == 14) { + return rPhiChiSquared < 37.058f; + } else if (layer4 == 8 and layer5 == 9) { + return rPhiChiSquared < 42.578f; + } + } else if (layer1 == 1 and layer2 == 7 and layer3 == 8) { + if (layer4 == 9 and layer5 == 10) { + return rPhiChiSquared < 32.253f; + } else if (layer4 == 9 and layer5 == 15) { + return rPhiChiSquared < 37.058f; + } + } else if (layer1 == 2 and layer2 == 3 and layer3 == 4) { + if (layer4 == 12 and layer5 == 13) { + return rPhiChiSquared < 97.947f; + } else if (layer4 == 5 and layer5 == 12) { + return rPhiChiSquared < 129.3f; + } else if (layer4 == 5 and layer5 == 6) { + return rPhiChiSquared < 170.68f; + } + } else if (layer1 == 2 and layer2 == 3 and layer3 == 7) { + if (layer4 == 13 and layer5 == 14) { + return rPhiChiSquared < 48.92f; + } else if (layer4 == 8 and layer5 == 14) { + return rPhiChiSquared < 74.2f; + } + } else if (layer1 == 2 and layer2 == 7 and layer3 == 8) { + if (layer4 == 14 and layer5 == 15) { + return rPhiChiSquared < 42.58f; + } else if (layer4 == 9 and layer5 == 10) { + return rPhiChiSquared < 37.06f; + } else if (layer4 == 9 and layer5 == 15) { + return rPhiChiSquared < 48.92f; + } + } else if (layer1 == 3 and layer2 == 7 and layer3 == 8 and layer4 == 14 and layer5 == 15) { + return rPhiChiSquared < 85.25f; + } else if (layer1 == 7 and layer2 == 8 and layer3 == 9) { + if (layer4 == 10 and layer5 == 11) { + return rPhiChiSquared < 42.58f; + } else if (layer4 == 10 and layer5 == 16) { + return rPhiChiSquared < 37.06f; + } else if (layer4 == 15 and layer5 == 16) { + return rPhiChiSquared < 37.06f; + } + } + return true; + }; + + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeChiSquaredpT5(TAcc const& acc, + unsigned int nPoints, + float* xs, + float* ys, + float* delta1, + float* delta2, + float* slopes, + bool* isFlat, + float g, + float f, + float radius) { + /* + Given values of (g, f, radius) and a set of points (and its uncertainties) compute chi squared + */ + float c = g * g + f * f - radius * radius; + float chiSquared = 0.f; + float absArctanSlope, angleM, xPrime, yPrime, sigma2; + for (size_t i = 0; i < nPoints; i++) { + absArctanSlope = ((slopes[i] != lst::lst_INF) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) + : 0.5f * float(M_PI)); + if (xs[i] > 0 and ys[i] > 0) { + angleM = 0.5f * float(M_PI) - absArctanSlope; + } else if (xs[i] < 0 and ys[i] > 0) { + angleM = absArctanSlope + 0.5f * float(M_PI); + } else if (xs[i] < 0 and ys[i] < 0) { + angleM = -(absArctanSlope + 0.5f * float(M_PI)); + } else if (xs[i] > 0 and ys[i] < 0) { + angleM = -(0.5f * float(M_PI) - absArctanSlope); + } else { + angleM = 0; + } + if (not isFlat[i]) { + xPrime = xs[i] * alpaka::math::cos(acc, angleM) + ys[i] * alpaka::math::sin(acc, angleM); + yPrime = ys[i] * alpaka::math::cos(acc, angleM) - xs[i] * alpaka::math::sin(acc, angleM); + } else { + xPrime = xs[i]; + yPrime = ys[i]; + } + sigma2 = 4 * ((xPrime * delta1[i]) * (xPrime * delta1[i]) + (yPrime * delta2[i]) * (yPrime * delta2[i])); + chiSquared += (xs[i] * xs[i] + ys[i] * ys[i] - 2 * g * xs[i] - 2 * f * ys[i] + c) * + (xs[i] * xs[i] + ys[i] * ys[i] - 2 * g * xs[i] - 2 * f * ys[i] + c) / (sigma2); + } + return chiSquared; + }; + + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression_pT5(TAcc const& acc, + lst::Modules const& modulesInGPU, + const uint16_t* lowerModuleIndices, + float* delta1, + float* delta2, + float* slopes, + bool* isFlat, + unsigned int nPoints = 5, + bool anchorHits = true) { + /* + bool anchorHits required to deal with a weird edge case wherein + the hits ultimately used in the regression are anchor hits, but the + lower modules need not all be Pixel Modules (in case of PS). Similarly, + when we compute the chi squared for the non-anchor hits, the "partner module" + need not always be a PS strip module, but all non-anchor hits sit on strip + modules. + */ + ModuleType moduleType; + short moduleSubdet, moduleSide; + float inv1 = kWidthPS / kWidth2S; + float inv2 = kPixelPSZpitch / kWidth2S; + float inv3 = kStripPSZpitch / kWidth2S; + for (size_t i = 0; i < nPoints; i++) { + moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; + moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; + moduleSide = modulesInGPU.sides[lowerModuleIndices[i]]; + const float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; + slopes[i] = modulesInGPU.dxdys[lowerModuleIndices[i]]; + //category 1 - barrel PS flat + if (moduleSubdet == Barrel and moduleType == PS and moduleSide == Center) { + delta1[i] = inv1; + delta2[i] = inv1; + slopes[i] = -999.f; + isFlat[i] = true; + } + //category 2 - barrel 2S + else if (moduleSubdet == Barrel and moduleType == TwoS) { + delta1[i] = 1.f; + delta2[i] = 1.f; + slopes[i] = -999.f; + isFlat[i] = true; + } + //category 3 - barrel PS tilted + else if (moduleSubdet == Barrel and moduleType == PS and moduleSide != Center) { + delta1[i] = inv1; + isFlat[i] = false; + + if (anchorHits) { + delta2[i] = (inv2 * drdz / alpaka::math::sqrt(acc, 1 + drdz * drdz)); + } else { + delta2[i] = (inv3 * drdz / alpaka::math::sqrt(acc, 1 + drdz * drdz)); + } + } + //category 4 - endcap PS + else if (moduleSubdet == Endcap and moduleType == PS) { + delta1[i] = inv1; + isFlat[i] = false; + /* + despite the type of the module layer of the lower module index, + all anchor hits are on the pixel side and all non-anchor hits are + on the strip side! + */ + if (anchorHits) { + delta2[i] = inv2; + } else { + delta2[i] = inv3; + } + } + //category 5 - endcap 2S + else if (moduleSubdet == Endcap and moduleType == TwoS) { + delta1[i] = 1.f; + delta2[i] = 500.f * inv1; + isFlat[i] = false; + } +#ifdef WARNINGS + else { + printf("ERROR!!!!! I SHOULDN'T BE HERE!!!! subdet = %d, type = %d, side = %d\n", + moduleSubdet, + moduleType, + moduleSide); + } +#endif + } + }; + + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquared(TAcc const& acc, + lst::Modules const& modulesInGPU, + uint16_t* lowerModuleIndices, + float g, + float f, + float radius, + float* xs, + float* ys) { + /* + Compute circle parameters from 3 pixel hits, and then use them to compute the chi squared for the outer hits + */ + + float delta1[5], delta2[5], slopes[5]; + bool isFlat[5]; + float chiSquared = 0; + + computeSigmasForRegression_pT5(acc, modulesInGPU, lowerModuleIndices, delta1, delta2, slopes, isFlat); + chiSquared = computeChiSquaredpT5(acc, 5, xs, ys, delta1, delta2, slopes, isFlat, g, f, radius); + + return chiSquared; + }; + + ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquaredInwards( + float g, float f, float r, float* xPix, float* yPix) { + /* + Using the computed regression center and radius, compute the chi squared for the pixels + */ + + float chiSquared = 0; + for (size_t i = 0; i < 2; i++) { + float residual = (xPix[i] - g) * (xPix[i] - g) + (yPix[i] - f) * (yPix[i] - f) - r * r; + chiSquared += residual * residual; + } + chiSquared *= 0.5f; + return chiSquared; + }; + + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredInwardsCuts(lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + uint16_t lowerModuleIndex4, + uint16_t lowerModuleIndex5, + float rPhiChiSquared) { + const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex1] == lst::TwoS); + const int layer2 = modulesInGPU.layers[lowerModuleIndex2] + + 6 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex2] == lst::TwoS); + const int layer3 = modulesInGPU.layers[lowerModuleIndex3] + + 6 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex3] == lst::TwoS); + const int layer4 = modulesInGPU.layers[lowerModuleIndex4] + + 6 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex4] == lst::TwoS); + const int layer5 = modulesInGPU.layers[lowerModuleIndex5] + + 6 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) + + 5 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap and + modulesInGPU.moduleType[lowerModuleIndex5] == lst::TwoS); + + if (layer1 == 1 and layer2 == 2 and layer3 == 3) { + if (layer4 == 12 and layer5 == 13) { + return rPhiChiSquared < 451.141f; + } else if (layer4 == 4 and layer5 == 12) { + return rPhiChiSquared < 786.173f; + } else if (layer4 == 4 and layer5 == 5) { + return rPhiChiSquared < 595.545f; + } else if (layer4 == 7 and layer5 == 13) { + return rPhiChiSquared < 581.339f; + } else if (layer4 == 7 and layer5 == 8) { + return rPhiChiSquared < 112.537f; + } + } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { + if (layer4 == 13 and layer5 == 14) { + return rPhiChiSquared < 225.322f; + } else if (layer4 == 8 and layer5 == 14) { + return rPhiChiSquared < 1192.402f; + } else if (layer4 == 8 and layer5 == 9) { + return rPhiChiSquared < 786.173f; + } + } else if (layer1 == 1 and layer2 == 7 and layer3 == 8) { + if (layer4 == 9 and layer5 == 10) { + return rPhiChiSquared < 1037.817f; + } else if (layer4 == 9 and layer5 == 15) { + return rPhiChiSquared < 1808.536f; + } + } else if (layer1 == 2 and layer2 == 3 and layer3 == 4) { + if (layer4 == 12 and layer5 == 13) { + return rPhiChiSquared < 684.253f; + } else if (layer4 == 5 and layer5 == 12) { + return rPhiChiSquared < 684.253f; + } else if (layer4 == 5 and layer5 == 6) { + return rPhiChiSquared < 684.253f; + } + } else if (layer1 == 2 and layer2 == 3 and layer3 == 7) { + if (layer4 == 13 and layer5 == 14) { + return rPhiChiSquared < 451.141f; + } else if (layer4 == 8 and layer5 == 14) { + return rPhiChiSquared < 518.34f; + } + } else if (layer1 == 2 and layer2 == 7 and layer3 == 8) { + if (layer4 == 14 and layer5 == 15) { + return rPhiChiSquared < 2077.92f; + } else if (layer4 == 9 and layer5 == 10) { + return rPhiChiSquared < 74.20f; + } else if (layer4 == 9 and layer5 == 15) { + return rPhiChiSquared < 1808.536f; + } + } else if (layer1 == 3 and layer2 == 7 and layer3 == 8 and layer4 == 14 and layer5 == 15) { + return rPhiChiSquared < 786.173f; + } else if (layer1 == 7 and layer2 == 8 and layer3 == 9) { + if (layer4 == 10 and layer5 == 11) { + return rPhiChiSquared < 1574.076f; + } else if (layer4 == 10 and layer5 == 16) { + return rPhiChiSquared < 5492.11f; + } else if (layer4 == 15 and layer5 == 16) { + return rPhiChiSquared < 2743.037f; + } + } + return true; + }; + + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelQuintupletDefaultAlgo(TAcc const& acc, + lst::Modules const& modulesInGPU, + lst::ObjectRanges const& rangesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Triplets const& tripletsInGPU, + lst::Quintuplets const& quintupletsInGPU, + unsigned int pixelSegmentIndex, + unsigned int quintupletIndex, + float& rzChiSquared, + float& rPhiChiSquared, + float& rPhiChiSquaredInwards, + float& pixelRadius, + float& quintupletRadius, + float& centerX, + float& centerY, + unsigned int pixelSegmentArrayIndex) { + unsigned int T5InnerT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex]; + unsigned int T5OuterT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]; + + float pixelRadiusTemp, tripletRadius, rPhiChiSquaredTemp, rzChiSquaredTemp, rPhiChiSquaredInwardsTemp, centerXTemp, + centerYTemp; + + if (not runPixelTripletDefaultAlgo(acc, + modulesInGPU, + rangesInGPU, + mdsInGPU, + segmentsInGPU, + tripletsInGPU, + pixelSegmentIndex, + T5InnerT3Index, + pixelRadiusTemp, + tripletRadius, + centerXTemp, + centerYTemp, + rzChiSquaredTemp, + rPhiChiSquaredTemp, + rPhiChiSquaredInwardsTemp, + false)) + return false; + + unsigned int firstSegmentIndex = tripletsInGPU.segmentIndices[2 * T5InnerT3Index]; + unsigned int secondSegmentIndex = tripletsInGPU.segmentIndices[2 * T5InnerT3Index + 1]; + unsigned int thirdSegmentIndex = tripletsInGPU.segmentIndices[2 * T5OuterT3Index]; + unsigned int fourthSegmentIndex = tripletsInGPU.segmentIndices[2 * T5OuterT3Index + 1]; + + unsigned int pixelInnerMDIndex = segmentsInGPU.mdIndices[2 * pixelSegmentIndex]; + unsigned int pixelOuterMDIndex = segmentsInGPU.mdIndices[2 * pixelSegmentIndex + 1]; + unsigned int firstMDIndex = segmentsInGPU.mdIndices[2 * firstSegmentIndex]; + unsigned int secondMDIndex = segmentsInGPU.mdIndices[2 * secondSegmentIndex]; + unsigned int thirdMDIndex = segmentsInGPU.mdIndices[2 * secondSegmentIndex + 1]; + unsigned int fourthMDIndex = segmentsInGPU.mdIndices[2 * thirdSegmentIndex + 1]; + unsigned int fifthMDIndex = segmentsInGPU.mdIndices[2 * fourthSegmentIndex + 1]; + + uint16_t lowerModuleIndex1 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex]; + uint16_t lowerModuleIndex2 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 1]; + uint16_t lowerModuleIndex3 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 2]; + uint16_t lowerModuleIndex4 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 3]; + uint16_t lowerModuleIndex5 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 4]; + + uint16_t lowerModuleIndices[Params_T5::kLayers] = { + lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, lowerModuleIndex4, lowerModuleIndex5}; + + float zPix[Params_pLS::kLayers] = {mdsInGPU.anchorZ[pixelInnerMDIndex], mdsInGPU.anchorZ[pixelOuterMDIndex]}; + float rtPix[Params_pLS::kLayers] = {mdsInGPU.anchorRt[pixelInnerMDIndex], mdsInGPU.anchorRt[pixelOuterMDIndex]}; + float zs[Params_T5::kLayers] = {mdsInGPU.anchorZ[firstMDIndex], + mdsInGPU.anchorZ[secondMDIndex], + mdsInGPU.anchorZ[thirdMDIndex], + mdsInGPU.anchorZ[fourthMDIndex], + mdsInGPU.anchorZ[fifthMDIndex]}; + float rts[Params_T5::kLayers] = {mdsInGPU.anchorRt[firstMDIndex], + mdsInGPU.anchorRt[secondMDIndex], + mdsInGPU.anchorRt[thirdMDIndex], + mdsInGPU.anchorRt[fourthMDIndex], + mdsInGPU.anchorRt[fifthMDIndex]}; + + rzChiSquared = computePT5RZChiSquared(acc, modulesInGPU, lowerModuleIndices, rtPix, zPix, rts, zs); + + if (/*pixelRadius*/ 0 < 5.0f * kR1GeVf) { // FIXME: pixelRadius is not defined yet + if (not passPT5RZChiSquaredCuts(modulesInGPU, + lowerModuleIndex1, + lowerModuleIndex2, + lowerModuleIndex3, + lowerModuleIndex4, + lowerModuleIndex5, + rzChiSquared)) + return false; + } + + //outer T5 + float xs[Params_T5::kLayers] = {mdsInGPU.anchorX[firstMDIndex], + mdsInGPU.anchorX[secondMDIndex], + mdsInGPU.anchorX[thirdMDIndex], + mdsInGPU.anchorX[fourthMDIndex], + mdsInGPU.anchorX[fifthMDIndex]}; + float ys[Params_T5::kLayers] = {mdsInGPU.anchorY[firstMDIndex], + mdsInGPU.anchorY[secondMDIndex], + mdsInGPU.anchorY[thirdMDIndex], + mdsInGPU.anchorY[fourthMDIndex], + mdsInGPU.anchorY[fifthMDIndex]}; + + //get the appropriate radii and centers + centerX = segmentsInGPU.circleCenterX[pixelSegmentArrayIndex]; + centerY = segmentsInGPU.circleCenterY[pixelSegmentArrayIndex]; + pixelRadius = segmentsInGPU.circleRadius[pixelSegmentArrayIndex]; + + float T5CenterX = quintupletsInGPU.regressionG[quintupletIndex]; + float T5CenterY = quintupletsInGPU.regressionF[quintupletIndex]; + quintupletRadius = quintupletsInGPU.regressionRadius[quintupletIndex]; + + rPhiChiSquared = + computePT5RPhiChiSquared(acc, modulesInGPU, lowerModuleIndices, centerX, centerY, pixelRadius, xs, ys); + + if (pixelRadius < 5.0f * kR1GeVf) { + if (not passPT5RPhiChiSquaredCuts(modulesInGPU, + lowerModuleIndex1, + lowerModuleIndex2, + lowerModuleIndex3, + lowerModuleIndex4, + lowerModuleIndex5, + rPhiChiSquared)) + return false; + } + + float xPix[] = {mdsInGPU.anchorX[pixelInnerMDIndex], mdsInGPU.anchorX[pixelOuterMDIndex]}; + float yPix[] = {mdsInGPU.anchorY[pixelInnerMDIndex], mdsInGPU.anchorY[pixelOuterMDIndex]}; + rPhiChiSquaredInwards = computePT5RPhiChiSquaredInwards(T5CenterX, T5CenterY, quintupletRadius, xPix, yPix); + + if (quintupletsInGPU.regressionRadius[quintupletIndex] < 5.0f * kR1GeVf) { + if (not passPT5RPhiChiSquaredInwardsCuts(modulesInGPU, + lowerModuleIndex1, + lowerModuleIndex2, + lowerModuleIndex3, + lowerModuleIndex4, + lowerModuleIndex5, + rPhiChiSquaredInwards)) + return false; + } + //trusting the T5 regression center to also be a good estimate.. + centerX = (centerX + T5CenterX) / 2; + centerY = (centerY + T5CenterY) / 2; + + return true; + }; + + template + ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RZChiSquared(TAcc const& acc, + lst::Modules const& modulesInGPU, + uint16_t* lowerModuleIndices, + float* rtPix, + float* zPix, + float* rts, + float* zs) { + //use the two anchor hits of the pixel segment to compute the slope + //then compute the pseudo chi squared of the five outer hits + + float slope = (zPix[1] - zPix[0]) / (rtPix[1] - rtPix[0]); + float residual = 0; + float error2 = 0; + //hardcoded array indices!!! + float RMSE = 0; + for (size_t i = 0; i < Params_T5::kLayers; i++) { + uint16_t& lowerModuleIndex = lowerModuleIndices[i]; + const int moduleType = modulesInGPU.moduleType[lowerModuleIndex]; + const int moduleSide = modulesInGPU.sides[lowerModuleIndex]; + const int moduleSubdet = modulesInGPU.subdets[lowerModuleIndex]; + + residual = (moduleSubdet == lst::Barrel) ? (zs[i] - zPix[0]) - slope * (rts[i] - rtPix[0]) + : (rts[i] - rtPix[0]) - (zs[i] - zPix[0]) / slope; + const float& drdz = modulesInGPU.drdzs[lowerModuleIndex]; + //PS Modules + if (moduleType == 0) { + error2 = kPixelPSZpitch * kPixelPSZpitch; + } else //2S modules + { + error2 = kStrip2SZpitch * kStrip2SZpitch; + } + + //special dispensation to tilted PS modules! + if (moduleType == 0 and moduleSubdet == lst::Barrel and moduleSide != Center) { + error2 /= (1.f + drdz * drdz); + } + RMSE += (residual * residual) / error2; + } + + RMSE = alpaka::math::sqrt(acc, 0.2f * RMSE); // Divided by the degree of freedom 5. + return RMSE; + }; + + struct createPixelQuintupletsInGPUFromMapv2 { + template + ALPAKA_FN_ACC void operator()(TAcc const& acc, + lst::Modules modulesInGPU, + lst::MiniDoublets mdsInGPU, + lst::Segments segmentsInGPU, + lst::Triplets tripletsInGPU, + lst::Quintuplets quintupletsInGPU, + lst::PixelQuintuplets pixelQuintupletsInGPU, + unsigned int* connectedPixelSize, + unsigned int* connectedPixelIndex, + unsigned int nPixelSegments, + lst::ObjectRanges rangesInGPU) const { + auto const globalBlockIdx = alpaka::getIdx(acc); + auto const globalThreadIdx = alpaka::getIdx(acc); + auto const gridBlockExtent = alpaka::getWorkDiv(acc); + auto const gridThreadExtent = alpaka::getWorkDiv(acc); + + for (unsigned int i_pLS = globalThreadIdx[1]; i_pLS < nPixelSegments; i_pLS += gridThreadExtent[1]) { + auto iLSModule_max = connectedPixelIndex[i_pLS] + connectedPixelSize[i_pLS]; + for (unsigned int iLSModule = connectedPixelIndex[i_pLS] + globalBlockIdx[0]; iLSModule < iLSModule_max; + iLSModule += gridBlockExtent[0]) { + //these are actual module indices + uint16_t quintupletLowerModuleIndex = modulesInGPU.connectedPixels[iLSModule]; + if (quintupletLowerModuleIndex >= *modulesInGPU.nLowerModules) + continue; + if (modulesInGPU.moduleType[quintupletLowerModuleIndex] == lst::TwoS) + continue; + uint16_t pixelModuleIndex = *modulesInGPU.nLowerModules; + if (segmentsInGPU.isDup[i_pLS]) + continue; + unsigned int nOuterQuintuplets = quintupletsInGPU.nQuintuplets[quintupletLowerModuleIndex]; + + if (nOuterQuintuplets == 0) + continue; + + unsigned int pixelSegmentIndex = rangesInGPU.segmentModuleIndices[pixelModuleIndex] + i_pLS; + + //fetch the quintuplet + for (unsigned int outerQuintupletArrayIndex = globalThreadIdx[2]; + outerQuintupletArrayIndex < nOuterQuintuplets; + outerQuintupletArrayIndex += gridThreadExtent[2]) { + unsigned int quintupletIndex = + rangesInGPU.quintupletModuleIndices[quintupletLowerModuleIndex] + outerQuintupletArrayIndex; + + if (quintupletsInGPU.isDup[quintupletIndex]) + continue; + + float rzChiSquared, rPhiChiSquared, rPhiChiSquaredInwards, pixelRadius, quintupletRadius, centerX, centerY; + + bool success = runPixelQuintupletDefaultAlgo(acc, + modulesInGPU, + rangesInGPU, + mdsInGPU, + segmentsInGPU, + tripletsInGPU, + quintupletsInGPU, + pixelSegmentIndex, + quintupletIndex, + rzChiSquared, + rPhiChiSquared, + rPhiChiSquaredInwards, + pixelRadius, + quintupletRadius, + centerX, + centerY, + static_cast(i_pLS)); + if (success) { + unsigned int totOccupancyPixelQuintuplets = + alpaka::atomicOp(acc, pixelQuintupletsInGPU.totOccupancyPixelQuintuplets, 1u); + if (totOccupancyPixelQuintuplets >= n_max_pixel_quintuplets) { +#ifdef WARNINGS + printf("Pixel Quintuplet excess alert!\n"); +#endif + } else { + unsigned int pixelQuintupletIndex = + alpaka::atomicOp(acc, pixelQuintupletsInGPU.nPixelQuintuplets, 1u); + float eta = __H2F(quintupletsInGPU.eta[quintupletIndex]); + float phi = __H2F(quintupletsInGPU.phi[quintupletIndex]); + + addPixelQuintupletToMemory(modulesInGPU, + mdsInGPU, + segmentsInGPU, + quintupletsInGPU, + pixelQuintupletsInGPU, + pixelSegmentIndex, + quintupletIndex, + pixelQuintupletIndex, + rzChiSquared, + rPhiChiSquared, + rPhiChiSquaredInwards, + rPhiChiSquared, + eta, + phi, + pixelRadius, + quintupletRadius, + centerX, + centerY); + + tripletsInGPU.partOfPT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex]] = true; + tripletsInGPU.partOfPT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]] = true; + segmentsInGPU.partOfPT5[i_pLS] = true; + quintupletsInGPU.partOfPT5[quintupletIndex] = true; + } // tot occupancy + } // end success + } // end T5 + } // end iLS + } // end i_pLS + } + }; +} // namespace lst +#endif diff --git a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h index ae0412c3e0bb4..3e6ad10c53fcf 100644 --- a/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h +++ b/RecoTracker/LSTCore/src/alpaka/PixelTriplet.h @@ -19,7 +19,6 @@ namespace lst { unsigned int* nPixelTriplets; unsigned int* totOccupancyPixelTriplets; - float* pixelRadiusError; float* rPhiChiSquared; float* rPhiChiSquaredInwards; float* rzChiSquared; @@ -62,7 +61,6 @@ namespace lst { lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); centerX = alpaka::getPtrNative(buf.centerX_buf); centerY = alpaka::getPtrNative(buf.centerY_buf); - pixelRadiusError = alpaka::getPtrNative(buf.pixelRadiusError_buf); rPhiChiSquared = alpaka::getPtrNative(buf.rPhiChiSquared_buf); rPhiChiSquaredInwards = alpaka::getPtrNative(buf.rPhiChiSquaredInwards_buf); rzChiSquared = alpaka::getPtrNative(buf.rzChiSquared_buf); @@ -132,11 +130,10 @@ namespace lst { inline void setData(PixelTripletsBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelTripletToMemory(struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Triplets& tripletsInGPU, - struct lst::PixelTriplets& pixelTripletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelTripletToMemory(lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Triplets const& tripletsInGPU, + lst::PixelTriplets& pixelTripletsInGPU, unsigned int pixelSegmentIndex, unsigned int tripletIndex, float pixelRadius, @@ -214,42 +211,15 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTrackletDefaultAlgopT3(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::ObjectRanges& rangesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& pixelLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& deltaPhi, - float& betaIn, - float& betaOut, - float& pt_beta, - float& zLo, - float& zHi, - float& rtLo, - float& rtHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, - float& kZ) { - zLo = -999; - zHi = -999; - rtLo = -999; - rtHi = -999; - zLoPointed = -999; - zHiPointed = -999; - kZ = -999; - betaInCut = -999; - + lst::Modules const& modulesInGPU, + lst::ObjectRanges const& rangesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t pixelLowerModuleIndex, + uint16_t outerInnerLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex) { short outerInnerLowerModuleSubdet = modulesInGPU.subdets[outerInnerLowerModuleIndex]; short outerOuterLowerModuleSubdet = modulesInGPU.subdets[outerOuterLowerModuleIndex]; @@ -274,21 +244,7 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - zHi, - zLoPointed, - zHiPointed, - sdlCut, - betaOutCut, - deltaBetaCut); + fourthMDIndex); } else if (outerInnerLowerModuleSubdet == lst::Endcap and outerOuterLowerModuleSubdet == lst::Endcap) { return runTripletDefaultAlgoPPEE(acc, modulesInGPU, @@ -303,31 +259,16 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - rtLo, - rtHi, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ); + fourthMDIndex); } return false; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RZChiSquaredCuts(struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - float& rzChiSquared) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RZChiSquaredCuts(lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + float rzChiSquared) { const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and @@ -426,18 +367,18 @@ namespace lst { //TODO: merge this one and the pT5 function later into a single function template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RPhiChiSquared(TAcc const& acc, - struct lst::Modules& modulesInGPU, + lst::Modules const& modulesInGPU, uint16_t* lowerModuleIndices, - float& g, - float& f, - float& radius, + float g, + float f, + float radius, float* xs, float* ys) { float delta1[3]{}, delta2[3]{}, slopes[3]; bool isFlat[3]{}; float chiSquared = 0; - float inv1 = widthPS / width2S; - float inv2 = pixelPSZpitch / width2S; + float inv1 = kWidthPS / kWidth2S; + float inv2 = kPixelPSZpitch / kWidth2S; for (size_t i = 0; i < 3; i++) { ModuleType moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; short moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; @@ -496,7 +437,7 @@ namespace lst { }; ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RPhiChiSquaredInwards( - struct lst::Modules& modulesInGPU, float& g, float& f, float& r, float* xPix, float* yPix) { + float g, float f, float r, float* xPix, float* yPix) { float residual = (xPix[0] - g) * (xPix[0] - g) + (yPix[0] - f) * (yPix[0] - f) - r * r; float chiSquared = residual * residual; residual = (xPix[1] - g) * (xPix[1] - g) + (yPix[1] - f) * (yPix[1] - f) - r * r; @@ -507,11 +448,11 @@ namespace lst { }; //90pc threshold - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - float& chiSquared) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredCuts(lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + float chiSquared) { const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and @@ -554,11 +495,11 @@ namespace lst { return true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - float& chiSquared) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT3RPhiChiSquaredInwardsCuts(lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + float chiSquared) { const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and @@ -613,19 +554,19 @@ namespace lst { return true; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlappT3(const float& firstMin, - const float& firstMax, - const float& secondMin, - const float& secondMax) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlappT3(float firstMin, + float firstMax, + float secondMin, + float secondMax) { return ((firstMin <= secondMin) && (secondMin < firstMax)) || ((secondMin < firstMin) && (firstMin < secondMax)); }; /*bounds for high Pt taken from : http://uaf-10.t2.ucsd.edu/~bsathian/SDL/T5_efficiency/efficiencies/new_efficiencies/efficiencies_20210513_T5_recovering_high_Pt_efficiencies/highE_radius_matching/highE_bounds.txt */ template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterionBBB(TAcc const& acc, - float const& pixelRadius, - float const& pixelRadiusError, - float const& tripletRadius) { + float pixelRadius, + float pixelRadiusError, + float tripletRadius) { float tripletInvRadiusErrorBound = 0.15624f; float pixelInvRadiusErrorBound = 0.17235f; @@ -647,9 +588,9 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterionBBE(TAcc const& acc, - float const& pixelRadius, - float const& pixelRadiusError, - float const& tripletRadius) { + float pixelRadius, + float pixelRadiusError, + float tripletRadius) { float tripletInvRadiusErrorBound = 0.45972f; float pixelInvRadiusErrorBound = 0.19644f; @@ -671,9 +612,9 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterionBEE(TAcc const& acc, - float const& pixelRadius, - float const& pixelRadiusError, - float const& tripletRadius) { + float pixelRadius, + float pixelRadiusError, + float tripletRadius) { float tripletInvRadiusErrorBound = 1.59294f; float pixelInvRadiusErrorBound = 0.255181f; @@ -697,9 +638,9 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterionEEE(TAcc const& acc, - float const& pixelRadius, - float const& pixelRadiusError, - float const& tripletRadius) { + float pixelRadius, + float pixelRadiusError, + float tripletRadius) { float tripletInvRadiusErrorBound = 1.7006f; float pixelInvRadiusErrorBound = 0.26367f; @@ -723,13 +664,13 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRadiusCriterion(TAcc const& acc, - struct lst::Modules const& modulesInGPU, - float const& pixelRadius, - float const& pixelRadiusError, - float const& tripletRadius, - uint16_t const& lowerModuleIndex, - uint16_t const& middleModuleIndex, - uint16_t const& upperModuleIndex) { + lst::Modules const& modulesInGPU, + float pixelRadius, + float pixelRadiusError, + float tripletRadius, + int16_t lowerModuleIndex, + uint16_t middleModuleIndex, + uint16_t upperModuleIndex) { if (modulesInGPU.subdets[lowerModuleIndex] == lst::Endcap) { return passRadiusCriterionEEE(acc, pixelRadius, pixelRadiusError, tripletRadius); } else if (modulesInGPU.subdets[middleModuleIndex] == lst::Endcap) { @@ -743,7 +684,7 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT3RZChiSquared(TAcc const& acc, - struct lst::Modules const& modulesInGPU, + lst::Modules const& modulesInGPU, const uint16_t* lowerModuleIndices, const float* rtPix, const float* xPix, @@ -811,10 +752,10 @@ namespace lst { //PS Modules if (moduleType == 0) { - error2 = pixelPSZpitch * pixelPSZpitch; + error2 = kPixelPSZpitch * kPixelPSZpitch; } else //2S modules { - error2 = strip2SZpitch * strip2SZpitch; + error2 = kStrip2SZpitch * kStrip2SZpitch; } //special dispensation to tilted PS modules! @@ -832,15 +773,14 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelTripletDefaultAlgo(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::ObjectRanges& rangesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Triplets& tripletsInGPU, - unsigned int& pixelSegmentIndex, + lst::Modules const& modulesInGPU, + lst::ObjectRanges const& rangesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Triplets const& tripletsInGPU, + unsigned int pixelSegmentIndex, unsigned int tripletIndex, float& pixelRadius, - float& pixelRadiusError, float& tripletRadius, float& centerX, float& centerY, @@ -856,10 +796,6 @@ namespace lst { uint16_t upperModuleIndex = tripletsInGPU.lowerModuleIndices[Params_T3::kLayers * tripletIndex + 2]; { - //placeholder - float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, betaOut, pt_beta; //temp stuff - float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut, betaOutCut, deltaBetaCut, kZ; - // pixel segment vs inner segment of the triplet if (not runPixelTrackletDefaultAlgopT3(acc, modulesInGPU, @@ -870,25 +806,7 @@ namespace lst { lowerModuleIndex, middleModuleIndex, pixelSegmentIndex, - tripletsInGPU.segmentIndices[Params_LS::kLayers * tripletIndex], - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - zHi, - rtLo, - rtHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ)) + tripletsInGPU.segmentIndices[Params_LS::kLayers * tripletIndex])) return false; //pixel segment vs outer segment of triplet @@ -901,25 +819,7 @@ namespace lst { middleModuleIndex, upperModuleIndex, pixelSegmentIndex, - tripletsInGPU.segmentIndices[Params_LS::kLayers * tripletIndex + 1], - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - zHi, - rtLo, - rtHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ)) + tripletsInGPU.segmentIndices[Params_LS::kLayers * tripletIndex + 1])) return false; } @@ -940,7 +840,7 @@ namespace lst { unsigned int pixelOuterMDIndex = segmentsInGPU.mdIndices[Params_pLS::kLayers * pixelSegmentIndex + 1]; pixelRadius = pixelSegmentPt * kR1GeVf; - pixelRadiusError = pixelSegmentPtError * kR1GeVf; + float pixelRadiusError = pixelSegmentPtError * kR1GeVf; unsigned int tripletInnerSegmentIndex = tripletsInGPU.segmentIndices[2 * tripletIndex]; unsigned int tripletOuterSegmentIndex = tripletsInGPU.segmentIndices[2 * tripletIndex + 1]; @@ -1014,7 +914,7 @@ namespace lst { float xPix[Params_pLS::kLayers] = {mdsInGPU.anchorX[pixelInnerMDIndex], mdsInGPU.anchorX[pixelOuterMDIndex]}; float yPix[Params_pLS::kLayers] = {mdsInGPU.anchorY[pixelInnerMDIndex], mdsInGPU.anchorY[pixelOuterMDIndex]}; - rPhiChiSquaredInwards = computePT3RPhiChiSquaredInwards(modulesInGPU, g, f, tripletRadius, xPix, yPix); + rPhiChiSquaredInwards = computePT3RPhiChiSquaredInwards(g, f, tripletRadius, xPix, yPix); if (runChiSquaredCuts and pixelSegmentPt < 5.0f) { if (not passPT3RPhiChiSquaredInwardsCuts( @@ -1029,12 +929,12 @@ namespace lst { struct createPixelTripletsInGPUFromMapv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::ObjectRanges rangesInGPU, - struct lst::MiniDoublets mdsInGPU, - struct lst::Segments segmentsInGPU, - struct lst::Triplets tripletsInGPU, - struct lst::PixelTriplets pixelTripletsInGPU, + lst::Modules modulesInGPU, + lst::ObjectRanges rangesInGPU, + lst::MiniDoublets mdsInGPU, + lst::Segments segmentsInGPU, + lst::Triplets tripletsInGPU, + lst::PixelTriplets pixelTripletsInGPU, unsigned int* connectedPixelSize, unsigned int* connectedPixelIndex, unsigned int nPixelSegments) const { @@ -1097,8 +997,7 @@ namespace lst { if (tripletsInGPU.partOfPT5[outerTripletIndex]) continue; //don't create pT3s for T3s accounted in pT5s - float pixelRadius, pixelRadiusError, tripletRadius, rPhiChiSquared, rzChiSquared, rPhiChiSquaredInwards, - centerX, centerY; + float pixelRadius, tripletRadius, rPhiChiSquared, rzChiSquared, rPhiChiSquaredInwards, centerX, centerY; bool success = runPixelTripletDefaultAlgo(acc, modulesInGPU, rangesInGPU, @@ -1108,7 +1007,6 @@ namespace lst { pixelSegmentIndex, outerTripletIndex, pixelRadius, - pixelRadiusError, tripletRadius, centerX, centerY, @@ -1136,8 +1034,7 @@ namespace lst { } else { unsigned int pixelTripletIndex = alpaka::atomicOp(acc, pixelTripletsInGPU.nPixelTriplets, 1u); - addPixelTripletToMemory(modulesInGPU, - mdsInGPU, + addPixelTripletToMemory(mdsInGPU, segmentsInGPU, tripletsInGPU, pixelTripletsInGPU, @@ -1170,75 +1067,82 @@ namespace lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE void runDeltaBetaIterationspT3(TAcc const& acc, float& betaIn, float& betaOut, - float& betaAv, + float betaAv, float& pt_beta, float sdIn_dr, float sdOut_dr, float dr, float lIn) { if (lIn == 0) { - betaOut += lst::copysignf( + betaOut += alpaka::math::copysign( + acc, alpaka::math::asin( acc, - alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), + alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), betaOut); return; } if (betaIn * betaOut > 0.f and - (alpaka::math::abs(acc, pt_beta) < 4.f * lst::pt_betaMax or + (alpaka::math::abs(acc, pt_beta) < 4.f * lst::kPt_betaMax or (lIn >= 11 and alpaka::math::abs(acc, pt_beta) < - 8.f * lst::pt_betaMax))) //and the pt_beta is well-defined; less strict for endcap-endcap + 8.f * lst::kPt_betaMax))) //and the pt_beta is well-defined; less strict for endcap-endcap { const float betaInUpd = - betaIn + - lst::copysignf(alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), - betaIn); //FIXME: need a faster version + betaIn + alpaka::math::copysign( + acc, + alpaka::math::asin( + acc, + alpaka::math::min( + acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), + betaIn); //FIXME: need a faster version const float betaOutUpd = - betaOut + - lst::copysignf(alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), - betaOut); //FIXME: need a faster version + betaOut + alpaka::math::copysign( + acc, + alpaka::math::asin( + acc, + alpaka::math::min( + acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), + betaOut); //FIXME: need a faster version betaAv = 0.5f * (betaInUpd + betaOutUpd); //1st update const float pt_beta_inv = 1.f / alpaka::math::abs(acc, dr * k2Rinv1GeVf / alpaka::math::sin(acc, betaAv)); //get a better pt estimate - betaIn += lst::copysignf( - alpaka::math::asin(acc, alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::sinAlphaMax)), + betaIn += alpaka::math::copysign( + acc, + alpaka::math::asin(acc, alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version - betaOut += lst::copysignf( - alpaka::math::asin(acc, alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::sinAlphaMax)), + betaOut += alpaka::math::copysign( + acc, + alpaka::math::asin(acc, alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::kSinAlphaMax)), betaOut); //FIXME: need a faster version //update the av and pt betaAv = 0.5f * (betaIn + betaOut); //2nd update pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate } else if (lIn < 11 && alpaka::math::abs(acc, betaOut) < 0.2f * alpaka::math::abs(acc, betaIn) && - alpaka::math::abs(acc, pt_beta) < 12.f * lst::pt_betaMax) //use betaIn sign as ref + alpaka::math::abs(acc, pt_beta) < 12.f * lst::kPt_betaMax) //use betaIn sign as ref { const float pt_betaIn = dr * k2Rinv1GeVf / alpaka::math::sin(acc, betaIn); const float betaInUpd = - betaIn + lst::copysignf( + betaIn + alpaka::math::copysign( + acc, alpaka::math::asin( acc, alpaka::math::min( - acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::sinAlphaMax)), + acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version const float betaOutUpd = betaOut + - lst::copysignf( + alpaka::math::copysign( + acc, alpaka::math::asin( acc, alpaka::math::min( - acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::sinAlphaMax)), + acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version betaAv = (alpaka::math::abs(acc, betaOut) > 0.2f * alpaka::math::abs(acc, betaIn)) ? (0.5f * (betaInUpd + betaOutUpd)) @@ -1246,15 +1150,17 @@ namespace lst { //1st update pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate - betaIn += lst::copysignf( + betaIn += alpaka::math::copysign( + acc, alpaka::math::asin( acc, - alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), + alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version - betaOut += lst::copysignf( + betaOut += alpaka::math::copysign( + acc, alpaka::math::asin( acc, - alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), + alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version //update the av and pt betaAv = 0.5f * (betaIn + betaOut); @@ -1265,34 +1171,21 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPBB(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::ObjectRanges& rangesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& pixelModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, + lst::Modules const& modulesInGPU, + lst::ObjectRanges const& rangesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t pixelModuleIndex, + uint16_t outerInnerLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, unsigned int thirdMDIndex, - unsigned int& fourthMDIndex, - float& /*z_OutLo*/, - float& /*rt_OutLo*/, - float& dPhiPos, - float& dPhi, - float& betaIn, - float& betaOut, - float& pt_beta, - float& zLo, - float& zHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaOutCut, - float& deltaBetaCut) // pixel to BB and BE segments - { + unsigned int fourthMDIndex) { + float dPhi, betaIn, betaOut, pt_beta, zLo, zHi, zLoPointed, zHiPointed, sdlCut, betaOutCut; + bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS); float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; @@ -1330,7 +1223,7 @@ namespace lst { ptSLo = alpaka::math::min(acc, 10.0f, ptSLo); float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, kSinAlphaMax)); const float rtRatio_OutLoInOut = rt_OutLo / rt_InOut; // Outer segment beginning rt divided by inner segment beginning rt; @@ -1338,11 +1231,11 @@ namespace lst { alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly const float zpitch_InLo = 0.05f; const float zpitch_InOut = 0.05f; - float zpitch_OutLo = (isPS_OutLo ? pixelPSZpitch : strip2SZpitch); + float zpitch_OutLo = (isPS_OutLo ? kPixelPSZpitch : kStrip2SZpitch); float zGeom = zpitch_InLo + zpitch_OutLo; - zHi = z_InUp + (z_InUp + deltaZLum) * (rtRatio_OutLoInOut - 1.f) * (z_InUp < 0.f ? 1.f : dzDrtScale) + + zHi = z_InUp + (z_InUp + kDeltaZLum) * (rtRatio_OutLoInOut - 1.f) * (z_InUp < 0.f ? 1.f : dzDrtScale) + (zpitch_InOut + zpitch_OutLo); - zLo = z_InUp + (z_InUp - deltaZLum) * (rtRatio_OutLoInOut - 1.f) * (z_InUp > 0.f ? 1.f : dzDrtScale) - + zLo = z_InUp + (z_InUp - kDeltaZLum) * (rtRatio_OutLoInOut - 1.f) * (z_InUp > 0.f ? 1.f : dzDrtScale) - (zpitch_InOut + zpitch_OutLo); //slope-correction only on outer end if ((z_OutLo < zLo) || (z_OutLo > zHi)) @@ -1382,10 +1275,6 @@ namespace lst { const float sdlPVoff = 0.1f / rt_OutLo; sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); -#ifdef CUT_VALUE_DEBUG - dPhiPos = lst::deltaPhi(acc, x_InUp, y_InUp, x_OutUp, y_OutUp); -#endif - //no dphipos cut float midPointX = 0.5f * (x_InLo + x_OutLo); float midPointY = 0.5f * (y_InLo + y_OutLo); @@ -1490,18 +1379,18 @@ namespace lst { betaOutRHmax *= betaOutMMSF; float min_ptBeta_ptBetaMax = alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), lst::pt_betaMax); //need to confirm the range-out value of 7 GeV + acc, alpaka::math::abs(acc, pt_beta), lst::kPt_betaMax); //need to confirm the range-out value of 7 GeV const float dBetaMuls2 = sdlThetaMulsF2 * 16.f / (min_ptBeta_ptBetaMax * min_ptBeta_ptBetaMax); const float alphaInAbsReg = alpaka::math::max(acc, alpaka::math::abs(acc, alpha_InLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InUp * k2Rinv1GeVf / 3.0f, sinAlphaMax))); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_InUp * k2Rinv1GeVf / 3.0f, kSinAlphaMax))); const float alphaOutAbsReg = alpaka::math::max(acc, alpaka::math::abs(acc, alpha_OutLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / 3.0f, sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * deltaZLum / z_InUp); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * deltaZLum / z_OutLo); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / 3.0f, kSinAlphaMax))); + const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * kDeltaZLum / z_InUp); + const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * kDeltaZLum / z_OutLo); const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); const float sinDPhi = alpaka::math::sin(acc, dPhi); @@ -1522,7 +1411,7 @@ namespace lst { const float dBetaROut2 = dBetaROut * dBetaROut; //FIXME: need faster version - betaOutCut = alpaka::math::asin(acc, alpaka::math::min(acc, drt_tl_axis * k2Rinv1GeVf / ptCut, sinAlphaMax)) + + betaOutCut = alpaka::math::asin(acc, alpaka::math::min(acc, drt_tl_axis * k2Rinv1GeVf / ptCut, kSinAlphaMax)) + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls2); //Cut #6: The real beta cut @@ -1535,44 +1424,26 @@ namespace lst { (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax)) * (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); float dBeta = betaIn - betaOut; - -#ifdef CUT_VALUE_DEBUG - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); -#endif return dBeta * dBeta <= dBetaCut2; }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletDefaultAlgoPPEE(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::ObjectRanges& rangesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& pixelModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& /*z_OutLo*/, - float& /*rt_OutLo*/, - float& deltaPhiPos, - float& dPhi, - float& betaIn, - float& betaOut, - float& pt_beta, - float& zLo, - float& rtLo, - float& rtHi, - float& sdlCut, - float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, - float& kZ) // pixel to EE segments - { + lst::Modules const& modulesInGPU, + lst::ObjectRanges const& rangesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t pixelModuleIndex, + uint16_t outerInnerLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, + unsigned int fourthMDIndex) { + float dPhi, betaIn, betaOut, pt_beta, rtLo, rtHi, sdlCut, betaOutCut; + bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS); float z_InUp = mdsInGPU.anchorZ[secondMDIndex]; @@ -1609,29 +1480,27 @@ namespace lst { ptSLo = alpaka::math::max(acc, ptCut, ptSLo - 10.0f * alpaka::math::max(acc, ptErr, 0.005f * ptSLo)); ptSLo = alpaka::math::min(acc, 10.0f, ptSLo); - float rtOut_o_rtIn = rt_OutLo / rt_InUp; const float zpitch_InLo = 0.05f; - float zpitch_OutLo = (isPS_OutLo ? pixelPSZpitch : strip2SZpitch); + float zpitch_OutLo = (isPS_OutLo ? kPixelPSZpitch : kStrip2SZpitch); float zGeom = zpitch_InLo + zpitch_OutLo; - const float sdlSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, sinAlphaMax)); + const float sdlSlope = + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, kSinAlphaMax)); const float dzDrtScale = alpaka::math::tan(acc, sdlSlope) / sdlSlope; //FIXME: need approximate value - zLo = z_InUp + (z_InUp - deltaZLum) * (rtOut_o_rtIn - 1.f) * (z_InUp > 0.f ? 1.f : dzDrtScale) - - zGeom; //slope-correction only on outer end - const float dLum = lst::copysignf(deltaZLum, z_InUp); + const float dLum = alpaka::math::copysign(acc, kDeltaZLum, z_InUp); bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS; const float rtGeom1 = isOutSgInnerMDPS - ? pixelPSZpitch - : strip2SZpitch; //FIXME: make this chosen by configuration for lay11,12 full PS - const float zGeom1 = lst::copysignf(zGeom, z_InUp); //used in B-E region + ? kPixelPSZpitch + : kStrip2SZpitch; //FIXME: make this chosen by configuration for lay11,12 full PS + const float zGeom1 = alpaka::math::copysign(acc, zGeom, z_InUp); //used in B-E region rtLo = rt_InUp * (1.f + (z_OutLo - z_InUp - zGeom1) / (z_InUp + zGeom1 + dLum) / dzDrtScale) - rtGeom1; //slope correction only on the lower end float zInForHi = z_InUp - zGeom1 - dLum; if (zInForHi * z_InUp < 0) - zInForHi = lst::copysignf(0.1f, z_InUp); + zInForHi = alpaka::math::copysign(acc, 0.1f, z_InUp); rtHi = rt_InUp * (1.f + (z_OutLo - z_InUp + zGeom1) / zInForHi) + rtGeom1; // Cut #2: rt condition @@ -1667,12 +1536,10 @@ namespace lst { return false; const float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / ptCut, kSinAlphaMax)); const float sdlPVoff = 0.1f / rt_OutLo; sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); - deltaPhiPos = lst::deltaPhi(acc, x_InUp, y_InUp, x_OutUp, y_OutUp); - float midPointX = 0.5f * (x_InLo + x_OutLo); float midPointY = 0.5f * (y_InLo + y_OutLo); @@ -1772,19 +1639,19 @@ namespace lst { betaOutRHmax *= betaOutMMSF; float min_ptBeta_ptBetaMax = alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), lst::pt_betaMax); //need to confirm the range-out value of 7 GeV + acc, alpaka::math::abs(acc, pt_beta), lst::kPt_betaMax); //need to confirm the range-out value of 7 GeV const float dBetaMuls2 = sdlThetaMulsF2 * 16.f / (min_ptBeta_ptBetaMax * min_ptBeta_ptBetaMax); const float alphaInAbsReg = alpaka::math::max(acc, alpaka::math::abs(acc, alpha_InLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InUp * k2Rinv1GeVf / 3.0f, sinAlphaMax))); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_InUp * k2Rinv1GeVf / 3.0f, kSinAlphaMax))); const float alphaOutAbsReg = alpaka::math::max(acc, alpaka::math::abs(acc, alpha_OutLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / 3.0f, sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * deltaZLum / z_InUp); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * deltaZLum / z_OutLo); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * k2Rinv1GeVf / 3.0f, kSinAlphaMax))); + const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * kDeltaZLum / z_InUp); + const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * kDeltaZLum / z_OutLo); const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); const float sinDPhi = alpaka::math::sin(acc, dPhi); @@ -1806,7 +1673,7 @@ namespace lst { betaOutCut = alpaka::math::asin( - acc, alpaka::math::min(acc, drt_tl_axis * k2Rinv1GeVf / ptCut, sinAlphaMax)) //FIXME: need faster version + acc, alpaka::math::min(acc, drt_tl_axis * k2Rinv1GeVf / ptCut, kSinAlphaMax)) //FIXME: need faster version + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls2); //Cut #6: The real beta cut @@ -1822,960 +1689,8 @@ namespace lst { (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax)) * (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); float dBeta = betaIn - betaOut; -#ifdef CUT_VALUE_DEBUG - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); -#endif return dBeta * dBeta <= dBetaCut2; }; -} // namespace lst -#endif - -#ifndef RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h -#define RecoTracker_LSTCore_src_alpaka_PixelQuintuplet_h - -#include "RecoTracker/LSTCore/interface/alpaka/Constants.h" -#include "RecoTracker/LSTCore/interface/Module.h" - -#include "Segment.h" -#include "MiniDoublet.h" -#include "Hit.h" -#include "Triplet.h" -#include "Quintuplet.h" -#include "PixelTriplet.h" - -namespace lst { - struct PixelQuintuplets { - unsigned int* pixelIndices; - unsigned int* T5Indices; - unsigned int* nPixelQuintuplets; - unsigned int* totOccupancyPixelQuintuplets; - bool* isDup; - FPX* score; - FPX* eta; - FPX* phi; - uint8_t* logicalLayers; - unsigned int* hitIndices; - uint16_t* lowerModuleIndices; - FPX* pixelRadius; - FPX* quintupletRadius; - FPX* centerX; - FPX* centerY; - float* rzChiSquared; - float* rPhiChiSquared; - float* rPhiChiSquaredInwards; - - template - void setData(TBuff& buf) { - pixelIndices = alpaka::getPtrNative(buf.pixelIndices_buf); - T5Indices = alpaka::getPtrNative(buf.T5Indices_buf); - nPixelQuintuplets = alpaka::getPtrNative(buf.nPixelQuintuplets_buf); - totOccupancyPixelQuintuplets = alpaka::getPtrNative(buf.totOccupancyPixelQuintuplets_buf); - isDup = alpaka::getPtrNative(buf.isDup_buf); - score = alpaka::getPtrNative(buf.score_buf); - eta = alpaka::getPtrNative(buf.eta_buf); - phi = alpaka::getPtrNative(buf.phi_buf); - logicalLayers = alpaka::getPtrNative(buf.logicalLayers_buf); - hitIndices = alpaka::getPtrNative(buf.hitIndices_buf); - lowerModuleIndices = alpaka::getPtrNative(buf.lowerModuleIndices_buf); - pixelRadius = alpaka::getPtrNative(buf.pixelRadius_buf); - quintupletRadius = alpaka::getPtrNative(buf.quintupletRadius_buf); - centerX = alpaka::getPtrNative(buf.centerX_buf); - centerY = alpaka::getPtrNative(buf.centerY_buf); - rzChiSquared = alpaka::getPtrNative(buf.rzChiSquared_buf); - rPhiChiSquared = alpaka::getPtrNative(buf.rPhiChiSquared_buf); - rPhiChiSquaredInwards = alpaka::getPtrNative(buf.rPhiChiSquaredInwards_buf); - } - }; - - template - struct PixelQuintupletsBuffer { - Buf pixelIndices_buf; - Buf T5Indices_buf; - Buf nPixelQuintuplets_buf; - Buf totOccupancyPixelQuintuplets_buf; - Buf isDup_buf; - Buf score_buf; - Buf eta_buf; - Buf phi_buf; - Buf logicalLayers_buf; - Buf hitIndices_buf; - Buf lowerModuleIndices_buf; - Buf pixelRadius_buf; - Buf quintupletRadius_buf; - Buf centerX_buf; - Buf centerY_buf; - Buf rzChiSquared_buf; - Buf rPhiChiSquared_buf; - Buf rPhiChiSquaredInwards_buf; - - PixelQuintuplets data_; - - template - PixelQuintupletsBuffer(unsigned int maxPixelQuintuplets, TDevAcc const& devAccIn, TQueue& queue) - : pixelIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - T5Indices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - nPixelQuintuplets_buf(allocBufWrapper(devAccIn, 1, queue)), - totOccupancyPixelQuintuplets_buf(allocBufWrapper(devAccIn, 1, queue)), - isDup_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - score_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - eta_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - phi_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - logicalLayers_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kLayers, queue)), - hitIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kHits, queue)), - lowerModuleIndices_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets * Params_pT5::kLayers, queue)), - pixelRadius_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - quintupletRadius_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - centerX_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - centerY_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - rzChiSquared_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - rPhiChiSquared_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)), - rPhiChiSquaredInwards_buf(allocBufWrapper(devAccIn, maxPixelQuintuplets, queue)) { - alpaka::memset(queue, nPixelQuintuplets_buf, 0u); - alpaka::memset(queue, totOccupancyPixelQuintuplets_buf, 0u); - alpaka::wait(queue); - } - - inline PixelQuintuplets const* data() const { return &data_; } - inline void setData(PixelQuintupletsBuffer& buf) { data_.setData(buf); } - }; - - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelQuintupletToMemory(struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Quintuplets& quintupletsInGPU, - struct lst::PixelQuintuplets& pixelQuintupletsInGPU, - unsigned int pixelIndex, - unsigned int T5Index, - unsigned int pixelQuintupletIndex, - float& rzChiSquared, - float& rPhiChiSquared, - float& rPhiChiSquaredInwards, - float score, - float eta, - float phi, - float& pixelRadius, - float& quintupletRadius, - float& centerX, - float& centerY) { - pixelQuintupletsInGPU.pixelIndices[pixelQuintupletIndex] = pixelIndex; - pixelQuintupletsInGPU.T5Indices[pixelQuintupletIndex] = T5Index; - pixelQuintupletsInGPU.isDup[pixelQuintupletIndex] = false; - pixelQuintupletsInGPU.score[pixelQuintupletIndex] = __F2H(score); - pixelQuintupletsInGPU.eta[pixelQuintupletIndex] = __F2H(eta); - pixelQuintupletsInGPU.phi[pixelQuintupletIndex] = __F2H(phi); - - pixelQuintupletsInGPU.pixelRadius[pixelQuintupletIndex] = __F2H(pixelRadius); - pixelQuintupletsInGPU.quintupletRadius[pixelQuintupletIndex] = __F2H(quintupletRadius); - pixelQuintupletsInGPU.centerX[pixelQuintupletIndex] = __F2H(centerX); - pixelQuintupletsInGPU.centerY[pixelQuintupletIndex] = __F2H(centerY); - - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex] = 0; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 1] = 0; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 2] = - quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 3] = - quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 1]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 4] = - quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 2]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 5] = - quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 3]; - pixelQuintupletsInGPU.logicalLayers[Params_pT5::kLayers * pixelQuintupletIndex + 6] = - quintupletsInGPU.logicalLayers[T5Index * Params_T5::kLayers + 4]; - - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex] = - segmentsInGPU.innerLowerModuleIndices[pixelIndex]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 1] = - segmentsInGPU.outerLowerModuleIndices[pixelIndex]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 2] = - quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 3] = - quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 1]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 4] = - quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 2]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 5] = - quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 3]; - pixelQuintupletsInGPU.lowerModuleIndices[Params_pT5::kLayers * pixelQuintupletIndex + 6] = - quintupletsInGPU.lowerModuleIndices[T5Index * Params_T5::kLayers + 4]; - - unsigned int pixelInnerMD = segmentsInGPU.mdIndices[Params_pLS::kLayers * pixelIndex]; - unsigned int pixelOuterMD = segmentsInGPU.mdIndices[Params_pLS::kLayers * pixelIndex + 1]; - - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex] = - mdsInGPU.anchorHitIndices[pixelInnerMD]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 1] = - mdsInGPU.outerHitIndices[pixelInnerMD]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 2] = - mdsInGPU.anchorHitIndices[pixelOuterMD]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 3] = - mdsInGPU.outerHitIndices[pixelOuterMD]; - - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 4] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 5] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 1]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 6] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 2]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 7] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 3]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 8] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 4]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 9] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 5]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 10] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 6]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 11] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 7]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 12] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 8]; - pixelQuintupletsInGPU.hitIndices[Params_pT5::kHits * pixelQuintupletIndex + 13] = - quintupletsInGPU.hitIndices[Params_T5::kHits * T5Index + 9]; - - pixelQuintupletsInGPU.rzChiSquared[pixelQuintupletIndex] = rzChiSquared; - pixelQuintupletsInGPU.rPhiChiSquared[pixelQuintupletIndex] = rPhiChiSquared; - pixelQuintupletsInGPU.rPhiChiSquaredInwards[pixelQuintupletIndex] = rPhiChiSquaredInwards; - }; - - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RZChiSquaredCuts(struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - uint16_t& lowerModuleIndex4, - uint16_t& lowerModuleIndex5, - float& rzChiSquared) { - const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + - 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex1] == lst::TwoS); - const int layer2 = modulesInGPU.layers[lowerModuleIndex2] + - 6 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex2] == lst::TwoS); - const int layer3 = modulesInGPU.layers[lowerModuleIndex3] + - 6 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex3] == lst::TwoS); - const int layer4 = modulesInGPU.layers[lowerModuleIndex4] + - 6 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex4] == lst::TwoS); - const int layer5 = modulesInGPU.layers[lowerModuleIndex5] + - 6 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex5] == lst::TwoS); - - if (layer1 == 1 and layer2 == 2 and layer3 == 3) { - if (layer4 == 12 and layer5 == 13) { - return rzChiSquared < 451.141f; - } else if (layer4 == 4 and layer5 == 12) { - return rzChiSquared < 392.654f; - } else if (layer4 == 4 and layer5 == 5) { - return rzChiSquared < 225.322f; - } else if (layer4 == 7 and layer5 == 13) { - return rzChiSquared < 595.546f; - } else if (layer4 == 7 and layer5 == 8) { - return rzChiSquared < 196.111f; - } - } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { - if (layer4 == 13 and layer5 == 14) { - return rzChiSquared < 297.446f; - } else if (layer4 == 8 and layer5 == 14) { - return rzChiSquared < 451.141f; - } else if (layer4 == 8 and layer5 == 9) { - return rzChiSquared < 518.339f; - } - } else if (layer1 == 1 and layer2 == 7 and layer3 == 8) { - if (layer4 == 9 and layer5 == 10) { - return rzChiSquared < 341.75f; - } else if (layer4 == 9 and layer5 == 15) { - return rzChiSquared < 341.75f; - } - } else if (layer1 == 2 and layer2 == 3 and layer3 == 4) { - if (layer4 == 12 and layer5 == 13) { - return rzChiSquared < 392.655f; - } else if (layer4 == 5 and layer5 == 12) { - return rzChiSquared < 341.75f; - } else if (layer4 == 5 and layer5 == 6) { - return rzChiSquared < 112.537f; - } - } else if (layer1 == 2 and layer2 == 3 and layer4 == 7) { - if (layer4 == 13 and layer5 == 14) { - return rzChiSquared < 595.545f; - } else if (layer4 == 8 and layer5 == 14) { - return rzChiSquared < 74.198f; - } - } else if (layer1 == 2 and layer2 == 7 and layer3 == 8) { - if (layer4 == 14 and layer5 == 15) { - return rzChiSquared < 518.339f; - } else if (layer4 == 9 and layer5 == 10) { - return rzChiSquared < 8.046f; - } else if (layer4 == 9 and layer5 == 15) { - return rzChiSquared < 451.141f; - } - } else if (layer1 == 3 and layer2 == 7 and layer3 == 8 and layer4 == 14 and layer5 == 15) { - return rzChiSquared < 56.207f; - } else if (layer1 == 7 and layer2 == 8 and layer3 == 9) { - if (layer4 == 10 and layer5 == 11) { - return rzChiSquared < 64.578f; - } else if (layer4 == 10 and layer5 == 16) { - return rzChiSquared < 85.250f; - } else if (layer4 == 15 and layer5 == 16) { - return rzChiSquared < 85.250f; - } - } - return true; - }; - - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredCuts(struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - uint16_t& lowerModuleIndex4, - uint16_t& lowerModuleIndex5, - float rPhiChiSquared) { - const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + - 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex1] == lst::TwoS); - const int layer2 = modulesInGPU.layers[lowerModuleIndex2] + - 6 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex2] == lst::TwoS); - const int layer3 = modulesInGPU.layers[lowerModuleIndex3] + - 6 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex3] == lst::TwoS); - const int layer4 = modulesInGPU.layers[lowerModuleIndex4] + - 6 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex4] == lst::TwoS); - const int layer5 = modulesInGPU.layers[lowerModuleIndex5] + - 6 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex5] == lst::TwoS); - - if (layer1 == 1 and layer2 == 2 and layer3 == 3) { - if (layer4 == 12 and layer5 == 13) { - return rPhiChiSquared < 48.921f; - } else if (layer4 == 4 and layer5 == 12) { - return rPhiChiSquared < 97.948f; - } else if (layer4 == 4 and layer5 == 5) { - return rPhiChiSquared < 129.3f; - } else if (layer4 == 7 and layer5 == 13) { - return rPhiChiSquared < 56.21f; - } else if (layer4 == 7 and layer5 == 8) { - return rPhiChiSquared < 74.198f; - } - } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { - if (layer4 == 13 and layer5 == 14) { - return rPhiChiSquared < 21.265f; - } else if (layer4 == 8 and layer5 == 14) { - return rPhiChiSquared < 37.058f; - } else if (layer4 == 8 and layer5 == 9) { - return rPhiChiSquared < 42.578f; - } - } else if (layer1 == 1 and layer2 == 7 and layer3 == 8) { - if (layer4 == 9 and layer5 == 10) { - return rPhiChiSquared < 32.253f; - } else if (layer4 == 9 and layer5 == 15) { - return rPhiChiSquared < 37.058f; - } - } else if (layer1 == 2 and layer2 == 3 and layer3 == 4) { - if (layer4 == 12 and layer5 == 13) { - return rPhiChiSquared < 97.947f; - } else if (layer4 == 5 and layer5 == 12) { - return rPhiChiSquared < 129.3f; - } else if (layer4 == 5 and layer5 == 6) { - return rPhiChiSquared < 170.68f; - } - } else if (layer1 == 2 and layer2 == 3 and layer3 == 7) { - if (layer4 == 13 and layer5 == 14) { - return rPhiChiSquared < 48.92f; - } else if (layer4 == 8 and layer5 == 14) { - return rPhiChiSquared < 74.2f; - } - } else if (layer1 == 2 and layer2 == 7 and layer3 == 8) { - if (layer4 == 14 and layer5 == 15) { - return rPhiChiSquared < 42.58f; - } else if (layer4 == 9 and layer5 == 10) { - return rPhiChiSquared < 37.06f; - } else if (layer4 == 9 and layer5 == 15) { - return rPhiChiSquared < 48.92f; - } - } else if (layer1 == 3 and layer2 == 7 and layer3 == 8 and layer4 == 14 and layer5 == 15) { - return rPhiChiSquared < 85.25f; - } else if (layer1 == 7 and layer2 == 8 and layer3 == 9) { - if (layer4 == 10 and layer5 == 11) { - return rPhiChiSquared < 42.58f; - } else if (layer4 == 10 and layer5 == 16) { - return rPhiChiSquared < 37.06f; - } else if (layer4 == 15 and layer5 == 16) { - return rPhiChiSquared < 37.06f; - } - } - return true; - }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE float computeChiSquaredpT5(TAcc const& acc, - unsigned int nPoints, - float* xs, - float* ys, - float* delta1, - float* delta2, - float* slopes, - bool* isFlat, - float g, - float f, - float radius) { - /* - Given values of (g, f, radius) and a set of points (and its uncertainties) compute chi squared - */ - float c = g * g + f * f - radius * radius; - float chiSquared = 0.f; - float absArctanSlope, angleM, xPrime, yPrime, sigma2; - for (size_t i = 0; i < nPoints; i++) { - absArctanSlope = ((slopes[i] != lst::lst_INF) ? alpaka::math::abs(acc, alpaka::math::atan(acc, slopes[i])) - : 0.5f * float(M_PI)); - if (xs[i] > 0 and ys[i] > 0) { - angleM = 0.5f * float(M_PI) - absArctanSlope; - } else if (xs[i] < 0 and ys[i] > 0) { - angleM = absArctanSlope + 0.5f * float(M_PI); - } else if (xs[i] < 0 and ys[i] < 0) { - angleM = -(absArctanSlope + 0.5f * float(M_PI)); - } else if (xs[i] > 0 and ys[i] < 0) { - angleM = -(0.5f * float(M_PI) - absArctanSlope); - } else { - angleM = 0; - } - if (not isFlat[i]) { - xPrime = xs[i] * alpaka::math::cos(acc, angleM) + ys[i] * alpaka::math::sin(acc, angleM); - yPrime = ys[i] * alpaka::math::cos(acc, angleM) - xs[i] * alpaka::math::sin(acc, angleM); - } else { - xPrime = xs[i]; - yPrime = ys[i]; - } - sigma2 = 4 * ((xPrime * delta1[i]) * (xPrime * delta1[i]) + (yPrime * delta2[i]) * (yPrime * delta2[i])); - chiSquared += (xs[i] * xs[i] + ys[i] * ys[i] - 2 * g * xs[i] - 2 * f * ys[i] + c) * - (xs[i] * xs[i] + ys[i] * ys[i] - 2 * g * xs[i] - 2 * f * ys[i] + c) / (sigma2); - } - return chiSquared; - }; - - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression_pT5(TAcc const& acc, - lst::Modules& modulesInGPU, - const uint16_t* lowerModuleIndices, - float* delta1, - float* delta2, - float* slopes, - bool* isFlat, - unsigned int nPoints = 5, - bool anchorHits = true) { - /* - bool anchorHits required to deal with a weird edge case wherein - the hits ultimately used in the regression are anchor hits, but the - lower modules need not all be Pixel Modules (in case of PS). Similarly, - when we compute the chi squared for the non-anchor hits, the "partner module" - need not always be a PS strip module, but all non-anchor hits sit on strip - modules. - */ - ModuleType moduleType; - short moduleSubdet, moduleSide; - float inv1 = widthPS / width2S; - float inv2 = pixelPSZpitch / width2S; - float inv3 = stripPSZpitch / width2S; - for (size_t i = 0; i < nPoints; i++) { - moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; - moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; - moduleSide = modulesInGPU.sides[lowerModuleIndices[i]]; - const float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; - slopes[i] = modulesInGPU.dxdys[lowerModuleIndices[i]]; - //category 1 - barrel PS flat - if (moduleSubdet == Barrel and moduleType == PS and moduleSide == Center) { - delta1[i] = inv1; - delta2[i] = inv1; - slopes[i] = -999.f; - isFlat[i] = true; - } - //category 2 - barrel 2S - else if (moduleSubdet == Barrel and moduleType == TwoS) { - delta1[i] = 1.f; - delta2[i] = 1.f; - slopes[i] = -999.f; - isFlat[i] = true; - } - //category 3 - barrel PS tilted - else if (moduleSubdet == Barrel and moduleType == PS and moduleSide != Center) { - delta1[i] = inv1; - isFlat[i] = false; - - if (anchorHits) { - delta2[i] = (inv2 * drdz / alpaka::math::sqrt(acc, 1 + drdz * drdz)); - } else { - delta2[i] = (inv3 * drdz / alpaka::math::sqrt(acc, 1 + drdz * drdz)); - } - } - //category 4 - endcap PS - else if (moduleSubdet == Endcap and moduleType == PS) { - delta1[i] = inv1; - isFlat[i] = false; - /* - despite the type of the module layer of the lower module index, - all anchor hits are on the pixel side and all non-anchor hits are - on the strip side! - */ - if (anchorHits) { - delta2[i] = inv2; - } else { - delta2[i] = inv3; - } - } - //category 5 - endcap 2S - else if (moduleSubdet == Endcap and moduleType == TwoS) { - delta1[i] = 1.f; - delta2[i] = 500.f * inv1; - isFlat[i] = false; - } -#ifdef WARNINGS - else { - printf("ERROR!!!!! I SHOULDN'T BE HERE!!!! subdet = %d, type = %d, side = %d\n", - moduleSubdet, - moduleType, - moduleSide); - } -#endif - } - }; - - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquared(TAcc const& acc, - struct lst::Modules& modulesInGPU, - uint16_t* lowerModuleIndices, - float& g, - float& f, - float& radius, - float* xs, - float* ys) { - /* - Compute circle parameters from 3 pixel hits, and then use them to compute the chi squared for the outer hits - */ - - float delta1[5], delta2[5], slopes[5]; - bool isFlat[5]; - float chiSquared = 0; - - computeSigmasForRegression_pT5(acc, modulesInGPU, lowerModuleIndices, delta1, delta2, slopes, isFlat); - chiSquared = computeChiSquaredpT5(acc, 5, xs, ys, delta1, delta2, slopes, isFlat, g, f, radius); - - return chiSquared; - }; - - ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RPhiChiSquaredInwards( - struct lst::Modules& modulesInGPU, float& g, float& f, float& r, float* xPix, float* yPix) { - /* - Using the computed regression center and radius, compute the chi squared for the pixels - */ - - float chiSquared = 0; - for (size_t i = 0; i < 2; i++) { - float residual = (xPix[i] - g) * (xPix[i] - g) + (yPix[i] - f) * (yPix[i] - f) - r * r; - chiSquared += residual * residual; - } - chiSquared *= 0.5f; - return chiSquared; - }; - - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPT5RPhiChiSquaredInwardsCuts(struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - uint16_t& lowerModuleIndex4, - uint16_t& lowerModuleIndex5, - float rPhiChiSquared) { - const int layer1 = modulesInGPU.layers[lowerModuleIndex1] + - 6 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex1] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex1] == lst::TwoS); - const int layer2 = modulesInGPU.layers[lowerModuleIndex2] + - 6 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex2] == lst::TwoS); - const int layer3 = modulesInGPU.layers[lowerModuleIndex3] + - 6 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex3] == lst::TwoS); - const int layer4 = modulesInGPU.layers[lowerModuleIndex4] + - 6 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex4] == lst::TwoS); - const int layer5 = modulesInGPU.layers[lowerModuleIndex5] + - 6 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) + - 5 * (modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap and - modulesInGPU.moduleType[lowerModuleIndex5] == lst::TwoS); - - if (layer1 == 1 and layer2 == 2 and layer3 == 3) { - if (layer4 == 12 and layer5 == 13) { - return rPhiChiSquared < 451.141f; - } else if (layer4 == 4 and layer5 == 12) { - return rPhiChiSquared < 786.173f; - } else if (layer4 == 4 and layer5 == 5) { - return rPhiChiSquared < 595.545f; - } else if (layer4 == 7 and layer5 == 13) { - return rPhiChiSquared < 581.339f; - } else if (layer4 == 7 and layer5 == 8) { - return rPhiChiSquared < 112.537f; - } - } else if (layer1 == 1 and layer2 == 2 and layer3 == 7) { - if (layer4 == 13 and layer5 == 14) { - return rPhiChiSquared < 225.322f; - } else if (layer4 == 8 and layer5 == 14) { - return rPhiChiSquared < 1192.402f; - } else if (layer4 == 8 and layer5 == 9) { - return rPhiChiSquared < 786.173f; - } - } else if (layer1 == 1 and layer2 == 7 and layer3 == 8) { - if (layer4 == 9 and layer5 == 10) { - return rPhiChiSquared < 1037.817f; - } else if (layer4 == 9 and layer5 == 15) { - return rPhiChiSquared < 1808.536f; - } - } else if (layer1 == 2 and layer2 == 3 and layer3 == 4) { - if (layer4 == 12 and layer5 == 13) { - return rPhiChiSquared < 684.253f; - } else if (layer4 == 5 and layer5 == 12) { - return rPhiChiSquared < 684.253f; - } else if (layer4 == 5 and layer5 == 6) { - return rPhiChiSquared < 684.253f; - } - } else if (layer1 == 2 and layer2 == 3 and layer3 == 7) { - if (layer4 == 13 and layer5 == 14) { - return rPhiChiSquared < 451.141f; - } else if (layer4 == 8 and layer5 == 14) { - return rPhiChiSquared < 518.34f; - } - } else if (layer1 == 2 and layer2 == 7 and layer3 == 8) { - if (layer4 == 14 and layer5 == 15) { - return rPhiChiSquared < 2077.92f; - } else if (layer4 == 9 and layer5 == 10) { - return rPhiChiSquared < 74.20f; - } else if (layer4 == 9 and layer5 == 15) { - return rPhiChiSquared < 1808.536f; - } - } else if (layer1 == 3 and layer2 == 7 and layer3 == 8 and layer4 == 14 and layer5 == 15) { - return rPhiChiSquared < 786.173f; - } else if (layer1 == 7 and layer2 == 8 and layer3 == 9) { - if (layer4 == 10 and layer5 == 11) { - return rPhiChiSquared < 1574.076f; - } else if (layer4 == 10 and layer5 == 16) { - return rPhiChiSquared < 5492.11f; - } else if (layer4 == 15 and layer5 == 16) { - return rPhiChiSquared < 2743.037f; - } - } - return true; - }; - - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runPixelQuintupletDefaultAlgo(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::ObjectRanges& rangesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Triplets& tripletsInGPU, - struct lst::Quintuplets& quintupletsInGPU, - unsigned int& pixelSegmentIndex, - unsigned int& quintupletIndex, - float& rzChiSquared, - float& rPhiChiSquared, - float& rPhiChiSquaredInwards, - float& pixelRadius, - float& quintupletRadius, - float& centerX, - float& centerY, - unsigned int pixelSegmentArrayIndex) { - unsigned int T5InnerT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex]; - unsigned int T5OuterT3Index = quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]; - - float pixelRadiusTemp, pixelRadiusError, tripletRadius, rPhiChiSquaredTemp, rzChiSquaredTemp, - rPhiChiSquaredInwardsTemp, centerXTemp, centerYTemp; - - if (not runPixelTripletDefaultAlgo(acc, - modulesInGPU, - rangesInGPU, - mdsInGPU, - segmentsInGPU, - tripletsInGPU, - pixelSegmentIndex, - T5InnerT3Index, - pixelRadiusTemp, - pixelRadiusError, - tripletRadius, - centerXTemp, - centerYTemp, - rzChiSquaredTemp, - rPhiChiSquaredTemp, - rPhiChiSquaredInwardsTemp, - false)) - return false; - - unsigned int firstSegmentIndex = tripletsInGPU.segmentIndices[2 * T5InnerT3Index]; - unsigned int secondSegmentIndex = tripletsInGPU.segmentIndices[2 * T5InnerT3Index + 1]; - unsigned int thirdSegmentIndex = tripletsInGPU.segmentIndices[2 * T5OuterT3Index]; - unsigned int fourthSegmentIndex = tripletsInGPU.segmentIndices[2 * T5OuterT3Index + 1]; - - unsigned int pixelInnerMDIndex = segmentsInGPU.mdIndices[2 * pixelSegmentIndex]; - unsigned int pixelOuterMDIndex = segmentsInGPU.mdIndices[2 * pixelSegmentIndex + 1]; - unsigned int firstMDIndex = segmentsInGPU.mdIndices[2 * firstSegmentIndex]; - unsigned int secondMDIndex = segmentsInGPU.mdIndices[2 * secondSegmentIndex]; - unsigned int thirdMDIndex = segmentsInGPU.mdIndices[2 * secondSegmentIndex + 1]; - unsigned int fourthMDIndex = segmentsInGPU.mdIndices[2 * thirdSegmentIndex + 1]; - unsigned int fifthMDIndex = segmentsInGPU.mdIndices[2 * fourthSegmentIndex + 1]; - - uint16_t lowerModuleIndex1 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex]; - uint16_t lowerModuleIndex2 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 1]; - uint16_t lowerModuleIndex3 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 2]; - uint16_t lowerModuleIndex4 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 3]; - uint16_t lowerModuleIndex5 = quintupletsInGPU.lowerModuleIndices[Params_T5::kLayers * quintupletIndex + 4]; - - uint16_t lowerModuleIndices[Params_T5::kLayers] = { - lowerModuleIndex1, lowerModuleIndex2, lowerModuleIndex3, lowerModuleIndex4, lowerModuleIndex5}; - - float zPix[Params_pLS::kLayers] = {mdsInGPU.anchorZ[pixelInnerMDIndex], mdsInGPU.anchorZ[pixelOuterMDIndex]}; - float rtPix[Params_pLS::kLayers] = {mdsInGPU.anchorRt[pixelInnerMDIndex], mdsInGPU.anchorRt[pixelOuterMDIndex]}; - float zs[Params_T5::kLayers] = {mdsInGPU.anchorZ[firstMDIndex], - mdsInGPU.anchorZ[secondMDIndex], - mdsInGPU.anchorZ[thirdMDIndex], - mdsInGPU.anchorZ[fourthMDIndex], - mdsInGPU.anchorZ[fifthMDIndex]}; - float rts[Params_T5::kLayers] = {mdsInGPU.anchorRt[firstMDIndex], - mdsInGPU.anchorRt[secondMDIndex], - mdsInGPU.anchorRt[thirdMDIndex], - mdsInGPU.anchorRt[fourthMDIndex], - mdsInGPU.anchorRt[fifthMDIndex]}; - - rzChiSquared = computePT5RZChiSquared(acc, modulesInGPU, lowerModuleIndices, rtPix, zPix, rts, zs); - - if (/*pixelRadius*/ 0 < 5.0f * kR1GeVf) { // FIXME: pixelRadius is not defined yet - if (not passPT5RZChiSquaredCuts(modulesInGPU, - lowerModuleIndex1, - lowerModuleIndex2, - lowerModuleIndex3, - lowerModuleIndex4, - lowerModuleIndex5, - rzChiSquared)) - return false; - } - - //outer T5 - float xs[Params_T5::kLayers] = {mdsInGPU.anchorX[firstMDIndex], - mdsInGPU.anchorX[secondMDIndex], - mdsInGPU.anchorX[thirdMDIndex], - mdsInGPU.anchorX[fourthMDIndex], - mdsInGPU.anchorX[fifthMDIndex]}; - float ys[Params_T5::kLayers] = {mdsInGPU.anchorY[firstMDIndex], - mdsInGPU.anchorY[secondMDIndex], - mdsInGPU.anchorY[thirdMDIndex], - mdsInGPU.anchorY[fourthMDIndex], - mdsInGPU.anchorY[fifthMDIndex]}; - - //get the appropriate radii and centers - centerX = segmentsInGPU.circleCenterX[pixelSegmentArrayIndex]; - centerY = segmentsInGPU.circleCenterY[pixelSegmentArrayIndex]; - pixelRadius = segmentsInGPU.circleRadius[pixelSegmentArrayIndex]; - - float T5CenterX = quintupletsInGPU.regressionG[quintupletIndex]; - float T5CenterY = quintupletsInGPU.regressionF[quintupletIndex]; - quintupletRadius = quintupletsInGPU.regressionRadius[quintupletIndex]; - - rPhiChiSquared = - computePT5RPhiChiSquared(acc, modulesInGPU, lowerModuleIndices, centerX, centerY, pixelRadius, xs, ys); - - if (pixelRadius < 5.0f * kR1GeVf) { - if (not passPT5RPhiChiSquaredCuts(modulesInGPU, - lowerModuleIndex1, - lowerModuleIndex2, - lowerModuleIndex3, - lowerModuleIndex4, - lowerModuleIndex5, - rPhiChiSquared)) - return false; - } - - float xPix[] = {mdsInGPU.anchorX[pixelInnerMDIndex], mdsInGPU.anchorX[pixelOuterMDIndex]}; - float yPix[] = {mdsInGPU.anchorY[pixelInnerMDIndex], mdsInGPU.anchorY[pixelOuterMDIndex]}; - rPhiChiSquaredInwards = - computePT5RPhiChiSquaredInwards(modulesInGPU, T5CenterX, T5CenterY, quintupletRadius, xPix, yPix); - - if (quintupletsInGPU.regressionRadius[quintupletIndex] < 5.0f * kR1GeVf) { - if (not passPT5RPhiChiSquaredInwardsCuts(modulesInGPU, - lowerModuleIndex1, - lowerModuleIndex2, - lowerModuleIndex3, - lowerModuleIndex4, - lowerModuleIndex5, - rPhiChiSquaredInwards)) - return false; - } - //trusting the T5 regression center to also be a good estimate.. - centerX = (centerX + T5CenterX) / 2; - centerY = (centerY + T5CenterY) / 2; - - return true; - }; - - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE float computePT5RZChiSquared(TAcc const& acc, - struct lst::Modules& modulesInGPU, - uint16_t* lowerModuleIndices, - float* rtPix, - float* zPix, - float* rts, - float* zs) { - //use the two anchor hits of the pixel segment to compute the slope - //then compute the pseudo chi squared of the five outer hits - - float slope = (zPix[1] - zPix[0]) / (rtPix[1] - rtPix[0]); - float residual = 0; - float error2 = 0; - //hardcoded array indices!!! - float RMSE = 0; - for (size_t i = 0; i < Params_T5::kLayers; i++) { - uint16_t& lowerModuleIndex = lowerModuleIndices[i]; - const int moduleType = modulesInGPU.moduleType[lowerModuleIndex]; - const int moduleSide = modulesInGPU.sides[lowerModuleIndex]; - const int moduleSubdet = modulesInGPU.subdets[lowerModuleIndex]; - - residual = (moduleSubdet == lst::Barrel) ? (zs[i] - zPix[0]) - slope * (rts[i] - rtPix[0]) - : (rts[i] - rtPix[0]) - (zs[i] - zPix[0]) / slope; - const float& drdz = modulesInGPU.drdzs[lowerModuleIndex]; - //PS Modules - if (moduleType == 0) { - error2 = pixelPSZpitch * pixelPSZpitch; - } else //2S modules - { - error2 = strip2SZpitch * strip2SZpitch; - } - - //special dispensation to tilted PS modules! - if (moduleType == 0 and moduleSubdet == lst::Barrel and moduleSide != Center) { - error2 /= (1.f + drdz * drdz); - } - RMSE += (residual * residual) / error2; - } - - RMSE = alpaka::math::sqrt(acc, 0.2f * RMSE); // Divided by the degree of freedom 5. - return RMSE; - }; - - struct createPixelQuintupletsInGPUFromMapv2 { - template - ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::MiniDoublets mdsInGPU, - struct lst::Segments segmentsInGPU, - struct lst::Triplets tripletsInGPU, - struct lst::Quintuplets quintupletsInGPU, - struct lst::PixelQuintuplets pixelQuintupletsInGPU, - unsigned int* connectedPixelSize, - unsigned int* connectedPixelIndex, - unsigned int nPixelSegments, - struct lst::ObjectRanges rangesInGPU) const { - auto const globalBlockIdx = alpaka::getIdx(acc); - auto const globalThreadIdx = alpaka::getIdx(acc); - auto const gridBlockExtent = alpaka::getWorkDiv(acc); - auto const gridThreadExtent = alpaka::getWorkDiv(acc); - - for (unsigned int i_pLS = globalThreadIdx[1]; i_pLS < nPixelSegments; i_pLS += gridThreadExtent[1]) { - auto iLSModule_max = connectedPixelIndex[i_pLS] + connectedPixelSize[i_pLS]; - for (unsigned int iLSModule = connectedPixelIndex[i_pLS] + globalBlockIdx[0]; iLSModule < iLSModule_max; - iLSModule += gridBlockExtent[0]) { - //these are actual module indices - uint16_t quintupletLowerModuleIndex = modulesInGPU.connectedPixels[iLSModule]; - if (quintupletLowerModuleIndex >= *modulesInGPU.nLowerModules) - continue; - if (modulesInGPU.moduleType[quintupletLowerModuleIndex] == lst::TwoS) - continue; - uint16_t pixelModuleIndex = *modulesInGPU.nLowerModules; - if (segmentsInGPU.isDup[i_pLS]) - continue; - unsigned int nOuterQuintuplets = quintupletsInGPU.nQuintuplets[quintupletLowerModuleIndex]; - - if (nOuterQuintuplets == 0) - continue; - - unsigned int pixelSegmentIndex = rangesInGPU.segmentModuleIndices[pixelModuleIndex] + i_pLS; - - //fetch the quintuplet - for (unsigned int outerQuintupletArrayIndex = globalThreadIdx[2]; - outerQuintupletArrayIndex < nOuterQuintuplets; - outerQuintupletArrayIndex += gridThreadExtent[2]) { - unsigned int quintupletIndex = - rangesInGPU.quintupletModuleIndices[quintupletLowerModuleIndex] + outerQuintupletArrayIndex; - - if (quintupletsInGPU.isDup[quintupletIndex]) - continue; - - float rzChiSquared, rPhiChiSquared, rPhiChiSquaredInwards, pixelRadius, quintupletRadius, centerX, centerY; - - bool success = runPixelQuintupletDefaultAlgo(acc, - modulesInGPU, - rangesInGPU, - mdsInGPU, - segmentsInGPU, - tripletsInGPU, - quintupletsInGPU, - pixelSegmentIndex, - quintupletIndex, - rzChiSquared, - rPhiChiSquared, - rPhiChiSquaredInwards, - pixelRadius, - quintupletRadius, - centerX, - centerY, - static_cast(i_pLS)); - if (success) { - unsigned int totOccupancyPixelQuintuplets = - alpaka::atomicOp(acc, pixelQuintupletsInGPU.totOccupancyPixelQuintuplets, 1u); - if (totOccupancyPixelQuintuplets >= n_max_pixel_quintuplets) { -#ifdef WARNINGS - printf("Pixel Quintuplet excess alert!\n"); -#endif - } else { - unsigned int pixelQuintupletIndex = - alpaka::atomicOp(acc, pixelQuintupletsInGPU.nPixelQuintuplets, 1u); - float eta = __H2F(quintupletsInGPU.eta[quintupletIndex]); - float phi = __H2F(quintupletsInGPU.phi[quintupletIndex]); - - addPixelQuintupletToMemory(modulesInGPU, - mdsInGPU, - segmentsInGPU, - quintupletsInGPU, - pixelQuintupletsInGPU, - pixelSegmentIndex, - quintupletIndex, - pixelQuintupletIndex, - rzChiSquared, - rPhiChiSquared, - rPhiChiSquaredInwards, - rPhiChiSquared, - eta, - phi, - pixelRadius, - quintupletRadius, - centerX, - centerY); - - tripletsInGPU.partOfPT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex]] = true; - tripletsInGPU.partOfPT5[quintupletsInGPU.tripletIndices[2 * quintupletIndex + 1]] = true; - segmentsInGPU.partOfPT5[i_pLS] = true; - quintupletsInGPU.partOfPT5[quintupletIndex] = true; - } // tot occupancy - } // end success - } // end T5 - } // end iLS - } // end i_pLS - } - }; } // namespace lst #endif diff --git a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h index 08ff1067642b9..12e213e68e050 100644 --- a/RecoTracker/LSTCore/src/alpaka/Quintuplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Quintuplet.h @@ -143,31 +143,31 @@ namespace lst { inline void setData(QuintupletsBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlap(const float& firstMin, - const float& firstMax, - const float& secondMin, - const float& secondMax) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool checkIntervalOverlap(float firstMin, + float firstMax, + float secondMin, + float secondMax) { return ((firstMin <= secondMin) && (secondMin < firstMax)) || ((secondMin < firstMin) && (firstMin < secondMax)); }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(struct lst::Triplets& tripletsInGPU, - struct lst::Quintuplets& quintupletsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addQuintupletToMemory(lst::Triplets const& tripletsInGPU, + lst::Quintuplets& quintupletsInGPU, unsigned int innerTripletIndex, unsigned int outerTripletIndex, - uint16_t& lowerModule1, - uint16_t& lowerModule2, - uint16_t& lowerModule3, - uint16_t& lowerModule4, - uint16_t& lowerModule5, - float& innerRadius, - float& bridgeRadius, - float& outerRadius, - float& regressionG, - float& regressionF, - float& regressionRadius, - float& rzChiSquared, - float& rPhiChiSquared, - float& nonAnchorChiSquared, + uint16_t lowerModule1, + uint16_t lowerModule2, + uint16_t lowerModule3, + uint16_t lowerModule4, + uint16_t lowerModule5, + float innerRadius, + float bridgeRadius, + float outerRadius, + float regressionG, + float regressionF, + float regressionRadius, + float rzChiSquared, + float rPhiChiSquared, + float nonAnchorChiSquared, float pt, float eta, float phi, @@ -233,13 +233,13 @@ namespace lst { }; //90% constraint - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passChiSquaredConstraint(struct lst::Modules& modulesInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - uint16_t& lowerModuleIndex4, - uint16_t& lowerModuleIndex5, - float& chiSquared) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passChiSquaredConstraint(lst::Modules const& modulesInGPU, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + uint16_t lowerModuleIndex4, + uint16_t lowerModuleIndex5, + float chiSquared) { // Using sdlLayer numbering convention defined in ModuleMethods.h const int layer1 = modulesInGPU.sdlLayers[lowerModuleIndex1]; const int layer2 = modulesInGPU.sdlLayers[lowerModuleIndex2]; @@ -318,18 +318,18 @@ namespace lst { //bounds can be found at http://uaf-10.t2.ucsd.edu/~bsathian/SDL/T5_RZFix/t5_rz_thresholds.txt template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passT5RZConstraint(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, unsigned int firstMDIndex, unsigned int secondMDIndex, unsigned int thirdMDIndex, unsigned int fourthMDIndex, unsigned int fifthMDIndex, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - uint16_t& lowerModuleIndex4, - uint16_t& lowerModuleIndex5, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + uint16_t lowerModuleIndex4, + uint16_t lowerModuleIndex5, float& rzChiSquared, float inner_pt, float innerRadius, @@ -567,10 +567,10 @@ namespace lst { //PS Modules if (moduleTypei == 0) { - error2 = pixelPSZpitch * pixelPSZpitch; + error2 = kPixelPSZpitch * kPixelPSZpitch; } else //2S modules { - error2 = strip2SZpitch * strip2SZpitch; + error2 = kStrip2SZpitch * kStrip2SZpitch; } //check the tilted module, side: PosZ, NegZ, Center(for not tilted) @@ -617,8 +617,8 @@ namespace lst { // creating a chi squared type quantity // 0-> PS, 1->2S - residual4_linear = (moduleType4 == 0) ? residual4_linear / pixelPSZpitch : residual4_linear / strip2SZpitch; - residual5_linear = (moduleType5 == 0) ? residual5_linear / pixelPSZpitch : residual5_linear / strip2SZpitch; + residual4_linear = (moduleType4 == 0) ? residual4_linear / kPixelPSZpitch : residual4_linear / kStrip2SZpitch; + residual5_linear = (moduleType5 == 0) ? residual5_linear / kPixelPSZpitch : residual5_linear / kStrip2SZpitch; residual4_linear = residual4_linear * 100; residual5_linear = residual5_linear * 100; @@ -752,8 +752,8 @@ namespace lst { }; template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool T5HasCommonMiniDoublet(struct lst::Triplets& tripletsInGPU, - struct lst::Segments& segmentsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE bool T5HasCommonMiniDoublet(lst::Triplets const& tripletsInGPU, + lst::Segments const& segmentsInGPU, unsigned int innerTripletIndex, unsigned int outerTripletIndex) { unsigned int innerOuterSegmentIndex = tripletsInGPU.segmentIndices[2 * innerTripletIndex + 1]; @@ -800,24 +800,15 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBEE12378(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius, + float bridgeRadiusMin2S, + float bridgeRadiusMax2S) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 0.178f; float bridgeInvRadiusErrorBound = 0.507f; - float outerInvRadiusErrorBound = 7.655f; innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) / innerRadius; innerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - innerInvRadiusErrorBound) / innerRadius); @@ -825,9 +816,6 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, alpaka::math::min(acc, bridgeInvRadiusMin, 1.0f / bridgeRadiusMax2S), @@ -837,23 +825,17 @@ namespace lst { /*bounds for high Pt taken from : http://uaf-10.t2.ucsd.edu/~bsathian/SDL/T5_efficiency/efficiencies/new_efficiencies/efficiencies_20210513_T5_recovering_high_Pt_efficiencies/highE_radius_matching/highE_bounds.txt */ template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBBB(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 0.1512f; float bridgeInvRadiusErrorBound = 0.1781f; - float outerInvRadiusErrorBound = 0.1840f; if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { innerInvRadiusErrorBound = 0.4449f; bridgeInvRadiusErrorBound = 0.4033f; - outerInvRadiusErrorBound = 0.8016f; } innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) / innerRadius; @@ -862,37 +844,22 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax); }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBBE(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 0.1781f; float bridgeInvRadiusErrorBound = 0.2167f; - float outerInvRadiusErrorBound = 1.1116f; if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { innerInvRadiusErrorBound = 0.4750f; bridgeInvRadiusErrorBound = 0.3903f; - outerInvRadiusErrorBound = 15.2120f; } innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) / innerRadius; @@ -901,75 +868,20 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax); }; - template - ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBEE(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { - float innerInvRadiusErrorBound = 0.1840f; - float bridgeInvRadiusErrorBound = 0.5971f; - float outerInvRadiusErrorBound = 11.7102f; - - if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) //as good as no selections - { - innerInvRadiusErrorBound = 1.0412f; - outerInvRadiusErrorBound = 32.2737f; - bridgeInvRadiusErrorBound = 10.9688f; - } - - innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) / innerRadius; - innerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - innerInvRadiusErrorBound) / innerRadius); - - bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; - bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - - return checkIntervalOverlap(innerInvRadiusMin, - innerInvRadiusMax, - alpaka::math::min(acc, bridgeInvRadiusMin, 1.0f / bridgeRadiusMax2S), - alpaka::math::max(acc, bridgeInvRadiusMax, 1.0f / bridgeRadiusMin2S)); - }; - template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBEE23478(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius, + float bridgeRadiusMin2S, + float bridgeRadiusMax2S) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 0.2097f; float bridgeInvRadiusErrorBound = 0.8557f; - float outerInvRadiusErrorBound = 24.0450f; innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) / innerRadius; innerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - innerInvRadiusErrorBound) / innerRadius); @@ -977,9 +889,6 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, alpaka::math::min(acc, bridgeInvRadiusMin, 1.0f / bridgeRadiusMax2S), @@ -988,24 +897,15 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBBEE34578(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius, + float bridgeRadiusMin2S, + float bridgeRadiusMax2S) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 0.066f; float bridgeInvRadiusErrorBound = 0.617f; - float outerInvRadiusErrorBound = 2.688f; innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) / innerRadius; innerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - innerInvRadiusErrorBound) / innerRadius); @@ -1013,9 +913,6 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, alpaka::math::min(acc, bridgeInvRadiusMin, 1.0f / bridgeRadiusMax2S), @@ -1024,29 +921,19 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBBEEE(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius, + float bridgeRadiusMin2S, + float bridgeRadiusMax2S) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 0.6376f; float bridgeInvRadiusErrorBound = 2.1381f; - float outerInvRadiusErrorBound = 20.4179f; if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) //as good as no selections! { innerInvRadiusErrorBound = 12.9173f; - outerInvRadiusErrorBound = 25.6702f; bridgeInvRadiusErrorBound = 5.1700f; } @@ -1056,9 +943,6 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(innerInvRadiusMin, innerInvRadiusMax, alpaka::math::min(acc, bridgeInvRadiusMin, 1.0f / bridgeRadiusMax2S), @@ -1067,28 +951,20 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiBEEEE(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius, + float innerRadiusMin2S, + float innerRadiusMax2S, + float bridgeRadiusMin2S, + float bridgeRadiusMax2S) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 1.9382f; float bridgeInvRadiusErrorBound = 3.7280f; - float outerInvRadiusErrorBound = 5.7030f; if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { innerInvRadiusErrorBound = 23.2713f; - outerInvRadiusErrorBound = 24.0450f; bridgeInvRadiusErrorBound = 21.7980f; } @@ -1098,9 +974,6 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(alpaka::math::min(acc, innerInvRadiusMin, 1.0 / innerRadiusMax2S), alpaka::math::max(acc, innerInvRadiusMax, 1.0 / innerRadiusMin2S), alpaka::math::min(acc, bridgeInvRadiusMin, 1.0 / bridgeRadiusMax2S), @@ -1109,29 +982,21 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool matchRadiiEEEEE(TAcc const& acc, - const float& innerRadius, - const float& bridgeRadius, - const float& outerRadius, - const float& innerRadiusMin2S, - const float& innerRadiusMax2S, - const float& bridgeRadiusMin2S, - const float& bridgeRadiusMax2S, - const float& outerRadiusMin2S, - const float& outerRadiusMax2S, - float& innerInvRadiusMin, - float& innerInvRadiusMax, - float& bridgeInvRadiusMin, - float& bridgeInvRadiusMax, - float& outerInvRadiusMin, - float& outerInvRadiusMax) { + float innerRadius, + float bridgeRadius, + float outerRadius, + float innerRadiusMin2S, + float innerRadiusMax2S, + float bridgeRadiusMin2S, + float bridgeRadiusMax2S) { + float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax; + float innerInvRadiusErrorBound = 1.9382f; float bridgeInvRadiusErrorBound = 2.2091f; - float outerInvRadiusErrorBound = 7.4084f; if (innerRadius > 2.0f / (2.f * k2Rinv1GeVf)) { innerInvRadiusErrorBound = 22.5226f; bridgeInvRadiusErrorBound = 21.0966f; - outerInvRadiusErrorBound = 19.1252f; } innerInvRadiusMax = (1.f + innerInvRadiusErrorBound) / innerRadius; @@ -1140,9 +1005,6 @@ namespace lst { bridgeInvRadiusMax = (1.f + bridgeInvRadiusErrorBound) / bridgeRadius; bridgeInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - bridgeInvRadiusErrorBound) / bridgeRadius); - outerInvRadiusMax = (1.f + outerInvRadiusErrorBound) / outerRadius; - outerInvRadiusMin = alpaka::math::max(acc, 0.f, (1.f - outerInvRadiusErrorBound) / outerRadius); - return checkIntervalOverlap(alpaka::math::min(acc, innerInvRadiusMin, 1.0 / innerRadiusMax2S), alpaka::math::max(acc, innerInvRadiusMax, 1.0 / innerRadiusMin2S), alpaka::math::min(acc, bridgeInvRadiusMin, 1.0 / bridgeRadiusMax2S), @@ -1151,7 +1013,7 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeSigmasForRegression(TAcc const& acc, - lst::Modules& modulesInGPU, + lst::Modules const& modulesInGPU, const uint16_t* lowerModuleIndices, float* delta1, float* delta2, @@ -1170,9 +1032,9 @@ namespace lst { ModuleType moduleType; short moduleSubdet, moduleSide; - float inv1 = widthPS / width2S; - float inv2 = pixelPSZpitch / width2S; - float inv3 = stripPSZpitch / width2S; + float inv1 = kWidthPS / kWidth2S; + float inv2 = kPixelPSZpitch / kWidth2S; + float inv3 = kStripPSZpitch / kWidth2S; for (size_t i = 0; i < nPoints; i++) { moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; @@ -1384,75 +1246,82 @@ namespace lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE void runDeltaBetaIterationsT5(TAcc const& acc, float& betaIn, float& betaOut, - float& betaAv, + float betaAv, float& pt_beta, float sdIn_dr, float sdOut_dr, float dr, float lIn) { if (lIn == 0) { - betaOut += lst::copysignf( + betaOut += alpaka::math::copysign( + acc, alpaka::math::asin( acc, - alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), + alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), betaOut); return; } if (betaIn * betaOut > 0.f and - (alpaka::math::abs(acc, pt_beta) < 4.f * lst::pt_betaMax or + (alpaka::math::abs(acc, pt_beta) < 4.f * lst::kPt_betaMax or (lIn >= 11 and alpaka::math::abs(acc, pt_beta) < - 8.f * lst::pt_betaMax))) //and the pt_beta is well-defined; less strict for endcap-endcap + 8.f * lst::kPt_betaMax))) //and the pt_beta is well-defined; less strict for endcap-endcap { const float betaInUpd = - betaIn + - lst::copysignf(alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), - betaIn); //FIXME: need a faster version + betaIn + alpaka::math::copysign( + acc, + alpaka::math::asin( + acc, + alpaka::math::min( + acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), + betaIn); //FIXME: need a faster version const float betaOutUpd = - betaOut + - lst::copysignf(alpaka::math::asin( - acc, - alpaka::math::min( - acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), - betaOut); //FIXME: need a faster version + betaOut + alpaka::math::copysign( + acc, + alpaka::math::asin( + acc, + alpaka::math::min( + acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), + betaOut); //FIXME: need a faster version betaAv = 0.5f * (betaInUpd + betaOutUpd); //1st update const float pt_beta_inv = 1.f / alpaka::math::abs(acc, dr * k2Rinv1GeVf / alpaka::math::sin(acc, betaAv)); //get a better pt estimate - betaIn += lst::copysignf( - alpaka::math::asin(acc, alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::sinAlphaMax)), + betaIn += alpaka::math::copysign( + acc, + alpaka::math::asin(acc, alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version - betaOut += lst::copysignf( - alpaka::math::asin(acc, alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::sinAlphaMax)), + betaOut += alpaka::math::copysign( + acc, + alpaka::math::asin(acc, alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf * pt_beta_inv, lst::kSinAlphaMax)), betaOut); //FIXME: need a faster version //update the av and pt betaAv = 0.5f * (betaIn + betaOut); //2nd update pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate } else if (lIn < 11 && alpaka::math::abs(acc, betaOut) < 0.2f * alpaka::math::abs(acc, betaIn) && - alpaka::math::abs(acc, pt_beta) < 12.f * lst::pt_betaMax) //use betaIn sign as ref + alpaka::math::abs(acc, pt_beta) < 12.f * lst::kPt_betaMax) //use betaIn sign as ref { const float pt_betaIn = dr * k2Rinv1GeVf / alpaka::math::sin(acc, betaIn); const float betaInUpd = - betaIn + lst::copysignf( + betaIn + alpaka::math::copysign( + acc, alpaka::math::asin( acc, alpaka::math::min( - acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::sinAlphaMax)), + acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version const float betaOutUpd = betaOut + - lst::copysignf( + alpaka::math::copysign( + acc, alpaka::math::asin( acc, alpaka::math::min( - acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::sinAlphaMax)), + acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_betaIn), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version betaAv = (alpaka::math::abs(acc, betaOut) > 0.2f * alpaka::math::abs(acc, betaIn)) ? (0.5f * (betaInUpd + betaOutUpd)) @@ -1460,15 +1329,17 @@ namespace lst { //1st update pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); //get a better pt estimate - betaIn += lst::copysignf( + betaIn += alpaka::math::copysign( + acc, alpaka::math::asin( acc, - alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), + alpaka::math::min(acc, sdIn_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version - betaOut += lst::copysignf( + betaOut += alpaka::math::copysign( + acc, alpaka::math::asin( acc, - alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::sinAlphaMax)), + alpaka::math::min(acc, sdOut_dr * lst::k2Rinv1GeVf / alpaka::math::abs(acc, pt_beta), lst::kSinAlphaMax)), betaIn); //FIXME: need a faster version //update the av and pt betaAv = 0.5f * (betaIn + betaOut); @@ -1479,34 +1350,19 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBBB(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& dPhi, - float& betaIn, - float& betaOut, - float& pt_beta, - float& zLo, - float& zHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaInCut, - float& betaOutCut, - float& deltaBetaCut) { + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t innerOuterLowerModuleIndex, + uint16_t outerInnerLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, + unsigned int fourthMDIndex) { bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == lst::PS); bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS); @@ -1519,22 +1375,20 @@ namespace lst { float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)); float rtRatio_OutLoInLo = rt_OutLo / rt_InLo; // Outer segment beginning rt divided by inner segment beginning rt; float dzDrtScale = alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly - float zpitch_InLo = (isPS_InLo ? lst::pixelPSZpitch : lst::strip2SZpitch); - float zpitch_OutLo = (isPS_OutLo ? lst::pixelPSZpitch : lst::strip2SZpitch); + float zpitch_InLo = (isPS_InLo ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); + float zpitch_OutLo = (isPS_OutLo ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); - zHi = z_InLo + (z_InLo + lst::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo < 0.f ? 1.f : dzDrtScale) + - (zpitch_InLo + zpitch_OutLo); - zLo = z_InLo + (z_InLo - lst::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo > 0.f ? 1.f : dzDrtScale) - - (zpitch_InLo + zpitch_OutLo); + float zHi = z_InLo + (z_InLo + lst::kDeltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo < 0.f ? 1.f : dzDrtScale) + + (zpitch_InLo + zpitch_OutLo); + float zLo = z_InLo + (z_InLo - lst::kDeltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo > 0.f ? 1.f : dzDrtScale) - + (zpitch_InLo + zpitch_OutLo); //Cut 1 - z compatibility - zOut = z_OutLo; - rtOut = rt_OutLo; if ((z_OutLo < zLo) || (z_OutLo > zHi)) return false; @@ -1559,17 +1413,17 @@ namespace lst { const float zWindow = dzErr / drt_InSeg * drt_OutLo_InLo + (zpitch_InLo + zpitch_OutLo); //FIXME for lst::ptCut lower than ~0.8 need to add curv path correction - zLoPointed = z_InLo + dzMean * (z_InLo > 0.f ? 1.f : dzDrtScale) - zWindow; - zHiPointed = z_InLo + dzMean * (z_InLo < 0.f ? 1.f : dzDrtScale) + zWindow; + float zLoPointed = z_InLo + dzMean * (z_InLo > 0.f ? 1.f : dzDrtScale) - zWindow; + float zHiPointed = z_InLo + dzMean * (z_InLo < 0.f ? 1.f : dzDrtScale) + zWindow; // Cut #2: Pointed Z (Inner segment two MD points to outer segment inner MD) if ((z_OutLo < zLoPointed) || (z_OutLo > zHiPointed)) return false; float sdlPVoff = 0.1f / rt_OutLo; - sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); + float sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); - deltaPhiPos = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); + float deltaPhiPos = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); // Cut #3: FIXME:deltaPhiPos can be tighter if (alpaka::math::abs(acc, deltaPhiPos) > sdlCut) return false; @@ -1579,7 +1433,7 @@ namespace lst { float diffX = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float diffY = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY); + float dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY); // Cut #4: deltaPhiChange if (alpaka::math::abs(acc, dPhi) > sdlCut) @@ -1611,11 +1465,12 @@ namespace lst { float tl_axis_lowEdge_x = tl_axis_x; float tl_axis_lowEdge_y = tl_axis_y; - betaIn = alpha_InLo - lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); + float betaIn = + alpha_InLo - lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = + float betaOut = -alpha_OutUp + lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut; @@ -1659,18 +1514,19 @@ namespace lst { (mdsInGPU.anchorX[secondMDIndex] - mdsInGPU.anchorX[firstMDIndex]) + (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex]) * (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); - betaInCut = alpaka::math::asin( - acc, - alpaka::math::min( - acc, (-rt_InSeg * corrF + drt_tl_axis) * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + - (0.02f / drt_InSeg); + float betaInCut = + alpaka::math::asin( + acc, + alpaka::math::min( + acc, (-rt_InSeg * corrF + drt_tl_axis) * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + + (0.02f / drt_InSeg); //Cut #5: first beta cut if (alpaka::math::abs(acc, betaInRHmin) >= betaInCut) return false; float betaAv = 0.5f * (betaIn + betaOut); - pt_beta = drt_tl_axis * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); + float pt_beta = drt_tl_axis * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); int lIn = 5; int lOut = isEC_lastLayer ? 11 : 5; float sdOut_dr = alpaka::math::sqrt(acc, @@ -1694,19 +1550,19 @@ namespace lst { betaOutRHmax *= betaOutMMSF; float min_ptBeta_maxPtBeta = alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), lst::pt_betaMax); //need to confimm the range-out value of 7 GeV + acc, alpaka::math::abs(acc, pt_beta), lst::kPt_betaMax); //need to confimm the range-out value of 7 GeV const float dBetaMuls2 = sdlThetaMulsF2 * 16.f / (min_ptBeta_maxPtBeta * min_ptBeta_maxPtBeta); const float alphaInAbsReg = alpaka::math::max( acc, alpaka::math::abs(acc, alpha_InLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * lst::k2Rinv1GeVf / 3.0f, lst::sinAlphaMax))); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * lst::k2Rinv1GeVf / 3.0f, lst::kSinAlphaMax))); const float alphaOutAbsReg = alpaka::math::max( acc, alpaka::math::abs(acc, alpha_OutLo), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / 3.0f, lst::sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * lst::deltaZLum / z_InLo); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * lst::deltaZLum / z_OutLo); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / 3.0f, lst::kSinAlphaMax))); + const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * lst::kDeltaZLum / z_InLo); + const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * lst::kDeltaZLum / z_OutLo); const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); const float sinDPhi = alpaka::math::sin(acc, dPhi); @@ -1725,9 +1581,9 @@ namespace lst { const float dBetaROut2 = dBetaROut * dBetaROut; - //FIXME: need faster version - betaOutCut = - alpaka::math::asin(acc, alpaka::math::min(acc, drt_tl_axis * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + + float betaOutCut = + alpaka::math::asin(acc, + alpaka::math::min(acc, drt_tl_axis * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls2); //Cut #6: The real beta cut @@ -1742,40 +1598,24 @@ namespace lst { (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); float dBeta = betaIn - betaOut; - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); return dBeta * dBeta <= dBetaCut2; }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoBBEE(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& dPhi, - float& betaIn, - float& betaOut, - float& pt_beta, - float& zLo, - float& rtLo, - float& rtHi, - float& sdlCut, - float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, - float& kZ) { + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t innerOuterLowerModuleIndex, + uint16_t outerInnerLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, + unsigned int fourthMDIndex) { bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == lst::PS); bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS); @@ -1788,29 +1628,25 @@ namespace lst { float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)); - float rtRatio_OutLoInLo = rt_OutLo / rt_InLo; // Outer segment beginning rt divided by inner segment beginning rt; float dzDrtScale = alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly - float zpitch_InLo = (isPS_InLo ? lst::pixelPSZpitch : lst::strip2SZpitch); - float zpitch_OutLo = (isPS_OutLo ? lst::pixelPSZpitch : lst::strip2SZpitch); + float zpitch_InLo = (isPS_InLo ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); + float zpitch_OutLo = (isPS_OutLo ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); float zGeom = zpitch_InLo + zpitch_OutLo; - zLo = z_InLo + (z_InLo - lst::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo > 0.f ? 1.f : dzDrtScale) - zGeom; - // Cut #0: Preliminary (Only here in endcap case) if (z_InLo * z_OutLo <= 0) return false; - float dLum = lst::copysignf(lst::deltaZLum, z_InLo); + float dLum = alpaka::math::copysign(acc, lst::kDeltaZLum, z_InLo); bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS; - float rtGeom1 = isOutSgInnerMDPS ? lst::pixelPSZpitch : lst::strip2SZpitch; - float zGeom1 = lst::copysignf(zGeom, z_InLo); - rtLo = rt_InLo * (1.f + (z_OutLo - z_InLo - zGeom1) / (z_InLo + zGeom1 + dLum) / dzDrtScale) - - rtGeom1; //slope correction only on the lower end - zOut = z_OutLo; - rtOut = rt_OutLo; + float rtGeom1 = isOutSgInnerMDPS ? lst::kPixelPSZpitch : lst::kStrip2SZpitch; + float zGeom1 = alpaka::math::copysign(acc, zGeom, z_InLo); + float rtLo = rt_InLo * (1.f + (z_OutLo - z_InLo - zGeom1) / (z_InLo + zGeom1 + dLum) / dzDrtScale) - + rtGeom1; //slope correction only on the lower end + float rtOut = rt_OutLo; //Cut #1: rt condition if (rtOut < rtLo) @@ -1818,9 +1654,9 @@ namespace lst { float zInForHi = z_InLo - zGeom1 - dLum; if (zInForHi * z_InLo < 0) { - zInForHi = lst::copysignf(0.1f, z_InLo); + zInForHi = alpaka::math::copysign(acc, 0.1f, z_InLo); } - rtHi = rt_InLo * (1.f + (z_OutLo - z_InLo + zGeom1) / zInForHi) + rtGeom1; + float rtHi = rt_InLo * (1.f + (z_OutLo - z_InLo + zGeom1) / zInForHi) + rtGeom1; //Cut #2: rt condition if ((rt_OutLo < rtLo) || (rt_OutLo > rtHi)) @@ -1835,8 +1671,8 @@ namespace lst { const float coshEta = dr3SDIn / drtSDIn; //direction estimate const float dzOutInAbs = alpaka::math::abs(acc, z_OutLo - z_InLo); const float multDzDr = dzOutInAbs * coshEta / (coshEta * coshEta - 1.f); - const float zGeom1_another = lst::pixelPSZpitch; - kZ = (z_OutLo - z_InLo) / dzSDIn; + const float zGeom1_another = lst::kPixelPSZpitch; + float kZ = (z_OutLo - z_InLo) / dzSDIn; float drtErr = zGeom1_another * zGeom1_another * drtSDIn * drtSDIn / dzSDIn / dzSDIn * (1.f - 2.f * kZ + 2.f * kZ * kZ); const float sdlThetaMulsF2 = @@ -1850,9 +1686,9 @@ namespace lst { return false; const float sdlPVoff = 0.1f / rt_OutLo; - sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); + float sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); - deltaPhiPos = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); + float deltaPhiPos = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); //Cut #4: deltaPhiPos can be tighter if (alpaka::math::abs(acc, deltaPhiPos) > sdlCut) @@ -1863,7 +1699,7 @@ namespace lst { float diffX = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float diffY = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY); + float dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY); // Cut #5: deltaPhiChange if (alpaka::math::abs(acc, dPhi) > sdlCut) return false; @@ -1887,11 +1723,12 @@ namespace lst { float tl_axis_x = mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - betaIn = sdIn_alpha - lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); + float betaIn = + sdIn_alpha - lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); float betaInRHmin = betaIn; float betaInRHmax = betaIn; - betaOut = + float betaOut = -sdOut_alphaOut + lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut; @@ -1930,9 +1767,9 @@ namespace lst { float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); const float corrF = 1.f; - betaInCut = + float betaInCut = alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + + acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + (0.02f / sdIn_d); //Cut #6: first beta cut @@ -1940,7 +1777,7 @@ namespace lst { return false; float betaAv = 0.5f * (betaIn + betaOut); - pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); + float pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); float lIn = 5; float lOut = 11; @@ -1966,19 +1803,19 @@ namespace lst { betaOutRHmax *= betaOutMMSF; float min_ptBeta_maxPtBeta = alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), lst::pt_betaMax); //need to confirm the range-out value of 7 GeV + acc, alpaka::math::abs(acc, pt_beta), lst::kPt_betaMax); //need to confirm the range-out value of 7 GeV const float dBetaMuls2 = sdlThetaMulsF2 * 16.f / (min_ptBeta_maxPtBeta * min_ptBeta_maxPtBeta); const float alphaInAbsReg = alpaka::math::max( acc, alpaka::math::abs(acc, sdIn_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * lst::k2Rinv1GeVf / 3.0f, lst::sinAlphaMax))); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * lst::k2Rinv1GeVf / 3.0f, lst::kSinAlphaMax))); const float alphaOutAbsReg = alpaka::math::max( acc, alpaka::math::abs(acc, sdOut_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / 3.0f, lst::sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * lst::deltaZLum / z_InLo); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * lst::deltaZLum / z_OutLo); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / 3.0f, lst::kSinAlphaMax))); + const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * lst::kDeltaZLum / z_InLo); + const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * lst::kDeltaZLum / z_OutLo); const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); const float sinDPhi = alpaka::math::sin(acc, dPhi); @@ -1996,9 +1833,9 @@ namespace lst { } const float dBetaROut2 = dBetaROut * dBetaROut; - //FIXME: need faster version - betaOutCut = alpaka::math::asin(acc, alpaka::math::min(acc, dr * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + - (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls2); + float betaOutCut = + alpaka::math::asin(acc, alpaka::math::min(acc, dr * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls2); //Cut #6: The real beta cut if (alpaka::math::abs(acc, betaOut) >= betaOutCut) @@ -2011,44 +1848,25 @@ namespace lst { (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax)) * (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); float dBeta = betaIn - betaOut; - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); //Cut #7: Cut on dBet return dBeta * dBeta <= dBetaCut2; }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletDefaultAlgoEEEE(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& dPhi, - float& betaIn, - float& betaOut, - float& pt_beta, - float& zLo, - float& rtLo, - float& rtHi, - float& sdlCut, - float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, - float& kZ) { - bool isPS_InLo = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == lst::PS); - bool isPS_OutLo = (modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS); - + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t innerOuterLowerModuleIndex, + uint16_t outerInnerLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, + unsigned int fourthMDIndex) { float rt_InLo = mdsInGPU.anchorRt[firstMDIndex]; float rt_InOut = mdsInGPU.anchorRt[secondMDIndex]; float rt_OutLo = mdsInGPU.anchorRt[thirdMDIndex]; @@ -2058,39 +1876,31 @@ namespace lst { float z_OutLo = mdsInGPU.anchorZ[thirdMDIndex]; float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)); - float rtRatio_OutLoInLo = rt_OutLo / rt_InLo; // Outer segment beginning rt divided by inner segment beginning rt; float dzDrtScale = alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly - float zpitch_InLo = (isPS_InLo ? lst::pixelPSZpitch : lst::strip2SZpitch); - float zpitch_OutLo = (isPS_OutLo ? lst::pixelPSZpitch : lst::strip2SZpitch); - float zGeom = zpitch_InLo + zpitch_OutLo; - - zLo = z_InLo + (z_InLo - lst::deltaZLum) * (rtRatio_OutLoInLo - 1.f) * (z_InLo > 0.f ? 1.f : dzDrtScale) - - zGeom; //slope-correction only on outer end // Cut #0: Preliminary (Only here in endcap case) if ((z_InLo * z_OutLo) <= 0) return false; - float dLum = lst::copysignf(lst::deltaZLum, z_InLo); + float dLum = alpaka::math::copysign(acc, lst::kDeltaZLum, z_InLo); bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerInnerLowerModuleIndex] == lst::PS; bool isInSgInnerMDPS = modulesInGPU.moduleType[innerInnerLowerModuleIndex] == lst::PS; - float rtGeom = (isInSgInnerMDPS and isOutSgInnerMDPS) ? 2.f * lst::pixelPSZpitch - : (isInSgInnerMDPS or isOutSgInnerMDPS) ? lst::pixelPSZpitch + lst::strip2SZpitch - : 2.f * lst::strip2SZpitch; + float rtGeom = (isInSgInnerMDPS and isOutSgInnerMDPS) ? 2.f * lst::kPixelPSZpitch + : (isInSgInnerMDPS or isOutSgInnerMDPS) ? lst::kPixelPSZpitch + lst::kStrip2SZpitch + : 2.f * lst::kStrip2SZpitch; float dz = z_OutLo - z_InLo; - rtLo = rt_InLo * (1.f + dz / (z_InLo + dLum) / dzDrtScale) - rtGeom; //slope correction only on the lower end + float rtLo = rt_InLo * (1.f + dz / (z_InLo + dLum) / dzDrtScale) - rtGeom; //slope correction only on the lower end - zOut = z_OutLo; - rtOut = rt_OutLo; + float rtOut = rt_OutLo; //Cut #1: rt condition - rtHi = rt_InLo * (1.f + dz / (z_InLo - dLum)) + rtGeom; + float rtHi = rt_InLo * (1.f + dz / (z_InLo - dLum)) + rtGeom; if ((rtOut < rtLo) || (rtOut > rtHi)) return false; @@ -2105,14 +1915,14 @@ namespace lst { float dzOutInAbs = alpaka::math::abs(acc, z_OutLo - z_InLo); float multDzDr = dzOutInAbs * coshEta / (coshEta * coshEta - 1.f); - kZ = (z_OutLo - z_InLo) / dzSDIn; + float kZ = (z_OutLo - z_InLo) / dzSDIn; float sdlThetaMulsF2 = (kMulsInGeV * kMulsInGeV) * (0.1f + 0.2f * (rt_OutLo - rt_InLo) / 50.f); float sdlMuls2 = sdlThetaMulsF2 * 9.f / (lst::ptCut * lst::ptCut) * 16.f; float drtErr = alpaka::math::sqrt( acc, - lst::pixelPSZpitch * lst::pixelPSZpitch * 2.f / (dzSDIn * dzSDIn) * (dzOutInAbs * dzOutInAbs) + + lst::kPixelPSZpitch * lst::kPixelPSZpitch * 2.f / (dzSDIn * dzSDIn) * (dzOutInAbs * dzOutInAbs) + sdlMuls2 * multDzDr * multDzDr / 3.f * coshEta * coshEta); float drtMean = drtSDIn * dzOutInAbs / alpaka::math::abs(acc, dzSDIn); @@ -2130,9 +1940,9 @@ namespace lst { } float sdlPVoff = 0.1f / rtOut; - sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); + float sdlCut = alpha1GeV_OutLo + alpaka::math::sqrt(acc, sdlMuls2 + sdlPVoff * sdlPVoff); - deltaPhiPos = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); + float deltaPhiPos = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[fourthMDIndex] - mdsInGPU.anchorPhi[secondMDIndex]); if (alpaka::math::abs(acc, deltaPhiPos) > sdlCut) return false; @@ -2142,7 +1952,7 @@ namespace lst { float diffX = mdsInGPU.anchorX[thirdMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float diffY = mdsInGPU.anchorY[thirdMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY); + float dPhi = lst::deltaPhi(acc, midPointX, midPointY, diffX, diffY); // Cut #5: deltaPhiChange if (alpaka::math::abs(acc, dPhi) > sdlCut) @@ -2163,14 +1973,15 @@ namespace lst { float tl_axis_x = mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex]; float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex]; - betaIn = sdIn_alpha - lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); + float betaIn = + sdIn_alpha - lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[firstMDIndex]); float sdIn_alphaRHmin = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]); float sdIn_alphaRHmax = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]); float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha; float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha; - betaOut = + float betaOut = -sdOut_alphaOut + lst::phi_mpi_pi(acc, lst::phi(acc, tl_axis_x, tl_axis_y) - mdsInGPU.anchorPhi[fourthMDIndex]); float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut; @@ -2197,9 +2008,9 @@ namespace lst { float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); const float corrF = 1.f; - betaInCut = + float betaInCut = alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + + acc, alpaka::math::min(acc, (-sdIn_dr * corrF + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + (0.02f / sdIn_d); //Cut #6: first beta cut @@ -2207,7 +2018,7 @@ namespace lst { return false; float betaAv = 0.5f * (betaIn + betaOut); - pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); + float pt_beta = dr * lst::k2Rinv1GeVf / alpaka::math::sin(acc, betaAv); int lIn = 11; //endcap int lOut = 13; //endcap @@ -2233,27 +2044,27 @@ namespace lst { betaOutRHmax *= betaOutMMSF; float min_ptBeta_maxPtBeta = alpaka::math::min( - acc, alpaka::math::abs(acc, pt_beta), lst::pt_betaMax); //need to confirm the range-out value of 7 GeV + acc, alpaka::math::abs(acc, pt_beta), lst::kPt_betaMax); //need to confirm the range-out value of 7 GeV const float dBetaMuls2 = sdlThetaMulsF2 * 16.f / (min_ptBeta_maxPtBeta * min_ptBeta_maxPtBeta); const float alphaInAbsReg = alpaka::math::max( acc, alpaka::math::abs(acc, sdIn_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * lst::k2Rinv1GeVf / 3.0f, lst::sinAlphaMax))); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_InLo * lst::k2Rinv1GeVf / 3.0f, lst::kSinAlphaMax))); const float alphaOutAbsReg = alpaka::math::max( acc, alpaka::math::abs(acc, sdOut_alpha), - alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / 3.0f, lst::sinAlphaMax))); - const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * lst::deltaZLum / z_InLo); - const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * lst::deltaZLum / z_OutLo); + alpaka::math::asin(acc, alpaka::math::min(acc, rt_OutLo * lst::k2Rinv1GeVf / 3.0f, lst::kSinAlphaMax))); + const float dBetaInLum = lIn < 11 ? 0.0f : alpaka::math::abs(acc, alphaInAbsReg * lst::kDeltaZLum / z_InLo); + const float dBetaOutLum = lOut < 11 ? 0.0f : alpaka::math::abs(acc, alphaOutAbsReg * lst::kDeltaZLum / z_OutLo); const float dBetaLum2 = (dBetaInLum + dBetaOutLum) * (dBetaInLum + dBetaOutLum); const float dBetaRIn2 = 0; // TODO-RH float dBetaROut2 = 0; //TODO-RH - //FIXME: need faster version - betaOutCut = alpaka::math::asin(acc, alpaka::math::min(acc, dr * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + - (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls2); + float betaOutCut = + alpaka::math::asin(acc, alpaka::math::min(acc, dr * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + + (0.02f / sdOut_d) + alpaka::math::sqrt(acc, dBetaLum2 + dBetaMuls2); //Cut #6: The real beta cut if (alpaka::math::abs(acc, betaOut) >= betaOutCut) @@ -2267,53 +2078,24 @@ namespace lst { (alpaka::math::abs(acc, betaInRHmin - betaInRHmax) + alpaka::math::abs(acc, betaOutRHmin - betaOutRHmax))); float dBeta = betaIn - betaOut; //Cut #7: Cut on dBeta - deltaBetaCut = alpaka::math::sqrt(acc, dBetaCut2); - return dBeta * dBeta <= dBetaCut2; }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runQuintupletAlgoSelector(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& innerOuterLowerModuleIndex, - uint16_t& outerInnerLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, - unsigned int& fourthMDIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& deltaPhi, - float& betaIn, - float& betaOut, - float& pt_beta, - float& zLo, - float& zHi, - float& rtLo, - float& rtHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaInCut, - float& betaOutCut, - float& deltaBetaCut, - float& kZ) { - zLo = -999; - zHi = -999; - rtLo = -999; - rtHi = -999; - zLoPointed = -999; - zHiPointed = -999; - kZ = -999; - betaInCut = -999; - + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t innerOuterLowerModuleIndex, + uint16_t outerInnerLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, + unsigned int fourthMDIndex) { short innerInnerLowerModuleSubdet = modulesInGPU.subdets[innerInnerLowerModuleIndex]; short innerOuterLowerModuleSubdet = modulesInGPU.subdets[innerOuterLowerModuleIndex]; short outerInnerLowerModuleSubdet = modulesInGPU.subdets[outerInnerLowerModuleIndex]; @@ -2334,22 +2116,7 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - zHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut); + fourthMDIndex); } else if (innerInnerLowerModuleSubdet == lst::Barrel and innerOuterLowerModuleSubdet == lst::Barrel and outerInnerLowerModuleSubdet == lst::Endcap and outerOuterLowerModuleSubdet == lst::Endcap) { return runQuintupletDefaultAlgoBBEE(acc, @@ -2365,22 +2132,7 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - rtLo, - rtHi, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ); + fourthMDIndex); } else if (innerInnerLowerModuleSubdet == lst::Barrel and innerOuterLowerModuleSubdet == lst::Barrel and outerInnerLowerModuleSubdet == lst::Barrel and outerOuterLowerModuleSubdet == lst::Endcap) { return runQuintupletDefaultAlgoBBBB(acc, @@ -2396,22 +2148,7 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - zHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut); + fourthMDIndex); } else if (innerInnerLowerModuleSubdet == lst::Barrel and innerOuterLowerModuleSubdet == lst::Endcap and outerInnerLowerModuleSubdet == lst::Endcap and outerOuterLowerModuleSubdet == lst::Endcap) { return runQuintupletDefaultAlgoBBEE(acc, @@ -2427,22 +2164,7 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - rtLo, - rtHi, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ); + fourthMDIndex); } else if (innerInnerLowerModuleSubdet == lst::Endcap and innerOuterLowerModuleSubdet == lst::Endcap and outerInnerLowerModuleSubdet == lst::Endcap and outerOuterLowerModuleSubdet == lst::Endcap) { return runQuintupletDefaultAlgoEEEE(acc, @@ -2458,22 +2180,7 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - rtLo, - rtHi, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ); + fourthMDIndex); } return false; @@ -2485,13 +2192,13 @@ namespace lst { struct lst::MiniDoublets& mdsInGPU, struct lst::Segments& segmentsInGPU, struct lst::Triplets& tripletsInGPU, - uint16_t& lowerModuleIndex1, - uint16_t& lowerModuleIndex2, - uint16_t& lowerModuleIndex3, - uint16_t& lowerModuleIndex4, - uint16_t& lowerModuleIndex5, - unsigned int& innerTripletIndex, - unsigned int& outerTripletIndex, + uint16_t lowerModuleIndex1, + uint16_t lowerModuleIndex2, + uint16_t lowerModuleIndex3, + uint16_t lowerModuleIndex4, + uint16_t lowerModuleIndex5, + unsigned int innerTripletIndex, + unsigned int outerTripletIndex, float& innerRadius, float& outerRadius, float& bridgeRadius, @@ -2516,10 +2223,6 @@ namespace lst { if (innerOuterOuterMiniDoubletIndex != outerInnerInnerMiniDoubletIndex) return false; - //apply T4 criteria between segments 1 and 3 - float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, betaOut, pt_beta; //temp stuff - float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut, betaOutCut, deltaBetaCut, kZ; - unsigned int firstMDIndex = segmentsInGPU.mdIndices[2 * firstSegmentIndex]; unsigned int secondMDIndex = segmentsInGPU.mdIndices[2 * secondSegmentIndex]; unsigned int thirdMDIndex = segmentsInGPU.mdIndices[2 * secondSegmentIndex + 1]; @@ -2539,25 +2242,7 @@ namespace lst { firstMDIndex, secondMDIndex, thirdMDIndex, - fourthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - zHi, - rtLo, - rtHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ)) + fourthMDIndex)) return false; if (not runQuintupletAlgoSelector(acc, @@ -2573,25 +2258,7 @@ namespace lst { firstMDIndex, secondMDIndex, fourthMDIndex, - fifthMDIndex, - zOut, - rtOut, - deltaPhiPos, - deltaPhi, - betaIn, - betaOut, - pt_beta, - zLo, - zHi, - rtLo, - rtHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, - betaOutCut, - deltaBetaCut, - kZ)) + fifthMDIndex)) return false; float x1 = mdsInGPU.anchorX[firstMDIndex]; @@ -2710,9 +2377,6 @@ namespace lst { if (innerRadius < 0.95f * ptCut / (2.f * k2Rinv1GeVf)) return false; - float innerInvRadiusMin, innerInvRadiusMax, bridgeInvRadiusMin, bridgeInvRadiusMax, outerInvRadiusMin, - outerInvRadiusMax; - //split by category bool matchedRadii; if (modulesInGPU.subdets[lowerModuleIndex1] == lst::Barrel and @@ -2720,93 +2384,27 @@ namespace lst { modulesInGPU.subdets[lowerModuleIndex3] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex4] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex5] == lst::Barrel) { - matchedRadii = matchRadiiBBBBB(acc, - innerRadius, - bridgeRadius, - outerRadius, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + matchedRadii = matchRadiiBBBBB(acc, innerRadius, bridgeRadius, outerRadius); } else if (modulesInGPU.subdets[lowerModuleIndex1] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex2] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex3] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex4] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) { - matchedRadii = matchRadiiBBBBE(acc, - innerRadius, - bridgeRadius, - outerRadius, - innerRadiusMin2S, - innerRadiusMax2S, - bridgeRadiusMin2S, - bridgeRadiusMax2S, - outerRadiusMin2S, - outerRadiusMax2S, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + matchedRadii = matchRadiiBBBBE(acc, innerRadius, bridgeRadius, outerRadius); } else if (modulesInGPU.subdets[lowerModuleIndex1] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex2] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex3] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) { if (modulesInGPU.layers[lowerModuleIndex1] == 1) { - matchedRadii = matchRadiiBBBEE12378(acc, - innerRadius, - bridgeRadius, - outerRadius, - innerRadiusMin2S, - innerRadiusMax2S, - bridgeRadiusMin2S, - bridgeRadiusMax2S, - outerRadiusMin2S, - outerRadiusMax2S, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + matchedRadii = + matchRadiiBBBEE12378(acc, innerRadius, bridgeRadius, outerRadius, bridgeRadiusMin2S, bridgeRadiusMax2S); } else if (modulesInGPU.layers[lowerModuleIndex1] == 2) { - matchedRadii = matchRadiiBBBEE23478(acc, - innerRadius, - bridgeRadius, - outerRadius, - innerRadiusMin2S, - innerRadiusMax2S, - bridgeRadiusMin2S, - bridgeRadiusMax2S, - outerRadiusMin2S, - outerRadiusMax2S, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + matchedRadii = + matchRadiiBBBEE23478(acc, innerRadius, bridgeRadius, outerRadius, bridgeRadiusMin2S, bridgeRadiusMax2S); } else { - matchedRadii = matchRadiiBBBEE34578(acc, - innerRadius, - bridgeRadius, - outerRadius, - innerRadiusMin2S, - innerRadiusMax2S, - bridgeRadiusMin2S, - bridgeRadiusMax2S, - outerRadiusMin2S, - outerRadiusMax2S, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + matchedRadii = + matchRadiiBBBEE34578(acc, innerRadius, bridgeRadius, outerRadius, bridgeRadiusMin2S, bridgeRadiusMax2S); } } @@ -2815,22 +2413,7 @@ namespace lst { modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and modulesInGPU.subdets[lowerModuleIndex4] == lst::Endcap and modulesInGPU.subdets[lowerModuleIndex5] == lst::Endcap) { - matchedRadii = matchRadiiBBEEE(acc, - innerRadius, - bridgeRadius, - outerRadius, - innerRadiusMin2S, - innerRadiusMax2S, - bridgeRadiusMin2S, - bridgeRadiusMax2S, - outerRadiusMin2S, - outerRadiusMax2S, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + matchedRadii = matchRadiiBBEEE(acc, innerRadius, bridgeRadius, outerRadius, bridgeRadiusMin2S, bridgeRadiusMax2S); } else if (modulesInGPU.subdets[lowerModuleIndex1] == lst::Barrel and modulesInGPU.subdets[lowerModuleIndex2] == lst::Endcap and modulesInGPU.subdets[lowerModuleIndex3] == lst::Endcap and @@ -2843,15 +2426,7 @@ namespace lst { innerRadiusMin2S, innerRadiusMax2S, bridgeRadiusMin2S, - bridgeRadiusMax2S, - outerRadiusMin2S, - outerRadiusMax2S, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + bridgeRadiusMax2S); } else { matchedRadii = matchRadiiEEEEE(acc, innerRadius, @@ -2860,15 +2435,7 @@ namespace lst { innerRadiusMin2S, innerRadiusMax2S, bridgeRadiusMin2S, - bridgeRadiusMax2S, - outerRadiusMin2S, - outerRadiusMax2S, - innerInvRadiusMin, - innerInvRadiusMax, - bridgeInvRadiusMin, - bridgeInvRadiusMax, - outerInvRadiusMin, - outerInvRadiusMax); + bridgeRadiusMax2S); } //compute regression radius right here - this computation is expensive!!! @@ -2914,8 +2481,8 @@ namespace lst { innerRadius, outerRadius, bridgeRadius); - TightCutFlag = TightCutFlag and (inference > lst::t5dnn::lstwp2); // T5-in-TC cut - if (inference <= lst::t5dnn::lstwp2) // T5-building cut + TightCutFlag = TightCutFlag and (inference > lst::t5dnn::kLSTWp2); // T5-in-TC cut + if (inference <= lst::t5dnn::kLSTWp2) // T5-building cut return false; #endif @@ -2973,12 +2540,12 @@ namespace lst { struct createQuintupletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::MiniDoublets mdsInGPU, - struct lst::Segments segmentsInGPU, - struct lst::Triplets tripletsInGPU, - struct lst::Quintuplets quintupletsInGPU, - struct lst::ObjectRanges rangesInGPU, + lst::Modules modulesInGPU, + lst::MiniDoublets mdsInGPU, + lst::Segments segmentsInGPU, + lst::Triplets tripletsInGPU, + lst::Quintuplets quintupletsInGPU, + lst::ObjectRanges rangesInGPU, uint16_t nEligibleT5Modules) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -3102,9 +2669,9 @@ namespace lst { struct createEligibleModulesListForQuintupletsGPU { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Triplets tripletsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Modules modulesInGPU, + lst::Triplets tripletsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -3202,9 +2769,9 @@ namespace lst { struct addQuintupletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Quintuplets quintupletsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Modules modulesInGPU, + lst::Quintuplets quintupletsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/Segment.h b/RecoTracker/LSTCore/src/alpaka/Segment.h index 83ef396a64746..6e79bacfa4902 100644 --- a/RecoTracker/LSTCore/src/alpaka/Segment.h +++ b/RecoTracker/LSTCore/src/alpaka/Segment.h @@ -177,7 +177,7 @@ namespace lst { inline void setData(SegmentsBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules_seg(struct lst::Modules& modulesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE float isTighterTiltedModules_seg(lst::Modules const& modulesInGPU, unsigned int moduleIndex) { // The "tighter" tilted modules are the subset of tilted modules that have smaller spacing // This is the same as what was previously considered as"isNormalTiltedModules" @@ -231,7 +231,7 @@ namespace lst { return moduleSeparation; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize_seg(struct lst::Modules& modulesInGPU, unsigned int moduleIndex) { + ALPAKA_FN_ACC ALPAKA_FN_INLINE float moduleGapSize_seg(lst::Modules const& modulesInGPU, unsigned int moduleIndex) { static constexpr float miniDeltaTilted[3] = {0.26f, 0.26f, 0.26f}; static constexpr float miniDeltaFlat[6] = {0.26f, 0.16f, 0.16f, 0.18f, 0.18f, 0.18f}; static constexpr float miniDeltaLooseTilted[3] = {0.4f, 0.4f, 0.4f}; @@ -266,46 +266,46 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void dAlphaThreshold(TAcc const& acc, float* dAlphaThresholdValues, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - float& xIn, - float& yIn, - float& zIn, - float& rtIn, - float& xOut, - float& yOut, - float& zOut, - float& rtOut, - uint16_t& innerLowerModuleIndex, - uint16_t& outerLowerModuleIndex, - unsigned int& innerMDIndex, - unsigned int& outerMDIndex) { + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + float xIn, + float yIn, + float zIn, + float rtIn, + float xOut, + float yOut, + float zOut, + float rtOut, + uint16_t innerLowerModuleIndex, + uint16_t outerLowerModuleIndex, + unsigned int innerMDIndex, + unsigned int outerMDIndex) { float sdMuls = (modulesInGPU.subdets[innerLowerModuleIndex] == lst::Barrel) - ? miniMulsPtScaleBarrel[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut - : miniMulsPtScaleEndcap[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut; + ? kMiniMulsPtScaleBarrel[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut + : kMiniMulsPtScaleEndcap[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut; //more accurate then outer rt - inner rt float segmentDr = alpaka::math::sqrt(acc, (yOut - yIn) * (yOut - yIn) + (xOut - xIn) * (xOut - xIn)); const float dAlpha_Bfield = - alpaka::math::asin(acc, alpaka::math::min(acc, segmentDr * k2Rinv1GeVf / ptCut, sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, segmentDr * k2Rinv1GeVf / ptCut, kSinAlphaMax)); bool isInnerTilted = modulesInGPU.subdets[innerLowerModuleIndex] == lst::Barrel and modulesInGPU.sides[innerLowerModuleIndex] != lst::Center; bool isOuterTilted = modulesInGPU.subdets[outerLowerModuleIndex] == lst::Barrel and modulesInGPU.sides[outerLowerModuleIndex] != lst::Center; - const float& drdzInner = modulesInGPU.drdzs[innerLowerModuleIndex]; - const float& drdzOuter = modulesInGPU.drdzs[outerLowerModuleIndex]; + float drdzInner = modulesInGPU.drdzs[innerLowerModuleIndex]; + float drdzOuter = modulesInGPU.drdzs[outerLowerModuleIndex]; float innerModuleGapSize = lst::moduleGapSize_seg(modulesInGPU, innerLowerModuleIndex); float outerModuleGapSize = lst::moduleGapSize_seg(modulesInGPU, outerLowerModuleIndex); const float innerminiTilt2 = isInnerTilted - ? ((0.5f * 0.5f) * (pixelPSZpitch * pixelPSZpitch) * (drdzInner * drdzInner) / + ? ((0.5f * 0.5f) * (kPixelPSZpitch * kPixelPSZpitch) * (drdzInner * drdzInner) / (1.f + drdzInner * drdzInner) / (innerModuleGapSize * innerModuleGapSize)) : 0; const float outerminiTilt2 = isOuterTilted - ? ((0.5f * 0.5f) * (pixelPSZpitch * pixelPSZpitch) * (drdzOuter * drdzOuter) / + ? ((0.5f * 0.5f) * (kPixelPSZpitch * kPixelPSZpitch) * (drdzOuter * drdzOuter) / (1.f + drdzOuter * drdzOuter) / (outerModuleGapSize * outerModuleGapSize)) : 0; @@ -317,14 +317,14 @@ namespace lst { if (modulesInGPU.subdets[innerLowerModuleIndex] == lst::Barrel) { sdLumForInnerMini2 = innerminiTilt2 * (dAlpha_Bfield * dAlpha_Bfield); } else { - sdLumForInnerMini2 = (mdsInGPU.dphis[innerMDIndex] * mdsInGPU.dphis[innerMDIndex]) * (deltaZLum * deltaZLum) / + sdLumForInnerMini2 = (mdsInGPU.dphis[innerMDIndex] * mdsInGPU.dphis[innerMDIndex]) * (kDeltaZLum * kDeltaZLum) / (mdsInGPU.dzs[innerMDIndex] * mdsInGPU.dzs[innerMDIndex]); } if (modulesInGPU.subdets[outerLowerModuleIndex] == lst::Barrel) { sdLumForOuterMini2 = outerminiTilt2 * (dAlpha_Bfield * dAlpha_Bfield); } else { - sdLumForOuterMini2 = (mdsInGPU.dphis[outerMDIndex] * mdsInGPU.dphis[outerMDIndex]) * (deltaZLum * deltaZLum) / + sdLumForOuterMini2 = (mdsInGPU.dphis[outerMDIndex] * mdsInGPU.dphis[outerMDIndex]) * (kDeltaZLum * kDeltaZLum) / (mdsInGPU.dzs[outerMDIndex] * mdsInGPU.dzs[outerMDIndex]); } @@ -358,24 +358,20 @@ namespace lst { dAlphaThresholdValues[2] = dAlpha_Bfield + alpaka::math::sqrt(acc, dAlpha_res * dAlpha_res + sdMuls * sdMuls); }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addSegmentToMemory(struct lst::Segments& segmentsInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addSegmentToMemory(lst::Segments& segmentsInGPU, unsigned int lowerMDIndex, unsigned int upperMDIndex, uint16_t innerLowerModuleIndex, uint16_t outerLowerModuleIndex, unsigned int innerMDAnchorHitIndex, unsigned int outerMDAnchorHitIndex, - float& dPhi, - float& dPhiMin, - float& dPhiMax, - float& dPhiChange, - float& dPhiChangeMin, - float& dPhiChangeMax, + float dPhi, + float dPhiMin, + float dPhiMax, + float dPhiChange, + float dPhiChangeMin, + float dPhiChangeMax, unsigned int idx) { - //idx will be computed in the kernel, which is the index into which the - //segment will be written - //nSegments will be incremented in the kernel - //printf("seg: %u %u %u %u\n",lowerMDIndex, upperMDIndex,innerLowerModuleIndex,outerLowerModuleIndex); segmentsInGPU.mdIndices[idx * 2] = lowerMDIndex; segmentsInGPU.mdIndices[idx * 2 + 1] = upperMDIndex; segmentsInGPU.innerLowerModuleIndices[idx] = innerLowerModuleIndex; @@ -393,8 +389,8 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE void addPixelSegmentToMemory(TAcc const& acc, - struct lst::Segments& segmentsInGPU, - struct lst::MiniDoublets& mdsInGPU, + lst::Segments& segmentsInGPU, + lst::MiniDoublets const& mdsInGPU, unsigned int innerMDIndex, unsigned int outerMDIndex, uint16_t pixelModuleIndex, @@ -456,36 +452,23 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgoBarrel(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - uint16_t& innerLowerModuleIndex, - uint16_t& outerLowerModuleIndex, - unsigned int& innerMDIndex, - unsigned int& outerMDIndex, - float& zIn, - float& zOut, - float& rtIn, - float& rtOut, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + uint16_t innerLowerModuleIndex, + uint16_t outerLowerModuleIndex, + unsigned int innerMDIndex, + unsigned int outerMDIndex, float& dPhi, float& dPhiMin, float& dPhiMax, float& dPhiChange, float& dPhiChangeMin, - float& dPhiChangeMax, - float& dAlphaInnerMDSegment, - float& dAlphaOuterMDSegment, - float& dAlphaInnerMDOuterMD, - float& zLo, - float& zHi, - float& sdCut, - float& dAlphaInnerMDSegmentThreshold, - float& dAlphaOuterMDSegmentThreshold, - float& dAlphaInnerMDOuterMDThreshold) { + float& dPhiChangeMax) { float sdMuls = (modulesInGPU.subdets[innerLowerModuleIndex] == lst::Barrel) - ? miniMulsPtScaleBarrel[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut - : miniMulsPtScaleEndcap[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut; + ? kMiniMulsPtScaleBarrel[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut + : kMiniMulsPtScaleEndcap[modulesInGPU.layers[innerLowerModuleIndex] - 1] * 3.f / ptCut; - float xIn, yIn, xOut, yOut; + float xIn, yIn, zIn, rtIn, xOut, yOut, zOut, rtOut; xIn = mdsInGPU.anchorX[innerMDIndex]; yIn = mdsInGPU.anchorY[innerMDIndex]; @@ -497,20 +480,20 @@ namespace lst { zOut = mdsInGPU.anchorZ[outerMDIndex]; rtOut = mdsInGPU.anchorRt[outerMDIndex]; - float sdSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * k2Rinv1GeVf / ptCut, sinAlphaMax)); + float sdSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * k2Rinv1GeVf / ptCut, kSinAlphaMax)); float sdPVoff = 0.1f / rtOut; float dzDrtScale = alpaka::math::tan(acc, sdSlope) / sdSlope; //FIXME: need appropriate value - const float zGeom = modulesInGPU.layers[innerLowerModuleIndex] <= 2 ? 2.f * pixelPSZpitch : 2.f * strip2SZpitch; + const float zGeom = modulesInGPU.layers[innerLowerModuleIndex] <= 2 ? 2.f * kPixelPSZpitch : 2.f * kStrip2SZpitch; - zLo = zIn + (zIn - deltaZLum) * (rtOut / rtIn - 1.f) * (zIn > 0.f ? 1.f : dzDrtScale) - - zGeom; //slope-correction only on outer end - zHi = zIn + (zIn + deltaZLum) * (rtOut / rtIn - 1.f) * (zIn < 0.f ? 1.f : dzDrtScale) + zGeom; + float zLo = zIn + (zIn - kDeltaZLum) * (rtOut / rtIn - 1.f) * (zIn > 0.f ? 1.f : dzDrtScale) - + zGeom; //slope-correction only on outer end + float zHi = zIn + (zIn + kDeltaZLum) * (rtOut / rtIn - 1.f) * (zIn < 0.f ? 1.f : dzDrtScale) + zGeom; if ((zOut < zLo) || (zOut > zHi)) return false; - sdCut = sdSlope + alpaka::math::sqrt(acc, sdMuls * sdMuls + sdPVoff * sdPVoff); + float sdCut = sdSlope + alpaka::math::sqrt(acc, sdMuls * sdMuls + sdPVoff * sdPVoff); dPhi = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[outerMDIndex] - mdsInGPU.anchorPhi[innerMDIndex]); @@ -542,13 +525,13 @@ namespace lst { float innerMDAlpha = mdsInGPU.dphichanges[innerMDIndex]; float outerMDAlpha = mdsInGPU.dphichanges[outerMDIndex]; - dAlphaInnerMDSegment = innerMDAlpha - dPhiChange; - dAlphaOuterMDSegment = outerMDAlpha - dPhiChange; - dAlphaInnerMDOuterMD = innerMDAlpha - outerMDAlpha; + float dAlphaInnerMDSegment = innerMDAlpha - dPhiChange; + float dAlphaOuterMDSegment = outerMDAlpha - dPhiChange; + float dAlphaInnerMDOuterMD = innerMDAlpha - outerMDAlpha; - dAlphaInnerMDSegmentThreshold = dAlphaThresholdValues[0]; - dAlphaOuterMDSegmentThreshold = dAlphaThresholdValues[1]; - dAlphaInnerMDOuterMDThreshold = dAlphaThresholdValues[2]; + float dAlphaInnerMDSegmentThreshold = dAlphaThresholdValues[0]; + float dAlphaOuterMDSegmentThreshold = dAlphaThresholdValues[1]; + float dAlphaInnerMDOuterMDThreshold = dAlphaThresholdValues[2]; if (alpaka::math::abs(acc, dAlphaInnerMDSegment) >= dAlphaInnerMDSegmentThreshold) return false; @@ -559,33 +542,19 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgoEndcap(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - uint16_t& innerLowerModuleIndex, - uint16_t& outerLowerModuleIndex, - unsigned int& innerMDIndex, - unsigned int& outerMDIndex, - float& zIn, - float& zOut, - float& rtIn, - float& rtOut, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + uint16_t innerLowerModuleIndex, + uint16_t outerLowerModuleIndex, + unsigned int innerMDIndex, + unsigned int outerMDIndex, float& dPhi, float& dPhiMin, float& dPhiMax, float& dPhiChange, float& dPhiChangeMin, - float& dPhiChangeMax, - float& dAlphaInnerMDSegment, - float& dAlphaOuterMDSegment, - float& rtLo, - float& rtHi, - float& sdCut, - float& dAlphaInnerMDSegmentThreshold, - float& dAlphaOuterMDSegmentThreshold, - float& dAlphaInnerMDOuterMDThreshold, - float& dAlphaInnerMDOuterMD) { - float xIn, yIn; - float xOut, yOut; + float& dPhiChangeMax) { + float xIn, yIn, zIn, rtIn, xOut, yOut, zOut, rtOut; xIn = mdsInGPU.anchorX[innerMDIndex]; yIn = mdsInGPU.anchorY[innerMDIndex]; @@ -600,13 +569,13 @@ namespace lst { bool outerLayerEndcapTwoS = (modulesInGPU.subdets[outerLowerModuleIndex] == lst::Endcap) && (modulesInGPU.moduleType[outerLowerModuleIndex] == lst::TwoS); - float sdSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * k2Rinv1GeVf / ptCut, sinAlphaMax)); + float sdSlope = alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * k2Rinv1GeVf / ptCut, kSinAlphaMax)); float disks2SMinRadius = 60.f; float rtGeom = ((rtIn < disks2SMinRadius && rtOut < disks2SMinRadius) - ? (2.f * pixelPSZpitch) - : ((rtIn < disks2SMinRadius || rtOut < disks2SMinRadius) ? (pixelPSZpitch + strip2SZpitch) - : (2.f * strip2SZpitch))); + ? (2.f * kPixelPSZpitch) + : ((rtIn < disks2SMinRadius || rtOut < disks2SMinRadius) ? (kPixelPSZpitch + kStrip2SZpitch) + : (2.f * kStrip2SZpitch))); //cut 0 - z compatibility if (zIn * zOut < 0) @@ -614,13 +583,13 @@ namespace lst { float dz = zOut - zIn; // Alpaka: Needs to be moved over - float dLum = lst::copysignf(deltaZLum, zIn); + float dLum = alpaka::math::copysign(acc, kDeltaZLum, zIn); float drtDzScale = sdSlope / alpaka::math::tan(acc, sdSlope); - rtLo = alpaka::math::max( + float rtLo = alpaka::math::max( acc, rtIn * (1.f + dz / (zIn + dLum) * drtDzScale) - rtGeom, rtIn - 0.5f * rtGeom); //rt should increase - rtHi = rtIn * (zOut - dLum) / (zIn - dLum) + - rtGeom; //dLum for luminous; rGeom for measurement size; no tanTheta_loc(pt) correction + float rtHi = rtIn * (zOut - dLum) / (zIn - dLum) + + rtGeom; //dLum for luminous; rGeom for measurement size; no tanTheta_loc(pt) correction // Completeness if ((rtOut < rtLo) || (rtOut > rtHi)) @@ -628,7 +597,7 @@ namespace lst { dPhi = lst::phi_mpi_pi(acc, mdsInGPU.anchorPhi[outerMDIndex] - mdsInGPU.anchorPhi[innerMDIndex]); - sdCut = sdSlope; + float sdCut = sdSlope; if (outerLayerEndcapTwoS) { float dPhiPos_high = lst::phi_mpi_pi(acc, mdsInGPU.anchorHighEdgePhi[outerMDIndex] - mdsInGPU.anchorPhi[innerMDIndex]); @@ -670,57 +639,37 @@ namespace lst { innerMDIndex, outerMDIndex); - dAlphaInnerMDSegmentThreshold = dAlphaThresholdValues[0]; - dAlphaOuterMDSegmentThreshold = dAlphaThresholdValues[1]; - dAlphaInnerMDOuterMDThreshold = dAlphaThresholdValues[2]; - float innerMDAlpha = mdsInGPU.dphichanges[innerMDIndex]; float outerMDAlpha = mdsInGPU.dphichanges[outerMDIndex]; - dAlphaInnerMDSegment = innerMDAlpha - dPhiChange; - dAlphaOuterMDSegment = outerMDAlpha - dPhiChange; - dAlphaInnerMDOuterMD = innerMDAlpha - outerMDAlpha; + float dAlphaInnerMDSegment = innerMDAlpha - dPhiChange; + float dAlphaOuterMDSegment = outerMDAlpha - dPhiChange; + float dAlphaInnerMDOuterMD = innerMDAlpha - outerMDAlpha; + + float dAlphaInnerMDSegmentThreshold = dAlphaThresholdValues[0]; + float dAlphaOuterMDSegmentThreshold = dAlphaThresholdValues[1]; + float dAlphaInnerMDOuterMDThreshold = dAlphaThresholdValues[2]; - if (alpaka::math::abs(acc, dAlphaInnerMDSegment) >= dAlphaThresholdValues[0]) + if (alpaka::math::abs(acc, dAlphaInnerMDSegment) >= dAlphaInnerMDSegmentThreshold) return false; - if (alpaka::math::abs(acc, dAlphaOuterMDSegment) >= dAlphaThresholdValues[1]) + if (alpaka::math::abs(acc, dAlphaOuterMDSegment) >= dAlphaOuterMDSegmentThreshold) return false; - return alpaka::math::abs(acc, dAlphaInnerMDOuterMD) < dAlphaThresholdValues[2]; + return alpaka::math::abs(acc, dAlphaInnerMDOuterMD) < dAlphaInnerMDOuterMDThreshold; }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runSegmentDefaultAlgo(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - uint16_t& innerLowerModuleIndex, - uint16_t& outerLowerModuleIndex, - unsigned int& innerMDIndex, - unsigned int& outerMDIndex, - float& zIn, - float& zOut, - float& rtIn, - float& rtOut, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + uint16_t innerLowerModuleIndex, + uint16_t outerLowerModuleIndex, + unsigned int innerMDIndex, + unsigned int outerMDIndex, float& dPhi, float& dPhiMin, float& dPhiMax, float& dPhiChange, float& dPhiChangeMin, - float& dPhiChangeMax, - float& dAlphaInnerMDSegment, - float& dAlphaOuterMDSegment, - float& dAlphaInnerMDOuterMD, - float& zLo, - float& zHi, - float& rtLo, - float& rtHi, - float& sdCut, - float& dAlphaInnerMDSegmentThreshold, - float& dAlphaOuterMDSegmentThreshold, - float& dAlphaInnerMDOuterMDThreshold) { - zLo = -999.f; - zHi = -999.f; - rtLo = -999.f; - rtHi = -999.f; - + float& dPhiChangeMax) { if (modulesInGPU.subdets[innerLowerModuleIndex] == lst::Barrel and modulesInGPU.subdets[outerLowerModuleIndex] == lst::Barrel) { return runSegmentDefaultAlgoBarrel(acc, @@ -730,25 +679,12 @@ namespace lst { outerLowerModuleIndex, innerMDIndex, outerMDIndex, - zIn, - zOut, - rtIn, - rtOut, dPhi, dPhiMin, dPhiMax, dPhiChange, dPhiChangeMin, - dPhiChangeMax, - dAlphaInnerMDSegment, - dAlphaOuterMDSegment, - dAlphaInnerMDOuterMD, - zLo, - zHi, - sdCut, - dAlphaInnerMDSegmentThreshold, - dAlphaOuterMDSegmentThreshold, - dAlphaInnerMDOuterMDThreshold); + dPhiChangeMax); } else { return runSegmentDefaultAlgoEndcap(acc, modulesInGPU, @@ -757,35 +693,22 @@ namespace lst { outerLowerModuleIndex, innerMDIndex, outerMDIndex, - zIn, - zOut, - rtIn, - rtOut, dPhi, dPhiMin, dPhiMax, dPhiChange, dPhiChangeMin, - dPhiChangeMax, - dAlphaInnerMDSegment, - dAlphaOuterMDSegment, - dAlphaInnerMDOuterMD, - rtLo, - rtHi, - sdCut, - dAlphaInnerMDSegmentThreshold, - dAlphaOuterMDSegmentThreshold, - dAlphaInnerMDOuterMDThreshold); + dPhiChangeMax); } }; struct createSegmentsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::MiniDoublets mdsInGPU, - struct lst::Segments segmentsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Modules modulesInGPU, + lst::MiniDoublets mdsInGPU, + lst::Segments segmentsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalBlockIdx = alpaka::getIdx(acc); auto const blockThreadIdx = alpaka::getIdx(acc); auto const gridBlockExtent = alpaka::getWorkDiv(acc); @@ -819,8 +742,7 @@ namespace lst { unsigned int innerMDIndex = rangesInGPU.mdRanges[innerLowerModuleIndex * 2] + innerMDArrayIdx; unsigned int outerMDIndex = rangesInGPU.mdRanges[outerLowerModuleIndex * 2] + outerMDArrayIdx; - float zIn, zOut, rtIn, rtOut, dPhi, dPhiMin, dPhiMax, dPhiChange, dPhiChangeMin, dPhiChangeMax, - dAlphaInnerMDSegment, dAlphaOuterMDSegment, dAlphaInnerMDOuterMD; + float dPhi, dPhiMin, dPhiMax, dPhiChange, dPhiChangeMin, dPhiChangeMax; unsigned int innerMiniDoubletAnchorHitIndex = mdsInGPU.anchorHitIndices[innerMDIndex]; unsigned int outerMiniDoubletAnchorHitIndex = mdsInGPU.anchorHitIndices[outerMDIndex]; @@ -828,8 +750,6 @@ namespace lst { dPhiMax = 0; dPhiChangeMin = 0; dPhiChangeMax = 0; - float zLo, zHi, rtLo, rtHi, sdCut, dAlphaInnerMDSegmentThreshold, dAlphaOuterMDSegmentThreshold, - dAlphaInnerMDOuterMDThreshold; if (runSegmentDefaultAlgo(acc, modulesInGPU, mdsInGPU, @@ -837,27 +757,12 @@ namespace lst { outerLowerModuleIndex, innerMDIndex, outerMDIndex, - zIn, - zOut, - rtIn, - rtOut, dPhi, dPhiMin, dPhiMax, dPhiChange, dPhiChangeMin, - dPhiChangeMax, - dAlphaInnerMDSegment, - dAlphaOuterMDSegment, - dAlphaInnerMDOuterMD, - zLo, - zHi, - rtLo, - rtHi, - sdCut, - dAlphaInnerMDSegmentThreshold, - dAlphaOuterMDSegmentThreshold, - dAlphaInnerMDOuterMDThreshold)) { + dPhiChangeMax)) { unsigned int totOccupancySegments = alpaka::atomicOp( acc, &segmentsInGPU.totOccupancySegments[innerLowerModuleIndex], 1u); if (static_cast(totOccupancySegments) >= rangesInGPU.segmentModuleOccupancy[innerLowerModuleIndex]) { @@ -894,9 +799,9 @@ namespace lst { struct createSegmentArrayRanges { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::ObjectRanges rangesInGPU, - struct lst::MiniDoublets mdsInGPU) const { + lst::Modules modulesInGPU, + lst::ObjectRanges rangesInGPU, + lst::MiniDoublets mdsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -994,9 +899,9 @@ namespace lst { struct addSegmentRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Segments segmentsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Modules modulesInGPU, + lst::Segments segmentsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -1015,18 +920,18 @@ namespace lst { struct addPixelSegmentToEventKernel { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::ObjectRanges rangesInGPU, - struct lst::Hits hitsInGPU, - struct lst::MiniDoublets mdsInGPU, - struct lst::Segments segmentsInGPU, + lst::Modules modulesInGPU, + lst::ObjectRanges rangesInGPU, + lst::Hits hitsInGPU, + lst::MiniDoublets mdsInGPU, + lst::Segments segmentsInGPU, unsigned int* hitIndices0, unsigned int* hitIndices1, unsigned int* hitIndices2, unsigned int* hitIndices3, float* dPhiChange, uint16_t pixelModuleIndex, - const int size) const { + int size) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -1050,7 +955,6 @@ namespace lst { 0, 0, 0, - 0, innerMDIndex); addMDToMemory(acc, mdsInGPU, @@ -1067,7 +971,6 @@ namespace lst { 0, 0, 0, - 0, outerMDIndex); //in outer hits - pt, eta, phi diff --git a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h index 7451f5e47dc80..ede4dd9471e8e 100644 --- a/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h +++ b/RecoTracker/LSTCore/src/alpaka/TrackCandidate.h @@ -109,7 +109,7 @@ namespace lst { inline void setData(TrackCandidatesBuffer& buf) { data_.setData(buf); } }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addpLSTrackCandidateToMemory(struct lst::TrackCandidates& trackCandidatesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addpLSTrackCandidateToMemory(lst::TrackCandidates& trackCandidatesInGPU, unsigned int trackletIndex, unsigned int trackCandidateIndex, uint4 hitIndices, @@ -128,7 +128,7 @@ namespace lst { trackCandidatesInGPU.hitIndices[Params_pT5::kHits * trackCandidateIndex + 3] = hitIndices.w; }; - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTrackCandidateToMemory(struct lst::TrackCandidates& trackCandidatesInGPU, + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTrackCandidateToMemory(lst::TrackCandidates& trackCandidatesInGPU, short trackCandidateType, unsigned int innerTrackletIndex, unsigned int outerTrackletIndex, @@ -167,9 +167,9 @@ namespace lst { ALPAKA_FN_ACC ALPAKA_FN_INLINE int checkPixelHits(unsigned int ix, unsigned int jx, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Hits& hitsInGPU) { + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Hits const& hitsInGPU) { int phits1[Params_pLS::kHits]; int phits2[Params_pLS::kHits]; @@ -208,11 +208,11 @@ namespace lst { struct crossCleanpT3 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::ObjectRanges rangesInGPU, - struct lst::PixelTriplets pixelTripletsInGPU, - struct lst::Segments segmentsInGPU, - struct lst::PixelQuintuplets pixelQuintupletsInGPU) const { + lst::Modules modulesInGPU, + lst::ObjectRanges rangesInGPU, + lst::PixelTriplets pixelTripletsInGPU, + lst::Segments segmentsInGPU, + lst::PixelQuintuplets pixelQuintupletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -249,11 +249,11 @@ namespace lst { struct crossCleanT5 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Quintuplets quintupletsInGPU, - struct lst::PixelQuintuplets pixelQuintupletsInGPU, - struct lst::PixelTriplets pixelTripletsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Modules modulesInGPU, + lst::Quintuplets quintupletsInGPU, + lst::PixelQuintuplets pixelQuintupletsInGPU, + lst::PixelTriplets pixelTripletsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -301,19 +301,17 @@ namespace lst { } }; - // Using Matt's block for the outer loop and thread for inner loop trick here! - // This will eliminate the need for another kernel just for adding the pLS, because we can __syncthreads() struct crossCleanpLS { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::ObjectRanges rangesInGPU, - struct lst::PixelTriplets pixelTripletsInGPU, - struct lst::TrackCandidates trackCandidatesInGPU, - struct lst::Segments segmentsInGPU, - struct lst::MiniDoublets mdsInGPU, - struct lst::Hits hitsInGPU, - struct lst::Quintuplets quintupletsInGPU) const { + lst::Modules modulesInGPU, + lst::ObjectRanges rangesInGPU, + lst::PixelTriplets pixelTripletsInGPU, + lst::TrackCandidates trackCandidatesInGPU, + lst::Segments segmentsInGPU, + lst::MiniDoublets mdsInGPU, + lst::Hits hitsInGPU, + lst::Quintuplets quintupletsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -388,10 +386,10 @@ namespace lst { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct lst::PixelTriplets pixelTripletsInGPU, - struct lst::TrackCandidates trackCandidatesInGPU, - struct lst::Segments segmentsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::PixelTriplets pixelTripletsInGPU, + lst::TrackCandidates trackCandidatesInGPU, + lst::Segments segmentsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -440,9 +438,9 @@ namespace lst { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct lst::Quintuplets quintupletsInGPU, - struct lst::TrackCandidates trackCandidatesInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Quintuplets quintupletsInGPU, + lst::TrackCandidates trackCandidatesInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -494,8 +492,8 @@ namespace lst { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct lst::TrackCandidates trackCandidatesInGPU, - struct lst::Segments segmentsInGPU, + lst::TrackCandidates trackCandidatesInGPU, + lst::Segments segmentsInGPU, bool tc_pls_triplets) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -533,10 +531,10 @@ namespace lst { template ALPAKA_FN_ACC void operator()(TAcc const& acc, uint16_t nLowerModules, - struct lst::PixelQuintuplets pixelQuintupletsInGPU, - struct lst::TrackCandidates trackCandidatesInGPU, - struct lst::Segments segmentsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::PixelQuintuplets pixelQuintupletsInGPU, + lst::TrackCandidates trackCandidatesInGPU, + lst::Segments segmentsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); diff --git a/RecoTracker/LSTCore/src/alpaka/Triplet.h b/RecoTracker/LSTCore/src/alpaka/Triplet.h index 4f98f2f205a69..fb1e8d59a9571 100644 --- a/RecoTracker/LSTCore/src/alpaka/Triplet.h +++ b/RecoTracker/LSTCore/src/alpaka/Triplet.h @@ -14,7 +14,7 @@ namespace lst { struct Triplets { unsigned int* segmentIndices; - uint16_t* lowerModuleIndices; //3 of them now + uint16_t* lowerModuleIndices; //3 of them unsigned int* nTriplets; unsigned int* totOccupancyTriplets; unsigned int* nMemoryLocations; @@ -32,16 +32,7 @@ namespace lst { //debug variables float* zOut; float* rtOut; - float* deltaPhiPos; - float* deltaPhi; - float* zLo; - float* zHi; - float* zLoPointed; - float* zHiPointed; - float* sdlCut; float* betaInCut; - float* rtLo; - float* rtHi; #endif template void setData(TBuff& buf) { @@ -62,16 +53,7 @@ namespace lst { #ifdef CUT_VALUE_DEBUG zOut = alpaka::getPtrNative(buf.zOut_buf); rtOut = alpaka::getPtrNative(buf.rtOut_buf); - deltaPhiPos = alpaka::getPtrNative(buf.deltaPhiPos_buf); - deltaPhi = alpaka::getPtrNative(buf.deltaPhi_buf); - zLo = alpaka::getPtrNative(buf.zLo_buf); - zHi = alpaka::getPtrNative(buf.zHi_buf); - zLoPointed = alpaka::getPtrNative(buf.zLoPointed_buf); - zHiPointed = alpaka::getPtrNative(buf.zHiPointed_buf); - sdlCut = alpaka::getPtrNative(buf.sdlCut_buf); betaInCut = alpaka::getPtrNative(buf.betaInCut_buf); - rtLo = alpaka::getPtrNative(buf.rtLo_buf); - rtHi = alpaka::getPtrNative(buf.rtHi_buf); #endif } }; @@ -154,47 +136,38 @@ namespace lst { }; #ifdef CUT_VALUE_DEBUG - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Triplets& tripletsInGPU, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - float& zOut, - float& rtOut, - float& deltaPhiPos, - float& deltaPhi, - float& betaIn, - float& circleRadius, - float& circleCenterX, - float& circleCenterY, - float& zLo, - float& zHi, - float& rtLo, - float& rtHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaInCut, - unsigned int& tripletIndex) + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Triplets& tripletsInGPU, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + float zOut, + float rtOut, + float betaIn, + float betaInCut, + float circleRadius, + float circleCenterX, + float circleCenterY, + unsigned int tripletIndex) #else - ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - struct lst::Triplets& tripletsInGPU, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - float& betaIn, - float& circleRadius, - float& circleCenterX, - float& circleCenterY, - unsigned int& tripletIndex) + ALPAKA_FN_ACC ALPAKA_FN_INLINE void addTripletToMemory(lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + lst::Triplets& tripletsInGPU, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + float betaIn, + float circleRadius, + float circleCenterX, + float circleCenterY, + unsigned int tripletIndex) #endif { tripletsInGPU.segmentIndices[tripletIndex * 2] = innerSegmentIndex; @@ -227,30 +200,21 @@ namespace lst { #ifdef CUT_VALUE_DEBUG tripletsInGPU.zOut[tripletIndex] = zOut; tripletsInGPU.rtOut[tripletIndex] = rtOut; - tripletsInGPU.deltaPhiPos[tripletIndex] = deltaPhiPos; - tripletsInGPU.deltaPhi[tripletIndex] = deltaPhi; - tripletsInGPU.zLo[tripletIndex] = zLo; - tripletsInGPU.zHi[tripletIndex] = zHi; - tripletsInGPU.rtLo[tripletIndex] = rtLo; - tripletsInGPU.rtHi[tripletIndex] = rtHi; - tripletsInGPU.zLoPointed[tripletIndex] = zLoPointed; - tripletsInGPU.zHiPointed[tripletIndex] = zHiPointed; - tripletsInGPU.sdlCut[tripletIndex] = sdlCut; tripletsInGPU.betaInCut[tripletIndex] = betaInCut; #endif }; template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passRZConstraint(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex) { + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex) { //get the rt and z const float& r1 = mdsInGPU.anchorRt[firstMDIndex]; const float& r2 = mdsInGPU.anchorRt[secondMDIndex]; @@ -302,18 +266,18 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintBBB(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, float& zOut, float& rtOut, - unsigned int& innerSegmentIndex, + unsigned int innerSegmentIndex, float& betaIn, float& betaInCut) { bool isPSIn = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == lst::PS); @@ -328,16 +292,16 @@ namespace lst { zOut = mdsInGPU.anchorZ[thirdMDIndex]; float alpha1GeVOut = - alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)); float rtRatio_OutIn = rtOut / rtIn; // Outer segment beginning rt divided by inner segment beginning rt; float dzDrtScale = alpaka::math::tan(acc, alpha1GeVOut) / alpha1GeVOut; // The track can bend in r-z plane slightly - float zpitchIn = (isPSIn ? lst::pixelPSZpitch : lst::strip2SZpitch); - float zpitchOut = (isPSOut ? lst::pixelPSZpitch : lst::strip2SZpitch); + float zpitchIn = (isPSIn ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); + float zpitchOut = (isPSOut ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); const float zHi = - zIn + (zIn + lst::deltaZLum) * (rtRatio_OutIn - 1.f) * (zIn < 0.f ? 1.f : dzDrtScale) + (zpitchIn + zpitchOut); - const float zLo = zIn + (zIn - lst::deltaZLum) * (rtRatio_OutIn - 1.f) * (zIn > 0.f ? 1.f : dzDrtScale) - + zIn + (zIn + lst::kDeltaZLum) * (rtRatio_OutIn - 1.f) * (zIn < 0.f ? 1.f : dzDrtScale) + (zpitchIn + zpitchOut); + const float zLo = zIn + (zIn - lst::kDeltaZLum) * (rtRatio_OutIn - 1.f) * (zIn > 0.f ? 1.f : dzDrtScale) - (zpitchIn + zpitchOut); //slope-correction only on outer end //Cut 1 - z compatibility @@ -392,7 +356,7 @@ namespace lst { (mdsInGPU.anchorY[secondMDIndex] - mdsInGPU.anchorY[firstMDIndex])); betaInCut = alpaka::math::asin( - acc, alpaka::math::min(acc, (-rt_InSeg + drt_tl_axis) * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + + acc, alpaka::math::min(acc, (-rt_InSeg + drt_tl_axis) * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + (0.02f / drt_InSeg); //Cut #3: first beta cut @@ -401,20 +365,20 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintBBE(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, float& zOut, float& rtOut, - uint16_t& innerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, + uint16_t innerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, float& betaIn, float& betaInCut) { bool isPSIn = (modulesInGPU.moduleType[innerInnerLowerModuleIndex] == lst::PS); @@ -429,29 +393,29 @@ namespace lst { zOut = mdsInGPU.anchorZ[thirdMDIndex]; float alpha1GeV_OutLo = - alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)); float dzDrtScale = alpaka::math::tan(acc, alpha1GeV_OutLo) / alpha1GeV_OutLo; // The track can bend in r-z plane slightly - float zpitchIn = (isPSIn ? lst::pixelPSZpitch : lst::strip2SZpitch); - float zpitchOut = (isPSOut ? lst::pixelPSZpitch : lst::strip2SZpitch); + float zpitchIn = (isPSIn ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); + float zpitchOut = (isPSOut ? lst::kPixelPSZpitch : lst::kStrip2SZpitch); float zGeom = zpitchIn + zpitchOut; // Cut #0: Preliminary (Only here in endcap case) if (zIn * zOut <= 0) return false; - float dLum = lst::copysignf(lst::deltaZLum, zIn); + float dLum = alpaka::math::copysign(acc, lst::kDeltaZLum, zIn); bool isOutSgInnerMDPS = modulesInGPU.moduleType[outerOuterLowerModuleIndex] == lst::PS; - float rtGeom1 = isOutSgInnerMDPS ? lst::pixelPSZpitch : lst::strip2SZpitch; - float zGeom1 = lst::copysignf(zGeom, zIn); + float rtGeom1 = isOutSgInnerMDPS ? lst::kPixelPSZpitch : lst::kStrip2SZpitch; + float zGeom1 = alpaka::math::copysign(acc, zGeom, zIn); float rtLo = rtIn * (1.f + (zOut - zIn - zGeom1) / (zIn + zGeom1 + dLum) / dzDrtScale) - rtGeom1; //slope correction only on the lower end //Cut #1: rt condition float zInForHi = zIn - zGeom1 - dLum; if (zInForHi * zIn < 0) { - zInForHi = lst::copysignf(0.1f, zIn); + zInForHi = alpaka::math::copysign(acc, 0.1f, zIn); } float rtHi = rtIn * (1.f + (zOut - zIn + zGeom1) / zInForHi) + rtGeom1; @@ -469,7 +433,7 @@ namespace lst { const float coshEta = dr3SDIn / drtSDIn; //direction estimate const float dzOutInAbs = alpaka::math::abs(acc, zOut - zIn); const float multDzDr = dzOutInAbs * coshEta / (coshEta * coshEta - 1.f); - const float zGeom1_another = lst::pixelPSZpitch; + const float zGeom1_another = lst::kPixelPSZpitch; const float kZ = (zOut - zIn) / dzSDIn; float drtErr = zGeom1_another * zGeom1_another * drtSDIn * drtSDIn / dzSDIn / dzSDIn * (1.f - 2.f * kZ + 2.f * kZ * kZ); @@ -513,7 +477,7 @@ namespace lst { float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); betaInCut = alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + + acc, alpaka::math::min(acc, (-sdIn_dr + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + (0.02f / sdIn_d); //Cut #4: first beta cut @@ -522,19 +486,19 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraintEEE(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, float& zOut, float& rtOut, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, float& betaIn, float& betaInCut) { float rtIn = mdsInGPU.anchorRt[firstMDIndex]; @@ -546,7 +510,7 @@ namespace lst { zOut = mdsInGPU.anchorZ[thirdMDIndex]; float alpha1GeV_Out = - alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)); + alpaka::math::asin(acc, alpaka::math::min(acc, rtOut * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)); float dzDrtScale = alpaka::math::tan(acc, alpha1GeV_Out) / alpha1GeV_Out; // The track can bend in r-z plane slightly @@ -555,13 +519,13 @@ namespace lst { if (zIn * zOut <= 0) return false; - float dLum = lst::copysignf(lst::deltaZLum, zIn); + float dLum = alpaka::math::copysign(acc, lst::kDeltaZLum, zIn); bool isOutSgOuterMDPS = modulesInGPU.moduleType[outerOuterLowerModuleIndex] == lst::PS; bool isInSgInnerMDPS = modulesInGPU.moduleType[innerInnerLowerModuleIndex] == lst::PS; - float rtGeom = (isInSgInnerMDPS and isOutSgOuterMDPS) ? 2.f * lst::pixelPSZpitch - : (isInSgInnerMDPS or isOutSgOuterMDPS) ? lst::pixelPSZpitch + lst::strip2SZpitch - : 2.f * lst::strip2SZpitch; + float rtGeom = (isInSgInnerMDPS and isOutSgOuterMDPS) ? 2.f * lst::kPixelPSZpitch + : (isInSgInnerMDPS or isOutSgOuterMDPS) ? lst::kPixelPSZpitch + lst::kStrip2SZpitch + : 2.f * lst::kStrip2SZpitch; float dz = zOut - zIn; const float rtLo = rtIn * (1.f + dz / (zIn + dLum) / dzDrtScale) - rtGeom; //slope correction only on the lower end @@ -589,7 +553,7 @@ namespace lst { float drtErr = alpaka::math::sqrt( acc, - lst::pixelPSZpitch * lst::pixelPSZpitch * 2.f / (dzSDIn * dzSDIn) * (dzOutInAbs * dzOutInAbs) + + lst::kPixelPSZpitch * lst::kPixelPSZpitch * 2.f / (dzSDIn * dzSDIn) * (dzOutInAbs * dzOutInAbs) + sdlMuls2 * multDzDr * multDzDr / 3.f * coshEta * coshEta); float drtMean = drtSDIn * dzOutInAbs / alpaka::math::abs(acc, dzSDIn); @@ -636,7 +600,7 @@ namespace lst { float dr = alpaka::math::sqrt(acc, tl_axis_x * tl_axis_x + tl_axis_y * tl_axis_y); betaInCut = alpaka::math::asin( - acc, alpaka::math::min(acc, (-sdIn_dr + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::sinAlphaMax)) + + acc, alpaka::math::min(acc, (-sdIn_dr + dr) * lst::k2Rinv1GeVf / lst::ptCut, lst::kSinAlphaMax)) + (0.02f / sdIn_d); //Cut #4: first beta cut @@ -645,20 +609,20 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool passPointingConstraint(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& firstMDIndex, - unsigned int& secondMDIndex, - unsigned int& thirdMDIndex, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int firstMDIndex, + unsigned int secondMDIndex, + unsigned int thirdMDIndex, float& zOut, float& rtOut, - uint16_t& innerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, + uint16_t innerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, float& betaIn, float& betaInCut) { short innerInnerLowerModuleSubdet = modulesInGPU.subdets[innerInnerLowerModuleIndex]; @@ -750,8 +714,6 @@ namespace lst { TAcc const& acc, float x1, float y1, float x2, float y2, float x3, float y3, float& g, float& f) { float radius = 0.f; - //writing manual code for computing radius, which obviously sucks - //TODO:Use fancy inbuilt libraries like cuBLAS or cuSOLVE for this! //(g,f) -> center //first anchor hit - (x1,y1), second anchor hit - (x2,y2), third anchor hit - (x3, y3) @@ -782,30 +744,21 @@ namespace lst { template ALPAKA_FN_ACC ALPAKA_FN_INLINE bool runTripletConstraintsAndAlgo(TAcc const& acc, - struct lst::Modules& modulesInGPU, - struct lst::MiniDoublets& mdsInGPU, - struct lst::Segments& segmentsInGPU, - uint16_t& innerInnerLowerModuleIndex, - uint16_t& middleLowerModuleIndex, - uint16_t& outerOuterLowerModuleIndex, - unsigned int& innerSegmentIndex, - unsigned int& outerSegmentIndex, + lst::Modules const& modulesInGPU, + lst::MiniDoublets const& mdsInGPU, + lst::Segments const& segmentsInGPU, + uint16_t innerInnerLowerModuleIndex, + uint16_t middleLowerModuleIndex, + uint16_t outerOuterLowerModuleIndex, + unsigned int innerSegmentIndex, + unsigned int outerSegmentIndex, float& zOut, float& rtOut, - float& deltaPhiPos, - float& deltaPhi, float& betaIn, + float& betaInCut, float& circleRadius, float& circleCenterX, - float& circleCenterY, - float& zLo, - float& zHi, - float& rtLo, - float& rtHi, - float& zLoPointed, - float& zHiPointed, - float& sdlCut, - float& betaInCut) { + float& circleCenterY) { //this cut reduces the number of candidates by a factor of 4, i.e., 3 out of 4 warps can end right here! if (segmentsInGPU.mdIndices[2 * innerSegmentIndex + 1] != segmentsInGPU.mdIndices[2 * outerSegmentIndex]) return false; @@ -858,11 +811,11 @@ namespace lst { struct createTripletsInGPUv2 { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::MiniDoublets mdsInGPU, - struct lst::Segments segmentsInGPU, - struct lst::Triplets tripletsInGPU, - struct lst::ObjectRanges rangesInGPU, + lst::Modules modulesInGPU, + lst::MiniDoublets mdsInGPU, + lst::Segments segmentsInGPU, + lst::Triplets tripletsInGPU, + lst::ObjectRanges rangesInGPU, uint16_t* index_gpu, uint16_t nonZeroModules) const { auto const globalThreadIdx = alpaka::getIdx(acc); @@ -895,8 +848,7 @@ namespace lst { uint16_t outerOuterLowerModuleIndex = segmentsInGPU.outerLowerModuleIndices[outerSegmentIndex]; - float zOut, rtOut, deltaPhiPos, deltaPhi, betaIn, circleRadius, circleCenterX, circleCenterY; - float zLo, zHi, rtLo, rtHi, zLoPointed, zHiPointed, sdlCut, betaInCut; + float zOut, rtOut, betaIn, betaInCut, circleRadius, circleCenterX, circleCenterY; bool success = runTripletConstraintsAndAlgo(acc, modulesInGPU, @@ -909,20 +861,11 @@ namespace lst { outerSegmentIndex, zOut, rtOut, - deltaPhiPos, - deltaPhi, betaIn, + betaInCut, circleRadius, circleCenterX, - circleCenterY, - zLo, - zHi, - rtLo, - rtHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut); + circleCenterY); if (success) { unsigned int totOccupancyTriplets = alpaka::atomicOp( @@ -949,20 +892,11 @@ namespace lst { outerOuterLowerModuleIndex, zOut, rtOut, - deltaPhiPos, - deltaPhi, betaIn, + betaInCut, circleRadius, circleCenterX, circleCenterY, - zLo, - zHi, - rtLo, - rtHi, - zLoPointed, - zHiPointed, - sdlCut, - betaInCut, tripletIndex); #else addTripletToMemory(modulesInGPU, @@ -991,9 +925,9 @@ namespace lst { struct createTripletArrayRanges { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::ObjectRanges rangesInGPU, - struct lst::Segments segmentsInGPU) const { + lst::Modules modulesInGPU, + lst::ObjectRanges rangesInGPU, + lst::Segments segmentsInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc); @@ -1090,9 +1024,9 @@ namespace lst { struct addTripletRangesToEventExplicit { template ALPAKA_FN_ACC void operator()(TAcc const& acc, - struct lst::Modules modulesInGPU, - struct lst::Triplets tripletsInGPU, - struct lst::ObjectRanges rangesInGPU) const { + lst::Modules modulesInGPU, + lst::Triplets tripletsInGPU, + lst::ObjectRanges rangesInGPU) const { auto const globalThreadIdx = alpaka::getIdx(acc); auto const gridThreadExtent = alpaka::getWorkDiv(acc);