CMS 3D CMS Logo

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 
211  edm::LogError("EcalUncalibRecHitProducerGPU")
212  << "max number of channels exceeded. See options 'maxNumberHitsEB and maxNumberHitsEE' ";
213  }
214 
215  // conditions
216  auto const& timeCalibConstantsData = setup.getData(timeCalibConstantsToken_);
217  auto const& sampleMaskData = setup.getData(sampleMaskToken_);
218  auto const& timeOffsetConstantData = setup.getData(timeOffsetConstantToken_);
219  auto const& multifitParametersData = setup.getData(multifitParametersToken_);
220 
221  auto const& pedestals = setup.getData(pedestalsToken_).getProduct(ctx.stream());
222  auto const& gainRatios = setup.getData(gainRatiosToken_).getProduct(ctx.stream());
223  auto const& pulseShapes = setup.getData(pulseShapesToken_).getProduct(ctx.stream());
224  auto const& pulseCovariances = setup.getData(pulseCovariancesToken_).getProduct(ctx.stream());
225  auto const& samplesCorrelation = setup.getData(samplesCorrelationToken_).getProduct(ctx.stream());
226  auto const& timeBiasCorrections = setup.getData(timeBiasCorrectionsToken_).getProduct(ctx.stream());
227  auto const& timeCalibConstants = timeCalibConstantsData.getProduct(ctx.stream());
228  auto const& multifitParameters = multifitParametersData.getProduct(ctx.stream());
229 
230  // assign ptrs/values: this is done not to change how things look downstream
231  configParameters_.amplitudeFitParametersEB = multifitParameters.amplitudeFitParametersEB.get();
232  configParameters_.amplitudeFitParametersEE = multifitParameters.amplitudeFitParametersEE.get();
233  configParameters_.timeFitParametersEB = multifitParameters.timeFitParametersEB.get();
234  configParameters_.timeFitParametersEE = multifitParameters.timeFitParametersEE.get();
235  configParameters_.timeFitParametersSizeEB = multifitParametersData.getValues()[2].get().size();
236  configParameters_.timeFitParametersSizeEE = multifitParametersData.getValues()[3].get().size();
237 
238  // bundle up conditions
240  gainRatios,
241  pulseShapes,
242  pulseCovariances,
243  samplesCorrelation,
244  timeBiasCorrections,
245  timeCalibConstants,
246  sampleMaskData,
247  timeOffsetConstantData,
248  timeCalibConstantsData.getOffset(),
249  multifitParameters};
250 
251  // dev mem
253 
254  // scratch mem
255  ecal::multifit::EventDataForScratchGPU eventDataForScratchGPU;
256  eventDataForScratchGPU.allocate(configParameters_, ctx.stream());
257 
258  //
259  // schedule algorithms
260  //
262  inputDataGPU, eventOutputDataGPU_, eventDataForScratchGPU, conditions, configParameters_, ctx.stream());
263 }
264 
266  //DurationMeasurer<std::chrono::milliseconds> timer{std::string{"produce duration"}};
268 
269  // set the size of eb and ee
272 
273  // put into the event
276 }
277 
EcalUncalibRecHitProducerGPU::acquire
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
Definition: EcalUncalibRecHitProducerGPU.cc:193
EcalUncalibRecHitProducerGPU
Definition: EcalUncalibRecHitProducerGPU.cc:33
EcalUncalibRecHitProducerGPU::timeOffsetConstantToken_
const edm::ESGetToken< EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd > timeOffsetConstantToken_
Definition: EcalUncalibRecHitProducerGPU.cc:58
ecal::multifit::EventInputDataGPU
Definition: DeclsForKernels.h:60
ecal::multifit::ConfigurationParameters::amplitudeFitParametersEE
const type * amplitudeFitParametersEE
Definition: DeclsForKernels.h:70
ecal::multifit::EventOutputDataGPU::allocate
void allocate(ConfigurationParameters const &configParameters, cudaStream_t cudaStream)
Definition: DeclsForKernels.h:101
EcalUncalibRecHitProducerGPU::cudaState_
cms::cuda::ContextState cudaState_
Definition: EcalUncalibRecHitProducerGPU.cc:67
EcalUncalibRecHitProducerGPU::pedestalsToken_
const edm::ESGetToken< EcalPedestalsGPU, EcalPedestalsRcd > pedestalsToken_
Definition: EcalUncalibRecHitProducerGPU.cc:50
cms::cuda::ScopedContextProduce
Definition: ScopedContext.h:149
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm::EDPutTokenT
Definition: EDPutToken.h:33
EcalUncalibRecHitProducerGPU::digisTokenEE_
const edm::EDGetTokenT< InputProduct > digisTokenEE_
Definition: EcalUncalibRecHitProducerGPU.cc:45
EcalTimeCalibConstantsGPU.h
EcalPedestalsGPU.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ecal::multifit::ConfigurationParameters::timeFitParametersEB
const type * timeFitParametersEB
Definition: DeclsForKernels.h:74
EDProducer.h
EcalTimeBiasCorrectionsGPU.h
HLT_FULL_cff.EEtimeNconst
EEtimeNconst
Definition: HLT_FULL_cff.py:8206
EcalUncalibRecHitProducerGPU::pulseShapesToken_
const edm::ESGetToken< EcalPulseShapesGPU, EcalPulseShapesRcd > pulseShapesToken_
Definition: EcalUncalibRecHitProducerGPU.cc:52
EcalUncalibRecHitProducerGPU::timeBiasCorrectionsToken_
const edm::ESGetToken< EcalTimeBiasCorrectionsGPU, EcalTimeBiasCorrectionsRcd > timeBiasCorrectionsToken_
Definition: EcalUncalibRecHitProducerGPU.cc:55
EcalSamplesCorrelationGPU.h
EcalUncalibRecHitProducerGPU::recHitsTokenEE_
const edm::EDPutTokenT< OutputProduct > recHitsTokenEE_
Definition: EcalUncalibRecHitProducerGPU.cc:47
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
EcalSamplesCorrelationRcd.h
ecal::multifit::EventDataForScratchGPU::allocate
void allocate(ConfigurationParameters const &configParameters, cudaStream_t cudaStream)
Definition: DeclsForKernels.h:168
ecal::multifit::ConfigurationParameters::amplitudeFitParametersEB
const type * amplitudeFitParametersEB
Definition: DeclsForKernels.h:70
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
MakerMacros.h
ecal::multifit::ConfigurationParameters::timeFitParametersSizeEE
uint32_t timeFitParametersSizeEE
Definition: DeclsForKernels.h:72
EcalTimeOffsetConstant.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EcalPulseCovariancesGPU.h
ecal::multifit::ConfigurationParameters::timeFitParametersSizeEB
uint32_t timeFitParametersSizeEB
Definition: DeclsForKernels.h:72
ecal::multifit::ConfigurationParameters::maxNumberHitsEB
uint32_t maxNumberHitsEB
Definition: DeclsForKernels.h:94
EcalTimeOffsetConstantRcd.h
EcalDigiCollections.h
ecal::multifit::ConfigurationParameters::timeFitParametersEE
const type * timeFitParametersEE
Definition: DeclsForKernels.h:74
EcalUncalibRecHitProducerGPU::timeCalibConstantsToken_
const edm::ESGetToken< EcalTimeCalibConstantsGPU, EcalTimeCalibConstantsRcd > timeCalibConstantsToken_
Definition: EcalUncalibRecHitProducerGPU.cc:56
EcalUncalibRecHitProducerGPU::nee_
uint32_t nee_
Definition: EcalUncalibRecHitProducerGPU.cc:69
HLT_FULL_cff.EEtimeConstantTerm
EEtimeConstantTerm
Definition: HLT_FULL_cff.py:8224
EcalPulseCovariancesRcd.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLT_FULL_cff.EBtimeNconst
EBtimeNconst
Definition: HLT_FULL_cff.py:8166
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSampleMaskRcd.h
EcalUncalibratedRecHit.h
JobConfigurationGPURecord.h
cms::cuda::ContextState
Definition: ContextState.h:15
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ecal::multifit::EventOutputDataGPU::recHitsEE
UncalibratedRecHit<::calo::common::DevStoragePolicy > recHitsEE
Definition: DeclsForKernels.h:99
EcalUncalibRecHitProducerGPU::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: EcalUncalibRecHitProducerGPU.cc:72
EcalUncalibRecHitProducerGPU::sampleMaskToken_
const edm::ESGetToken< EcalSampleMask, EcalSampleMaskRcd > sampleMaskToken_
Definition: EcalUncalibRecHitProducerGPU.cc:57
EcalUncalibRecHitProducerGPU::digisTokenEB_
const edm::EDGetTokenT< InputProduct > digisTokenEB_
Definition: EcalUncalibRecHitProducerGPU.cc:45
cudaCheck.h
edm::stream::EDProducer
Definition: EDProducer.h:38
ecal::multifit::entryPoint
void entryPoint(EventInputDataGPU const &, EventOutputDataGPU &, EventDataForScratchGPU &, ConditionsProducts const &, ConfigurationParameters const &, cudaStream_t)
edm::EventSetup
Definition: EventSetup.h:58
ecal::multifit::EventOutputDataGPU::recHitsEB
UncalibratedRecHit<::calo::common::DevStoragePolicy > recHitsEB
Definition: DeclsForKernels.h:99
EcalGainRatiosRcd.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
ecal::multifit::ConditionsProducts
Definition: DeclsForKernels.h:216
edm::ESGetToken< EcalPedestalsGPU, EcalPedestalsRcd >
ecal::multifit::EventOutputDataGPU
Definition: DeclsForKernels.h:98
EcalMultifitParametersGPU.h
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
DeclsForKernels.h
EcalUncalibRecHitProducerGPU::neb_
uint32_t neb_
Definition: EcalUncalibRecHitProducerGPU.cc:69
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
EcalUncalibRecHitProducerGPU::~EcalUncalibRecHitProducerGPU
~EcalUncalibRecHitProducerGPU() override
Definition: EcalUncalibRecHitProducerGPU.cc:191
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
EcalUncalibRecHitProducerGPU::eventOutputDataGPU_
ecal::multifit::EventOutputDataGPU eventOutputDataGPU_
Definition: EcalUncalibRecHitProducerGPU.cc:65
eostools.move
def move(src, dest)
Definition: eostools.py:511
EcalUncalibRecHitProducerGPU::EcalUncalibRecHitProducerGPU
EcalUncalibRecHitProducerGPU(edm::ParameterSet const &ps)
Definition: EcalUncalibRecHitProducerGPU.cc:106
EcalUncalibRecHitProducerGPU::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: EcalUncalibRecHitProducerGPU.cc:265
EcalUncalibRecHitProducerGPU::recHitsTokenEB_
const edm::EDPutTokenT< OutputProduct > recHitsTokenEB_
Definition: EcalUncalibRecHitProducerGPU.cc:47
ecal::multifit::ConfigurationParameters::maxNumberHitsEE
uint32_t maxNumberHitsEE
Definition: DeclsForKernels.h:95
cms::cuda::Product
Definition: Product.h:34
EcalUncalibRecHitProducerGPU::multifitParametersToken_
const edm::ESGetToken< EcalMultifitParametersGPU, JobConfigurationGPURecord > multifitParametersToken_
Definition: EcalUncalibRecHitProducerGPU.cc:59
ScopedContext.h
EcalUncalibRecHitMultiFitAlgoGPU.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalUncalibRecHitProducerGPU::configParameters_
ecal::multifit::ConfigurationParameters configParameters_
Definition: EcalUncalibRecHitProducerGPU.cc:62
EcalUncalibRecHitProducerGPU::gainRatiosToken_
const edm::ESGetToken< EcalGainRatiosGPU, EcalGainRatiosRcd > gainRatiosToken_
Definition: EcalUncalibRecHitProducerGPU.cc:51
EcalPedestalsRcd.h
EcalGainRatiosGPU.h
ParameterSet.h
EcalUncalibRecHitProducerGPU::pulseCovariancesToken_
const edm::ESGetToken< EcalPulseCovariancesGPU, EcalPulseCovariancesRcd > pulseCovariancesToken_
Definition: EcalUncalibRecHitProducerGPU.cc:53
EcalTimeCalibConstantsRcd.h
EcalPulseShapesGPU.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
EcalTimeBiasCorrectionsRcd.h
ecal::multifit::EventDataForScratchGPU
Definition: DeclsForKernels.h:139
ecal::multifit::ConfigurationParameters
Definition: DeclsForKernels.h:67
SimL1EmulatorDM_cff.eeDigis
eeDigis
Definition: SimL1EmulatorDM_cff.py:18
edm::InputTag
Definition: InputTag.h:15
EcalUncalibRecHitProducerGPU::samplesCorrelationToken_
const edm::ESGetToken< EcalSamplesCorrelationGPU, EcalSamplesCorrelationRcd > samplesCorrelationToken_
Definition: EcalUncalibRecHitProducerGPU.cc:54
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
EcalPulseShapesRcd.h
HLT_FULL_cff.EBtimeConstantTerm
EBtimeConstantTerm
Definition: HLT_FULL_cff.py:8225