CMS 3D CMS Logo

GpuTask.cc
Go to the documentation of this file.
2 
5 
8 
11 
12 namespace ecaldqm {
14  : DQWorkerTask(),
15  runGpuTask_(false),
16  enableDigi_(false),
17  enableUncalib_(false),
18  enableRecHit_(false),
19  digi1D_(false),
20  digi2D_(false),
21  uncalib1D_(false),
22  uncalib2D_(false),
23  rechit1D_(false),
24  rechit2D_(false),
25  EBCpuDigis_(nullptr),
26  EECpuDigis_(nullptr),
27  EBCpuUncalibRecHits_(nullptr),
28  EECpuUncalibRecHits_(nullptr),
29  EBCpuRecHits_(nullptr),
30  EECpuRecHits_(nullptr) {}
31 
33  // Ensure we run on CPU objects before GPU objects
34  if (enableDigi_) {
37  }
38 
39  if (enableUncalib_) {
42  }
43 
44  if (enableRecHit_) {
47  }
48  }
49 
51  runGpuTask_ = params.getUntrackedParameter<bool>("runGpuTask");
52 
53  // Enabling objects set to false if runGpuTask_ is false
54  enableDigi_ = runGpuTask_ && params.getUntrackedParameter<bool>("enableDigi");
55  enableUncalib_ = runGpuTask_ && params.getUntrackedParameter<bool>("enableUncalib");
56  enableRecHit_ = runGpuTask_ && params.getUntrackedParameter<bool>("enableRecHit");
57 
58  // Flags set to false if corresponding type is not enabled
59  digi1D_ = enableDigi_ && params.getUntrackedParameter<bool>("digi1D");
60  digi2D_ = enableDigi_ && params.getUntrackedParameter<bool>("digi2D");
61  uncalib1D_ = enableUncalib_ && params.getUntrackedParameter<bool>("uncalib1D");
62  uncalib2D_ = enableUncalib_ && params.getUntrackedParameter<bool>("uncalib2D");
63  rechit1D_ = enableRecHit_ && params.getUntrackedParameter<bool>("rechit1D");
64  rechit2D_ = enableRecHit_ && params.getUntrackedParameter<bool>("rechit2D");
65 
66  uncalibOOTAmps_ = params.getUntrackedParameter<std::vector<int> >("uncalibOOTAmps");
67 
68  if (!enableDigi_) {
69  MEs_.erase(std::string("DigiCpu"));
70  MEs_.erase(std::string("DigiCpuAmplitude"));
71  MEs_.erase(std::string("DigiGpuCpu"));
72  MEs_.erase(std::string("DigiGpuCpuAmplitude"));
73  }
74  if (!enableUncalib_) {
75  MEs_.erase(std::string("UncalibCpu"));
76  MEs_.erase(std::string("UncalibCpuAmp"));
77  MEs_.erase(std::string("UncalibCpuAmpError"));
78  MEs_.erase(std::string("UncalibCpuPedestal"));
79  MEs_.erase(std::string("UncalibCpuJitter"));
80  MEs_.erase(std::string("UncalibCpuJitterError"));
81  MEs_.erase(std::string("UncalibCpuChi2"));
82  MEs_.erase(std::string("UncalibCpuOOTAmp"));
83  MEs_.erase(std::string("UncalibCpuFlags"));
84  MEs_.erase(std::string("UncalibGpuCpu"));
85  MEs_.erase(std::string("UncalibGpuCpuAmp"));
86  MEs_.erase(std::string("UncalibGpuCpuAmpError"));
87  MEs_.erase(std::string("UncalibGpuCpuPedestal"));
88  MEs_.erase(std::string("UncalibGpuCpuJitter"));
89  MEs_.erase(std::string("UncalibGpuCpuJitterError"));
90  MEs_.erase(std::string("UncalibGpuCpuChi2"));
91  MEs_.erase(std::string("UncalibGpuCpuOOTAmp"));
92  MEs_.erase(std::string("UncalibGpuCpuFlags"));
93  }
94  if (!enableRecHit_) {
95  MEs_.erase(std::string("RecHitCpu"));
96  MEs_.erase(std::string("RecHitCpuEnergy"));
97  MEs_.erase(std::string("RecHitCpuTime"));
98  MEs_.erase(std::string("RecHitCpuFlags"));
99  MEs_.erase(std::string("RecHitGpuCpu"));
100  MEs_.erase(std::string("RecHitGpuCpuEnergy"));
101  MEs_.erase(std::string("RecHitGpuCpuTime"));
102  MEs_.erase(std::string("RecHitGpuCpuFlags"));
103  }
104  if (!digi1D_) {
105  MEs_.erase(std::string("DigiGpu"));
106  MEs_.erase(std::string("DigiGpuAmplitude"));
107  }
108  if (!uncalib1D_) {
109  MEs_.erase(std::string("UncalibGpu"));
110  MEs_.erase(std::string("UncalibGpuAmp"));
111  MEs_.erase(std::string("UncalibGpuAmpError"));
112  MEs_.erase(std::string("UncalibGpuPedestal"));
113  MEs_.erase(std::string("UncalibGpuJitter"));
114  MEs_.erase(std::string("UncalibGpuJitterError"));
115  MEs_.erase(std::string("UncalibGpuChi2"));
116  MEs_.erase(std::string("UncalibGpuOOTAmp"));
117  MEs_.erase(std::string("UncalibGpuFlags"));
118  }
119  if (!rechit1D_) {
120  MEs_.erase(std::string("RecHitGpu"));
121  MEs_.erase(std::string("RecHitGpuEnergy"));
122  MEs_.erase(std::string("RecHitGpuTime"));
123  MEs_.erase(std::string("RecHitGpuFlags"));
124  }
125  if (!digi2D_) {
126  MEs_.erase(std::string("Digi2D"));
127  MEs_.erase(std::string("Digi2DAmplitude"));
128  }
129  if (!uncalib2D_) {
130  MEs_.erase(std::string("Uncalib2D"));
131  MEs_.erase(std::string("Uncalib2DAmp"));
132  MEs_.erase(std::string("Uncalib2DAmpError"));
133  MEs_.erase(std::string("Uncalib2DPedestal"));
134  MEs_.erase(std::string("Uncalib2DJitter"));
135  MEs_.erase(std::string("Uncalib2DJitterError"));
136  MEs_.erase(std::string("Uncalib2DChi2"));
137  MEs_.erase(std::string("Uncalib2DOOTAmp"));
138  MEs_.erase(std::string("Uncalib2DFlags"));
139  }
140  if (!rechit2D_) {
141  MEs_.erase(std::string("RecHit2D"));
142  MEs_.erase(std::string("RecHit2DEnergy"));
143  MEs_.erase(std::string("RecHit2DTime"));
144  MEs_.erase(std::string("RecHit2DFlags"));
145  }
146  }
147 
148  bool GpuTask::filterRunType(short const* runType) {
149  for (unsigned iFED(0); iFED != ecaldqm::nDCC; iFED++) {
153  return true;
154  }
155 
156  return false;
157  }
158 
159  void GpuTask::beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) {
160  EBCpuDigis_ = nullptr;
161  EECpuDigis_ = nullptr;
162  EBCpuUncalibRecHits_ = nullptr;
163  EECpuUncalibRecHits_ = nullptr;
164  EBCpuRecHits_ = nullptr;
165  EECpuRecHits_ = nullptr;
166  }
167 
168  template <typename DigiCollection>
170  MESet& meDigiCpu(MEs_.at("DigiCpu"));
171  MESet& meDigiCpuAmplitude(MEs_.at("DigiCpuAmplitude"));
172 
173  int iSubdet(collection == kEBCpuDigi ? EcalBarrel : EcalEndcap);
174 
175  // Save CpuDigis for comparison with GpuDigis
176  // "if constexpr" ensures cpuDigis is the correct type at compile time
177  if constexpr (std::is_same_v<DigiCollection, EBDigiCollection>) {
178  assert(iSubdet == EcalBarrel);
179  EBCpuDigis_ = &cpuDigis;
180  } else {
181  assert(iSubdet == EcalEndcap);
182  EECpuDigis_ = &cpuDigis;
183  }
184 
185  unsigned nCpuDigis(cpuDigis.size());
186  meDigiCpu.fill(getEcalDQMSetupObjects(), iSubdet, nCpuDigis);
187 
188  for (auto const& cpuDigi : cpuDigis) {
189  // EcalDataFrame is not a derived class of edm::DataFrame, but can take edm::DataFrame (digis) in the constructor
190  EcalDataFrame cpuDataFrame(cpuDigi);
191 
192  for (unsigned iSample = 0; iSample < ecalPh1::sampleSize; iSample++) {
193  static_cast<MESetMulti&>(meDigiCpuAmplitude).use(iSample);
194 
195  int cpuAmp(cpuDataFrame.sample(iSample).adc());
196  meDigiCpuAmplitude.fill(getEcalDQMSetupObjects(), iSubdet, cpuAmp);
197  }
198  }
199  }
200 
201  template <typename DigiCollection>
203  MESet& meDigiGpuCpu(MEs_.at("DigiGpuCpu"));
204  MESet& meDigiGpuCpuAmplitude(MEs_.at("DigiGpuCpuAmplitude"));
205 
206  int iSubdet(collection == kEBGpuDigi ? EcalBarrel : EcalEndcap);
207 
208  // Get CpuDigis saved from GpuTask::runOnCpuDigis() for this event
209  // "if constexpr" ensures cpuDigis is the correct type at compile time
210  // Note: gpuDigis is a collection and cpuDigis is a pointer to a collection (for historical reasons)
211  DigiCollection const* cpuDigis;
212  if constexpr (std::is_same_v<DigiCollection, EBDigiCollection>) {
213  assert(iSubdet == EcalBarrel);
214  cpuDigis = EBCpuDigis_;
215  } else {
216  assert(iSubdet == EcalEndcap);
217  cpuDigis = EECpuDigis_;
218  }
219 
220  if (!cpuDigis) {
221  edm::LogWarning("EcalDQM") << "GpuTask: Did not find " << ((iSubdet == EcalBarrel) ? "EB" : "EE")
222  << "CpuDigis Collection. Aborting runOnGpuDigis\n";
223  return;
224  }
225 
226  unsigned nGpuDigis(gpuDigis.size());
227  unsigned nCpuDigis(cpuDigis->size());
228 
229  meDigiGpuCpu.fill(getEcalDQMSetupObjects(), iSubdet, nGpuDigis - nCpuDigis);
230 
231  if (digi1D_) {
232  MESet& meDigiGpu(MEs_.at("DigiGpu"));
233  meDigiGpu.fill(getEcalDQMSetupObjects(), iSubdet, nGpuDigis);
234  }
235 
236  if (digi2D_) {
237  MESet& meDigi2D(MEs_.at("Digi2D"));
238  meDigi2D.fill(getEcalDQMSetupObjects(), iSubdet, nCpuDigis, nGpuDigis);
239  }
240 
241  for (auto const& gpuDigi : gpuDigis) {
242  // Find CpuDigi with matching DetId
243  DetId gpuId(gpuDigi.id());
244  typename DigiCollection::const_iterator cpuItr(cpuDigis->find(gpuId));
245  if (cpuItr == cpuDigis->end()) {
246  edm::LogWarning("EcalDQM") << "GpuTask: Did not find CpuDigi DetId " << gpuId.rawId() << " in CPU collection\n";
247  continue;
248  }
249 
250  // EcalDataFrame is not a derived class of edm::DataFrame, but can take edm::DataFrame (digis) in the constructor
251  EcalDataFrame gpuDataFrame(gpuDigi);
252  EcalDataFrame cpuDataFrame(*cpuItr);
253 
254  for (unsigned iSample = 0; iSample < ecalPh1::sampleSize; iSample++) {
255  static_cast<MESetMulti&>(meDigiGpuCpuAmplitude).use(iSample);
256 
257  int gpuAmp(gpuDataFrame.sample(iSample).adc());
258  int cpuAmp(cpuDataFrame.sample(iSample).adc());
259 
260  meDigiGpuCpuAmplitude.fill(getEcalDQMSetupObjects(), iSubdet, gpuAmp - cpuAmp);
261 
262  if (digi1D_) {
263  MESet& meDigiGpuAmplitude(MEs_.at("DigiGpuAmplitude"));
264  static_cast<MESetMulti&>(meDigiGpuAmplitude).use(iSample);
265  meDigiGpuAmplitude.fill(getEcalDQMSetupObjects(), iSubdet, gpuAmp);
266  }
267 
268  if (digi2D_) {
269  MESet& meDigi2DAmplitude(MEs_.at("Digi2DAmplitude"));
270  static_cast<MESetMulti&>(meDigi2DAmplitude).use(iSample);
271  meDigi2DAmplitude.fill(getEcalDQMSetupObjects(), iSubdet, cpuAmp, gpuAmp);
272  }
273  }
274  }
275  }
276 
278  MESet& meUncalibCpu(MEs_.at("UncalibCpu"));
279  MESet& meUncalibCpuAmp(MEs_.at("UncalibCpuAmp"));
280  MESet& meUncalibCpuAmpError(MEs_.at("UncalibCpuAmpError"));
281  MESet& meUncalibCpuPedestal(MEs_.at("UncalibCpuPedestal"));
282  MESet& meUncalibCpuJitter(MEs_.at("UncalibCpuJitter"));
283  MESet& meUncalibCpuJitterError(MEs_.at("UncalibCpuJitterError"));
284  MESet& meUncalibCpuChi2(MEs_.at("UncalibCpuChi2"));
285  MESet& meUncalibCpuOOTAmp(MEs_.at("UncalibCpuOOTAmp"));
286  MESet& meUncalibCpuFlags(MEs_.at("UncalibCpuFlags"));
287 
289 
290  // Save CpuUncalibRecHits for comparison with GpuUncalibRecHits
291  if (iSubdet == EcalBarrel)
292  EBCpuUncalibRecHits_ = &cpuHits;
293  else
294  EECpuUncalibRecHits_ = &cpuHits;
295 
296  unsigned nCpuHits(cpuHits.size());
297  meUncalibCpu.fill(getEcalDQMSetupObjects(), iSubdet, nCpuHits);
298 
299  for (auto const& cpuHit : cpuHits) {
300  float cpuAmp(cpuHit.amplitude());
301  float cpuAmpError(cpuHit.amplitudeError());
302  float cpuPedestal(cpuHit.pedestal());
303  float cpuJitter(cpuHit.jitter());
304  float cpuJitterError(cpuHit.jitterError());
305  float cpuChi2(cpuHit.chi2());
306  uint32_t cpuFlags(cpuHit.flags());
307 
308  if (cpuJitterError == 10000) // Set this so 10000 (special value) shows up in last bin
309  cpuJitterError = 0.249999;
310 
311  meUncalibCpuAmp.fill(getEcalDQMSetupObjects(), iSubdet, cpuAmp);
312  meUncalibCpuAmpError.fill(getEcalDQMSetupObjects(), iSubdet, cpuAmpError);
313  meUncalibCpuPedestal.fill(getEcalDQMSetupObjects(), iSubdet, cpuPedestal);
314  meUncalibCpuJitter.fill(getEcalDQMSetupObjects(), iSubdet, cpuJitter);
315  meUncalibCpuJitterError.fill(getEcalDQMSetupObjects(), iSubdet, cpuJitterError);
316  meUncalibCpuChi2.fill(getEcalDQMSetupObjects(), iSubdet, cpuChi2);
317  meUncalibCpuFlags.fill(getEcalDQMSetupObjects(), iSubdet, cpuFlags);
318 
319  for (unsigned iAmp = 0; iAmp < uncalibOOTAmps_.size(); iAmp++) {
320  static_cast<MESetMulti&>(meUncalibCpuOOTAmp).use(iAmp);
321 
322  // Get corresponding OOT Amplitude
323  int cpuOOTAmp(cpuHit.outOfTimeAmplitude(uncalibOOTAmps_[iAmp]));
324  meUncalibCpuOOTAmp.fill(getEcalDQMSetupObjects(), iSubdet, cpuOOTAmp);
325  }
326  }
327  }
328 
330  MESet& meUncalibGpuCpu(MEs_.at("UncalibGpuCpu"));
331  MESet& meUncalibGpuCpuAmp(MEs_.at("UncalibGpuCpuAmp"));
332  MESet& meUncalibGpuCpuAmpError(MEs_.at("UncalibGpuCpuAmpError"));
333  MESet& meUncalibGpuCpuPedestal(MEs_.at("UncalibGpuCpuPedestal"));
334  MESet& meUncalibGpuCpuJitter(MEs_.at("UncalibGpuCpuJitter"));
335  MESet& meUncalibGpuCpuJitterError(MEs_.at("UncalibGpuCpuJitterError"));
336  MESet& meUncalibGpuCpuChi2(MEs_.at("UncalibGpuCpuChi2"));
337  MESet& meUncalibGpuCpuOOTAmp(MEs_.at("UncalibGpuCpuOOTAmp"));
338  MESet& meUncalibGpuCpuFlags(MEs_.at("UncalibGpuCpuFlags"));
339 
341 
342  // Get CpuUncalibRecHits saved from GpuTask::runOnCpuUncalibRecHits() for this event
343  // Note: _gpuHits is a collection and cpuHits is a pointer to a collection (for historical reasons)
344  EcalUncalibratedRecHitCollection const* cpuHits =
346  if (!cpuHits) {
347  edm::LogWarning("EcalDQM") << "GpuTask: Did not find " << ((iSubdet == EcalBarrel) ? "EB" : "EE")
348  << "CpuUncalibRecHits Collection. Aborting runOnGpuUncalibRecHits\n";
349  return;
350  }
351 
352  unsigned nGpuHits(gpuHits.size());
353  unsigned nCpuHits(cpuHits->size());
354 
355  meUncalibGpuCpu.fill(getEcalDQMSetupObjects(), iSubdet, nGpuHits - nCpuHits);
356 
357  if (uncalib1D_) {
358  MESet& meUncalibGpu(MEs_.at("UncalibGpu"));
359  meUncalibGpu.fill(getEcalDQMSetupObjects(), iSubdet, nGpuHits);
360  }
361 
362  if (uncalib2D_) {
363  MESet& meUncalib2D(MEs_.at("Uncalib2D"));
364  meUncalib2D.fill(getEcalDQMSetupObjects(), iSubdet, nCpuHits, nGpuHits);
365  }
366 
367  for (auto const& gpuHit : gpuHits) {
368  // Find CpuUncalibRecHit with matching DetId
369  DetId gpuId(gpuHit.id());
371  if (cpuItr == cpuHits->end()) {
372  edm::LogWarning("EcalDQM") << "GpuTask: Did not find GpuUncalibRecHit DetId " << gpuId.rawId()
373  << " in CPU collection\n";
374  continue;
375  }
376 
377  float gpuAmp(gpuHit.amplitude());
378  float gpuAmpError(gpuHit.amplitudeError());
379  float gpuPedestal(gpuHit.pedestal());
380  float gpuJitter(gpuHit.jitter());
381  float gpuJitterError(gpuHit.jitterError());
382  float gpuChi2(gpuHit.chi2());
383  uint32_t gpuFlags(gpuHit.flags());
384 
385  if (gpuJitterError == 10000) // Set this so 10000 (special value) shows up in last bin
386  gpuJitterError = 0.249999;
387 
388  float cpuAmp(cpuItr->amplitude());
389  float cpuAmpError(cpuItr->amplitudeError());
390  float cpuPedestal(cpuItr->pedestal());
391  float cpuJitter(cpuItr->jitter());
392  float cpuJitterError(cpuItr->jitterError());
393  float cpuChi2(cpuItr->chi2());
394  uint32_t cpuFlags(cpuItr->flags());
395 
396  if (cpuJitterError == 10000) // Set this so 10000 (special value) shows up in last bin
397  cpuJitterError = 0.249999;
398 
399  meUncalibGpuCpuAmp.fill(getEcalDQMSetupObjects(), iSubdet, gpuAmp - cpuAmp);
400  meUncalibGpuCpuAmpError.fill(getEcalDQMSetupObjects(), iSubdet, gpuAmpError - cpuAmpError);
401  meUncalibGpuCpuPedestal.fill(getEcalDQMSetupObjects(), iSubdet, gpuPedestal - cpuPedestal);
402  meUncalibGpuCpuJitter.fill(getEcalDQMSetupObjects(), iSubdet, gpuJitter - cpuJitter);
403  meUncalibGpuCpuJitterError.fill(getEcalDQMSetupObjects(), iSubdet, gpuJitterError - cpuJitterError);
404  meUncalibGpuCpuChi2.fill(getEcalDQMSetupObjects(), iSubdet, gpuChi2 - cpuChi2);
405  meUncalibGpuCpuFlags.fill(getEcalDQMSetupObjects(), iSubdet, gpuFlags - cpuFlags);
406 
407  if (uncalib1D_) {
408  MESet& meUncalibGpuAmp(MEs_.at("UncalibGpuAmp"));
409  MESet& meUncalibGpuAmpError(MEs_.at("UncalibGpuAmpError"));
410  MESet& meUncalibGpuPedestal(MEs_.at("UncalibGpuPedestal"));
411  MESet& meUncalibGpuJitter(MEs_.at("UncalibGpuJitter"));
412  MESet& meUncalibGpuJitterError(MEs_.at("UncalibGpuJitterError"));
413  MESet& meUncalibGpuChi2(MEs_.at("UncalibGpuChi2"));
414  MESet& meUncalibGpuFlags(MEs_.at("UncalibGpuFlags"));
415 
416  meUncalibGpuAmp.fill(getEcalDQMSetupObjects(), iSubdet, gpuAmp);
417  meUncalibGpuAmpError.fill(getEcalDQMSetupObjects(), iSubdet, gpuAmpError);
418  meUncalibGpuPedestal.fill(getEcalDQMSetupObjects(), iSubdet, gpuPedestal);
419  meUncalibGpuJitter.fill(getEcalDQMSetupObjects(), iSubdet, gpuJitter);
420  meUncalibGpuJitterError.fill(getEcalDQMSetupObjects(), iSubdet, gpuJitterError);
421  meUncalibGpuChi2.fill(getEcalDQMSetupObjects(), iSubdet, gpuChi2);
422  meUncalibGpuFlags.fill(getEcalDQMSetupObjects(), iSubdet, gpuFlags);
423  }
424 
425  if (uncalib2D_) {
426  MESet& meUncalib2DAmp(MEs_.at("Uncalib2DAmp"));
427  MESet& meUncalib2DAmpError(MEs_.at("Uncalib2DAmpError"));
428  MESet& meUncalib2DPedestal(MEs_.at("Uncalib2DPedestal"));
429  MESet& meUncalib2DJitter(MEs_.at("Uncalib2DJitter"));
430  MESet& meUncalib2DJitterError(MEs_.at("Uncalib2DJitterError"));
431  MESet& meUncalib2DChi2(MEs_.at("Uncalib2DChi2"));
432  MESet& meUncalib2DFlags(MEs_.at("Uncalib2DFlags"));
433 
434  meUncalib2DAmp.fill(getEcalDQMSetupObjects(), iSubdet, cpuAmp, gpuAmp);
435  meUncalib2DAmpError.fill(getEcalDQMSetupObjects(), iSubdet, cpuAmpError, gpuAmpError);
436  meUncalib2DPedestal.fill(getEcalDQMSetupObjects(), iSubdet, cpuPedestal, gpuPedestal);
437  meUncalib2DJitter.fill(getEcalDQMSetupObjects(), iSubdet, cpuJitter, gpuJitter);
438  meUncalib2DJitterError.fill(getEcalDQMSetupObjects(), iSubdet, cpuJitterError, gpuJitterError);
439  meUncalib2DChi2.fill(getEcalDQMSetupObjects(), iSubdet, cpuChi2, gpuChi2);
440  meUncalib2DFlags.fill(getEcalDQMSetupObjects(), iSubdet, cpuFlags, gpuFlags);
441  }
442 
443  for (unsigned iAmp = 0; iAmp < uncalibOOTAmps_.size(); iAmp++) {
444  static_cast<MESetMulti&>(meUncalibGpuCpuOOTAmp).use(iAmp);
445 
446  // Get corresponding OOT Amplitude
447  int gpuOOTAmp(gpuHit.outOfTimeAmplitude(uncalibOOTAmps_[iAmp]));
448  int cpuOOTAmp(cpuItr->outOfTimeAmplitude(uncalibOOTAmps_[iAmp]));
449 
450  meUncalibGpuCpuOOTAmp.fill(getEcalDQMSetupObjects(), iSubdet, gpuOOTAmp - cpuOOTAmp);
451 
452  if (uncalib1D_) {
453  MESet& meUncalibGpuOOTAmp(MEs_.at("UncalibGpuOOTAmp"));
454  static_cast<MESetMulti&>(meUncalibGpuOOTAmp).use(iAmp);
455  meUncalibGpuOOTAmp.fill(getEcalDQMSetupObjects(), iSubdet, gpuOOTAmp);
456  }
457 
458  if (uncalib2D_) {
459  MESet& meUncalib2DOOTAmp(MEs_.at("Uncalib2DOOTAmp"));
460  static_cast<MESetMulti&>(meUncalib2DOOTAmp).use(iAmp);
461  meUncalib2DOOTAmp.fill(getEcalDQMSetupObjects(), iSubdet, cpuOOTAmp, gpuOOTAmp);
462  }
463  }
464  }
465  }
466 
468  MESet& meRecHitCpu(MEs_.at("RecHitCpu"));
469  MESet& meRecHitCpuEnergy(MEs_.at("RecHitCpuEnergy"));
470  MESet& meRecHitCpuTime(MEs_.at("RecHitCpuTime"));
471  MESet& meRecHitCpuFlags(MEs_.at("RecHitCpuFlags"));
472 
473  int iSubdet(collection == kEBCpuRecHit ? EcalBarrel : EcalEndcap);
474 
475  // Save CpuRecHits for comparison with GpuRecHits
476  if (iSubdet == EcalBarrel)
477  EBCpuRecHits_ = &cpuHits;
478  else
479  EECpuRecHits_ = &cpuHits;
480 
481  unsigned nCpuHits(cpuHits.size());
482  meRecHitCpu.fill(getEcalDQMSetupObjects(), iSubdet, nCpuHits);
483 
484  for (auto const& cpuHit : cpuHits) {
485  float cpuEnergy(cpuHit.energy());
486  float cpuTime(cpuHit.time());
487  uint32_t cpuFlags(cpuHit.flagsBits());
488 
489  meRecHitCpuEnergy.fill(getEcalDQMSetupObjects(), iSubdet, cpuEnergy);
490  meRecHitCpuTime.fill(getEcalDQMSetupObjects(), iSubdet, cpuTime);
491  meRecHitCpuFlags.fill(getEcalDQMSetupObjects(), iSubdet, cpuFlags);
492  }
493  }
494 
496  MESet& meRecHitGpuCpu(MEs_.at("RecHitGpuCpu"));
497  MESet& meRecHitGpuCpuEnergy(MEs_.at("RecHitGpuCpuEnergy"));
498  MESet& meRecHitGpuCpuTime(MEs_.at("RecHitGpuCpuTime"));
499  MESet& meRecHitGpuCpuFlags(MEs_.at("RecHitGpuCpuFlags"));
500 
501  int iSubdet(collection == kEBGpuRecHit ? EcalBarrel : EcalEndcap);
502 
503  // Get CpuRecHits saved from GpuTask::runOnCpuRecHits() for this event
504  // Note: _gpuHits is a collection and cpuHits is a pointer to a collection (for historical reasons)
505  EcalRecHitCollection const* cpuHits = (iSubdet == EcalBarrel) ? EBCpuRecHits_ : EECpuRecHits_;
506  if (!cpuHits) {
507  edm::LogWarning("EcalDQM") << "GpuTask: Did not find " << ((iSubdet == EcalBarrel) ? "EB" : "EE")
508  << "CpuRecHits Collection. Aborting runOnGpuRecHits\n";
509  return;
510  }
511 
512  unsigned nGpuHits(gpuHits.size());
513  unsigned nCpuHits(cpuHits->size());
514 
515  meRecHitGpuCpu.fill(getEcalDQMSetupObjects(), iSubdet, nGpuHits - nCpuHits);
516 
517  if (rechit1D_) {
518  MESet& meRecHitGpu(MEs_.at("RecHitGpu"));
519  meRecHitGpu.fill(getEcalDQMSetupObjects(), iSubdet, nGpuHits);
520  }
521  if (rechit2D_) {
522  MESet& meRecHit2D(MEs_.at("RecHit2D"));
523  meRecHit2D.fill(getEcalDQMSetupObjects(), iSubdet, nCpuHits, nGpuHits);
524  }
525 
526  for (auto const& gpuHit : gpuHits) {
527  // Find CpuRecHit with matching DetId
528  DetId gpuId(gpuHit.detid());
529  EcalRecHitCollection::const_iterator cpuItr(cpuHits->find(gpuId));
530  if (cpuItr == cpuHits->end()) {
531  edm::LogWarning("EcalDQM") << "GpuTask: Did not find GpuRecHit DetId " << gpuId.rawId()
532  << " in CPU collection\n";
533  continue;
534  }
535 
536  float gpuEnergy(gpuHit.energy());
537  float gpuTime(gpuHit.time());
538  uint32_t gpuFlags(gpuHit.flagsBits());
539 
540  float cpuEnergy(cpuItr->energy());
541  float cpuTime(cpuItr->time());
542  uint32_t cpuFlags(cpuItr->flagsBits());
543 
544  meRecHitGpuCpuEnergy.fill(getEcalDQMSetupObjects(), iSubdet, gpuEnergy - cpuEnergy);
545  meRecHitGpuCpuTime.fill(getEcalDQMSetupObjects(), iSubdet, gpuTime - cpuTime);
546  meRecHitGpuCpuFlags.fill(getEcalDQMSetupObjects(), iSubdet, gpuFlags - cpuFlags);
547 
548  if (rechit1D_) {
549  MESet& meRecHitGpuEnergy(MEs_.at("RecHitGpuEnergy"));
550  MESet& meRecHitGpuTime(MEs_.at("RecHitGpuTime"));
551  MESet& meRecHitGpuFlags(MEs_.at("RecHitGpuFlags"));
552 
553  meRecHitGpuEnergy.fill(getEcalDQMSetupObjects(), iSubdet, gpuEnergy);
554  meRecHitGpuTime.fill(getEcalDQMSetupObjects(), iSubdet, gpuTime);
555  meRecHitGpuFlags.fill(getEcalDQMSetupObjects(), iSubdet, gpuFlags);
556  }
557 
558  if (rechit2D_) {
559  MESet& meRecHit2DEnergy(MEs_.at("RecHit2DEnergy"));
560  MESet& meRecHit2DTime(MEs_.at("RecHit2DTime"));
561  MESet& meRecHit2DFlags(MEs_.at("RecHit2DFlags"));
562 
563  meRecHit2DEnergy.fill(getEcalDQMSetupObjects(), iSubdet, cpuEnergy, gpuEnergy);
564  meRecHit2DTime.fill(getEcalDQMSetupObjects(), iSubdet, cpuTime, gpuTime);
565  meRecHit2DFlags.fill(getEcalDQMSetupObjects(), iSubdet, cpuFlags, gpuFlags);
566  }
567  }
568  }
569 
571 } // namespace ecaldqm
bool uncalib2D_
Definition: GpuTask.h:43
bool runGpuTask_
Definition: GpuTask.h:35
void addDependencies(DependencySet &) override
Definition: GpuTask.cc:32
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:168
EBDigiCollection const * EBCpuDigis_
Definition: GpuTask.h:49
void runOnGpuRecHits(EcalRecHitCollection const &, Collections)
Definition: GpuTask.cc:495
bool filterRunType(short const *) override
Definition: GpuTask.cc:148
MESet & at(const std::string &key)
Definition: MESet.h:399
size_type size() const
void runOnCpuUncalibRecHits(EcalUncalibratedRecHitCollection const &, Collections)
Definition: GpuTask.cc:277
std::vector< T >::const_iterator const_iterator
bool rechit2D_
Definition: GpuTask.h:45
EEDigiCollection const * EECpuDigis_
Definition: GpuTask.h:50
assert(be >=bs)
EcalRecHitCollection const * EECpuRecHits_
Definition: GpuTask.h:56
void fill(EcalDQMSetupObjects const edso, DetId const &_id, double _xyw=1., double _yw=1., double _w=1.) override
Definition: MESetMulti.h:29
bool enableDigi_
Definition: GpuTask.h:36
void setParams(edm::ParameterSet const &) override
Definition: GpuTask.cc:50
bool rechit1D_
Definition: GpuTask.h:44
void runOnGpuUncalibRecHits(EcalUncalibratedRecHitCollection const &, Collections)
Definition: GpuTask.cc:329
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
bool enableUncalib_
Definition: GpuTask.h:37
virtual void fill(EcalDQMSetupObjects const, DetId const &, double=1., double=1., double=1.)
Definition: MESet.h:74
void beginEvent(edm::Event const &, edm::EventSetup const &, bool const &, bool &) override
Definition: GpuTask.cc:159
EcalRecHitCollection const * EBCpuRecHits_
Definition: GpuTask.h:55
const_iterator end() const
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
static constexpr int nDCC
std::vector< int > uncalibOOTAmps_
Definition: GpuTask.h:47
MESetCollection MEs_
Definition: DQWorker.h:131
void runOnGpuDigis(DigiCollection const &, Collections)
Definition: GpuTask.cc:202
static constexpr unsigned int sampleSize
Definition: EcalConstants.h:53
iterator find(key_type k)
EcalUncalibratedRecHitCollection const * EECpuUncalibRecHits_
Definition: GpuTask.h:53
int adc() const
get the ADC sample (12 bits)
EcalUncalibratedRecHitCollection const * EBCpuUncalibRecHits_
Definition: GpuTask.h:52
bool uncalib1D_
Definition: GpuTask.h:42
Log< level::Warning, false > LogWarning
bool enableRecHit_
Definition: GpuTask.h:38
void erase(const std::string &key)
Definition: MESet.h:390
void runOnCpuRecHits(EcalRecHitCollection const &, Collections)
Definition: GpuTask.cc:467
void runOnCpuDigis(DigiCollection const &, Collections)
Definition: GpuTask.cc:169