CMS 3D CMS Logo

HBHERecHitProducerGPU.cc
Go to the documentation of this file.
10 
11 #include "SimpleAlgoGPU.h"
12 
25 
26 class HBHERecHitProducerGPU : public edm::stream::EDProducer<edm::ExternalWork> {
27 public:
29  ~HBHERecHitProducerGPU() override;
31 
32 private:
34  void produce(edm::Event&, edm::EventSetup const&) override;
35 
38 
41 
44 
48 
68 
72 };
73 
75  : digisTokenF01HE_{consumes<IProductTypef01>(ps.getParameter<edm::InputTag>("digisLabelF01HE"))},
76  digisTokenF5HB_{consumes<IProductTypef5>(ps.getParameter<edm::InputTag>("digisLabelF5HB"))},
77  digisTokenF3HB_{consumes<IProductTypef3>(ps.getParameter<edm::InputTag>("digisLabelF3HB"))},
78  rechitsM0Token_{produces<OProductType>(ps.getParameter<std::string>("recHitsLabelM0HBHE"))},
79  recoParamsToken_{esConsumes()},
80  gainWidthsToken_{esConsumes()},
81  gainsToken_{esConsumes()},
82  lutCorrsToken_{esConsumes()},
83  pedestalWidthsToken_{esConsumes()},
84  effectivePedestalWidthsToken_{esConsumes()},
85  pedestalsToken_{esConsumes()},
86  qieCodersToken_{esConsumes()},
87  respCorrsToken_{esConsumes()},
88  timeCorrsToken_{esConsumes()},
89  qieTypesToken_{esConsumes()},
90  topologyToken_{esConsumes()},
91  recConstantsToken_{esConsumes()},
92  sipmParametersToken_{esConsumes()},
93  sipmCharacteristicsToken_{esConsumes()},
94  chQualProductToken_{esConsumes()},
95  pulseOffsetsToken_{esConsumes()} {
96  configParameters_.maxTimeSamples = ps.getParameter<uint32_t>("maxTimeSamples");
97  configParameters_.kprep1dChannelsPerBlock = ps.getParameter<uint32_t>("kprep1dChannelsPerBlock");
98  configParameters_.sipmQTSShift = ps.getParameter<int>("sipmQTSShift");
99  configParameters_.sipmQNTStoSum = ps.getParameter<int>("sipmQNTStoSum");
100  configParameters_.firstSampleShift = ps.getParameter<int>("firstSampleShift");
101  configParameters_.useEffectivePedestals = ps.getParameter<bool>("useEffectivePedestals");
102  if (configParameters_.useEffectivePedestals) {
103  effectivePedestalsToken_ = esConsumes();
104  }
105 
106  configParameters_.meanTime = ps.getParameter<double>("meanTime");
107  configParameters_.timeSigmaSiPM = ps.getParameter<double>("timeSigmaSiPM");
108  configParameters_.timeSigmaHPD = ps.getParameter<double>("timeSigmaHPD");
109  configParameters_.ts4Thresh = ps.getParameter<double>("ts4Thresh");
110 
111  configParameters_.applyTimeSlew = ps.getParameter<bool>("applyTimeSlew");
112  auto const tzeroValues = ps.getParameter<std::vector<double>>("tzeroTimeSlewParameters");
113  auto const slopeValues = ps.getParameter<std::vector<double>>("slopeTimeSlewParameters");
114  auto const tmaxValues = ps.getParameter<std::vector<double>>("tmaxTimeSlewParameters");
115 
116  configParameters_.tzeroTimeSlew = tzeroValues[HcalTimeSlew::Medium];
117  configParameters_.slopeTimeSlew = slopeValues[HcalTimeSlew::Medium];
118  configParameters_.tmaxTimeSlew = tmaxValues[HcalTimeSlew::Medium];
119 
120  auto threadsMinimize = ps.getParameter<std::vector<uint32_t>>("kernelMinimizeThreads");
121  configParameters_.kernelMinimizeThreads[0] = threadsMinimize[0];
122  configParameters_.kernelMinimizeThreads[1] = threadsMinimize[1];
123  configParameters_.kernelMinimizeThreads[2] = threadsMinimize[2];
124 }
125 
127 
130  desc.add<uint32_t>("maxTimeSamples", 10);
131  desc.add<uint32_t>("kprep1dChannelsPerBlock", 32);
132  desc.add<edm::InputTag>("digisLabelF01HE", edm::InputTag{"hcalRawToDigiGPU", "f01HEDigisGPU"});
133  desc.add<edm::InputTag>("digisLabelF5HB", edm::InputTag{"hcalRawToDigiGPU", "f5HBDigisGPU"});
134  desc.add<edm::InputTag>("digisLabelF3HB", edm::InputTag{"hcalRawToDigiGPU", "f3HBDigisGPU"});
135  desc.add<std::string>("recHitsLabelM0HBHE", "recHitsM0HBHE");
136  desc.add<int>("sipmQTSShift", 0);
137  desc.add<int>("sipmQNTStoSum", 3);
138  desc.add<int>("firstSampleShift", 0);
139  desc.add<bool>("useEffectivePedestals", true);
140 
141  desc.add<double>("meanTime", 0.f);
142  desc.add<double>("timeSigmaSiPM", 2.5f);
143  desc.add<double>("timeSigmaHPD", 5.0f);
144  desc.add<double>("ts4Thresh", 0.0);
145 
146  desc.add<bool>("applyTimeSlew", true);
147  desc.add<std::vector<double>>("tzeroTimeSlewParameters", {23.960177, 11.977461, 9.109694});
148  desc.add<std::vector<double>>("slopeTimeSlewParameters", {-3.178648, -1.5610227, -1.075824});
149  desc.add<std::vector<double>>("tmaxTimeSlewParameters", {16.00, 10.00, 6.25});
150  desc.add<std::vector<uint32_t>>("kernelMinimizeThreads", {16, 1, 1});
151 
152  cdesc.addWithDefaultLabel(desc);
153 }
154 
156  edm::EventSetup const& setup,
158 #ifdef HCAL_MAHI_CPUDEBUG
160 #endif
161 
162  // input + raii
163  auto const& f01HEProduct = event.get(digisTokenF01HE_);
164  auto const& f5HBProduct = event.get(digisTokenF5HB_);
165  auto const& f3HBProduct = event.get(digisTokenF3HB_);
166  cms::cuda::ScopedContextAcquire ctx{f01HEProduct, std::move(holder), cudaState_};
167  auto const& f01HEDigis = ctx.get(f01HEProduct);
168  auto const& f5HBDigis = ctx.get(f5HBProduct);
169  auto const& f3HBDigis = ctx.get(f3HBProduct);
170  auto const totalChannels = f01HEDigis.size + f5HBDigis.size + f3HBDigis.size;
171 
172  hcal::reconstruction::InputDataGPU inputGPU{f01HEDigis, f5HBDigis, f3HBDigis};
173 
174  // conditions
175  auto const& recoParamsProduct = setup.getData(recoParamsToken_).getProduct(ctx.stream());
176 
177  auto const& gainWidthsProduct = setup.getData(gainWidthsToken_).getProduct(ctx.stream());
178 
179  auto const& gainsProduct = setup.getData(gainsToken_).getProduct(ctx.stream());
180 
181  auto const& lutCorrsProduct = setup.getData(lutCorrsToken_).getProduct(ctx.stream());
182 
183  // use only 1 depending on useEffectivePedestals
184  auto const& pedestalWidthsProduct = setup.getData(pedestalWidthsToken_).getProduct(ctx.stream());
185  auto const& effectivePedestalWidthsProduct = setup.getData(effectivePedestalWidthsToken_).getProduct(ctx.stream());
186 
187  auto const& pedestals = setup.getData(pedestalsToken_);
188  auto const& pedestalsProduct = pedestals.getProduct(ctx.stream());
189 
190  edm::ESHandle<HcalConvertedEffectivePedestalsGPU> effectivePedestalsHandle;
192  effectivePedestalsHandle = setup.getHandle(effectivePedestalsToken_);
193  auto const* effectivePedestalsProduct =
194  configParameters_.useEffectivePedestals ? &effectivePedestalsHandle->getProduct(ctx.stream()) : nullptr;
195 
196  auto const& qieCodersProduct = setup.getData(qieCodersToken_).getProduct(ctx.stream());
197 
198  auto const& respCorrsProduct = setup.getData(respCorrsToken_).getProduct(ctx.stream());
199 
200  auto const& timeCorrsProduct = setup.getData(timeCorrsToken_).getProduct(ctx.stream());
201 
202  auto const& qieTypesProduct = setup.getData(qieTypesToken_).getProduct(ctx.stream());
203 
204  HcalTopology const& topology = setup.getData(topologyToken_);
205  HcalDDDRecConstants const& recConstants = setup.getData(recConstantsToken_);
206 
207  auto const& sipmParametersProduct = setup.getData(sipmParametersToken_).getProduct(ctx.stream());
208 
209  auto const& sipmCharacteristicsProduct = setup.getData(sipmCharacteristicsToken_).getProduct(ctx.stream());
210 
211  auto const& chQualProduct = setup.getData(chQualProductToken_).getProduct(ctx.stream());
212 
213  auto const& pulseOffsets = setup.getData(pulseOffsetsToken_);
214  auto const& pulseOffsetsProduct = pulseOffsets.getProduct(ctx.stream());
215 
216  // bundle up conditions
218  gainsProduct,
219  lutCorrsProduct,
220  pedestalWidthsProduct,
221  effectivePedestalWidthsProduct,
222  pedestalsProduct,
223  qieCodersProduct,
224  chQualProduct,
225  recoParamsProduct,
226  respCorrsProduct,
227  timeCorrsProduct,
228  qieTypesProduct,
229  sipmParametersProduct,
230  sipmCharacteristicsProduct,
231  effectivePedestalsProduct,
232  &topology,
233  &recConstants,
234  pedestals.offsetForHashes(),
235  pulseOffsetsProduct,
236  pulseOffsets.getValues()};
237 
238  // scratch mem on device
240  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
241  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
242  cms::cuda::make_device_unique<float[]>(totalChannels * configParameters_.maxTimeSamples, ctx.stream()),
244  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
246  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
248  totalChannels * configParameters_.maxTimeSamples * configParameters_.maxTimeSamples, ctx.stream()),
249  cms::cuda::make_device_unique<int8_t[]>(totalChannels, ctx.stream()),
250  };
251 
252  // output dev mem
253  outputGPU_.allocate(configParameters_, totalChannels, ctx.stream());
254 
255  hcal::reconstruction::entryPoint(inputGPU, outputGPU_, conditions, scratchGPU, configParameters_, ctx.stream());
256 
257 #ifdef HCAL_MAHI_CPUDEBUG
259  auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
260  std::cout << "acquire duration = " << duration << std::endl;
261 #endif
262 }
263 
267 }
268 
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_