CMS 3D CMS Logo

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