Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:22

0001 #ifndef RecoLocalTracker_SiPixelRecHits_PixelCPEFast_h
0002 #define RecoLocalTracker_SiPixelRecHits_PixelCPEFast_h
0003 
0004 #include <utility>
0005 
0006 #include "CondFormats/SiPixelTransient/interface/SiPixelGenError.h"
0007 #include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h"
0008 #include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
0009 #include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
0010 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEGenericBase.h"
0011 #include "RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforGPU.h"
0012 #include "Geometry/CommonTopologies/interface/SimplePixelTopology.h"
0013 
0014 class MagneticField;
0015 template <typename TrackerTraits>
0016 class PixelCPEFast final : public PixelCPEGenericBase {
0017 public:
0018   PixelCPEFast(edm::ParameterSet const &conf,
0019                const MagneticField *,
0020                const TrackerGeometry &,
0021                const TrackerTopology &,
0022                const SiPixelLorentzAngle *,
0023                const SiPixelGenErrorDBObject *,
0024                const SiPixelLorentzAngle *);
0025 
0026   ~PixelCPEFast() override = default;
0027 
0028   static void fillPSetDescription(edm::ParameterSetDescription &desc);
0029 
0030   // The return value can only be used safely in kernels launched on
0031   // the same cudaStream, or after cudaStreamSynchronize.
0032   using ParamsOnGPU = pixelCPEforGPU::ParamsOnGPUT<TrackerTraits>;
0033   using LayerGeometry = pixelCPEforGPU::LayerGeometryT<TrackerTraits>;
0034   using AverageGeometry = pixelTopology::AverageGeometryT<TrackerTraits>;
0035 
0036   const ParamsOnGPU *getGPUProductAsync(cudaStream_t cudaStream) const;
0037 
0038   ParamsOnGPU const &getCPUProduct() const { return cpuData_; }
0039 
0040 private:
0041   LocalPoint localPosition(DetParam const &theDetParam, ClusterParam &theClusterParam) const override;
0042   LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override;
0043 
0044   void errorFromTemplates(DetParam const &theDetParam, ClusterParamGeneric &theClusterParam, float qclus) const;
0045 
0046   //--- DB Error Parametrization object, new light templates
0047   std::vector<SiPixelGenErrorStore> thePixelGenError_;
0048 
0049   // allocate this with posix malloc to be compatible with the cpu workflow
0050   std::vector<pixelCPEforGPU::DetParams> detParamsGPU_;
0051   pixelCPEforGPU::CommonParams commonParamsGPU_;
0052   LayerGeometry layerGeometry_;
0053   AverageGeometry averageGeometry_;
0054   ParamsOnGPU cpuData_;
0055 
0056   struct GPUData {
0057     ~GPUData();
0058     // not needed if not used on CPU...
0059     ParamsOnGPU paramsOnGPU_h;
0060     ParamsOnGPU *paramsOnGPU_d = nullptr;  // copy of the above on the Device
0061   };
0062   cms::cuda::ESProduct<GPUData> gpuData_;
0063 
0064   void fillParamsForGpu();
0065 };
0066 
0067 #endif  // RecoLocalTracker_SiPixelRecHits_PixelCPEFast_h