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.addUntracked<std::vector<uint32_t>>("kernelMinimizeThreads", {32, 1, 1});
92  desc.add<bool>("shouldRunTimingComputation", true);
93  confDesc.addWithDefaultLabel(desc);
94 }
95 
97  : digisTokenEB_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("digisLabelEB"))},
98  digisTokenEE_{consumes<InputProduct>(ps.getParameter<edm::InputTag>("digisLabelEE"))},
99  recHitsTokenEB_{produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"))},
100  recHitsTokenEE_{produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEE"))},
101  pedestalsToken_{esConsumes<EcalPedestalsGPU, EcalPedestalsRcd>()},
102  gainRatiosToken_{esConsumes<EcalGainRatiosGPU, EcalGainRatiosRcd>()},
103  pulseShapesToken_{esConsumes<EcalPulseShapesGPU, EcalPulseShapesRcd>()},
104  pulseCovariancesToken_{esConsumes<EcalPulseCovariancesGPU, EcalPulseCovariancesRcd>()},
105  samplesCorrelationToken_{esConsumes<EcalSamplesCorrelationGPU, EcalSamplesCorrelationRcd>()},
106  timeBiasCorrectionsToken_{esConsumes<EcalTimeBiasCorrectionsGPU, EcalTimeBiasCorrectionsRcd>()},
107  timeCalibConstantsToken_{esConsumes<EcalTimeCalibConstantsGPU, EcalTimeCalibConstantsRcd>()},
108  sampleMaskToken_{esConsumes<EcalSampleMask, EcalSampleMaskRcd>()},
109  timeOffsetConstantToken_{esConsumes<EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd>()},
110  multifitParametersToken_{esConsumes<EcalMultifitParametersGPU, JobConfigurationGPURecord>()} {
111  std::pair<double, double> EBtimeFitLimits, EEtimeFitLimits;
112  EBtimeFitLimits.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
113  EBtimeFitLimits.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
114  EEtimeFitLimits.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
115  EEtimeFitLimits.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
116 
117  auto EBtimeConstantTerm = ps.getParameter<double>("EBtimeConstantTerm");
118  auto EEtimeConstantTerm = ps.getParameter<double>("EEtimeConstantTerm");
119  auto EBtimeNconst = ps.getParameter<double>("EBtimeNconst");
120  auto EEtimeNconst = ps.getParameter<double>("EEtimeNconst");
121 
122  auto outOfTimeThreshG12pEB = ps.getParameter<double>("outOfTimeThresholdGain12pEB");
123  auto outOfTimeThreshG12mEB = ps.getParameter<double>("outOfTimeThresholdGain12mEB");
124  auto outOfTimeThreshG61pEB = ps.getParameter<double>("outOfTimeThresholdGain61pEB");
125  auto outOfTimeThreshG61mEB = ps.getParameter<double>("outOfTimeThresholdGain61mEB");
126  auto outOfTimeThreshG12pEE = ps.getParameter<double>("outOfTimeThresholdGain12pEE");
127  auto outOfTimeThreshG12mEE = ps.getParameter<double>("outOfTimeThresholdGain12mEE");
128  auto outOfTimeThreshG61pEE = ps.getParameter<double>("outOfTimeThresholdGain61pEE");
129  auto outOfTimeThreshG61mEE = ps.getParameter<double>("outOfTimeThresholdGain61mEE");
130  auto amplitudeThreshEB = ps.getParameter<double>("amplitudeThresholdEB");
131  auto amplitudeThreshEE = ps.getParameter<double>("amplitudeThresholdEE");
132 
133  // switch to run timing computation kernels
134  configParameters_.shouldRunTimingComputation = ps.getParameter<bool>("shouldRunTimingComputation");
135 
136  // minimize kernel launch conf
137  auto threadsMinimize = ps.getUntrackedParameter<std::vector<uint32_t>>("kernelMinimizeThreads");
138  configParameters_.kernelMinimizeThreads[0] = threadsMinimize[0];
139  configParameters_.kernelMinimizeThreads[1] = threadsMinimize[1];
140  configParameters_.kernelMinimizeThreads[2] = threadsMinimize[2];
141 
142  //
143  // configuration and physics parameters: done once
144  // assume there is a single device
145  // use sync copying
146  //
147 
148  // time fit parameters and limits
149  configParameters_.timeFitLimitsFirstEB = EBtimeFitLimits.first;
150  configParameters_.timeFitLimitsSecondEB = EBtimeFitLimits.second;
151  configParameters_.timeFitLimitsFirstEE = EEtimeFitLimits.first;
152  configParameters_.timeFitLimitsSecondEE = EEtimeFitLimits.second;
153 
154  // time constant terms
155  configParameters_.timeConstantTermEB = EBtimeConstantTerm;
156  configParameters_.timeConstantTermEE = EEtimeConstantTerm;
157 
158  // time N const
159  configParameters_.timeNconstEB = EBtimeNconst;
160  configParameters_.timeNconstEE = EEtimeNconst;
161 
162  // amplitude threshold for time flags
163  configParameters_.amplitudeThreshEB = amplitudeThreshEB;
164  configParameters_.amplitudeThreshEE = amplitudeThreshEE;
165 
166  // out of time thresholds gain-dependent
167  configParameters_.outOfTimeThreshG12pEB = outOfTimeThreshG12pEB;
168  configParameters_.outOfTimeThreshG12pEE = outOfTimeThreshG12pEE;
169  configParameters_.outOfTimeThreshG61pEB = outOfTimeThreshG61pEB;
170  configParameters_.outOfTimeThreshG61pEE = outOfTimeThreshG61pEE;
171  configParameters_.outOfTimeThreshG12mEB = outOfTimeThreshG12mEB;
172  configParameters_.outOfTimeThreshG12mEE = outOfTimeThreshG12mEE;
173  configParameters_.outOfTimeThreshG61mEB = outOfTimeThreshG61mEB;
174  configParameters_.outOfTimeThreshG61mEE = outOfTimeThreshG61mEE;
175 }
176 
178 
180  //DurationMeasurer<std::chrono::milliseconds> timer{std::string{"produce duration"}};
181 
182  // cuda products
183  auto const& ebDigisProduct = event.get(digisTokenEB_);
184  auto const& eeDigisProduct = event.get(digisTokenEE_);
185  // event data
186  ecal::multifit::EventOutputDataGPU eventOutputDataGPU;
187 
188  // raii
189  cms::cuda::ScopedContextProduce ctx{ebDigisProduct};
190 
191  // get actual obj
192  auto const& ebDigis = ctx.get(ebDigisProduct);
193  auto const& eeDigis = ctx.get(eeDigisProduct);
194  ecal::multifit::EventInputDataGPU inputDataGPU{ebDigis, eeDigis};
195  const uint32_t neb = ebDigis.size;
196  const uint32_t nee = eeDigis.size;
197 
198  // stop here if there are no digis
199  if (neb + nee > 0) {
200  // conditions
201  auto const& timeCalibConstantsData = setup.getData(timeCalibConstantsToken_);
202  auto const& sampleMaskData = setup.getData(sampleMaskToken_);
203  auto const& timeOffsetConstantData = setup.getData(timeOffsetConstantToken_);
204  auto const& multifitParametersData = setup.getData(multifitParametersToken_);
205 
206  auto const& pedestals = setup.getData(pedestalsToken_).getProduct(ctx.stream());
207  auto const& gainRatios = setup.getData(gainRatiosToken_).getProduct(ctx.stream());
208  auto const& pulseShapes = setup.getData(pulseShapesToken_).getProduct(ctx.stream());
209  auto const& pulseCovariances = setup.getData(pulseCovariancesToken_).getProduct(ctx.stream());
210  auto const& samplesCorrelation = setup.getData(samplesCorrelationToken_).getProduct(ctx.stream());
211  auto const& timeBiasCorrections = setup.getData(timeBiasCorrectionsToken_).getProduct(ctx.stream());
212  auto const& timeCalibConstants = timeCalibConstantsData.getProduct(ctx.stream());
213  auto const& multifitParameters = multifitParametersData.getProduct(ctx.stream());
214 
215  // assign ptrs/values: this is done not to change how things look downstream
216  configParameters_.amplitudeFitParametersEB = multifitParameters.amplitudeFitParametersEB.get();
217  configParameters_.amplitudeFitParametersEE = multifitParameters.amplitudeFitParametersEE.get();
218  configParameters_.timeFitParametersEB = multifitParameters.timeFitParametersEB.get();
219  configParameters_.timeFitParametersEE = multifitParameters.timeFitParametersEE.get();
220  configParameters_.timeFitParametersSizeEB = multifitParametersData.getValues()[2].get().size();
221  configParameters_.timeFitParametersSizeEE = multifitParametersData.getValues()[3].get().size();
222 
223  // bundle up conditions
225  gainRatios,
226  pulseShapes,
227  pulseCovariances,
228  samplesCorrelation,
229  timeBiasCorrections,
230  timeCalibConstants,
231  sampleMaskData,
232  timeOffsetConstantData,
233  timeCalibConstantsData.getOffset(),
234  multifitParameters};
235 
236  // dev mem
237  eventOutputDataGPU.allocate(configParameters_, neb, nee, ctx.stream());
238 
239  // scratch mem
240  ecal::multifit::EventDataForScratchGPU eventDataForScratchGPU;
241  eventDataForScratchGPU.allocate(configParameters_, neb, nee, ctx.stream());
242 
243  //
244  // schedule algorithms
245  //
247  inputDataGPU, eventOutputDataGPU, eventDataForScratchGPU, conditions, configParameters_, ctx.stream());
248  }
249 
250  // set the size of eb and ee
251  eventOutputDataGPU.recHitsEB.size = neb;
252  eventOutputDataGPU.recHitsEE.size = nee;
253 
254  // put into the event
255  ctx.emplace(event, recHitsTokenEB_, std::move(eventOutputDataGPU.recHitsEB));
256  ctx.emplace(event, recHitsTokenEE_, std::move(eventOutputDataGPU.recHitsEE));
257 }
258 
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_
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_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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_