CMS 3D CMS Logo

LSTEvent.h
Go to the documentation of this file.
1 #ifndef RecoTracker_LSTCore_src_alpaka_LSTEvent_h
2 #define RecoTracker_LSTCore_src_alpaka_LSTEvent_h
3 
4 #include <optional>
5 
28 
29 #include "Hit.h"
30 #include "Kernels.h"
31 
33 
35 
36  class LSTEvent {
37  private:
39 
40  std::array<unsigned int, 6> n_minidoublets_by_layer_barrel_{};
41  std::array<unsigned int, 5> n_minidoublets_by_layer_endcap_{};
42  std::array<unsigned int, 6> n_segments_by_layer_barrel_{};
43  std::array<unsigned int, 5> n_segments_by_layer_endcap_{};
44  std::array<unsigned int, 6> n_triplets_by_layer_barrel_{};
45  std::array<unsigned int, 5> n_triplets_by_layer_endcap_{};
46  std::array<unsigned int, 6> n_quintuplets_by_layer_barrel_{};
47  std::array<unsigned int, 5> n_quintuplets_by_layer_endcap_{};
48  unsigned int nTotalSegments_;
49 
50  //Device stuff
51  std::optional<ObjectRangesDeviceCollection> rangesDC_;
52  std::optional<HitsDeviceCollection> hitsDC_;
53  std::optional<MiniDoubletsDeviceCollection> miniDoubletsDC_;
54  std::optional<SegmentsDeviceCollection> segmentsDC_;
55  std::optional<TripletsDeviceCollection> tripletsDC_;
56  std::optional<QuintupletsDeviceCollection> quintupletsDC_;
57  std::optional<TrackCandidatesDeviceCollection> trackCandidatesDC_;
58  std::optional<PixelTripletsDeviceCollection> pixelTripletsDC_;
59  std::optional<PixelQuintupletsDeviceCollection> pixelQuintupletsDC_;
60 
61  //CPU interface stuff
62  std::optional<ObjectRangesHostCollection> rangesHC_;
63  std::optional<HitsHostCollection> hitsHC_;
64  std::optional<MiniDoubletsHostCollection> miniDoubletsHC_;
65  std::optional<SegmentsHostCollection> segmentsHC_;
66  std::optional<TripletsHostCollection> tripletsHC_;
67  std::optional<TrackCandidatesHostCollection> trackCandidatesHC_;
68  std::optional<ModulesHostCollection> modulesHC_;
69  std::optional<QuintupletsHostCollection> quintupletsHC_;
70  std::optional<PixelTripletsHostCollection> pixelTripletsHC_;
71  std::optional<PixelQuintupletsHostCollection> pixelQuintupletsHC_;
72 
73  const uint16_t nModules_;
74  const uint16_t nLowerModules_;
75  const unsigned int nPixels_;
76  const unsigned int nEndCapMap_;
78  PixelMap const& pixelMapping_;
81 
82  public:
83  // Constructor used for CMSSW integration. Uses an external queue.
84  LSTEvent(bool verbose, Queue& q, const LSTESData<Device>* deviceESData)
85  : queue_(q),
86  nModules_(deviceESData->nModules),
87  nLowerModules_(deviceESData->nLowerModules),
88  nPixels_(deviceESData->nPixels),
89  nEndCapMap_(deviceESData->nEndCapMap),
90  modules_(*deviceESData->modules),
91  pixelMapping_(*deviceESData->pixelMapping),
92  endcapGeometry_(*deviceESData->endcapGeometry),
94  void initSync(); // synchronizes, for standalone usage
95  void resetEventSync(); // synchronizes, for standalone usage
96  void wait() const { alpaka::wait(queue_); }
97 
98  // Calls the appropriate hit function, then increments the counter
99  void addHitToEvent(std::vector<float> const& x,
100  std::vector<float> const& y,
101  std::vector<float> const& z,
102  std::vector<unsigned int> const& detId,
103  std::vector<unsigned int> const& idxInNtuple);
104  void addPixelSegmentToEvent(std::vector<unsigned int> const& hitIndices0,
105  std::vector<unsigned int> const& hitIndices1,
106  std::vector<unsigned int> const& hitIndices2,
107  std::vector<unsigned int> const& hitIndices3,
108  std::vector<float> const& dPhiChange,
109  std::vector<float> const& ptIn,
110  std::vector<float> const& ptErr,
111  std::vector<float> const& px,
112  std::vector<float> const& py,
113  std::vector<float> const& pz,
114  std::vector<float> const& eta,
115  std::vector<float> const& etaErr,
116  std::vector<float> const& phi,
117  std::vector<int> const& charge,
118  std::vector<unsigned int> const& seedIdx,
119  std::vector<int> const& superbin,
120  std::vector<PixelType> const& pixelType,
121  std::vector<char> const& isQuad);
122 
123  void createMiniDoublets();
125  void createTriplets();
126  void createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets);
127  void createPixelTriplets();
128  void createQuintuplets();
129  void pixelLineSegmentCleaning(bool no_pls_dupclean);
130  void createPixelQuintuplets();
131 
132  // functions that map the objects to the appropriate modules
137  void resetObjectsInModule();
138 
139  unsigned int getNumberOfMiniDoublets();
140  unsigned int getNumberOfMiniDoubletsByLayer(unsigned int layer);
141  unsigned int getNumberOfMiniDoubletsByLayerBarrel(unsigned int layer);
142  unsigned int getNumberOfMiniDoubletsByLayerEndcap(unsigned int layer);
143 
144  unsigned int getNumberOfSegments();
145  unsigned int getNumberOfSegmentsByLayer(unsigned int layer);
146  unsigned int getNumberOfSegmentsByLayerBarrel(unsigned int layer);
147  unsigned int getNumberOfSegmentsByLayerEndcap(unsigned int layer);
148 
149  unsigned int getNumberOfTriplets();
150  unsigned int getNumberOfTripletsByLayer(unsigned int layer);
151  unsigned int getNumberOfTripletsByLayerBarrel(unsigned int layer);
152  unsigned int getNumberOfTripletsByLayerEndcap(unsigned int layer);
153 
156 
157  unsigned int getNumberOfQuintuplets();
158  unsigned int getNumberOfQuintupletsByLayer(unsigned int layer);
159  unsigned int getNumberOfQuintupletsByLayerBarrel(unsigned int layer);
160  unsigned int getNumberOfQuintupletsByLayerEndcap(unsigned int layer);
161 
168 
169  // sync adds alpaka::wait at the end of filling a buffer during lazy fill
170  // (has no effect on repeated calls)
171  // set to false may allow faster operation with concurrent calls of get*
172  // HANDLE WITH CARE
173  template <typename TSoA, typename TDev = Device>
174  typename TSoA::ConstView getHits(bool inCMSSW = false, bool sync = true);
175  template <typename TDev = Device>
176  ObjectRangesConst getRanges(bool sync = true);
177  template <typename TSoA, typename TDev = Device>
178  typename TSoA::ConstView getMiniDoublets(bool sync = true);
179  template <typename TSoA, typename TDev = Device>
180  typename TSoA::ConstView getSegments(bool sync = true);
181  template <typename TSoA, typename TDev = Device>
182  typename TSoA::ConstView getTriplets(bool sync = true);
183  template <typename TSoA, typename TDev = Device>
184  typename TSoA::ConstView getQuintuplets(bool sync = true);
185  template <typename TDev = Device>
186  PixelTripletsConst getPixelTriplets(bool sync = true);
187  template <typename TDev = Device>
188  PixelQuintupletsConst getPixelQuintuplets(bool sync = true);
189  const TrackCandidatesConst& getTrackCandidates(bool inCMSSW = false, bool sync = true);
190  template <typename TSoA, typename TDev = Device>
191  typename TSoA::ConstView getModules(bool sync = true);
192  };
193 
194 } // namespace ALPAKA_ACCELERATOR_NAMESPACE::lst
195 #endif
unsigned int getNumberOfMiniDoubletsByLayerBarrel(unsigned int layer)
PixelQuintupletsConst getPixelQuintuplets(bool sync=true)
const TrackCandidatesConst & getTrackCandidates(bool inCMSSW=false, bool sync=true)
std::optional< TripletsHostCollection > tripletsHC_
Definition: LSTEvent.h:66
unsigned int getNumberOfTripletsByLayerEndcap(unsigned int layer)
TSoA::ConstView getQuintuplets(bool sync=true)
std::array< unsigned int, 6 > n_triplets_by_layer_barrel_
Definition: LSTEvent.h:44
TSoA::ConstView getTriplets(bool sync=true)
ModulesDeviceCollection const & modules_
Definition: LSTEvent.h:77
std::optional< PixelQuintupletsDeviceCollection > pixelQuintupletsDC_
Definition: LSTEvent.h:59
bool verbose
std::optional< PixelTripletsHostCollection > pixelTripletsHC_
Definition: LSTEvent.h:70
std::optional< TrackCandidatesDeviceCollection > trackCandidatesDC_
Definition: LSTEvent.h:57
PixelTripletsSoA::ConstView PixelTripletsConst
void addPixelSegmentToEvent(std::vector< unsigned int > const &hitIndices0, std::vector< unsigned int > const &hitIndices1, std::vector< unsigned int > const &hitIndices2, std::vector< unsigned int > const &hitIndices3, std::vector< float > const &dPhiChange, std::vector< float > const &ptIn, std::vector< float > const &ptErr, std::vector< float > const &px, std::vector< float > const &py, std::vector< float > const &pz, std::vector< float > const &eta, std::vector< float > const &etaErr, std::vector< float > const &phi, std::vector< int > const &charge, std::vector< unsigned int > const &seedIdx, std::vector< int > const &superbin, std::vector< PixelType > const &pixelType, std::vector< char > const &isQuad)
std::array< unsigned int, 5 > n_triplets_by_layer_endcap_
Definition: LSTEvent.h:45
std::array< unsigned int, 6 > n_segments_by_layer_barrel_
Definition: LSTEvent.h:42
std::optional< QuintupletsDeviceCollection > quintupletsDC_
Definition: LSTEvent.h:56
std::optional< ModulesHostCollection > modulesHC_
Definition: LSTEvent.h:68
std::array< unsigned int, 5 > n_quintuplets_by_layer_endcap_
Definition: LSTEvent.h:47
std::array< unsigned int, 5 > n_segments_by_layer_endcap_
Definition: LSTEvent.h:43
void pixelLineSegmentCleaning(bool no_pls_dupclean)
ObjectRangesConst getRanges(bool sync=true)
unsigned int getNumberOfQuintupletsByLayer(unsigned int layer)
unsigned int getNumberOfMiniDoubletsByLayerEndcap(unsigned int layer)
void addHitToEvent(std::vector< float > const &x, std::vector< float > const &y, std::vector< float > const &z, std::vector< unsigned int > const &detId, std::vector< unsigned int > const &idxInNtuple)
Definition: LSTEvent.dev.cc:75
ALPAKA_ACCELERATOR_NAMESPACE::Queue Queue
Definition: LSTEvent.dev.cc:14
std::optional< PixelTripletsDeviceCollection > pixelTripletsDC_
Definition: LSTEvent.h:58
TSoA::ConstView getModules(bool sync=true)
unsigned int getNumberOfMiniDoubletsByLayer(unsigned int layer)
unsigned int getNumberOfTripletsByLayer(unsigned int layer)
PortableCollection< EndcapGeometryDevSoA > EndcapGeometryDevDeviceCollection
TrackCandidatesSoA::ConstView TrackCandidatesConst
TSoA::ConstView getMiniDoublets(bool sync=true)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float phi(TAcc const &acc, float x, float y)
Definition: Hit.h:29
TSoA::ConstView getSegments(bool sync=true)
unsigned int getNumberOfSegmentsByLayerEndcap(unsigned int layer)
unsigned int getNumberOfSegmentsByLayerBarrel(unsigned int layer)
EndcapGeometryDevDeviceCollection const & endcapGeometry_
Definition: LSTEvent.h:79
std::array< unsigned int, 6 > n_quintuplets_by_layer_barrel_
Definition: LSTEvent.h:46
std::optional< ObjectRangesHostCollection > rangesHC_
Definition: LSTEvent.h:62
std::optional< SegmentsHostCollection > segmentsHC_
Definition: LSTEvent.h:65
PixelTripletsConst getPixelTriplets(bool sync=true)
TSoA::ConstView getHits(bool inCMSSW=false, bool sync=true)
LSTEvent(bool verbose, Queue &q, const LSTESData< Device > *deviceESData)
Definition: LSTEvent.h:84
PixelQuintupletsSoA::ConstView PixelQuintupletsConst
std::optional< ObjectRangesDeviceCollection > rangesDC_
Definition: LSTEvent.h:51
std::optional< TripletsDeviceCollection > tripletsDC_
Definition: LSTEvent.h:55
std::optional< HitsDeviceCollection > hitsDC_
Definition: LSTEvent.h:52
void createTrackCandidates(bool no_pls_dupclean, bool tc_pls_triplets)
std::array< unsigned int, 6 > n_minidoublets_by_layer_barrel_
Definition: LSTEvent.h:40
unsigned int getNumberOfSegmentsByLayer(unsigned int layer)
ObjectRangesSoA::ConstView ObjectRangesConst
std::optional< PixelQuintupletsHostCollection > pixelQuintupletsHC_
Definition: LSTEvent.h:71
std::optional< QuintupletsHostCollection > quintupletsHC_
Definition: LSTEvent.h:69
std::optional< SegmentsDeviceCollection > segmentsDC_
Definition: LSTEvent.h:54
std::optional< MiniDoubletsHostCollection > miniDoubletsHC_
Definition: LSTEvent.h:64
std::array< unsigned int, 5 > n_minidoublets_by_layer_endcap_
Definition: LSTEvent.h:41
std::optional< HitsHostCollection > hitsHC_
Definition: LSTEvent.h:63
std::optional< TrackCandidatesHostCollection > trackCandidatesHC_
Definition: LSTEvent.h:67
unsigned int getNumberOfQuintupletsByLayerBarrel(unsigned int layer)
PortableCollection2< ModulesSoA, ModulesPixelSoA > ModulesDeviceCollection
unsigned int getNumberOfTripletsByLayerBarrel(unsigned int layer)
std::optional< MiniDoubletsDeviceCollection > miniDoubletsDC_
Definition: LSTEvent.h:53
unsigned int getNumberOfQuintupletsByLayerEndcap(unsigned int layer)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE float eta(TAcc const &acc, float x, float y, float z)
Definition: Hit.h:11