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 
55 
59 };
60 
62  : digisTokenF01HE_{consumes<IProductTypef01>(ps.getParameter<edm::InputTag>("digisLabelF01HE"))},
63  digisTokenF5HB_{consumes<IProductTypef5>(ps.getParameter<edm::InputTag>("digisLabelF5HB"))},
64  digisTokenF3HB_{consumes<IProductTypef3>(ps.getParameter<edm::InputTag>("digisLabelF3HB"))},
65  rechitsM0Token_{produces<OProductType>(ps.getParameter<std::string>("recHitsLabelM0HBHE"))},
66  recoParamsToken_{esConsumes()},
67  gainWidthsToken_{esConsumes()},
68  gainsToken_{esConsumes()},
69  lutCorrsToken_{esConsumes()},
70  pedestalWidthsToken_{esConsumes()},
71  effectivePedestalWidthsToken_{esConsumes()},
72  pedestalsToken_{esConsumes()},
73  qieCodersToken_{esConsumes()},
74  respCorrsToken_{esConsumes()},
75  timeCorrsToken_{esConsumes()},
76  qieTypesToken_{esConsumes()},
77  topologyToken_{esConsumes()},
78  recConstantsToken_{esConsumes()},
79  sipmParametersToken_{esConsumes()},
80  sipmCharacteristicsToken_{esConsumes()},
81  chQualProductToken_{esConsumes()},
82  pulseOffsetsToken_{esConsumes()} {
83  configParameters_.maxTimeSamples = ps.getParameter<uint32_t>("maxTimeSamples");
84  configParameters_.kprep1dChannelsPerBlock = ps.getParameter<uint32_t>("kprep1dChannelsPerBlock");
85  configParameters_.sipmQTSShift = ps.getParameter<int>("sipmQTSShift");
86  configParameters_.sipmQNTStoSum = ps.getParameter<int>("sipmQNTStoSum");
87  configParameters_.firstSampleShift = ps.getParameter<int>("firstSampleShift");
88  configParameters_.useEffectivePedestals = ps.getParameter<bool>("useEffectivePedestals");
89  if (configParameters_.useEffectivePedestals) {
90  effectivePedestalsToken_ = esConsumes();
91  }
92 
93  configParameters_.meanTime = ps.getParameter<double>("meanTime");
94  configParameters_.timeSigmaSiPM = ps.getParameter<double>("timeSigmaSiPM");
95  configParameters_.timeSigmaHPD = ps.getParameter<double>("timeSigmaHPD");
96  configParameters_.ts4Thresh = ps.getParameter<double>("ts4Thresh");
97 
98  configParameters_.applyTimeSlew = ps.getParameter<bool>("applyTimeSlew");
99  auto const tzeroValues = ps.getParameter<std::vector<double>>("tzeroTimeSlewParameters");
100  auto const slopeValues = ps.getParameter<std::vector<double>>("slopeTimeSlewParameters");
101  auto const tmaxValues = ps.getParameter<std::vector<double>>("tmaxTimeSlewParameters");
102 
103  configParameters_.tzeroTimeSlew = tzeroValues[HcalTimeSlew::Medium];
104  configParameters_.slopeTimeSlew = slopeValues[HcalTimeSlew::Medium];
105  configParameters_.tmaxTimeSlew = tmaxValues[HcalTimeSlew::Medium];
106 
107  auto threadsMinimize = ps.getParameter<std::vector<uint32_t>>("kernelMinimizeThreads");
108  configParameters_.kernelMinimizeThreads[0] = threadsMinimize[0];
109  configParameters_.kernelMinimizeThreads[1] = threadsMinimize[1];
110  configParameters_.kernelMinimizeThreads[2] = threadsMinimize[2];
111 }
112 
114 
117  desc.addOptionalNode(edm::ParameterDescription<uint32_t>("maxChannels", true, true), 10000u)
118  ->setComment("This parameter is obsolete and will be ignored.");
119  desc.add<uint32_t>("maxTimeSamples", 10);
120  desc.add<uint32_t>("kprep1dChannelsPerBlock", 32);
121  desc.add<edm::InputTag>("digisLabelF01HE", edm::InputTag{"hcalRawToDigiGPU", "f01HEDigisGPU"});
122  desc.add<edm::InputTag>("digisLabelF5HB", edm::InputTag{"hcalRawToDigiGPU", "f5HBDigisGPU"});
123  desc.add<edm::InputTag>("digisLabelF3HB", edm::InputTag{"hcalRawToDigiGPU", "f3HBDigisGPU"});
124  desc.add<std::string>("recHitsLabelM0HBHE", "recHitsM0HBHE");
125  desc.add<int>("sipmQTSShift", 0);
126  desc.add<int>("sipmQNTStoSum", 3);
127  desc.add<int>("firstSampleShift", 0);
128  desc.add<bool>("useEffectivePedestals", true);
129 
130  desc.add<double>("meanTime", 0.f);
131  desc.add<double>("timeSigmaSiPM", 2.5f);
132  desc.add<double>("timeSigmaHPD", 5.0f);
133  desc.add<double>("ts4Thresh", 0.0);
134 
135  desc.add<bool>("applyTimeSlew", true);
136  desc.add<std::vector<double>>("tzeroTimeSlewParameters", {23.960177, 11.977461, 9.109694});
137  desc.add<std::vector<double>>("slopeTimeSlewParameters", {-3.178648, -1.5610227, -1.075824});
138  desc.add<std::vector<double>>("tmaxTimeSlewParameters", {16.00, 10.00, 6.25});
139  desc.add<std::vector<uint32_t>>("kernelMinimizeThreads", {16, 1, 1});
140 
141  cdesc.addWithDefaultLabel(desc);
142 }
143 
145  edm::EventSetup const& setup,
147 #ifdef HCAL_MAHI_CPUDEBUG
149 #endif
150 
151  // input + raii
152  auto const& f01HEProduct = event.get(digisTokenF01HE_);
153  auto const& f5HBProduct = event.get(digisTokenF5HB_);
154  auto const& f3HBProduct = event.get(digisTokenF3HB_);
155  cms::cuda::ScopedContextAcquire ctx{f01HEProduct, std::move(holder), cudaState_};
156  auto const& f01HEDigis = ctx.get(f01HEProduct);
157  auto const& f5HBDigis = ctx.get(f5HBProduct);
158  auto const& f3HBDigis = ctx.get(f3HBProduct);
159  auto const totalChannels = f01HEDigis.size + f5HBDigis.size + f3HBDigis.size;
160 
161  hcal::reconstruction::InputDataGPU inputGPU{f01HEDigis, f5HBDigis, f3HBDigis};
162 
163  // conditions
164  auto const& recoParamsProduct = setup.getData(recoParamsToken_).getProduct(ctx.stream());
165 
166  auto const& gainWidthsProduct = setup.getData(gainWidthsToken_).getProduct(ctx.stream());
167 
168  auto const& gainsProduct = setup.getData(gainsToken_).getProduct(ctx.stream());
169 
170  auto const& lutCorrsProduct = setup.getData(lutCorrsToken_).getProduct(ctx.stream());
171 
172  // use only 1 depending on useEffectivePedestals
173  auto const& pedestalWidthsProduct = setup.getData(pedestalWidthsToken_).getProduct(ctx.stream());
174  auto const& effectivePedestalWidthsProduct = setup.getData(effectivePedestalWidthsToken_).getProduct(ctx.stream());
175 
176  auto const& pedestals = setup.getData(pedestalsToken_);
177  auto const& pedestalsProduct = pedestals.getProduct(ctx.stream());
178 
179  edm::ESHandle<HcalConvertedEffectivePedestalsGPU> effectivePedestalsHandle;
181  effectivePedestalsHandle = setup.getHandle(effectivePedestalsToken_);
182  auto const* effectivePedestalsProduct =
183  configParameters_.useEffectivePedestals ? &effectivePedestalsHandle->getProduct(ctx.stream()) : nullptr;
184 
185  auto const& qieCodersProduct = setup.getData(qieCodersToken_).getProduct(ctx.stream());
186 
187  auto const& respCorrsProduct = setup.getData(respCorrsToken_).getProduct(ctx.stream());
188 
189  auto const& timeCorrsProduct = setup.getData(timeCorrsToken_).getProduct(ctx.stream());
190 
191  auto const& qieTypesProduct = setup.getData(qieTypesToken_).getProduct(ctx.stream());
192 
193  HcalTopology const& topology = setup.getData(topologyToken_);
194  HcalDDDRecConstants const& recConstants = setup.getData(recConstantsToken_);
195 
196  auto const& sipmParametersProduct = setup.getData(sipmParametersToken_).getProduct(ctx.stream());
197 
198  auto const& sipmCharacteristicsProduct = setup.getData(sipmCharacteristicsToken_).getProduct(ctx.stream());
199 
200  auto const& chQualProduct = setup.getData(chQualProductToken_).getProduct(ctx.stream());
201 
202  auto const& pulseOffsets = setup.getData(pulseOffsetsToken_);
203  auto const& pulseOffsetsProduct = pulseOffsets.getProduct(ctx.stream());
204 
205  // bundle up conditions
207  gainsProduct,
208  lutCorrsProduct,
209  pedestalWidthsProduct,
210  effectivePedestalWidthsProduct,
211  pedestalsProduct,
212  qieCodersProduct,
213  chQualProduct,
214  recoParamsProduct,
215  respCorrsProduct,
216  timeCorrsProduct,
217  qieTypesProduct,
218  sipmParametersProduct,
219  sipmCharacteristicsProduct,
220  effectivePedestalsProduct,
221  &topology,
222  &recConstants,
223  pedestals.offsetForHashes(),
224  pulseOffsetsProduct,
225  pulseOffsets.getValues()};
226 
227  // scratch mem on device
229  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
230  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
231  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
233  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
235  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
237  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
238  cms::cuda::make_device_unique<int8_t[]>(totalChannels, ctx.stream()),
239  };
240 
241  // output dev mem
242  outputGPU_.allocate(configParameters_, totalChannels, ctx.stream());
243 
244  hcal::reconstruction::entryPoint(inputGPU, outputGPU_, conditions, scratchGPU, configParameters_, ctx.stream());
245 
246 #ifdef HCAL_MAHI_CPUDEBUG
248  auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
249  std::cout << "acquire duration = " << duration << std::endl;
250 #endif
251 }
252 
256 }
257 
Definition: start.py:1
const edm::ESGetToken< HcalQIETypesGPU, HcalQIETypesRcd > qieTypesToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< HcalGainWidthsGPU, HcalGainWidthsRcd > gainWidthsToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
cms::cuda::ContextState cudaState_
const edm::ESGetToken< HcalSiPMCharacteristicsGPU, HcalSiPMCharacteristicsRcd > sipmCharacteristicsToken_
const edm::ESGetToken< HcalConvertedEffectivePedestalWidthsGPU, HcalConvertedPedestalWidthsRcd > effectivePedestalWidthsToken_
const edm::ESGetToken< HcalQIECodersGPU, HcalQIEDataRcd > qieCodersToken_
Product const & getProduct(cudaStream_t) const
edm::EDGetTokenT< IProductTypef3 > digisTokenF3HB_
void entryPoint(InputDataGPU const &, OutputDataGPU &, ConditionsProducts const &, ScratchDataGPU &, ConfigParameters const &, cudaStream_t)
edm::ESGetToken< HcalConvertedEffectivePedestalsGPU, HcalConvertedPedestalsRcd > effectivePedestalsToken_
const edm::ESGetToken< HcalRecoParamsWithPulseShapesGPU, HcalRecoParamsRcd > recoParamsToken_
hcal::reconstruction::OutputDataGPU outputGPU_
const edm::ESGetToken< HcalMahiPulseOffsetsGPU, JobConfigurationGPURecord > pulseOffsetsToken_
RecHitCollection<::calo::common::DevStoragePolicy > recHits
const edm::ESGetToken< HcalGainsGPU, HcalGainsRcd > gainsToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
const edm::ESGetToken< HcalConvertedPedestalWidthsGPU, HcalConvertedPedestalWidthsRcd > pedestalWidthsToken_
const edm::ESGetToken< HcalSiPMParametersGPU, HcalSiPMParametersRcd > sipmParametersToken_
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > recConstantsToken_
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
const edm::ESGetToken< HcalTimeCorrsGPU, HcalTimeCorrsRcd > timeCorrsToken_
hcal::reconstruction::ConfigParameters configParameters_
const edm::ESGetToken< HcalChannelQualityGPU, HcalChannelQualityRcd > chQualProductToken_
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topologyToken_
const edm::ESGetToken< HcalLUTCorrsGPU, HcalLUTCorrsRcd > lutCorrsToken_
void produce(edm::Event &, edm::EventSetup const &) override
edm::EDGetTokenT< IProductTypef01 > digisTokenF01HE_
HBHERecHitProducerGPU(edm::ParameterSet const &)
device::impl::make_device_unique_selector< T >::non_array make_device_unique(cudaStream_t stream)
const edm::ESGetToken< HcalConvertedPedestalsGPU, HcalConvertedPedestalsRcd > pedestalsToken_
edm::EDGetTokenT< IProductTypef5 > digisTokenF5HB_
void allocate(ConfigParameters const &config, uint32_t size, cudaStream_t cudaStream)
const edm::ESGetToken< HcalRespCorrsGPU, HcalRespCorrsRcd > respCorrsToken_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
edm::EDPutTokenT< OProductType > rechitsM0Token_