CMS 3D CMS Logo

HEBRecHitGPU.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 
11 
13 
18 
23 
25 public:
26  explicit HEBRecHitGPU(const edm::ParameterSet &ps);
27  ~HEBRecHitGPU() override;
28 
29  void produce(edm::Event &, const edm::EventSetup &) override;
30 
31 private:
34 
35  std::unique_ptr<HGChebRecHitCollection> rechits_;
36 
37  //constants
40 
41  //memory
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>("HGCHEBUncalibRecHitsTok"))},
62  recHitGPUToken_{produces<cms::cuda::Product<HGCRecHitGPUProduct>>()} {
63  cdata_.keV2DIGI_ = ps.getParameter<double>("HGCHEB_keV2DIGI");
64  cdata_.noise_MIP_ = ps.getParameter<edm::ParameterSet>("HGCHEB_noise_MIP").getParameter<double>("noise_MIP");
65  vdata_.weights_ = ps.getParameter<std::vector<double>>("weights");
66  cdata_.uncalib2GeV_ = 1e-6 / cdata_.keV2DIGI_;
67  cdata_.layerOffset_ = 28;
68  assert_sizes_constants_(vdata_);
69 
70  kcdata_ = new KernelConstantData<HGChebUncalibRecHitConstantData>(cdata_, vdata_);
71  convert_constant_data_(kcdata_);
72 
73  tools_ = std::make_unique<hgcal::RecHitTools>();
74 }
75 
77 
79  std::string str1 = "The '";
80  std::string str2 = "' array must be of size ";
81  std::string str3 = " to hold the configuration data.";
82  return str1 + var + str2 + std::to_string(s) + str3;
83 }
84 
87  edm::LogError("WrongSize") << this->assert_error_message_("weights", vdata_.fCPerMIP_.size());
88 }
89 
91  cms::cuda::ScopedContextProduce ctx{event.streamID()};
92 
93  const auto &hits = event.get(uncalibRecHitCPUToken_);
94  unsigned int nhits(hits.size());
95  rechits_ = std::make_unique<HGCRecHitCollection>();
96 
97  if (nhits == 0)
98  edm::LogError("HEBRecHitGPU") << "WARNING: no input hits!";
99 
100  prod_ = HGCRecHitGPUProduct(nhits, ctx.stream());
101  d_uncalib_ = HGCUncalibRecHitDevice(nhits, ctx.stream());
103 
105  km.run_kernels(kcdata_, ctx.stream());
106 
107  ctx.emplace(event, recHitGPUToken_, std::move(prod_));
108 }
109 
111  for (size_t i = 0; i < kcdata->vdata_.weights_.size(); ++i)
112  kcdata->data_.weights_[i] = kcdata->vdata_.weights_[i];
113 }
114 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
HEBRecHitGPU(const edm::ParameterSet &ps)
Definition: HEBRecHitGPU.cc:59
HGCConstantVectorData vdata_
Definition: HEBRecHitGPU.cc:39
std::string assert_error_message_(std::string, const size_t &)
Definition: HEBRecHitGPU.cc:78
Log< level::Error, false > LogError
void convert_collection_data_to_soa_(const uint32_t &, const HGChebUncalibratedRecHitCollection &)
static std::string to_string(const XMLCh *ch)
edm::EDPutTokenT< cms::cuda::Product< HGCRecHitGPUProduct > > recHitGPUToken_
Definition: HEBRecHitGPU.cc:33
HGChebUncalibRecHitConstantData cdata_
Definition: HEBRecHitGPU.cc:38
HGCUncalibRecHitDevice d_uncalib_
Definition: HEBRecHitGPU.cc:53
HGCRecHitGPUProduct prod_
Definition: HEBRecHitGPU.cc:52
void convert_constant_data_(KernelConstantData< HGChebUncalibRecHitConstantData > *)
void run_kernels(const KernelConstantData< HGCeeUncalibRecHitConstantData > *, const cudaStream_t &)
std::unique_ptr< HGChebRecHitCollection > rechits_
Definition: HEBRecHitGPU.cc:35
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::unique_ptr< hgcal::RecHitTools > tools_
Definition: HEBRecHitGPU.cc:46
HGCUncalibRecHitHost< HGChebUncalibratedRecHitCollection > h_uncalib_
Definition: HEBRecHitGPU.cc:54
std::vector< DeviationSensor2D * > vd
HGCUncalibRecHitSoA get() const
~HEBRecHitGPU() override
Definition: HEBRecHitGPU.cc:76
edm::EDGetTokenT< HGChebUncalibratedRecHitCollection > uncalibRecHitCPUToken_
Definition: HEBRecHitGPU.cc:32
HGCConstantVectorData vdata_
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HEBRecHitGPU.cc:90
KernelConstantData< HGChebUncalibRecHitConstantData > * kcdata_
Definition: HEBRecHitGPU.cc:56
void assert_sizes_constants_(const HGCConstantVectorData &)
Definition: HEBRecHitGPU.cc:85
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1