Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-02 03:39:33

0001 #ifndef RecoPixelVertexing_PixelTriplets_plugins_HelixFitOnGPU_h
0002 #define RecoPixelVertexing_PixelTriplets_plugins_HelixFitOnGPU_h
0003 
0004 #include "CUDADataFormats/Track/interface/PixelTrackHeterogeneous.h"
0005 #include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DHeterogeneous.h"
0006 #include "RecoPixelVertexing/PixelTrackFitting/interface/FitResult.h"
0007 
0008 #include "CAConstants.h"
0009 
0010 namespace riemannFit {
0011   // in case of memory issue can be made smaller
0012   constexpr uint32_t maxNumberOfConcurrentFits = caConstants::maxNumberOfTuples;
0013   constexpr uint32_t stride = maxNumberOfConcurrentFits;
0014   using Matrix3x4d = Eigen::Matrix<double, 3, 4>;
0015   using Map3x4d = Eigen::Map<Matrix3x4d, 0, Eigen::Stride<3 * stride, stride> >;
0016   using Matrix6x4f = Eigen::Matrix<float, 6, 4>;
0017   using Map6x4f = Eigen::Map<Matrix6x4f, 0, Eigen::Stride<6 * stride, stride> >;
0018 
0019   // hits
0020   template <int N>
0021   using Matrix3xNd = Eigen::Matrix<double, 3, N>;
0022   template <int N>
0023   using Map3xNd = Eigen::Map<Matrix3xNd<N>, 0, Eigen::Stride<3 * stride, stride> >;
0024   // errors
0025   template <int N>
0026   using Matrix6xNf = Eigen::Matrix<float, 6, N>;
0027   template <int N>
0028   using Map6xNf = Eigen::Map<Matrix6xNf<N>, 0, Eigen::Stride<6 * stride, stride> >;
0029   // fast fit
0030   using Map4d = Eigen::Map<Vector4d, 0, Eigen::InnerStride<stride> >;
0031 
0032 }  // namespace riemannFit
0033 
0034 class HelixFitOnGPU {
0035 public:
0036   using HitsView = TrackingRecHit2DSOAView;
0037 
0038   using Tuples = pixelTrack::HitContainer;
0039   using OutputSoA = pixelTrack::TrackSoA;
0040 
0041   using TupleMultiplicity = caConstants::TupleMultiplicity;
0042 
0043   explicit HelixFitOnGPU(float bf, bool fitNas4) : bField_(bf), fitNas4_(fitNas4) {}
0044   ~HelixFitOnGPU() { deallocateOnGPU(); }
0045 
0046   void setBField(double bField) { bField_ = bField; }
0047   void launchRiemannKernels(HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples, cudaStream_t cudaStream);
0048   void launchBrokenLineKernels(HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples, cudaStream_t cudaStream);
0049 
0050   void launchRiemannKernelsOnCPU(HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples);
0051   void launchBrokenLineKernelsOnCPU(HitsView const *hv, uint32_t nhits, uint32_t maxNumberOfTuples);
0052 
0053   void allocateOnGPU(Tuples const *tuples, TupleMultiplicity const *tupleMultiplicity, OutputSoA *outputSoA);
0054   void deallocateOnGPU();
0055 
0056 private:
0057   static constexpr uint32_t maxNumberOfConcurrentFits_ = riemannFit::maxNumberOfConcurrentFits;
0058 
0059   // fowarded
0060   Tuples const *tuples_ = nullptr;
0061   TupleMultiplicity const *tupleMultiplicity_ = nullptr;
0062   OutputSoA *outputSoa_;
0063   float bField_;
0064 
0065   const bool fitNas4_;
0066 };
0067 
0068 #endif  // RecoPixelVertexing_PixelTriplets_plugins_HelixFitOnGPU_h