CMS 3D CMS Logo

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