CMS 3D CMS Logo

Typedefs | Functions | Variables
RiemannFitOnGPU.h File Reference
#include <cstdint>
#include <cuda_runtime.h>
#include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DHeterogeneous.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cuda_assert.h"
#include "RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforGPU.h"
#include "RecoPixelVertexing/PixelTrackFitting/interface/RiemannFit.h"
#include "HelixFitOnGPU.h"

Go to the source code of this file.

Typedefs

using HitsOnGPU = TrackingRecHit2DSOAView
 
using OutputSoA = pixelTrack::TrackSoA
 
using Tuples = pixelTrack::HitContainer
 

Functions

template<int N>
 __attribute__ ((always_inline)) void kernel_FastFit(Tuples const *__restrict__ foundNtuplets
 
 assert (foundNtuplets)
 
 assert (hitsInFit<=nHits)
 
 assert (pfast_fit)
 
 assert (tupleMultiplicity)
 
 for (int local_idx=local_start, nt=riemannFit::maxNumberOfConcurrentFits;local_idx< nt;local_idx+=gridDim.x *blockDim.x)
 

Variables

const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ hhp
 
auto local_start = blockIdx.x * blockDim.x + threadIdx.x
 
const caConstants::TupleMultiplicity *__restrict__ uint32_t nHits
 
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t offset
 
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ pfast_fit
 
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ phits
 
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ phits_ge
 
const caConstants::TupleMultiplicity *__restrict__ tupleMultiplicity
 

Typedef Documentation

◆ HitsOnGPU

Definition at line 17 of file RiemannFitOnGPU.h.

◆ OutputSoA

Definition at line 19 of file RiemannFitOnGPU.h.

◆ Tuples

Definition at line 18 of file RiemannFitOnGPU.h.

Function Documentation

◆ __attribute__()

template<int N>
__attribute__ ( (always_inline)  ) const
inline

Definition at line 87 of file RiemannFitOnGPU.h.

94  {
95  assert(circle_fit);
96  assert(N <= nHits);
97 
98  // same as above...
99 
100  // look in bin for this hit multiplicity
101  auto local_start = blockIdx.x * blockDim.x + threadIdx.x;
102  for (int local_idx = local_start, nt = riemannFit::maxNumberOfConcurrentFits; local_idx < nt;
103  local_idx += gridDim.x * blockDim.x) {
104  auto tuple_idx = local_idx + offset;
105  if (tuple_idx >= tupleMultiplicity->size(nHits))
106  break;
107 
108  riemannFit::Map3xNd<N> hits(phits + local_idx);
109  riemannFit::Map4d fast_fit(pfast_fit_input + local_idx);
110  riemannFit::Map6xNf<N> hits_ge(phits_ge + local_idx);
111 
112  riemannFit::VectorNd<N> rad = (hits.block(0, 0, 2, N).colwise().norm());
113 
115  riemannFit::loadCovariance2D(hits_ge, hits_cov);
116 
117  circle_fit[local_idx] = riemannFit::circleFit(hits.block(0, 0, 2, N), hits_cov, fast_fit, rad, bField, true);
118 
119 #ifdef RIEMANN_DEBUG
120 // auto tkid = *(tupleMultiplicity->begin(nHits) + tuple_idx);
121 // printf("kernelCircleFit circle.par(0,1,2): %d %f,%f,%f\n", tkid,
122 // circle_fit[local_idx].par(0), circle_fit[local_idx].par(1), circle_fit[local_idx].par(2));
123 #endif
124  }
125 }

References assert(), Calorimetry_cff::bField, cms::cudacompat::blockDim, cms::cudacompat::blockIdx, riemannFit::circleFit(), cms::cudacompat::gridDim, hfClusterShapes_cfi::hits, riemannFit::loadCovariance2D(), local_start, riemannFit::maxNumberOfConcurrentFits, N, nHits, nt, offset, phits, phits_ge, cms::cudacompat::threadIdx, and tupleMultiplicity.

◆ assert() [1/4]

assert ( foundNtuplets  )

◆ assert() [2/4]

assert ( hitsInFit<=  nHits)

Referenced by __attribute__(), and for().

◆ assert() [3/4]

assert ( pfast_fit  )

◆ assert() [4/4]

assert ( tupleMultiplicity  )

◆ for()

for ( int  local_idx = local_start)

Definition at line 46 of file RiemannFitOnGPU.h.

47  {
48  auto tuple_idx = local_idx + offset;
49  if (tuple_idx >= tupleMultiplicity->size(nHits))
50  break;
51 
52  // get it from the ntuple container (one to one to helix)
53  auto tkid = *(tupleMultiplicity->begin(nHits) + tuple_idx);
54  assert(tkid < foundNtuplets->nbins());
55 
56  assert(foundNtuplets->size(tkid) == nHits);
57 
58  riemannFit::Map3xNd<N> hits(phits + local_idx);
59  riemannFit::Map4d fast_fit(pfast_fit + local_idx);
60  riemannFit::Map6xNf<N> hits_ge(phits_ge + local_idx);
61 
62  // Prepare data structure
63  auto const *hitId = foundNtuplets->begin(tkid);
64  for (unsigned int i = 0; i < hitsInFit; ++i) {
65  auto hit = hitId[i];
66  // printf("Hit global: %f,%f,%f\n", hhp->xg_d[hit],hhp->yg_d[hit],hhp->zg_d[hit]);
67  float ge[6];
68  hhp->cpeParams()
69  .detParams(hhp->detectorIndex(hit))
70  .frame.toGlobal(hhp->xerrLocal(hit), 0, hhp->yerrLocal(hit), ge);
71  // printf("Error: %d: %f,%f,%f,%f,%f,%f\n",hhp->detInd_d[hit],ge[0],ge[1],ge[2],ge[3],ge[4],ge[5]);
72 
73  hits.col(i) << hhp->xGlobal(hit), hhp->yGlobal(hit), hhp->zGlobal(hit);
74  hits_ge.col(i) << ge[0], ge[1], ge[2], ge[3], ge[4], ge[5];
75  }
76  riemannFit::fastFit(hits, fast_fit);
77 
78  // no NaN here....
79  assert(fast_fit(0) == fast_fit(0));
80  assert(fast_fit(1) == fast_fit(1));
81  assert(fast_fit(2) == fast_fit(2));
82  assert(fast_fit(3) == fast_fit(3));
83  }

References assert(), riemannFit::fastFit(), foundNtuplets, amptDefault_cfi::frame, hhp, hfClusterShapes_cfi::hits, mps_fire::i, LaserClient_cfi::nbins, nHits, offset, pfast_fit, phits, phits_ge, and tupleMultiplicity.

Variable Documentation

◆ hhp

const caConstants::TupleMultiplicity* __restrict__ uint32_t const HitsOnGPU* __restrict__ hhp

Definition at line 23 of file RiemannFitOnGPU.h.

Referenced by for().

◆ local_start

auto local_start = blockIdx.x * blockDim.x + threadIdx.x

Definition at line 39 of file RiemannFitOnGPU.h.

Referenced by __attribute__().

◆ nHits

const caConstants::TupleMultiplicity* __restrict__ uint32_t nHits

Definition at line 23 of file RiemannFitOnGPU.h.

Referenced by __attribute__(), and for().

◆ offset

const caConstants::TupleMultiplicity* __restrict__ uint32_t const HitsOnGPU* __restrict__ double* __restrict__ float* __restrict__ double* __restrict__ uint32_t offset
Initial value:
{
constexpr uint32_t hitsInFit = N

Definition at line 29 of file RiemannFitOnGPU.h.

Referenced by __attribute__(), and for().

◆ pfast_fit

const caConstants::TupleMultiplicity* __restrict__ uint32_t const HitsOnGPU* __restrict__ double* __restrict__ float* __restrict__ double* __restrict__ pfast_fit

Definition at line 23 of file RiemannFitOnGPU.h.

Referenced by for().

◆ phits

const caConstants::TupleMultiplicity* __restrict__ uint32_t const HitsOnGPU* __restrict__ double* __restrict__ phits

Definition at line 23 of file RiemannFitOnGPU.h.

Referenced by __attribute__(), and for().

◆ phits_ge

const caConstants::TupleMultiplicity* __restrict__ uint32_t const HitsOnGPU* __restrict__ double* __restrict__ float* __restrict__ phits_ge

Definition at line 23 of file RiemannFitOnGPU.h.

Referenced by __attribute__(), and for().

◆ tupleMultiplicity

const caConstants::TupleMultiplicity* __restrict__ tupleMultiplicity

Definition at line 23 of file RiemannFitOnGPU.h.

Referenced by __attribute__(), and for().

offset
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t offset
Definition: RiemannFitOnGPU.h:29
mps_fire.i
i
Definition: mps_fire.py:428
pfast_fit
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ pfast_fit
Definition: RiemannFitOnGPU.h:23
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
nt
int nt
Definition: AMPTWrapper.h:42
riemannFit::Matrix2Nd
Eigen::Matrix< double, 2 *N, 2 *N > Matrix2Nd
Definition: FitUtils.h:21
phits_ge
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ phits_ge
Definition: RiemannFitOnGPU.h:23
riemannFit::maxNumberOfConcurrentFits
constexpr uint32_t maxNumberOfConcurrentFits
Definition: HelixFitOnGPU.h:12
nHits
const caConstants::TupleMultiplicity *__restrict__ uint32_t nHits
Definition: RiemannFitOnGPU.h:23
N
#define N
Definition: blowfish.cc:9
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
cms::cudacompat::gridDim
const dim3 gridDim
Definition: cudaCompat.h:33
cms::cudacompat::blockDim
const dim3 blockDim
Definition: cudaCompat.h:30
assert
assert(hitsInFit<=nHits)
riemannFit::Map6xNf
Eigen::Map< Matrix6xNf< N >, 0, Eigen::Stride< 6 *stride, stride > > Map6xNf
Definition: HelixFitOnGPU.h:28
foundNtuplets
const uint32_t *__restrict__ HitContainer * foundNtuplets
Definition: CAHitNtupletGeneratorKernelsImpl.h:124
cms::cudacompat::threadIdx
const dim3 threadIdx
Definition: cudaCompat.h:29
riemannFit::fastFit
__host__ __device__ void fastFit(const M3xN &hits, V4 &result)
A very fast helix fit: it fits a circle by three points (first, middle and last point) and a line by ...
Definition: RiemannFit.h:375
riemannFit::VectorNd
Eigen::Matrix< double, N, 1 > VectorNd
Definition: FitUtils.h:33
Calorimetry_cff.bField
bField
Definition: Calorimetry_cff.py:284
tupleMultiplicity
const caConstants::TupleMultiplicity *__restrict__ tupleMultiplicity
Definition: RiemannFitOnGPU.h:23
riemannFit::Map3xNd
Eigen::Map< Matrix3xNd< N >, 0, Eigen::Stride< 3 *stride, stride > > Map3xNd
Definition: HelixFitOnGPU.h:23
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
local_start
auto local_start
Definition: RiemannFitOnGPU.h:39
riemannFit::circleFit
__host__ __device__ CircleFit circleFit(const M2xN &hits2D, const Matrix2Nd< N > &hits_cov2D, const V4 &fast_fit, const VectorNd< N > &rad, const double bField, const bool error)
Fit a generic number of 2D points with a circle using Riemann-Chernov algorithm. Covariance matrix of...
Definition: RiemannFit.h:455
riemannFit::loadCovariance2D
__host__ __device__ void loadCovariance2D(M6xNf const &ge, M2Nd &hits_cov)
Definition: FitUtils.h:88
phits
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ double *__restrict__ phits
Definition: RiemannFitOnGPU.h:23
hhp
const caConstants::TupleMultiplicity *__restrict__ uint32_t const HitsOnGPU *__restrict__ hhp
Definition: RiemannFitOnGPU.h:23
hit
Definition: SiStripHitEffFromCalibTree.cc:88
riemannFit::Map4d
Eigen::Map< Vector4d, 0, Eigen::InnerStride< stride > > Map4d
Definition: HelixFitOnGPU.h:30
cms::cudacompat::blockIdx
const dim3 blockIdx
Definition: cudaCompat.h:32