CMS 3D CMS Logo

CAHitNtupletGeneratorKernels.h
Go to the documentation of this file.
1 #ifndef RecoPixelVertexing_PixelTriplets_plugins_CAHitNtupletGeneratorKernels_h
2 #define RecoPixelVertexing_PixelTriplets_plugins_CAHitNtupletGeneratorKernels_h
3 
5 #include "GPUCACell.h"
6 
7 // #define DUMP_GPU_TK_TUPLES
8 
10 
11  // counters
12  struct Counters {
13  unsigned long long nEvents;
14  unsigned long long nHits;
15  unsigned long long nCells;
16  unsigned long long nTuples;
17  unsigned long long nFitTracks;
18  unsigned long long nGoodTracks;
19  unsigned long long nUsedHits;
20  unsigned long long nDupHits;
21  unsigned long long nKilledCells;
22  unsigned long long nEmptyCells;
23  unsigned long long nZeroTrackCells;
24  };
25 
28 
31 
35 
36  struct QualityCuts {
37  // chi2 cut = chi2Scale * (chi2Coeff[0] + pT/GeV * (chi2Coeff[1] + pT/GeV * (chi2Coeff[2] + pT/GeV * chi2Coeff[3])))
38  float chi2Coeff[4];
39  float chi2MaxPt; // GeV
40  float chi2Scale;
41 
42  struct Region {
43  float maxTip; // cm
44  float minPt; // GeV
45  float maxZip; // cm
46  };
47 
50  };
51 
52  // params
53  struct Params {
54  Params(bool onGPU,
55  uint32_t minHitsPerNtuplet,
56  uint32_t maxNumberOfDoublets,
57  uint16_t minHitsForSharingCuts,
58  bool useRiemannFit,
59  bool fit5as4,
60  bool includeJumpingForwardDoublets,
61  bool earlyFishbone,
62  bool lateFishbone,
63  bool idealConditions,
64  bool doStats,
65  bool doClusterCut,
66  bool doZ0Cut,
67  bool doPtCut,
68  bool doSharedHitCut,
69  float ptmin,
70  float CAThetaCutBarrel,
71  float CAThetaCutForward,
72  float hardCurvCut,
73  float dcaCutInnerTriplet,
74  float dcaCutOuterTriplet,
75 
76  QualityCuts const& cuts)
77  : onGPU_(onGPU),
78  minHitsPerNtuplet_(minHitsPerNtuplet),
80  minHitsForSharingCut_(minHitsForSharingCuts),
81  useRiemannFit_(useRiemannFit),
82  fit5as4_(fit5as4),
83  includeJumpingForwardDoublets_(includeJumpingForwardDoublets),
84  earlyFishbone_(earlyFishbone),
85  lateFishbone_(lateFishbone),
87  doStats_(doStats),
91  doSharedHitCut_(doSharedHitCut),
92  ptmin_(ptmin),
93  CAThetaCutBarrel_(CAThetaCutBarrel),
94  CAThetaCutForward_(CAThetaCutForward),
95  hardCurvCut_(hardCurvCut),
96  dcaCutInnerTriplet_(dcaCutInnerTriplet),
97  dcaCutOuterTriplet_(dcaCutOuterTriplet),
98  cuts_(cuts) {}
99 
100  const bool onGPU_;
101  const uint32_t minHitsPerNtuplet_;
102  const uint32_t maxNumberOfDoublets_;
103  const uint16_t minHitsForSharingCut_;
104  const bool useRiemannFit_;
105  const bool fit5as4_;
107  const bool earlyFishbone_;
108  const bool lateFishbone_;
109  const bool idealConditions_;
110  const bool doStats_;
111  const bool doClusterCut_;
112  const bool doZ0Cut_;
113  const bool doPtCut_;
114  const bool doSharedHitCut_;
115  const float ptmin_;
116  const float CAThetaCutBarrel_;
117  const float CAThetaCutForward_;
118  const float hardCurvCut_;
119  const float dcaCutInnerTriplet_;
120  const float dcaCutOuterTriplet_;
121 
122  // quality cuts
123  QualityCuts cuts_{// polynomial coefficients for the pT-dependent chi2 cut
124  {0.68177776, 0.74609577, -0.08035491, 0.00315399},
125  // max pT used to determine the chi2 cut
126  10.,
127  // chi2 scale factor: 30 for broken line fit, 45 for Riemann fit
128  30.,
129  // regional cuts for triplets
130  {
131  0.3, // |Tip| < 0.3 cm
132  0.5, // pT > 0.5 GeV
133  12.0 // |Zip| < 12.0 cm
134  },
135  // regional cuts for quadruplets
136  {
137  0.5, // |Tip| < 0.5 cm
138  0.3, // pT > 0.3 GeV
139  12.0 // |Zip| < 12.0 cm
140  }};
141 
142  }; // Params
143 
144 } // namespace cAHitNtupletGenerator
145 
146 template <typename TTraits>
148 public:
149  using Traits = TTraits;
150 
154 
155  template <typename T>
157 
161 
164 
168 
170  : params_(params), paramsMaxDoubletes3Quarters_(3 * params.maxNumberOfDoublets_ / 4) {}
171  ~CAHitNtupletGeneratorKernels() = default;
172 
174 
175  void launchKernels(HitsOnCPU const& hh, TkSoA* tuples_d, cudaStream_t cudaStream);
176 
177  void classifyTuples(HitsOnCPU const& hh, TkSoA* tuples_d, cudaStream_t cudaStream);
178 
179  void fillHitDetIndices(HitsView const* hv, TkSoA* tuples_d, cudaStream_t cudaStream);
180 
181  void buildDoublets(HitsOnCPU const& hh, cudaStream_t stream);
182  void allocateOnGPU(cudaStream_t stream);
183  void cleanup(cudaStream_t cudaStream);
184 
185  static void printCounters(Counters const* counters);
187 
188 private:
189  Counters* counters_ = nullptr;
190 
191  // workspace
197 
200  uint32_t* device_nCells_ = nullptr;
201 
204 
206 
208 
210  // params
211  Params const& params_;
215  inline uint32_t nDoubletBlocks(uint32_t blockSize) {
216  // We want (3 * params_.maxNumberOfDoublets_ / 4 + blockSize - 1) / blockSize, but first part is pre-computed.
217  return (paramsMaxDoubletes3Quarters_ + blockSize - 1) / blockSize;
218  }
219 
221  inline uint32_t nQuadrupletBlocks(uint32_t blockSize) {
222  // caConstants::maxNumberOfQuadruplets is a constexpr, so the compiler will pre compute the 3*max/4
223  return (3 * caConstants::maxNumberOfQuadruplets / 4 + blockSize - 1) / blockSize;
224  }
225 };
226 
229 
230 #endif // RecoPixelVertexing_PixelTriplets_plugins_CAHitNtupletGeneratorKernels_h
cAHitNtupletGenerator::Params::earlyFishbone_
const bool earlyFishbone_
Definition: CAHitNtupletGeneratorKernels.h:107
cAHitNtupletGenerator::Counters::nEvents
unsigned long long nEvents
Definition: CAHitNtupletGeneratorKernels.h:13
CAHitNtupletGeneratorKernels::device_theCellTracksContainer_
caConstants::CellTracks * device_theCellTracksContainer_
Definition: CAHitNtupletGeneratorKernels.h:196
PixelTracks_cff.idealConditions
idealConditions
Definition: PixelTracks_cff.py:101
gpuPixelDoublets::doPtCut
uint32_t CellNeighborsVector CellTracksVector TrackingRecHit2DSOAView const *__restrict__ GPUCACell::OuterHitOfCell int bool bool bool bool doPtCut
Definition: gpuPixelDoublets.h:99
CAHitNtupletGeneratorKernels::device_hitTuple_apc_
cms::cuda::AtomicPairCounter * device_hitTuple_apc_
Definition: CAHitNtupletGeneratorKernels.h:205
cuts
const TkSoA *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
Definition: CAHitNtupletGeneratorKernelsImpl.h:338
cAHitNtupletGenerator::QualityCuts::Region::maxTip
float maxTip
Definition: CAHitNtupletGeneratorKernels.h:43
cAHitNtupletGenerator::Params::Params
Params(bool onGPU, uint32_t minHitsPerNtuplet, uint32_t maxNumberOfDoublets, uint16_t minHitsForSharingCuts, bool useRiemannFit, bool fit5as4, bool includeJumpingForwardDoublets, bool earlyFishbone, bool lateFishbone, bool idealConditions, bool doStats, bool doClusterCut, bool doZ0Cut, bool doPtCut, bool doSharedHitCut, float ptmin, float CAThetaCutBarrel, float CAThetaCutForward, float hardCurvCut, float dcaCutInnerTriplet, float dcaCutOuterTriplet, QualityCuts const &cuts)
Definition: CAHitNtupletGeneratorKernels.h:54
cAHitNtupletGenerator::Counters::nHits
unsigned long long nHits
Definition: CAHitNtupletGeneratorKernels.h:14
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
cAHitNtupletGenerator::QualityCuts
Definition: CAHitNtupletGeneratorKernels.h:36
CAHitNtupletGeneratorKernels::setCounters
void setCounters(Counters *counters)
Definition: CAHitNtupletGeneratorKernels.h:186
cAHitNtupletGenerator::Params::minHitsForSharingCut_
const uint16_t minHitsForSharingCut_
Definition: CAHitNtupletGeneratorKernels.h:103
CAHitNtupletGeneratorKernels::Counters
cAHitNtupletGenerator::Counters Counters
Definition: CAHitNtupletGeneratorKernels.h:153
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
CAHitNtupletGeneratorKernels::params_
Params const & params_
Definition: CAHitNtupletGeneratorKernels.h:211
RecoPixelVertexing_cff.onGPU
onGPU
Definition: RecoPixelVertexing_cff.py:20
CAHitNtupletGeneratorKernels::allocateOnGPU
void allocateOnGPU(cudaStream_t stream)
Definition: CAHitNtupletGeneratorKernelsAlloc.h:9
TrackingRecHit2DHeterogeneous
Definition: TrackingRecHit2DHeterogeneous.h:8
CAHitNtupletGeneratorKernels::device_theCellTracks_
unique_ptr< caConstants::CellTracksVector > device_theCellTracks_
Definition: CAHitNtupletGeneratorKernels.h:195
cAHitNtupletGenerator::Params::dcaCutInnerTriplet_
const float dcaCutInnerTriplet_
Definition: CAHitNtupletGeneratorKernels.h:119
CAHitNtupletGeneratorKernels::device_theCellNeighbors_
unique_ptr< caConstants::CellNeighborsVector > device_theCellNeighbors_
Definition: CAHitNtupletGeneratorKernels.h:193
CAHitNtupletGeneratorKernels::~CAHitNtupletGeneratorKernels
~CAHitNtupletGeneratorKernels()=default
TrackingRecHit2DSOAView
Definition: TrackingRecHit2DSOAView.h:15
CAHitNtupletGeneratorKernels::device_theCells_
unique_ptr< GPUCACell[]> device_theCells_
Definition: CAHitNtupletGeneratorKernels.h:198
CAHitNtupletGeneratorKernels::nDoubletBlocks
uint32_t nDoubletBlocks(uint32_t blockSize)
Compute the number of doublet blocks for block size.
Definition: CAHitNtupletGeneratorKernels.h:215
caConstants::maxNumberOfQuadruplets
constexpr uint32_t maxNumberOfQuadruplets
Definition: CAConstants.h:41
cAHitNtupletGenerator::QualityCuts::Region
Definition: CAHitNtupletGeneratorKernels.h:42
CAHitNtupletGeneratorKernels::CAHitNtupletGeneratorKernels
CAHitNtupletGeneratorKernels(Params const &params)
Definition: CAHitNtupletGeneratorKernels.h:169
CAHitNtupletGeneratorKernels::launchKernels
void launchKernels(HitsOnCPU const &hh, TkSoA *tuples_d, cudaStream_t cudaStream)
Definition: CAHitNtupletGeneratorKernels.cc:77
CAHitNtupletGeneratorKernels::device_nCells_
uint32_t * device_nCells_
Definition: CAHitNtupletGeneratorKernels.h:200
CAHitNtupletGeneratorKernels::device_tupleMultiplicity_
unique_ptr< TupleMultiplicity > device_tupleMultiplicity_
Definition: CAHitNtupletGeneratorKernels.h:207
CAHitNtupletGeneratorKernels::device_hitToTuple_apc_
cms::cuda::AtomicPairCounter * device_hitToTuple_apc_
Definition: CAHitNtupletGeneratorKernels.h:203
cAHitNtupletGenerator::Params::idealConditions_
const bool idealConditions_
Definition: CAHitNtupletGeneratorKernels.h:109
cAHitNtupletGenerator::Params::lateFishbone_
const bool lateFishbone_
Definition: CAHitNtupletGeneratorKernels.h:108
pixelTrack::Quality
Quality
Definition: TrackSoAHeterogeneousT.h:10
cAHitNtupletGenerator::Params::doSharedHitCut_
const bool doSharedHitCut_
Definition: CAHitNtupletGeneratorKernels.h:114
counters
const caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple cms::cuda::AtomicPairCounter const GPUCACell *__restrict__ const uint32_t *__restrict__ const gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell *__restrict__ uint32_t uint32_t CAHitNtupletGeneratorKernelsGPU::Counters * counters
Definition: CAHitNtupletGeneratorKernelsImpl.h:43
cAHitNtupletGenerator
Definition: CAHitNtupletGeneratorKernels.h:9
cAHitNtupletGenerator::Params::onGPU_
const bool onGPU_
Definition: CAHitNtupletGeneratorKernels.h:100
cAHitNtupletGenerator::Params::maxNumberOfDoublets_
const uint32_t maxNumberOfDoublets_
Definition: CAHitNtupletGeneratorKernels.h:102
CAHitNtupletGeneratorKernels::device_theCellNeighborsContainer_
caConstants::CellNeighbors * device_theCellNeighborsContainer_
Definition: CAHitNtupletGeneratorKernels.h:194
cAHitNtupletGenerator::Params::minHitsPerNtuplet_
const uint32_t minHitsPerNtuplet_
Definition: CAHitNtupletGeneratorKernels.h:101
caConstants::TupleMultiplicity
cms::cuda::OneToManyAssoc< tindex_type, 8, maxTuples > TupleMultiplicity
Definition: CAConstants.h:79
CAHitNtupletGeneratorKernels::device_hitToTuple_
unique_ptr< HitToTuple > device_hitToTuple_
Definition: CAHitNtupletGeneratorKernels.h:202
cAHitNtupletGenerator::Params::hardCurvCut_
const float hardCurvCut_
Definition: CAHitNtupletGeneratorKernels.h:118
cAHitNtupletGenerator::QualityCuts::chi2MaxPt
float chi2MaxPt
Definition: CAHitNtupletGeneratorKernels.h:39
CAHitNtupletGeneratorKernels::classifyTuples
void classifyTuples(HitsOnCPU const &hh, TkSoA *tuples_d, cudaStream_t cudaStream)
Definition: CAHitNtupletGeneratorKernels.cc:157
CAHitNtupletGeneratorKernels::nQuadrupletBlocks
uint32_t nQuadrupletBlocks(uint32_t blockSize)
Compute the number of quadruplet blocks for block size.
Definition: CAHitNtupletGeneratorKernels.h:221
gpuPixelDoublets::doZ0Cut
uint32_t CellNeighborsVector CellTracksVector TrackingRecHit2DSOAView const *__restrict__ GPUCACell::OuterHitOfCell int bool bool bool doZ0Cut
Definition: gpuPixelDoublets.h:99
cAHitNtupletGenerator::Params::dcaCutOuterTriplet_
const float dcaCutOuterTriplet_
Definition: CAHitNtupletGeneratorKernels.h:120
cAHitNtupletGenerator::Counters::nDupHits
unsigned long long nDupHits
Definition: CAHitNtupletGeneratorKernels.h:20
TrackSoAHeterogeneousT
Definition: TrackSoAHeterogeneousT.h:14
CAHitNtupletGeneratorKernels::Traits
TTraits Traits
Definition: CAHitNtupletGeneratorKernels.h:149
CAHitNtupletGeneratorKernels::device_isOuterHitOfCell_
unique_ptr< GPUCACell::OuterHitOfCell[]> device_isOuterHitOfCell_
Definition: CAHitNtupletGeneratorKernels.h:199
CAHitNtupletGeneratorKernels::device_storage_
unique_ptr< cms::cuda::AtomicPairCounter::c_type[]> device_storage_
Definition: CAHitNtupletGeneratorKernels.h:209
cAHitNtupletGenerator::Counters::nZeroTrackCells
unsigned long long nZeroTrackCells
Definition: CAHitNtupletGeneratorKernels.h:23
hh
const auto & hh
Definition: CAHitNtupletGeneratorKernelsImpl.h:455
cAHitNtupletGenerator::Counters::nEmptyCells
unsigned long long nEmptyCells
Definition: CAHitNtupletGeneratorKernels.h:22
cms::cuda::AtomicPairCounter
Definition: AtomicPairCounter.h:11
cAHitNtupletGenerator::QualityCuts::Region::maxZip
float maxZip
Definition: CAHitNtupletGeneratorKernels.h:45
CAHitNtupletGeneratorKernels::HitsView
TrackingRecHit2DSOAView HitsView
Definition: CAHitNtupletGeneratorKernels.h:158
cAHitNtupletGenerator::Counters::nGoodTracks
unsigned long long nGoodTracks
Definition: CAHitNtupletGeneratorKernels.h:18
cAHitNtupletGenerator::QualityCuts::triplet
Region triplet
Definition: CAHitNtupletGeneratorKernels.h:48
cAHitNtupletGenerator::QualityCuts::chi2Coeff
float chi2Coeff[4]
Definition: CAHitNtupletGeneratorKernels.h:38
cAHitNtupletGenerator::Params::cuts_
QualityCuts cuts_
Definition: CAHitNtupletGeneratorKernels.h:123
cAHitNtupletGenerator::Params::doPtCut_
const bool doPtCut_
Definition: CAHitNtupletGeneratorKernels.h:113
cAHitNtupletGenerator::Params::includeJumpingForwardDoublets_
const bool includeJumpingForwardDoublets_
Definition: CAHitNtupletGeneratorKernels.h:106
cAHitNtupletGenerator::Params::CAThetaCutForward_
const float CAThetaCutForward_
Definition: CAHitNtupletGeneratorKernels.h:117
cms::cuda::VecArray
Definition: VecArray.h:14
CAHitNtupletGeneratorKernels::unique_ptr
typename Traits::template unique_ptr< T > unique_ptr
Definition: CAHitNtupletGeneratorKernels.h:156
cAHitNtupletGenerator::Counters::nKilledCells
unsigned long long nKilledCells
Definition: CAHitNtupletGeneratorKernels.h:21
CAHitNtupletGeneratorKernels::fillHitDetIndices
void fillHitDetIndices(HitsView const *hv, TkSoA *tuples_d, cudaStream_t cudaStream)
Definition: CAHitNtupletGeneratorKernels.cc:9
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
cAHitNtupletGenerator::Counters::nFitTracks
unsigned long long nFitTracks
Definition: CAHitNtupletGeneratorKernels.h:17
cAHitNtupletGenerator::Params::doZ0Cut_
const bool doZ0Cut_
Definition: CAHitNtupletGeneratorKernels.h:112
CAHitNtupletGeneratorKernels::printCounters
static void printCounters(Counters const *counters)
Definition: CAHitNtupletGeneratorKernels.cc:4
CAHitNtupletGeneratorKernels::paramsMaxDoubletes3Quarters_
const uint32_t paramsMaxDoubletes3Quarters_
Intermediate result avoiding repeated computations.
Definition: CAHitNtupletGeneratorKernels.h:213
cAHitNtupletGenerator::QualityCuts::chi2Scale
float chi2Scale
Definition: CAHitNtupletGeneratorKernels.h:40
cAHitNtupletGenerator::Counters
Definition: CAHitNtupletGeneratorKernels.h:12
CAHitNtupletGeneratorKernels
Definition: CAHitNtupletGeneratorKernels.h:147
CAHitNtupletGeneratorKernels::tupleMultiplicity
TupleMultiplicity const * tupleMultiplicity() const
Definition: CAHitNtupletGeneratorKernels.h:173
GPUCACell.h
cAHitNtupletGenerator::QualityCuts::Region::minPt
float minPt
Definition: CAHitNtupletGeneratorKernels.h:44
ptmin
double ptmin
Definition: HydjetWrapper.h:84
maxNumberOfDoublets
const caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple cms::cuda::AtomicPairCounter const GPUCACell *__restrict__ const uint32_t *__restrict__ const gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell *__restrict__ uint32_t uint32_t maxNumberOfDoublets
Definition: CAHitNtupletGeneratorKernelsImpl.h:33
cAHitNtupletGenerator::Params::useRiemannFit_
const bool useRiemannFit_
Definition: CAHitNtupletGeneratorKernels.h:104
PixelTrackHeterogeneous.h
CAHitNtupletGeneratorKernels::cellStorage_
unique_ptr< unsigned char[]> cellStorage_
Definition: CAHitNtupletGeneratorKernels.h:192
CAHitNtupletGeneratorKernels::buildDoublets
void buildDoublets(HitsOnCPU const &hh, cudaStream_t stream)
Definition: CAHitNtupletGeneratorKernels.cc:14
pixelTrack::HitContainer
TrackSoA::HitContainer HitContainer
Definition: TrackSoAHeterogeneousT.h:69
cAHitNtupletGenerator::Params::doClusterCut_
const bool doClusterCut_
Definition: CAHitNtupletGeneratorKernels.h:111
caConstants::HitToTuple
cms::cuda::OneToManyAssoc< tindex_type, pixelGPUConstants::maxNumberOfHits, 4 *maxTuples > HitToTuple
Definition: CAConstants.h:78
pixelTrack::TrackSoA
TrackSoAHeterogeneousT< maxNumber()> TrackSoA
Definition: TrackSoAHeterogeneousT.h:67
cms::cuda::HistoContainer
Definition: HistoContainer.h:152
gpuPixelDoublets::doClusterCut
uint32_t CellNeighborsVector CellTracksVector TrackingRecHit2DSOAView const *__restrict__ GPUCACell::OuterHitOfCell int bool bool doClusterCut
Definition: gpuPixelDoublets.h:99
cAHitNtupletGenerator::Counters::nCells
unsigned long long nCells
Definition: CAHitNtupletGeneratorKernels.h:15
CAHitNtupletGeneratorKernels::counters_
Counters * counters_
Definition: CAHitNtupletGeneratorKernels.h:189
cAHitNtupletGenerator::Params
Definition: CAHitNtupletGeneratorKernels.h:53
cAHitNtupletGenerator::Params::doStats_
const bool doStats_
Definition: CAHitNtupletGeneratorKernels.h:110
cAHitNtupletGenerator::Counters::nUsedHits
unsigned long long nUsedHits
Definition: CAHitNtupletGeneratorKernels.h:19
cAHitNtupletGenerator::Params::ptmin_
const float ptmin_
Definition: CAHitNtupletGeneratorKernels.h:115
cAHitNtupletGenerator::QualityCuts::quadruplet
Region quadruplet
Definition: CAHitNtupletGeneratorKernels.h:49
cAHitNtupletGenerator::Counters::nTuples
unsigned long long nTuples
Definition: CAHitNtupletGeneratorKernels.h:16
CAHitNtupletGeneratorKernels::cleanup
void cleanup(cudaStream_t cudaStream)
cAHitNtupletGenerator::Params::CAThetaCutBarrel_
const float CAThetaCutBarrel_
Definition: CAHitNtupletGeneratorKernels.h:116
cAHitNtupletGenerator::Params::fit5as4_
const bool fit5as4_
Definition: CAHitNtupletGeneratorKernels.h:105