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_.maxChannels = ps.getParameter<uint32_t>("maxChannels");
84  configParameters_.maxTimeSamples = ps.getParameter<uint32_t>("maxTimeSamples");
85  configParameters_.kprep1dChannelsPerBlock = ps.getParameter<uint32_t>("kprep1dChannelsPerBlock");
86  configParameters_.sipmQTSShift = ps.getParameter<int>("sipmQTSShift");
87  configParameters_.sipmQNTStoSum = ps.getParameter<int>("sipmQNTStoSum");
88  configParameters_.firstSampleShift = ps.getParameter<int>("firstSampleShift");
89  configParameters_.useEffectivePedestals = ps.getParameter<bool>("useEffectivePedestals");
90  if (configParameters_.useEffectivePedestals) {
91  effectivePedestalsToken_ = esConsumes();
92  }
93 
94  configParameters_.meanTime = ps.getParameter<double>("meanTime");
95  configParameters_.timeSigmaSiPM = ps.getParameter<double>("timeSigmaSiPM");
96  configParameters_.timeSigmaHPD = ps.getParameter<double>("timeSigmaHPD");
97  configParameters_.ts4Thresh = ps.getParameter<double>("ts4Thresh");
98 
99  configParameters_.applyTimeSlew = ps.getParameter<bool>("applyTimeSlew");
100  auto const tzeroValues = ps.getParameter<std::vector<double>>("tzeroTimeSlewParameters");
101  auto const slopeValues = ps.getParameter<std::vector<double>>("slopeTimeSlewParameters");
102  auto const tmaxValues = ps.getParameter<std::vector<double>>("tmaxTimeSlewParameters");
103 
104  configParameters_.tzeroTimeSlew = tzeroValues[HcalTimeSlew::Medium];
105  configParameters_.slopeTimeSlew = slopeValues[HcalTimeSlew::Medium];
106  configParameters_.tmaxTimeSlew = tmaxValues[HcalTimeSlew::Medium];
107 
108  auto threadsMinimize = ps.getParameter<std::vector<uint32_t>>("kernelMinimizeThreads");
109  configParameters_.kernelMinimizeThreads[0] = threadsMinimize[0];
110  configParameters_.kernelMinimizeThreads[1] = threadsMinimize[1];
111  configParameters_.kernelMinimizeThreads[2] = threadsMinimize[2];
112 }
113 
115 
118  desc.add<uint32_t>("maxChannels", 10000u);
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 
160  hcal::reconstruction::InputDataGPU inputGPU{f01HEDigis, f5HBDigis, f3HBDigis};
161 
162  // conditions
163  auto const& recoParamsProduct = setup.getData(recoParamsToken_).getProduct(ctx.stream());
164 
165  auto const& gainWidthsProduct = setup.getData(gainWidthsToken_).getProduct(ctx.stream());
166 
167  auto const& gainsProduct = setup.getData(gainsToken_).getProduct(ctx.stream());
168 
169  auto const& lutCorrsProduct = setup.getData(lutCorrsToken_).getProduct(ctx.stream());
170 
171  // use only 1 depending on useEffectivePedestals
172  auto const& pedestalWidthsProduct = setup.getData(pedestalWidthsToken_).getProduct(ctx.stream());
173  auto const& effectivePedestalWidthsProduct = setup.getData(effectivePedestalWidthsToken_).getProduct(ctx.stream());
174 
175  auto const& pedestals = setup.getData(pedestalsToken_);
176  auto const& pedestalsProduct = pedestals.getProduct(ctx.stream());
177 
178  edm::ESHandle<HcalConvertedEffectivePedestalsGPU> effectivePedestalsHandle;
180  effectivePedestalsHandle = setup.getHandle(effectivePedestalsToken_);
181  auto const* effectivePedestalsProduct =
182  configParameters_.useEffectivePedestals ? &effectivePedestalsHandle->getProduct(ctx.stream()) : nullptr;
183 
184  auto const& qieCodersProduct = setup.getData(qieCodersToken_).getProduct(ctx.stream());
185 
186  auto const& respCorrsProduct = setup.getData(respCorrsToken_).getProduct(ctx.stream());
187 
188  auto const& timeCorrsProduct = setup.getData(timeCorrsToken_).getProduct(ctx.stream());
189 
190  auto const& qieTypesProduct = setup.getData(qieTypesToken_).getProduct(ctx.stream());
191 
192  HcalTopology const& topology = setup.getData(topologyToken_);
193  HcalDDDRecConstants const& recConstants = setup.getData(recConstantsToken_);
194 
195  auto const& sipmParametersProduct = setup.getData(sipmParametersToken_).getProduct(ctx.stream());
196 
197  auto const& sipmCharacteristicsProduct = setup.getData(sipmCharacteristicsToken_).getProduct(ctx.stream());
198 
199  auto const& chQualProduct = setup.getData(chQualProductToken_).getProduct(ctx.stream());
200 
201  auto const& pulseOffsets = setup.getData(pulseOffsetsToken_);
202  auto const& pulseOffsetsProduct = pulseOffsets.getProduct(ctx.stream());
203 
204  // bundle up conditions
206  gainsProduct,
207  lutCorrsProduct,
208  pedestalWidthsProduct,
209  effectivePedestalWidthsProduct,
210  pedestalsProduct,
211  qieCodersProduct,
212  chQualProduct,
213  recoParamsProduct,
214  respCorrsProduct,
215  timeCorrsProduct,
216  qieTypesProduct,
217  sipmParametersProduct,
218  sipmCharacteristicsProduct,
219  effectivePedestalsProduct,
220  &topology,
221  &recConstants,
222  pedestals.offsetForHashes(),
223  pulseOffsetsProduct,
224  pulseOffsets.getValues()};
225 
226  // scratch mem on device
228  cms::cuda::make_device_unique<float[]>(configParameters_.maxChannels * configParameters_.maxTimeSamples,
229  ctx.stream()),
231  ctx.stream()),
233  ctx.stream()),
236  ctx.stream()),
239  ctx.stream()),
242  ctx.stream()),
244  };
245 
246  // output dev mem
247  outputGPU_.allocate(configParameters_, ctx.stream());
248 
249  hcal::reconstruction::entryPoint(inputGPU, outputGPU_, conditions, scratchGPU, configParameters_, ctx.stream());
250 
251 #ifdef HCAL_MAHI_CPUDEBUG
253  auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
254  std::cout << "acquire duration = " << duration << std::endl;
255 #endif
256 }
257 
261 }
262 
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_
void allocate(ConfigParameters const &config, cudaStream_t cudaStream)
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_
const edm::ESGetToken< HcalRespCorrsGPU, HcalRespCorrsRcd > respCorrsToken_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
edm::EDPutTokenT< OProductType > rechitsM0Token_