CMS 3D CMS Logo

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