CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalUncalibRecHitProducerGPU.cc
Go to the documentation of this file.
29 
30 #include "DeclsForKernels.h"
32 
33 class EcalUncalibRecHitProducerGPU : public edm::stream::EDProducer<edm::ExternalWork> {
34 public:
38 
39 private:
41  void produce(edm::Event&, edm::EventSetup const&) override;
42 
43 private:
48 
49  // conditions tokens
60 
61  // configuration parameters
63 
64  // event data
66 
68 
69  uint32_t neb_, nee_;
70 };
71 
74 
75  desc.add<edm::InputTag>("digisLabelEB", edm::InputTag("ecalRawToDigiGPU", "ebDigis"));
76  desc.add<edm::InputTag>("digisLabelEE", edm::InputTag("ecalRawToDigiGPU", "eeDigis"));
77 
78  desc.add<std::string>("recHitsLabelEB", "EcalUncalibRecHitsEB");
79  desc.add<std::string>("recHitsLabelEE", "EcalUncalibRecHitsEE");
80 
81  desc.add<double>("EBtimeFitLimits_Lower", 0.2);
82  desc.add<double>("EBtimeFitLimits_Upper", 1.4);
83  desc.add<double>("EEtimeFitLimits_Lower", 0.2);
84  desc.add<double>("EEtimeFitLimits_Upper", 1.4);
85  desc.add<double>("EBtimeConstantTerm", .6);
86  desc.add<double>("EEtimeConstantTerm", 1.0);
87  desc.add<double>("EBtimeNconst", 28.5);
88  desc.add<double>("EEtimeNconst", 31.8);
89  desc.add<double>("outOfTimeThresholdGain12pEB", 5);
90  desc.add<double>("outOfTimeThresholdGain12mEB", 5);
91  desc.add<double>("outOfTimeThresholdGain61pEB", 5);
92  desc.add<double>("outOfTimeThresholdGain61mEB", 5);
93  desc.add<double>("outOfTimeThresholdGain12pEE", 1000);
94  desc.add<double>("outOfTimeThresholdGain12mEE", 1000);
95  desc.add<double>("outOfTimeThresholdGain61pEE", 1000);
96  desc.add<double>("outOfTimeThresholdGain61mEE", 1000);
97  desc.add<double>("amplitudeThresholdEB", 10);
98  desc.add<double>("amplitudeThresholdEE", 10);
99  desc.add<uint32_t>("maxNumberHitsEB", 61200);
100  desc.add<uint32_t>("maxNumberHitsEE", 14648);
101  desc.addUntracked<std::vector<uint32_t>>("kernelMinimizeThreads", {32, 1, 1});
102  desc.add<bool>("shouldRunTimingComputation", true);
103  confDesc.addWithDefaultLabel(desc);
104 }
105 
107  : digisTokenEB_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("digisLabelEB"))},
108  digisTokenEE_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("digisLabelEE"))},
109  recHitsTokenEB_{produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"))},
110  recHitsTokenEE_{produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEE"))},
111  pedestalsToken_{esConsumes<EcalPedestalsGPU, EcalPedestalsRcd>()},
112  gainRatiosToken_{esConsumes<EcalGainRatiosGPU, EcalGainRatiosRcd>()},
113  pulseShapesToken_{esConsumes<EcalPulseShapesGPU, EcalPulseShapesRcd>()},
114  pulseCovariancesToken_{esConsumes<EcalPulseCovariancesGPU, EcalPulseCovariancesRcd>()},
115  samplesCorrelationToken_{esConsumes<EcalSamplesCorrelationGPU, EcalSamplesCorrelationRcd>()},
116  timeBiasCorrectionsToken_{esConsumes<EcalTimeBiasCorrectionsGPU, EcalTimeBiasCorrectionsRcd>()},
117  timeCalibConstantsToken_{esConsumes<EcalTimeCalibConstantsGPU, EcalTimeCalibConstantsRcd>()},
118  sampleMaskToken_{esConsumes<EcalSampleMask, EcalSampleMaskRcd>()},
119  timeOffsetConstantToken_{esConsumes<EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd>()},
120  multifitParametersToken_{esConsumes<EcalMultifitParametersGPU, JobConfigurationGPURecord>()} {
121  std::pair<double, double> EBtimeFitLimits, EEtimeFitLimits;
122  EBtimeFitLimits.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
123  EBtimeFitLimits.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
124  EEtimeFitLimits.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
125  EEtimeFitLimits.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
126 
127  auto EBtimeConstantTerm = ps.getParameter<double>("EBtimeConstantTerm");
128  auto EEtimeConstantTerm = ps.getParameter<double>("EEtimeConstantTerm");
129  auto EBtimeNconst = ps.getParameter<double>("EBtimeNconst");
130  auto EEtimeNconst = ps.getParameter<double>("EEtimeNconst");
131 
132  auto outOfTimeThreshG12pEB = ps.getParameter<double>("outOfTimeThresholdGain12pEB");
133  auto outOfTimeThreshG12mEB = ps.getParameter<double>("outOfTimeThresholdGain12mEB");
134  auto outOfTimeThreshG61pEB = ps.getParameter<double>("outOfTimeThresholdGain61pEB");
135  auto outOfTimeThreshG61mEB = ps.getParameter<double>("outOfTimeThresholdGain61mEB");
136  auto outOfTimeThreshG12pEE = ps.getParameter<double>("outOfTimeThresholdGain12pEE");
137  auto outOfTimeThreshG12mEE = ps.getParameter<double>("outOfTimeThresholdGain12mEE");
138  auto outOfTimeThreshG61pEE = ps.getParameter<double>("outOfTimeThresholdGain61pEE");
139  auto outOfTimeThreshG61mEE = ps.getParameter<double>("outOfTimeThresholdGain61mEE");
140  auto amplitudeThreshEB = ps.getParameter<double>("amplitudeThresholdEB");
141  auto amplitudeThreshEE = ps.getParameter<double>("amplitudeThresholdEE");
142 
143  // max number of digis to allocate for
144  configParameters_.maxNumberHitsEB = ps.getParameter<uint32_t>("maxNumberHitsEB");
145  configParameters_.maxNumberHitsEE = ps.getParameter<uint32_t>("maxNumberHitsEE");
146 
147  // switch to run timing computation kernels
148  configParameters_.shouldRunTimingComputation = ps.getParameter<bool>("shouldRunTimingComputation");
149 
150  // minimize kernel launch conf
151  auto threadsMinimize = ps.getUntrackedParameter<std::vector<uint32_t>>("kernelMinimizeThreads");
152  configParameters_.kernelMinimizeThreads[0] = threadsMinimize[0];
153  configParameters_.kernelMinimizeThreads[1] = threadsMinimize[1];
154  configParameters_.kernelMinimizeThreads[2] = threadsMinimize[2];
155 
156  //
157  // configuration and physics parameters: done once
158  // assume there is a single device
159  // use sync copying
160  //
161 
162  // time fit parameters and limits
163  configParameters_.timeFitLimitsFirstEB = EBtimeFitLimits.first;
164  configParameters_.timeFitLimitsSecondEB = EBtimeFitLimits.second;
165  configParameters_.timeFitLimitsFirstEE = EEtimeFitLimits.first;
166  configParameters_.timeFitLimitsSecondEE = EEtimeFitLimits.second;
167 
168  // time constant terms
169  configParameters_.timeConstantTermEB = EBtimeConstantTerm;
170  configParameters_.timeConstantTermEE = EEtimeConstantTerm;
171 
172  // time N const
173  configParameters_.timeNconstEB = EBtimeNconst;
174  configParameters_.timeNconstEE = EEtimeNconst;
175 
176  // amplitude threshold for time flags
177  configParameters_.amplitudeThreshEB = amplitudeThreshEB;
178  configParameters_.amplitudeThreshEE = amplitudeThreshEE;
179 
180  // out of time thresholds gain-dependent
181  configParameters_.outOfTimeThreshG12pEB = outOfTimeThreshG12pEB;
182  configParameters_.outOfTimeThreshG12pEE = outOfTimeThreshG12pEE;
183  configParameters_.outOfTimeThreshG61pEB = outOfTimeThreshG61pEB;
184  configParameters_.outOfTimeThreshG61pEE = outOfTimeThreshG61pEE;
185  configParameters_.outOfTimeThreshG12mEB = outOfTimeThreshG12mEB;
186  configParameters_.outOfTimeThreshG12mEE = outOfTimeThreshG12mEE;
187  configParameters_.outOfTimeThreshG61mEB = outOfTimeThreshG61mEB;
188  configParameters_.outOfTimeThreshG61mEE = outOfTimeThreshG61mEE;
189 }
190 
192 
194  edm::EventSetup const& setup,
196  // cuda products
197  auto const& ebDigisProduct = event.get(digisTokenEB_);
198  auto const& eeDigisProduct = event.get(digisTokenEE_);
199 
200  // raii
201  cms::cuda::ScopedContextAcquire ctx{ebDigisProduct, std::move(holder), cudaState_};
202 
203  // get actual obj
204  auto const& ebDigis = ctx.get(ebDigisProduct);
205  auto const& eeDigis = ctx.get(eeDigisProduct);
206  ecal::multifit::EventInputDataGPU inputDataGPU{ebDigis, eeDigis};
207  neb_ = ebDigis.size;
208  nee_ = eeDigis.size;
209 
210  // stop here if there are no digis
211  if (neb_ + nee_ == 0)
212  return;
213 
215  edm::LogError("EcalUncalibRecHitProducerGPU")
216  << "Max number of channels exceeded in barrel or endcap. Number of barrel channels: " << neb_
217  << " with maxNumberHitsEB=" << configParameters_.maxNumberHitsEB << ", number of endcap channels: " << nee_
218  << " with maxNumberHitsEE=" << configParameters_.maxNumberHitsEE;
219  }
220 
221  // conditions
222  auto const& timeCalibConstantsData = setup.getData(timeCalibConstantsToken_);
223  auto const& sampleMaskData = setup.getData(sampleMaskToken_);
224  auto const& timeOffsetConstantData = setup.getData(timeOffsetConstantToken_);
225  auto const& multifitParametersData = setup.getData(multifitParametersToken_);
226 
227  auto const& pedestals = setup.getData(pedestalsToken_).getProduct(ctx.stream());
228  auto const& gainRatios = setup.getData(gainRatiosToken_).getProduct(ctx.stream());
229  auto const& pulseShapes = setup.getData(pulseShapesToken_).getProduct(ctx.stream());
230  auto const& pulseCovariances = setup.getData(pulseCovariancesToken_).getProduct(ctx.stream());
231  auto const& samplesCorrelation = setup.getData(samplesCorrelationToken_).getProduct(ctx.stream());
232  auto const& timeBiasCorrections = setup.getData(timeBiasCorrectionsToken_).getProduct(ctx.stream());
233  auto const& timeCalibConstants = timeCalibConstantsData.getProduct(ctx.stream());
234  auto const& multifitParameters = multifitParametersData.getProduct(ctx.stream());
235 
236  // assign ptrs/values: this is done not to change how things look downstream
237  configParameters_.amplitudeFitParametersEB = multifitParameters.amplitudeFitParametersEB.get();
238  configParameters_.amplitudeFitParametersEE = multifitParameters.amplitudeFitParametersEE.get();
239  configParameters_.timeFitParametersEB = multifitParameters.timeFitParametersEB.get();
240  configParameters_.timeFitParametersEE = multifitParameters.timeFitParametersEE.get();
241  configParameters_.timeFitParametersSizeEB = multifitParametersData.getValues()[2].get().size();
242  configParameters_.timeFitParametersSizeEE = multifitParametersData.getValues()[3].get().size();
243 
244  // bundle up conditions
246  gainRatios,
247  pulseShapes,
248  pulseCovariances,
249  samplesCorrelation,
250  timeBiasCorrections,
251  timeCalibConstants,
252  sampleMaskData,
253  timeOffsetConstantData,
254  timeCalibConstantsData.getOffset(),
255  multifitParameters};
256 
257  // dev mem
259 
260  // scratch mem
261  ecal::multifit::EventDataForScratchGPU eventDataForScratchGPU;
262  eventDataForScratchGPU.allocate(configParameters_, ctx.stream());
263 
264  //
265  // schedule algorithms
266  //
268  inputDataGPU, eventOutputDataGPU_, eventDataForScratchGPU, conditions, configParameters_, ctx.stream());
269 }
270 
272  //DurationMeasurer<std::chrono::milliseconds> timer{std::string{"produce duration"}};
274 
275  // set the size of eb and ee
278 
279  // put into the event
282 }
283 
const edm::ESGetToken< EcalGainRatiosGPU, EcalGainRatiosRcd > gainRatiosToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::ESGetToken< EcalPulseCovariancesGPU, EcalPulseCovariancesRcd > pulseCovariancesToken_
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
const edm::EDGetTokenT< InputProduct > digisTokenEE_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::ESGetToken< EcalPedestalsGPU, EcalPedestalsRcd > pedestalsToken_
void allocate(ConfigurationParameters const &configParameters, cudaStream_t cudaStream)
Log< level::Error, false > LogError
const edm::EDPutTokenT< OutputProduct > recHitsTokenEE_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const edm::ESGetToken< EcalPulseShapesGPU, EcalPulseShapesRcd > pulseShapesToken_
UncalibratedRecHit<::calo::common::DevStoragePolicy > recHitsEB
const edm::ESGetToken< EcalTimeBiasCorrectionsGPU, EcalTimeBiasCorrectionsRcd > timeBiasCorrectionsToken_
const edm::ESGetToken< EcalSampleMask, EcalSampleMaskRcd > sampleMaskToken_
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void entryPoint(EventInputDataGPU const &, EventOutputDataGPU &, EventDataForScratchGPU &, ConditionsProducts const &, ConfigurationParameters const &, cudaStream_t)
UncalibratedRecHit<::calo::common::DevStoragePolicy > recHitsEE
const edm::ESGetToken< EcalTimeCalibConstantsGPU, EcalTimeCalibConstantsRcd > timeCalibConstantsToken_
const edm::EDPutTokenT< OutputProduct > recHitsTokenEB_
ecal::multifit::EventOutputDataGPU eventOutputDataGPU_
void produce(edm::Event &, edm::EventSetup const &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static void fillDescriptions(edm::ConfigurationDescriptions &)
const edm::EDGetTokenT< InputProduct > digisTokenEB_
void allocate(ConfigurationParameters const &configParameters, cudaStream_t cudaStream)
EcalUncalibRecHitProducerGPU(edm::ParameterSet const &ps)
const edm::ESGetToken< EcalSamplesCorrelationGPU, EcalSamplesCorrelationRcd > samplesCorrelationToken_
const edm::ESGetToken< EcalMultifitParametersGPU, JobConfigurationGPURecord > multifitParametersToken_
const edm::ESGetToken< EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd > timeOffsetConstantToken_
ecal::multifit::ConfigurationParameters configParameters_