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