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  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<HGChefRecHitCollection> rechits_;
37 
38  //constants
41 
42  //memory
43  std::string assert_error_message_(std::string, const size_t &, const size_t &);
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>("HGCHEFUncalibRecHitsTok"))},
63  recHitGPUToken_{produces<cms::cuda::Product<HGCRecHitGPUProduct>>()} {
64  cdata_.keV2DIGI_ = ps.getParameter<double>("HGCHEF_keV2DIGI");
65  cdata_.xmin_ = ps.getParameter<double>("minValSiPar"); //float
66  cdata_.xmax_ = ps.getParameter<double>("maxValSiPar"); //float
67  cdata_.aterm_ = ps.getParameter<double>("noiseSiPar"); //float
68  cdata_.cterm_ = ps.getParameter<double>("constSiPar"); //float
69  vdata_.fCPerMIP_ = ps.getParameter<std::vector<double>>("HGCHEF_fCPerMIP");
70  vdata_.cce_ = ps.getParameter<edm::ParameterSet>("HGCHEF_cce").getParameter<std::vector<double>>("values");
71  vdata_.noise_fC_ = ps.getParameter<edm::ParameterSet>("HGCHEF_noise_fC").getParameter<std::vector<double>>("values");
72  vdata_.rcorr_ = ps.getParameter<std::vector<double>>("rcorr");
73  vdata_.weights_ = ps.getParameter<std::vector<double>>("weights");
74  cdata_.uncalib2GeV_ = 1e-6 / cdata_.keV2DIGI_;
75  cdata_.layerOffset_ = 28;
76  assert_sizes_constants_(vdata_);
77 
78  kcdata_ = new KernelConstantData<HGChefUncalibRecHitConstantData>(cdata_, vdata_);
79  convert_constant_data_(kcdata_);
80 
81  tools_ = std::make_unique<hgcal::RecHitTools>();
82 }
83 
85 
86 std::string HEFRecHitGPU::assert_error_message_(std::string var, const size_t &s1, const size_t &s2) {
87  std::string str1 = "The '";
88  std::string str2 = "' array must be of size ";
89  std::string str3 = " to hold the configuration data, but is of size ";
90  return str1 + var + str2 + std::to_string(s1) + str3 + std::to_string(s2);
91 }
92 
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_(
107  edm::LogError("WrongSize") << this->assert_error_message_(
109 }
110 
112 
114  cms::cuda::ScopedContextProduce ctx{event.streamID()};
115 
116  const auto &hits = event.get(uncalibRecHitCPUToken_);
117  unsigned int nhits(hits.size());
118  rechits_ = std::make_unique<HGCRecHitCollection>();
119 
120  if (nhits == 0)
121  edm::LogError("HEFRecHitGPU") << "WARNING: no input hits!";
122 
123  prod_ = HGCRecHitGPUProduct(nhits, ctx.stream());
124  d_uncalib_ = HGCUncalibRecHitDevice(nhits, ctx.stream());
126 
128  km.run_kernels(kcdata_, ctx.stream());
129 
130  ctx.emplace(event, recHitGPUToken_, std::move(prod_));
131 }
132 
134  for (size_t i = 0; i < kcdata->vdata_.fCPerMIP_.size(); ++i)
135  kcdata->data_.fCPerMIP_[i] = kcdata->vdata_.fCPerMIP_[i];
136  for (size_t i = 0; i < kcdata->vdata_.cce_.size(); ++i)
137  kcdata->data_.cce_[i] = kcdata->vdata_.cce_[i];
138  for (size_t i = 0; i < kcdata->vdata_.noise_fC_.size(); ++i)
139  kcdata->data_.noise_fC_[i] = kcdata->vdata_.noise_fC_[i];
140  for (size_t i = 0; i < kcdata->vdata_.rcorr_.size(); ++i)
141  kcdata->data_.rcorr_[i] = kcdata->vdata_.rcorr_[i];
142  for (size_t i = 0; i < kcdata->vdata_.weights_.size(); ++i)
143  kcdata->data_.weights_[i] = kcdata->vdata_.weights_[i];
144 }
145 
HEFRecHitGPU::~HEFRecHitGPU
~HEFRecHitGPU() override
Definition: HEFRecHitGPU.cc:84
HGCUncalibRecHitHost
Definition: HGCUncalibRecHitHost.h:12
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
HGChefUncalibRecHitConstantData::noise_fC_
double noise_fC_[hef_noise_fC]
Definition: HGCUncalibRecHitsToRecHitsConstants.h:48
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
KernelConstantData::vdata_
HGCConstantVectorData vdata_
Definition: KernelManagerHGCalRecHit.h:30
KernelConstantData::data_
T data_
Definition: KernelManagerHGCalRecHit.h:29
cms::cuda::ScopedContextProduce
Definition: ScopedContext.h:149
edm::Run
Definition: Run.h:45
HGCRecHitGPUProduct.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm::EDPutTokenT
Definition: EDPutToken.h:33
RecHitTools.h
HEFRecHitGPU::d_uncalib_
HGCUncalibRecHitDevice d_uncalib_
Definition: HEFRecHitGPU.cc:54
HGCConstantVectorData
Definition: HGCUncalibRecHitsToRecHitsConstants.h:7
EDProducer.h
edm::SortedCollection
Definition: SortedCollection.h:49
vd
std::vector< DeviationSensor2D * > vd
Definition: DeviationsFromFileSensor2D.h:21
HEFRecHitGPU::recHitGPUToken_
edm::EDPutTokenT< cms::cuda::Product< HGCRecHitGPUProduct > > recHitGPUToken_
Definition: HEFRecHitGPU.cc:34
HGCRecHitGPUProduct
Definition: HGCRecHitGPUProduct.h:12
HGChefUncalibRecHitConstantData::hef_rcorr
static constexpr size_t hef_rcorr
Definition: HGCUncalibRecHitsToRecHitsConstants.h:43
KernelManagerHGCalRecHit
Definition: KernelManagerHGCalRecHit.h:33
HEFRecHitGPU::assert_sizes_constants_
void assert_sizes_constants_(const HGCConstantVectorData &)
Definition: HEFRecHitGPU.cc:93
HEFRecHitGPU
Definition: HEFRecHitGPU.cc:24
HEFRecHitGPU::convert_constant_data_
void convert_constant_data_(KernelConstantData< HGChefUncalibRecHitConstantData > *)
Definition: HEFRecHitGPU.cc:133
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
MakerMacros.h
HGCUncalibRecHitHost.h
HEFRecHitGPU::h_uncalib_
HGCUncalibRecHitHost< HGChefUncalibratedRecHitCollection > h_uncalib_
Definition: HEFRecHitGPU.cc:55
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HEFRecHitGPU::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HEFRecHitGPU.cc:113
HGCUncalibRecHitDevice
Definition: HGCUncalibRecHitDevice.h:11
KernelManagerHGCalRecHit.h
HGCConstantVectorData::fCPerMIP_
std::vector< double > fCPerMIP_
Definition: HGCUncalibRecHitsToRecHitsConstants.h:9
HEFRecHitGPU::kcdata_
KernelConstantData< HGChefUncalibRecHitConstantData > * kcdata_
Definition: HEFRecHitGPU.cc:57
nhits
Definition: HIMultiTrackSelector.h:42
EDGetToken.h
HGChefUncalibRecHitConstantData::weights_
double weights_[hef_weights]
Definition: HGCUncalibRecHitsToRecHitsConstants.h:50
HEFRecHitGPU::rechits_
std::unique_ptr< HGChefRecHitCollection > rechits_
Definition: HEFRecHitGPU.cc:36
HGChefUncalibRecHitConstantData::hef_fCPerMIP
static constexpr size_t hef_fCPerMIP
Definition: HGCUncalibRecHitsToRecHitsConstants.h:40
HGCRecHitCollections.h
edm::ParameterSet
Definition: ParameterSet.h:47
EDPutToken.h
cudaCheck.h
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
HGCConstantVectorData::rcorr_
std::vector< double > rcorr_
Definition: HGCUncalibRecHitsToRecHitsConstants.h:12
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:15
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGChefUncalibRecHitConstantData::hef_cce
static constexpr size_t hef_cce
Definition: HGCUncalibRecHitsToRecHitsConstants.h:41
InputTag.h
HGCConstantVectorData::cce_
std::vector< double > cce_
Definition: HGCUncalibRecHitsToRecHitsConstants.h:10
HGCRecHitGPUProduct::get
HGCRecHitSoA get()
Definition: HGCRecHitGPUProduct.h:27
KernelManagerHGCalRecHit::run_kernels
void run_kernels(const KernelConstantData< HGCeeUncalibRecHitConstantData > *, const cudaStream_t &)
ContextState.h
HGChefUncalibRecHitConstantData::rcorr_
double rcorr_[hef_rcorr]
Definition: HGCUncalibRecHitsToRecHitsConstants.h:49
eostools.move
def move(src, dest)
Definition: eostools.py:511
HGCUncalibRecHitDevice::get
HGCUncalibRecHitSoA get() const
Definition: HGCUncalibRecHitDevice.h:23
HEFRecHitGPU::prod_
HGCRecHitGPUProduct prod_
Definition: HEFRecHitGPU.cc:53
HGChefUncalibRecHitConstantData::hef_weights
static constexpr size_t hef_weights
Definition: HGCUncalibRecHitsToRecHitsConstants.h:44
ScopedContext.h
HGChefUncalibRecHitConstantData::hef_noise_fC
static constexpr size_t hef_noise_fC
Definition: HGCUncalibRecHitsToRecHitsConstants.h:42
HEFRecHitGPU::assert_error_message_
std::string assert_error_message_(std::string, const size_t &, const size_t &)
Definition: HEFRecHitGPU.cc:86
HGChefUncalibRecHitConstantData
Definition: HGCUncalibRecHitsToRecHitsConstants.h:38
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HGChefUncalibRecHitConstantData::fCPerMIP_
double fCPerMIP_[hef_fCPerMIP]
Definition: HGCUncalibRecHitsToRecHitsConstants.h:46
KernelConstantData< HGChefUncalibRecHitConstantData >
HEFRecHitGPU::HEFRecHitGPU
HEFRecHitGPU(const edm::ParameterSet &ps)
Definition: HEFRecHitGPU.cc:60
HEFRecHitGPU::tools_
std::unique_ptr< hgcal::RecHitTools > tools_
Definition: HEFRecHitGPU.cc:47
ParameterSet.h
HEFRecHitGPU::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: HEFRecHitGPU.cc:111
HEFRecHitGPU::cdata_
HGChefUncalibRecHitConstantData cdata_
Definition: HEFRecHitGPU.cc:39
HGCUncalibRecHitDevice.h
HEFRecHitGPU::uncalibRecHitCPUToken_
edm::EDGetTokenT< HGChefUncalibratedRecHitCollection > uncalibRecHitCPUToken_
Definition: HEFRecHitGPU.cc:33
HGChefUncalibRecHitConstantData::cce_
double cce_[hef_cce]
Definition: HGCUncalibRecHitsToRecHitsConstants.h:47
HGCConstantVectorData::weights_
std::vector< double > weights_
Definition: HGCUncalibRecHitsToRecHitsConstants.h:13
event
Definition: event.py:1
HGCConstantVectorData::noise_fC_
std::vector< double > noise_fC_
Definition: HGCUncalibRecHitsToRecHitsConstants.h:11
edm::Event
Definition: Event.h:73
edm::Log
Definition: MessageLogger.h:70
edm::InputTag
Definition: InputTag.h:15
HEFRecHitGPU::convert_collection_data_to_soa_
void convert_collection_data_to_soa_(const uint32_t &, const HGChefUncalibratedRecHitCollection &)
HEFRecHitGPU::vdata_
HGCConstantVectorData vdata_
Definition: HEFRecHitGPU.cc:40
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37