CMS 3D CMS Logo

HBHERecHitProducerGPU.cc
Go to the documentation of this file.
10 
11 #include "SimpleAlgoGPU.h"
12 
13 class HBHERecHitProducerGPU : public edm::stream::EDProducer<edm::ExternalWork> {
14 public:
16  ~HBHERecHitProducerGPU() override;
18 
19 private:
21  void produce(edm::Event&, edm::EventSetup const&) override;
22 
25 
28 
31 
35 
39 };
40 
42  : digisTokenF01HE_{consumes<IProductTypef01>(ps.getParameter<edm::InputTag>("digisLabelF01HE"))},
43  digisTokenF5HB_{consumes<IProductTypef5>(ps.getParameter<edm::InputTag>("digisLabelF5HB"))},
44  digisTokenF3HB_{consumes<IProductTypef3>(ps.getParameter<edm::InputTag>("digisLabelF3HB"))},
45  rechitsM0Token_{produces<OProductType>(ps.getParameter<std::string>("recHitsLabelM0HBHE"))} {
46  configParameters_.maxChannels = ps.getParameter<uint32_t>("maxChannels");
47  configParameters_.maxTimeSamples = ps.getParameter<uint32_t>("maxTimeSamples");
48  configParameters_.kprep1dChannelsPerBlock = ps.getParameter<uint32_t>("kprep1dChannelsPerBlock");
49  configParameters_.sipmQTSShift = ps.getParameter<int>("sipmQTSShift");
50  configParameters_.sipmQNTStoSum = ps.getParameter<int>("sipmQNTStoSum");
51  configParameters_.firstSampleShift = ps.getParameter<int>("firstSampleShift");
52  configParameters_.useEffectivePedestals = ps.getParameter<bool>("useEffectivePedestals");
53 
54  configParameters_.meanTime = ps.getParameter<double>("meanTime");
55  configParameters_.timeSigmaSiPM = ps.getParameter<double>("timeSigmaSiPM");
56  configParameters_.timeSigmaHPD = ps.getParameter<double>("timeSigmaHPD");
57  configParameters_.ts4Thresh = ps.getParameter<double>("ts4Thresh");
58 
59  configParameters_.applyTimeSlew = ps.getParameter<bool>("applyTimeSlew");
60  auto const tzeroValues = ps.getParameter<std::vector<double>>("tzeroTimeSlewParameters");
61  auto const slopeValues = ps.getParameter<std::vector<double>>("slopeTimeSlewParameters");
62  auto const tmaxValues = ps.getParameter<std::vector<double>>("tmaxTimeSlewParameters");
63 
64  configParameters_.tzeroTimeSlew = tzeroValues[HcalTimeSlew::Medium];
65  configParameters_.slopeTimeSlew = slopeValues[HcalTimeSlew::Medium];
66  configParameters_.tmaxTimeSlew = tmaxValues[HcalTimeSlew::Medium];
67 
68  auto threadsMinimize = ps.getParameter<std::vector<uint32_t>>("kernelMinimizeThreads");
69  configParameters_.kernelMinimizeThreads[0] = threadsMinimize[0];
70  configParameters_.kernelMinimizeThreads[1] = threadsMinimize[1];
71  configParameters_.kernelMinimizeThreads[2] = threadsMinimize[2];
72 }
73 
75 
78  desc.add<uint32_t>("maxChannels", 10000u);
79  desc.add<uint32_t>("maxTimeSamples", 10);
80  desc.add<uint32_t>("kprep1dChannelsPerBlock", 32);
81  desc.add<edm::InputTag>("digisLabelF01HE", edm::InputTag{"hcalRawToDigiGPU", "f01HEDigisGPU"});
82  desc.add<edm::InputTag>("digisLabelF5HB", edm::InputTag{"hcalRawToDigiGPU", "f5HBDigisGPU"});
83  desc.add<edm::InputTag>("digisLabelF3HB", edm::InputTag{"hcalRawToDigiGPU", "f3HBDigisGPU"});
84  desc.add<std::string>("recHitsLabelM0HBHE", "recHitsM0HBHE");
85  desc.add<int>("sipmQTSShift", 0);
86  desc.add<int>("sipmQNTStoSum", 3);
87  desc.add<int>("firstSampleShift", 0);
88  desc.add<bool>("useEffectivePedestals", true);
89 
90  desc.add<double>("meanTime", 0.f);
91  desc.add<double>("timeSigmaSiPM", 2.5f);
92  desc.add<double>("timeSigmaHPD", 5.0f);
93  desc.add<double>("ts4Thresh", 0.0);
94 
95  desc.add<bool>("applyTimeSlew", true);
96  desc.add<std::vector<double>>("tzeroTimeSlewParameters", {23.960177, 11.977461, 9.109694});
97  desc.add<std::vector<double>>("slopeTimeSlewParameters", {-3.178648, -1.5610227, -1.075824});
98  desc.add<std::vector<double>>("tmaxTimeSlewParameters", {16.00, 10.00, 6.25});
99  desc.add<std::vector<uint32_t>>("kernelMinimizeThreads", {16, 1, 1});
100 
101  cdesc.addWithDefaultLabel(desc);
102 }
103 
105  edm::EventSetup const& setup,
107 #ifdef HCAL_MAHI_CPUDEBUG
109 #endif
110 
111  // input + raii
112  auto const& f01HEProduct = event.get(digisTokenF01HE_);
113  auto const& f5HBProduct = event.get(digisTokenF5HB_);
114  auto const& f3HBProduct = event.get(digisTokenF3HB_);
115  cms::cuda::ScopedContextAcquire ctx{f01HEProduct, std::move(holder), cudaState_};
116  auto const& f01HEDigis = ctx.get(f01HEProduct);
117  auto const& f5HBDigis = ctx.get(f5HBProduct);
118  auto const& f3HBDigis = ctx.get(f3HBProduct);
119 
120  hcal::reconstruction::InputDataGPU inputGPU{f01HEDigis, f5HBDigis, f3HBDigis};
121 
122  // conditions
124  setup.get<HcalRecoParamsRcd>().get(recoParamsHandle);
125  auto const& recoParamsProduct = recoParamsHandle->getProduct(ctx.stream());
126 
127  edm::ESHandle<HcalGainWidthsGPU> gainWidthsHandle;
128  setup.get<HcalGainWidthsRcd>().get(gainWidthsHandle);
129  auto const& gainWidthsProduct = gainWidthsHandle->getProduct(ctx.stream());
130 
131  edm::ESHandle<HcalGainsGPU> gainsHandle;
132  setup.get<HcalGainsRcd>().get(gainsHandle);
133  auto const& gainsProduct = gainsHandle->getProduct(ctx.stream());
134 
135  edm::ESHandle<HcalLUTCorrsGPU> lutCorrsHandle;
136  setup.get<HcalLUTCorrsRcd>().get(lutCorrsHandle);
137  auto const& lutCorrsProduct = lutCorrsHandle->getProduct(ctx.stream());
138 
139  // use only 1 depending on useEffectivePedestals
141  edm::ESHandle<HcalConvertedEffectivePedestalWidthsGPU> effectivePedestalWidthsHandle;
142  setup.get<HcalConvertedPedestalWidthsRcd>().get(effectivePedestalWidthsHandle);
143  setup.get<HcalConvertedPedestalWidthsRcd>().get(pedestalWidthsHandle);
144  auto const& pedestalWidthsProduct = pedestalWidthsHandle->getProduct(ctx.stream());
145  auto const& effectivePedestalWidthsProduct = effectivePedestalWidthsHandle->getProduct(ctx.stream());
146 
148  setup.get<HcalConvertedPedestalsRcd>().get(pedestalsHandle);
149  auto const& pedestalsProduct = pedestalsHandle->getProduct(ctx.stream());
150 
151  edm::ESHandle<HcalConvertedEffectivePedestalsGPU> effectivePedestalsHandle;
153  setup.get<HcalConvertedPedestalsRcd>().get(effectivePedestalsHandle);
154  auto const* effectivePedestalsProduct =
155  configParameters_.useEffectivePedestals ? &effectivePedestalsHandle->getProduct(ctx.stream()) : nullptr;
156 
157  edm::ESHandle<HcalQIECodersGPU> qieCodersHandle;
158  setup.get<HcalQIEDataRcd>().get(qieCodersHandle);
159  auto const& qieCodersProduct = qieCodersHandle->getProduct(ctx.stream());
160 
161  edm::ESHandle<HcalRespCorrsGPU> respCorrsHandle;
162  setup.get<HcalRespCorrsRcd>().get(respCorrsHandle);
163  auto const& respCorrsProduct = respCorrsHandle->getProduct(ctx.stream());
164 
165  edm::ESHandle<HcalTimeCorrsGPU> timeCorrsHandle;
166  setup.get<HcalTimeCorrsRcd>().get(timeCorrsHandle);
167  auto const& timeCorrsProduct = timeCorrsHandle->getProduct(ctx.stream());
168 
169  edm::ESHandle<HcalQIETypesGPU> qieTypesHandle;
170  setup.get<HcalQIETypesRcd>().get(qieTypesHandle);
171  auto const& qieTypesProduct = qieTypesHandle->getProduct(ctx.stream());
172 
173  edm::ESHandle<HcalTopology> topologyHandle;
174  setup.get<HcalRecNumberingRecord>().get(topologyHandle);
175  edm::ESHandle<HcalDDDRecConstants> recConstantsHandle;
176  setup.get<HcalRecNumberingRecord>().get(recConstantsHandle);
177 
178  edm::ESHandle<HcalSiPMParametersGPU> sipmParametersHandle;
179  setup.get<HcalSiPMParametersRcd>().get(sipmParametersHandle);
180  auto const& sipmParametersProduct = sipmParametersHandle->getProduct(ctx.stream());
181 
182  edm::ESHandle<HcalSiPMCharacteristicsGPU> sipmCharacteristicsHandle;
183  setup.get<HcalSiPMCharacteristicsRcd>().get(sipmCharacteristicsHandle);
184  auto const& sipmCharacteristicsProduct = sipmCharacteristicsHandle->getProduct(ctx.stream());
185 
186  edm::ESHandle<HcalMahiPulseOffsetsGPU> pulseOffsetsHandle;
187  setup.get<JobConfigurationGPURecord>().get(pulseOffsetsHandle);
188  auto const& pulseOffsetsProduct = pulseOffsetsHandle->getProduct(ctx.stream());
189 
190  // bundle up conditions
192  gainsProduct,
193  lutCorrsProduct,
194  pedestalWidthsProduct,
195  effectivePedestalWidthsProduct,
196  pedestalsProduct,
197  qieCodersProduct,
198  recoParamsProduct,
199  respCorrsProduct,
200  timeCorrsProduct,
201  qieTypesProduct,
202  sipmParametersProduct,
203  sipmCharacteristicsProduct,
204  effectivePedestalsProduct,
205  topologyHandle.product(),
206  recConstantsHandle.product(),
207  pedestalsHandle->offsetForHashes(),
208  pulseOffsetsProduct,
209  pulseOffsetsHandle->getValues()};
210 
211  // scratch mem on device
213  cms::cuda::make_device_unique<float[]>(configParameters_.maxChannels * configParameters_.maxTimeSamples,
214  ctx.stream()),
216  ctx.stream()),
218  ctx.stream()),
221  ctx.stream()),
224  ctx.stream()),
227  ctx.stream()),
229  };
230 
231  // output dev mem
232  outputGPU_.allocate(configParameters_, ctx.stream());
233 
234  hcal::reconstruction::entryPoint(inputGPU, outputGPU_, conditions, scratchGPU, configParameters_, ctx.stream());
235 
236 #ifdef HCAL_MAHI_CPUDEBUG
238  auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
239  std::cout << "acquire duration = " << duration << std::endl;
240 #endif
241 }
242 
246 }
247 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
HcalQIECodersGPU::getProduct
const Product & getProduct(cudaStream_t) const
Definition: HcalQIECodersGPU.cc:36
hcal::reconstruction::OutputDataGPU
Definition: DeclsForKernels.h:89
start
Definition: start.py:1
HcalSiPMCharacteristicsRcd
Definition: HcalSiPMCharacteristicsRcd.h:4
HBHERecHitProducerGPU::HBHERecHitProducerGPU
HBHERecHitProducerGPU(edm::ParameterSet const &)
Definition: HBHERecHitProducerGPU.cc:41
HcalTimeCorrsGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalTimeCorrsGPU.cc:25
HcalTimeSlew::Medium
Definition: HcalTimeSlew.h:71
cms::cuda::ScopedContextProduce
Definition: ScopedContext.h:149
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
cms::cuda::make_device_unique
device::impl::make_device_unique_selector< T >::non_array make_device_unique(cudaStream_t stream)
Definition: device_unique_ptr.h:52
edm::EDGetTokenT
Definition: EDGetToken.h:33
HcalGainsRcd
Definition: HcalGainsRcd.h:8
edm::EDPutTokenT
Definition: EDPutToken.h:33
hcal::reconstruction::ConfigParameters::maxTimeSamples
uint32_t maxTimeSamples
Definition: DeclsForKernels.h:68
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HcalRespCorrsGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalRespCorrsGPU.cc:25
HBHERecHitProducerGPU::digisTokenF5HB_
edm::EDGetTokenT< IProductTypef5 > digisTokenF5HB_
Definition: HBHERecHitProducerGPU.cc:27
HcalConvertedPedestalsGPU::offsetForHashes
uint32_t offsetForHashes() const
Definition: HcalConvertedPedestalsGPU.h:31
hcal::reconstruction::OutputDataGPU::allocate
void allocate(ConfigParameters const &config, cudaStream_t cudaStream)
Definition: DeclsForKernels.h:92
EDProducer.h
HcalConvertedPedestalsGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalConvertedPedestalsGPU.cc:109
HBHERecHitProducerGPU::~HBHERecHitProducerGPU
~HBHERecHitProducerGPU() override
Definition: HBHERecHitProducerGPU.cc:74
HBHERecHitProducerGPU::cudaState_
cms::cuda::ContextState cudaState_
Definition: HBHERecHitProducerGPU.cc:38
HBHERecHitProducerGPU::digisTokenF01HE_
edm::EDGetTokenT< IProductTypef01 > digisTokenF01HE_
Definition: HBHERecHitProducerGPU.cc:24
HcalGainWidthsRcd
Definition: HcalGainWidthsRcd.h:8
hcal::reconstruction::InputDataGPU
Definition: DeclsForKernels.h:107
HcalLUTCorrsRcd
Definition: HcalLUTCorrsRcd.h:25
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
hcal::reconstruction::OutputDataGPU::recHits
RecHitCollection<::calo::common::DevStoragePolicy > recHits
Definition: DeclsForKernels.h:90
HcalSiPMParametersGPU::getProduct
const Product & getProduct(cudaStream_t) const
Definition: HcalSiPMParametersGPU.cc:40
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
MakerMacros.h
HcalQIETypesRcd
Definition: HcalQIETypesRcd.h:25
HBHERecHitProducerGPU::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: HBHERecHitProducerGPU.cc:76
HcalSiPMParametersRcd
Definition: HcalSiPMParametersRcd.h:7
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HBHERecHitProducerGPU
Definition: HBHERecHitProducerGPU.cc:13
Service.h
mps_fire.end
end
Definition: mps_fire.py:242
HcalQIETypesGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalQIETypesGPU.cc:25
edm::ESHandle
Definition: DTSurvey.h:22
HcalMahiPulseOffsetsGPU::getValues
std::vector< int, cms::cuda::HostAllocator< int > > const & getValues() const
Definition: HcalMahiPulseOffsetsGPU.h:25
HBHERecHitProducerGPU::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: HBHERecHitProducerGPU.cc:243
JobConfigurationGPURecord
Definition: JobConfigurationGPURecord.h:6
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
hcal::reconstruction::ConfigParameters::useEffectivePedestals
bool useEffectivePedestals
Definition: DeclsForKernels.h:73
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
JobConfigurationGPURecord.h
cms::cuda::ContextState
Definition: ContextState.h:15
HcalLUTCorrsGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalLUTCorrsGPU.cc:25
edm::ParameterSet
Definition: ParameterSet.h:47
hcal::reconstruction::entryPoint
void entryPoint(InputDataGPU const &, OutputDataGPU &, ConditionsProducts const &, ScratchDataGPU &, ConfigParameters const &, cudaStream_t)
Event.h
HBHERecHitProducerGPU::outputGPU_
hcal::reconstruction::OutputDataGPU outputGPU_
Definition: HBHERecHitProducerGPU.cc:37
SimpleAlgoGPU.h
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
HcalRespCorrsRcd
Definition: HcalRespCorrsRcd.h:27
get
#define get
HcalMahiPulseOffsetsGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalMahiPulseOffsetsGPU.cc:18
hcal::reconstruction::ConfigParameters
Definition: DeclsForKernels.h:66
HcalRecoParamsWithPulseShapesGPU::getProduct
const Product & getProduct(cudaStream_t) const
Definition: HcalRecoParamsWithPulseShapesGPU.cc:156
CUDAService.h
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
HBHERecHitProducerGPU::rechitsM0Token_
edm::EDPutTokenT< OProductType > rechitsM0Token_
Definition: HBHERecHitProducerGPU.cc:34
HcalGainsGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalGainsGPU.cc:33
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
eostools.move
def move(src, dest)
Definition: eostools.py:511
HcalConvertedPedestalWidthsGPU::getProduct
Product const & getProduct(cudaStream_t) const
Definition: HcalConvertedPedestalWidthsGPU.cc:137
hcal::reconstruction::ConditionsProducts
Definition: DeclsForKernels.h:44
HcalGainWidthsGPU::getProduct
const Product & getProduct(cudaStream_t) const
Definition: HcalGainWidthsGPU.cc:35
HcalQIEDataRcd
Definition: HcalQIEDataRcd.h:8
cms::cuda::Product
Definition: Product.h:34
ScopedContext.h
HBHERecHitProducerGPU::digisTokenF3HB_
edm::EDGetTokenT< IProductTypef3 > digisTokenF3HB_
Definition: HBHERecHitProducerGPU.cc:30
HcalRecoParamsRcd
Definition: HcalRecoParamsRcd.h:6
EventSetup.h
hcal::reconstruction::ScratchDataGPU
Definition: DeclsForKernels.h:101
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalSiPMCharacteristicsGPU::getProduct
const Product & getProduct(cudaStream_t) const
Definition: HcalSiPMCharacteristicsGPU.cc:38
ParameterSet.h
HBHERecHitProducerGPU::acquire
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
Definition: HBHERecHitProducerGPU.cc:104
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
hcal::reconstruction::ConfigParameters::maxChannels
uint32_t maxChannels
Definition: DeclsForKernels.h:67
HBHERecHitProducerGPU::configParameters_
hcal::reconstruction::ConfigParameters configParameters_
Definition: HBHERecHitProducerGPU.cc:36
HcalCombinedRecord
Definition: HcalCombinedRecordsGPU.h:11
HcalTimeCorrsRcd
Definition: HcalTimeCorrsRcd.h:25
edm::InputTag
Definition: InputTag.h:15
hcal::RecHitCollection< calo::common::DevStoragePolicy >
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87