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.add<uint32_t>("maxTimeSamples", 10);
118  desc.add<uint32_t>("kprep1dChannelsPerBlock", 32);
119  desc.add<edm::InputTag>("digisLabelF01HE", edm::InputTag{"hcalRawToDigiGPU", "f01HEDigisGPU"});
120  desc.add<edm::InputTag>("digisLabelF5HB", edm::InputTag{"hcalRawToDigiGPU", "f5HBDigisGPU"});
121  desc.add<edm::InputTag>("digisLabelF3HB", edm::InputTag{"hcalRawToDigiGPU", "f3HBDigisGPU"});
122  desc.add<std::string>("recHitsLabelM0HBHE", "recHitsM0HBHE");
123  desc.add<int>("sipmQTSShift", 0);
124  desc.add<int>("sipmQNTStoSum", 3);
125  desc.add<int>("firstSampleShift", 0);
126  desc.add<bool>("useEffectivePedestals", true);
127 
128  desc.add<double>("meanTime", 0.f);
129  desc.add<double>("timeSigmaSiPM", 2.5f);
130  desc.add<double>("timeSigmaHPD", 5.0f);
131  desc.add<double>("ts4Thresh", 0.0);
132 
133  desc.add<bool>("applyTimeSlew", true);
134  desc.add<std::vector<double>>("tzeroTimeSlewParameters", {23.960177, 11.977461, 9.109694});
135  desc.add<std::vector<double>>("slopeTimeSlewParameters", {-3.178648, -1.5610227, -1.075824});
136  desc.add<std::vector<double>>("tmaxTimeSlewParameters", {16.00, 10.00, 6.25});
137  desc.add<std::vector<uint32_t>>("kernelMinimizeThreads", {16, 1, 1});
138 
139  cdesc.addWithDefaultLabel(desc);
140 }
141 
143  edm::EventSetup const& setup,
145 #ifdef HCAL_MAHI_CPUDEBUG
147 #endif
148 
149  // input + raii
150  auto const& f01HEProduct = event.get(digisTokenF01HE_);
151  auto const& f5HBProduct = event.get(digisTokenF5HB_);
152  auto const& f3HBProduct = event.get(digisTokenF3HB_);
153  cms::cuda::ScopedContextAcquire ctx{f01HEProduct, std::move(holder), cudaState_};
154  auto const& f01HEDigis = ctx.get(f01HEProduct);
155  auto const& f5HBDigis = ctx.get(f5HBProduct);
156  auto const& f3HBDigis = ctx.get(f3HBProduct);
157  auto const totalChannels = f01HEDigis.size + f5HBDigis.size + f3HBDigis.size;
158 
159  hcal::reconstruction::InputDataGPU inputGPU{f01HEDigis, f5HBDigis, f3HBDigis};
160 
161  // conditions
162  auto const& recoParamsProduct = setup.getData(recoParamsToken_).getProduct(ctx.stream());
163 
164  auto const& gainWidthsProduct = setup.getData(gainWidthsToken_).getProduct(ctx.stream());
165 
166  auto const& gainsProduct = setup.getData(gainsToken_).getProduct(ctx.stream());
167 
168  auto const& lutCorrsProduct = setup.getData(lutCorrsToken_).getProduct(ctx.stream());
169 
170  // use only 1 depending on useEffectivePedestals
171  auto const& pedestalWidthsProduct = setup.getData(pedestalWidthsToken_).getProduct(ctx.stream());
172  auto const& effectivePedestalWidthsProduct = setup.getData(effectivePedestalWidthsToken_).getProduct(ctx.stream());
173 
174  auto const& pedestals = setup.getData(pedestalsToken_);
175  auto const& pedestalsProduct = pedestals.getProduct(ctx.stream());
176 
177  edm::ESHandle<HcalConvertedEffectivePedestalsGPU> effectivePedestalsHandle;
179  effectivePedestalsHandle = setup.getHandle(effectivePedestalsToken_);
180  auto const* effectivePedestalsProduct =
181  configParameters_.useEffectivePedestals ? &effectivePedestalsHandle->getProduct(ctx.stream()) : nullptr;
182 
183  auto const& qieCodersProduct = setup.getData(qieCodersToken_).getProduct(ctx.stream());
184 
185  auto const& respCorrsProduct = setup.getData(respCorrsToken_).getProduct(ctx.stream());
186 
187  auto const& timeCorrsProduct = setup.getData(timeCorrsToken_).getProduct(ctx.stream());
188 
189  auto const& qieTypesProduct = setup.getData(qieTypesToken_).getProduct(ctx.stream());
190 
191  HcalTopology const& topology = setup.getData(topologyToken_);
192  HcalDDDRecConstants const& recConstants = setup.getData(recConstantsToken_);
193 
194  auto const& sipmParametersProduct = setup.getData(sipmParametersToken_).getProduct(ctx.stream());
195 
196  auto const& sipmCharacteristicsProduct = setup.getData(sipmCharacteristicsToken_).getProduct(ctx.stream());
197 
198  auto const& chQualProduct = setup.getData(chQualProductToken_).getProduct(ctx.stream());
199 
200  auto const& pulseOffsets = setup.getData(pulseOffsetsToken_);
201  auto const& pulseOffsetsProduct = pulseOffsets.getProduct(ctx.stream());
202 
203  // bundle up conditions
205  gainsProduct,
206  lutCorrsProduct,
207  pedestalWidthsProduct,
208  effectivePedestalWidthsProduct,
209  pedestalsProduct,
210  qieCodersProduct,
211  chQualProduct,
212  recoParamsProduct,
213  respCorrsProduct,
214  timeCorrsProduct,
215  qieTypesProduct,
216  sipmParametersProduct,
217  sipmCharacteristicsProduct,
218  effectivePedestalsProduct,
219  &topology,
220  &recConstants,
221  pedestals.offsetForHashes(),
222  pulseOffsetsProduct,
223  pulseOffsets.getValues()};
224 
225  // scratch mem on device
227  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
228  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
229  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
231  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
233  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
235  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
236  cms::cuda::make_device_unique<int8_t[]>(totalChannels, ctx.stream()),
237  };
238 
239  // output dev mem
240  outputGPU_.allocate(configParameters_, totalChannels, ctx.stream());
241 
242  hcal::reconstruction::entryPoint(inputGPU, outputGPU_, conditions, scratchGPU, configParameters_, ctx.stream());
243 
244 #ifdef HCAL_MAHI_CPUDEBUG
246  auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
247  std::cout << "acquire duration = " << duration << std::endl;
248 #endif
249 }
250 
254 }
255 
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:307
const edm::ESGetToken< HcalGainWidthsGPU, HcalGainWidthsRcd > gainWidthsToken_
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_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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_