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