File indexing completed on 2025-05-09 22:40:20
0001 #ifndef RecoTracker_LSTCore_src_alpaka_LSTEvent_h
0002 #define RecoTracker_LSTCore_src_alpaka_LSTEvent_h
0003
0004 #include <optional>
0005
0006 #include "RecoTracker/LSTCore/interface/LSTInputHostCollection.h"
0007 #include "RecoTracker/LSTCore/interface/HitsHostCollection.h"
0008 #include "RecoTracker/LSTCore/interface/MiniDoubletsHostCollection.h"
0009 #include "RecoTracker/LSTCore/interface/PixelQuintupletsHostCollection.h"
0010 #include "RecoTracker/LSTCore/interface/PixelTripletsHostCollection.h"
0011 #include "RecoTracker/LSTCore/interface/QuintupletsHostCollection.h"
0012 #include "RecoTracker/LSTCore/interface/SegmentsHostCollection.h"
0013 #include "RecoTracker/LSTCore/interface/PixelSegmentsHostCollection.h"
0014 #include "RecoTracker/LSTCore/interface/TrackCandidatesHostCollection.h"
0015 #include "RecoTracker/LSTCore/interface/TripletsHostCollection.h"
0016 #include "RecoTracker/LSTCore/interface/ObjectRangesHostCollection.h"
0017 #include "RecoTracker/LSTCore/interface/ModulesHostCollection.h"
0018 #include "RecoTracker/LSTCore/interface/alpaka/Common.h"
0019 #include "RecoTracker/LSTCore/interface/alpaka/LST.h"
0020 #include "RecoTracker/LSTCore/interface/alpaka/LSTInputDeviceCollection.h"
0021 #include "RecoTracker/LSTCore/interface/alpaka/HitsDeviceCollection.h"
0022 #include "RecoTracker/LSTCore/interface/alpaka/MiniDoubletsDeviceCollection.h"
0023 #include "RecoTracker/LSTCore/interface/alpaka/PixelQuintupletsDeviceCollection.h"
0024 #include "RecoTracker/LSTCore/interface/alpaka/PixelTripletsDeviceCollection.h"
0025 #include "RecoTracker/LSTCore/interface/alpaka/QuintupletsDeviceCollection.h"
0026 #include "RecoTracker/LSTCore/interface/alpaka/SegmentsDeviceCollection.h"
0027 #include "RecoTracker/LSTCore/interface/alpaka/PixelSegmentsDeviceCollection.h"
0028 #include "RecoTracker/LSTCore/interface/alpaka/TrackCandidatesDeviceCollection.h"
0029 #include "RecoTracker/LSTCore/interface/alpaka/TripletsDeviceCollection.h"
0030 #include "RecoTracker/LSTCore/interface/alpaka/ModulesDeviceCollection.h"
0031 #include "RecoTracker/LSTCore/interface/alpaka/ObjectRangesDeviceCollection.h"
0032 #include "RecoTracker/LSTCore/interface/alpaka/EndcapGeometryDevDeviceCollection.h"
0033
0034 #include "HeterogeneousCore/AlpakaInterface/interface/host.h"
0035
0036 namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
0037
0038 class LSTEvent {
0039 private:
0040 Queue& queue_;
0041 const float ptCut_;
0042
0043 std::array<unsigned int, 6> n_minidoublets_by_layer_barrel_{};
0044 std::array<unsigned int, 5> n_minidoublets_by_layer_endcap_{};
0045 std::array<unsigned int, 6> n_segments_by_layer_barrel_{};
0046 std::array<unsigned int, 5> n_segments_by_layer_endcap_{};
0047 std::array<unsigned int, 6> n_triplets_by_layer_barrel_{};
0048 std::array<unsigned int, 5> n_triplets_by_layer_endcap_{};
0049 std::array<unsigned int, 6> n_quintuplets_by_layer_barrel_{};
0050 std::array<unsigned int, 5> n_quintuplets_by_layer_endcap_{};
0051 unsigned int nTotalSegments_;
0052 unsigned int pixelSize_;
0053 uint16_t pixelModuleIndex_;
0054
0055
0056 LSTInputDeviceCollection const* lstInputDC_;
0057 std::optional<ObjectRangesDeviceCollection> rangesDC_;
0058 std::optional<HitsDeviceCollection> hitsDC_;
0059 std::optional<MiniDoubletsDeviceCollection> miniDoubletsDC_;
0060 std::optional<SegmentsDeviceCollection> segmentsDC_;
0061 std::optional<PixelSegmentsDeviceCollection> pixelSegmentsDC_;
0062 std::optional<TripletsDeviceCollection> tripletsDC_;
0063 std::optional<QuintupletsDeviceCollection> quintupletsDC_;
0064 std::optional<TrackCandidatesDeviceCollection> trackCandidatesDC_;
0065 std::optional<PixelTripletsDeviceCollection> pixelTripletsDC_;
0066 std::optional<PixelQuintupletsDeviceCollection> pixelQuintupletsDC_;
0067
0068
0069 std::optional<LSTInputHostCollection> lstInputHC_;
0070 std::optional<ObjectRangesHostCollection> rangesHC_;
0071 std::optional<HitsHostCollection> hitsHC_;
0072 std::optional<MiniDoubletsHostCollection> miniDoubletsHC_;
0073 std::optional<SegmentsHostCollection> segmentsHC_;
0074 std::optional<PixelSegmentsHostCollection> pixelSegmentsHC_;
0075 std::optional<TripletsHostCollection> tripletsHC_;
0076 std::optional<TrackCandidatesHostCollection> trackCandidatesHC_;
0077 std::optional<ModulesHostCollection> modulesHC_;
0078 std::optional<QuintupletsHostCollection> quintupletsHC_;
0079 std::optional<PixelTripletsHostCollection> pixelTripletsHC_;
0080 std::optional<PixelQuintupletsHostCollection> pixelQuintupletsHC_;
0081
0082 const uint16_t nModules_;
0083 const uint16_t nLowerModules_;
0084 const unsigned int nPixels_;
0085 const unsigned int nEndCapMap_;
0086 ModulesDeviceCollection const& modules_;
0087 PixelMap const& pixelMapping_;
0088 EndcapGeometryDevDeviceCollection const& endcapGeometry_;
0089 bool addObjects_;
0090
0091 public:
0092
0093 LSTEvent(bool verbose, const float pt_cut, Queue& q, const LSTESData<Device>* deviceESData)
0094 : queue_(q),
0095 ptCut_(pt_cut),
0096 nModules_(deviceESData->nModules),
0097 nLowerModules_(deviceESData->nLowerModules),
0098 nPixels_(deviceESData->nPixels),
0099 nEndCapMap_(deviceESData->nEndCapMap),
0100 modules_(*deviceESData->modules),
0101 pixelMapping_(*deviceESData->pixelMapping),
0102 endcapGeometry_(*deviceESData->endcapGeometry),
0103 addObjects_(verbose) {
0104 if (pt_cut < 0.6f) {
0105 throw std::invalid_argument("Minimum pT cut must be at least 0.6 GeV. Provided value: " +
0106 std::to_string(pt_cut));
0107 }
0108 }
0109 void initSync();
0110 void resetEventSync();
0111 void wait() const { alpaka::wait(queue_); }
0112
0113 void addInputToEvent(LSTInputDeviceCollection const* lstInputDC);
0114
0115 void addHitToEvent();
0116 void addPixelSegmentToEventStart();
0117
0118 void createMiniDoublets();
0119 void addPixelSegmentToEventFinalize();
0120 void createSegmentsWithModuleMap();
0121 void createTriplets();
0122 void createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets);
0123 void createPixelTriplets();
0124 void createQuintuplets();
0125 void pixelLineSegmentCleaning(bool no_pls_dupclean);
0126 void createPixelQuintuplets();
0127
0128
0129 void addMiniDoubletsToEventExplicit();
0130 void addSegmentsToEventExplicit();
0131 void addQuintupletsToEventExplicit();
0132 void addTripletsToEventExplicit();
0133 void resetObjectsInModule();
0134
0135 unsigned int getNumberOfMiniDoublets();
0136 unsigned int getNumberOfMiniDoubletsByLayerBarrel(unsigned int layer);
0137 unsigned int getNumberOfMiniDoubletsByLayerEndcap(unsigned int layer);
0138
0139 unsigned int getNumberOfSegments();
0140 unsigned int getNumberOfSegmentsByLayerBarrel(unsigned int layer);
0141 unsigned int getNumberOfSegmentsByLayerEndcap(unsigned int layer);
0142
0143 unsigned int getNumberOfTriplets();
0144 unsigned int getNumberOfTripletsByLayerBarrel(unsigned int layer);
0145 unsigned int getNumberOfTripletsByLayerEndcap(unsigned int layer);
0146
0147 int getNumberOfPixelTriplets();
0148 int getNumberOfPixelQuintuplets();
0149
0150 unsigned int getNumberOfQuintuplets();
0151 unsigned int getNumberOfQuintupletsByLayerBarrel(unsigned int layer);
0152 unsigned int getNumberOfQuintupletsByLayerEndcap(unsigned int layer);
0153
0154 int getNumberOfTrackCandidates();
0155 int getNumberOfPT5TrackCandidates();
0156 int getNumberOfPT3TrackCandidates();
0157 int getNumberOfPLSTrackCandidates();
0158 int getNumberOfPixelTrackCandidates();
0159 int getNumberOfT5TrackCandidates();
0160
0161
0162
0163
0164
0165 template <typename TSoA, typename TDev = Device>
0166 typename TSoA::ConstView getInput(bool sync = true);
0167 template <typename TDev = Device>
0168 HitsBaseConst getTrimmedHitsBase(bool sync = true);
0169 template <typename TSoA, typename TDev = Device>
0170 typename TSoA::ConstView getHits(bool sync = true);
0171 template <typename TDev = Device>
0172 ObjectRangesConst getRanges(bool sync = true);
0173 template <typename TSoA, typename TDev = Device>
0174 typename TSoA::ConstView getMiniDoublets(bool sync = true);
0175 template <typename TSoA, typename TDev = Device>
0176 typename TSoA::ConstView getSegments(bool sync = true);
0177 template <typename TSoA, typename TDev = Device>
0178 typename TSoA::ConstView getTriplets(bool sync = true);
0179 template <typename TSoA, typename TDev = Device>
0180 typename TSoA::ConstView getQuintuplets(bool sync = true);
0181 template <typename TDev = Device>
0182 PixelTripletsConst getPixelTriplets(bool sync = true);
0183 template <typename TDev = Device>
0184 PixelSegmentsConst getPixelSegments(bool sync = true);
0185 template <typename TDev = Device>
0186 PixelQuintupletsConst getPixelQuintuplets(bool sync = true);
0187 const TrackCandidatesConst& getTrackCandidates(bool inCMSSW = false, bool sync = true);
0188 template <typename TSoA, typename TDev = Device>
0189 typename TSoA::ConstView getModules(bool sync = true);
0190 };
0191
0192 }
0193 #endif