CMS 3D CMS Logo

EERecHitGPU.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 
11 
13 
18 
23 
25 public:
26  explicit EERecHitGPU(const edm::ParameterSet &ps);
27  ~EERecHitGPU() override;
28 
29  void produce(edm::Event &, const edm::EventSetup &) override;
30 
31 private:
34 
35  std::unique_ptr<HGCeeRecHitCollection> rechits_;
36 
37  //constants
40 
41  std::string assert_error_message_(std::string, const size_t &, const size_t &);
43 
44  //conditions (geometry, topology, ...)
45  std::unique_ptr<hgcal::RecHitTools> tools_;
46 
47  //data processing
50 
54 
56 };
57 
59  : uncalibRecHitCPUToken_{consumes<HGCUncalibratedRecHitCollection>(
60  ps.getParameter<edm::InputTag>("HGCEEUncalibRecHitsTok"))},
61  recHitGPUToken_{produces<cms::cuda::Product<HGCRecHitGPUProduct>>()} {
62  cdata_.keV2DIGI_ = ps.getParameter<double>("HGCEE_keV2DIGI");
63  cdata_.xmin_ = ps.getParameter<double>("minValSiPar"); //float
64  cdata_.xmax_ = ps.getParameter<double>("maxValSiPar"); //float
65  cdata_.aterm_ = ps.getParameter<double>("noiseSiPar"); //float
66  cdata_.cterm_ = ps.getParameter<double>("constSiPar"); //float
67  vdata_.fCPerMIP_ = ps.getParameter<std::vector<double>>("HGCEE_fCPerMIP");
68  vdata_.cce_ = ps.getParameter<edm::ParameterSet>("HGCEE_cce").getParameter<std::vector<double>>("values");
69  vdata_.noise_fC_ = ps.getParameter<edm::ParameterSet>("HGCEE_noise_fC").getParameter<std::vector<double>>("values");
70  vdata_.rcorr_ = ps.getParameter<std::vector<double>>("rcorr");
71  vdata_.weights_ = ps.getParameter<std::vector<double>>("weights");
72  cdata_.uncalib2GeV_ = 1e-6 / cdata_.keV2DIGI_;
73  assert_sizes_constants_(vdata_);
74 
75  kcdata_ = new KernelConstantData<HGCeeUncalibRecHitConstantData>(cdata_, vdata_);
76  convert_constant_data_(kcdata_);
77 
78  tools_ = std::make_unique<hgcal::RecHitTools>();
79 }
80 
82 
83 std::string EERecHitGPU::assert_error_message_(std::string var, const size_t &s1, const size_t &s2) {
84  std::string str1 = "The '";
85  std::string str2 = "' array must be of size ";
86  std::string str3 = " to hold the configuration data, but is of size ";
87  return str1 + var + str2 + std::to_string(s1) + str3 + std::to_string(s2);
88 }
89 
92  edm::LogError("WrongSize") << this->assert_error_message_(
95  edm::LogError("WrongSize") << this->assert_error_message_(
98  edm::LogError("WrongSize") << this->assert_error_message_(
101  edm::LogError("WrongSize") << this->assert_error_message_(
104  edm::LogError("WrongSize") << this->assert_error_message_(
106 }
107 
109  cms::cuda::ScopedContextProduce ctx{event.streamID()};
110 
111  const auto &hits = event.get(uncalibRecHitCPUToken_);
112  const unsigned nhits(hits.size());
113  rechits_ = std::make_unique<HGCRecHitCollection>();
114 
115  if (nhits == 0)
116  edm::LogError("EERecHitGPU") << "WARNING: no input hits!";
117 
118  prod_ = HGCRecHitGPUProduct(nhits, ctx.stream());
119  d_uncalib_ = HGCUncalibRecHitDevice(nhits, ctx.stream());
121 
123  km.run_kernels(kcdata_, ctx.stream());
124 
125  ctx.emplace(event, recHitGPUToken_, std::move(prod_));
126 }
127 
129  for (size_t i = 0; i < kcdata->vdata_.fCPerMIP_.size(); ++i)
130  kcdata->data_.fCPerMIP_[i] = kcdata->vdata_.fCPerMIP_[i];
131  for (size_t i = 0; i < kcdata->vdata_.cce_.size(); ++i)
132  kcdata->data_.cce_[i] = kcdata->vdata_.cce_[i];
133  for (size_t i = 0; i < kcdata->vdata_.noise_fC_.size(); ++i)
134  kcdata->data_.noise_fC_[i] = kcdata->vdata_.noise_fC_[i];
135  for (size_t i = 0; i < kcdata->vdata_.rcorr_.size(); ++i)
136  kcdata->data_.rcorr_[i] = kcdata->vdata_.rcorr_[i];
137  for (size_t i = 0; i < kcdata->vdata_.weights_.size(); ++i)
138  kcdata->data_.weights_[i] = kcdata->vdata_.weights_[i];
139 }
140 
void produce(edm::Event &, const edm::EventSetup &) override
Definition: EERecHitGPU.cc:108
edm::EDGetTokenT< HGCeeUncalibratedRecHitCollection > uncalibRecHitCPUToken_
Definition: EERecHitGPU.cc:32
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
HGCUncalibRecHitHost< HGCeeUncalibratedRecHitCollection > h_uncalib_
Definition: EERecHitGPU.cc:53
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
void convert_constant_data_(KernelConstantData< HGCeeUncalibRecHitConstantData > *)
Definition: EERecHitGPU.cc:128
std::unique_ptr< HGCeeRecHitCollection > rechits_
Definition: EERecHitGPU.cc:35
Log< level::Error, false > LogError
KernelConstantData< HGCeeUncalibRecHitConstantData > * kcdata_
Definition: EERecHitGPU.cc:55
static std::string to_string(const XMLCh *ch)
~EERecHitGPU() override
Definition: EERecHitGPU.cc:81
HGCUncalibRecHitDevice d_uncalib_
Definition: EERecHitGPU.cc:52
void run_kernels(const KernelConstantData< HGCeeUncalibRecHitConstantData > *, const cudaStream_t &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EERecHitGPU(const edm::ParameterSet &ps)
Definition: EERecHitGPU.cc:58
std::vector< DeviationSensor2D * > vd
void convert_collection_data_to_soa_(const uint32_t &, const HGCeeUncalibratedRecHitCollection &)
HGCUncalibRecHitSoA get() const
std::string assert_error_message_(std::string, const size_t &, const size_t &)
Definition: EERecHitGPU.cc:83
HGCConstantVectorData vdata_
Definition: EERecHitGPU.cc:39
HGCeeUncalibRecHitConstantData cdata_
Definition: EERecHitGPU.cc:38
HGCConstantVectorData vdata_
HGCRecHitGPUProduct prod_
Definition: EERecHitGPU.cc:51
std::unique_ptr< hgcal::RecHitTools > tools_
Definition: EERecHitGPU.cc:45
edm::EDPutTokenT< cms::cuda::Product< HGCRecHitGPUProduct > > recHitGPUToken_
Definition: EERecHitGPU.cc:33
def move(src, dest)
Definition: eostools.py:511
void assert_sizes_constants_(const HGCConstantVectorData &)
Definition: EERecHitGPU.cc:90
Definition: event.py:1