CMS 3D CMS Logo

DBWriterWorkers.cc
Go to the documentation of this file.
3 
5 
8 
35 // #include "OnlineDB/EcalCondDB/interface/MonPNLed1Dat.h"
36 // #include "OnlineDB/EcalCondDB/interface/MonPNLed2Dat.h"
41 
49 
53 
54 namespace ecaldqm {
55  enum Quality { kBad = 0, kGood = 1, kUnknown = 2, kMBad = 3, kMGood = 4, kMUnknown = 5 };
56 
57  bool qualityOK(int _quality) { return (_quality != kBad && _quality != kUnknown); }
58 
60  : name_(_name), runTypes_(), source_(), active_(false) {
62 
63  std::vector<std::string> runTypes(params.getUntrackedParameter<std::vector<std::string>>("runTypes"));
64  for (unsigned iT(0); iT < runTypes.size(); ++iT)
65  runTypes_.insert(runTypes[iT]);
66 
67  if (!params.existsAs<edm::ParameterSet>("source", false))
68  return;
69 
70  edm::ParameterSet const &sourceParams(params.getUntrackedParameterSet("source"));
71  std::vector<std::string> const &meNames(sourceParams.getParameterNames());
72  for (unsigned iP(0); iP < meNames.size(); ++iP) {
73  std::string meName(meNames[iP]);
74  edm::ParameterSet const &meParam(sourceParams.getUntrackedParameterSet(meName));
75  source_.insert(meName, createMESet(meParam));
76  }
77  }
78 
80  std::string failedPath;
81  for (MESetCollection::iterator sItr(this->source_.begin()); sItr != this->source_.end(); ++sItr) {
82  if (!sItr->second->retrieve(_igetter, &failedPath)) {
83  edm::LogError("EcalDQM") << name_ << ": MESet " << sItr->first << "@" << failedPath << " not found";
84  this->active_ = false;
85  return;
86  }
87  }
88  }
89 
91  /*
92  uses
93  OccupancyTask.Digi (h_)
94  PNDiodeTask.Occupancy (hmem_)
95  IntegrityTask.Gain (h01_)
96  IntegrityTask.ChId (h02_)
97  IntegrityTask.GainSwitch (h03_)
98  IntegrityTask.TowerId (h04_)
99  IntegrityTask.BlockSize (h05_)
100  RawDataTask.L1AFE
101  RawDataTask.BXFE
102  PNDiodeTask.MemChId (h06_)
103  PNDiodeTask.MemGain (h07_)
104  PNDiodeTask.MemTowerId (h08_)
105  PNDiodeTask.MomBlockSize (h09_)
106  IntegrityClient.Quality
107  PNIntegrityClient.QualitySummary
108  */
109 
110  bool result(true);
111 
112  std::map<EcalLogicID, MonCrystalConsistencyDat> crystalConsistencies;
113  std::map<EcalLogicID, MonTTConsistencyDat> towerConsistencies;
114  std::map<EcalLogicID, MonMemChConsistencyDat> memChannelConsistencies;
115  std::map<EcalLogicID, MonMemTTConsistencyDat> memTowerConsistencies;
116 
117  MESet const &digiME(source_.at("Digi"));
118  MESet const &gainME(source_.at("Gain"));
119  MESet const &chidME(source_.at("ChId"));
120  MESet const &gainswitchME(source_.at("GainSwitch"));
121  MESet const &qualityME(source_.at("Quality"));
122 
123  MESet const &toweridME(source_.at("TowerId"));
124  MESet const &blocksizeME(source_.at("BlockSize"));
125  MESet const &l1aME(source_.at("L1AFE"));
126  MESet const &bxME(source_.at("BXFE"));
127 
128  MESet const &memdigiME(source_.at("MEMDigi"));
129  MESet const &memchidME(source_.at("MEMChId"));
130  MESet const &memgainME(source_.at("MEMGain"));
131  MESet const &pnqualityME(source_.at("PNQuality"));
132 
133  MESet const &memtoweridME(source_.at("MEMTowerId"));
134  MESet const &memblocksizeME(source_.at("MEMBlockSize"));
135 
136  if (verbosity_ > 1)
137  edm::LogInfo("EcalDQM") << " Looping over crystals";
138 
139  MESet::const_iterator dEnd(digiME.end());
140  MESet::const_iterator qItr(qualityME);
141  for (MESet::const_iterator dItr(digiME.beginChannel()); dItr != dEnd; dItr.toNextChannel()) {
142  DetId id(dItr->getId());
143 
144  int nDigis(dItr->getBinContent());
145  int gain(gainME.getBinContent(id));
146  int chid(chidME.getBinContent(id));
147  int gainswitch(gainswitchME.getBinContent(id));
148  qItr = dItr;
149 
150  if (gain > 0 || chid > 0 || gainswitch > 0) {
151  MonCrystalConsistencyDat &data(crystalConsistencies[crystalID(id)]);
152  data.setProcessedEvents(nDigis);
153  data.setProblematicEvents(gain + chid + gainswitch);
155  data.setProblemsID(chid);
156  data.setProblemsGainSwitch(gainswitch);
157 
158  int channelStatus(qItr->getBinContent());
159  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
160  data.setTaskStatus(channelBad);
161 
162  result &= qualityOK(channelStatus);
163  }
164  }
165 
166  if (verbosity_ > 1)
167  edm::LogInfo("EcalDQM") << " Looping over towers";
168 
169  for (unsigned iDCC(kEEmLow); iDCC <= kEBpHigh; ++iDCC) {
170  for (unsigned iTower(1); iTower <= 68; ++iTower) {
171  if (!ccuExists(iDCC + 1, iTower))
172  continue;
173 
174  EcalElectronicsId eid(iDCC + 1, iTower, 1, 1);
175  std::vector<DetId> channels(getElectronicsMap()->dccTowerConstituents(iDCC + 1, iTower));
176  int nDigis(0);
177  bool towerBad(false);
178  for (unsigned iD(0); iD < channels.size(); ++iD) {
179  int n(digiME.getBinContent(channels[iD]));
180  if (n > nDigis)
181  nDigis = n;
182  int channelStatus(qualityME.getBinContent(channels[iD]));
183  if (channelStatus == kBad || channelStatus == kMBad)
184  towerBad = true;
185  }
186 
187  int towerid(toweridME.getBinContent(eid));
188  int blocksize(blocksizeME.getBinContent(eid));
189  int l1a(l1aME.getBinContent(iDCC + 1, iTower));
190  int bx(bxME.getBinContent(iDCC + 1, iTower));
191 
192  if (towerid > 0 || blocksize > 0 || l1a > 0 || bx > 0) {
193  MonTTConsistencyDat &data(towerConsistencies[towerID(eid)]);
194  data.setProcessedEvents(nDigis);
195  data.setProblematicEvents(towerid + blocksize + l1a + bx);
196  data.setProblemsID(towerid);
197  data.setProblemsSize(blocksize);
198  data.setProblemsLV1(l1a);
199  data.setProblemsBunchX(bx);
200  data.setTaskStatus(towerBad);
201 
202  result &= !towerBad;
203  }
204  }
205  }
206 
207  if (verbosity_ > 1)
208  edm::LogInfo("EcalDQM") << " Looping over MEM channels and towers";
209 
210  for (unsigned iMD(0); iMD < memDCC.size(); ++iMD) {
211  unsigned iDCC(memDCC[iMD]);
212 
213  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
214 
215  for (unsigned iPN(1); iPN <= 10; ++iPN) {
216  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
217 
218  int nDigis(memdigiME.getBinContent(pnid));
219  int memchid(memchidME.getBinContent(pnid));
220  int memgain(memgainME.getBinContent(pnid));
221 
222  if (memchid > 0 || memgain > 0) {
223  MonMemChConsistencyDat &data(memChannelConsistencies[memChannelID(pnid)]);
224 
225  data.setProcessedEvents(nDigis);
226  data.setProblematicEvents(memchid + memgain);
227  data.setProblemsID(memchid);
228  data.setProblemsGainZero(memgain);
229 
230  int channelStatus(pnqualityME.getBinContent(pnid));
231  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
232  data.setTaskStatus(channelBad);
233 
234  result &= qualityOK(channelStatus);
235  }
236  }
237 
238  for (unsigned iTower(69); iTower <= 70; ++iTower) {
239  EcalElectronicsId eid(iDCC + 1, iTower, 1, 1);
240 
241  int nDigis(0);
242  bool towerBad(false);
243  for (unsigned iPN(1); iPN <= 10; ++iPN) {
244  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
245  int n(memdigiME.getBinContent(pnid));
246  if (n > nDigis)
247  nDigis = n;
248  int channelStatus(pnqualityME.getBinContent(pnid));
249  if (channelStatus == kBad || channelStatus == kMBad)
250  towerBad = true;
251  }
252 
253  int towerid(memtoweridME.getBinContent(eid));
254  int blocksize(memblocksizeME.getBinContent(eid));
255 
256  if (towerid > 0 || blocksize > 0) {
257  MonMemTTConsistencyDat &data(memTowerConsistencies[memTowerID(eid)]);
258 
259  data.setProcessedEvents(nDigis);
260  data.setProblematicEvents(towerid + blocksize);
261  data.setProblemsID(towerid);
262  data.setProblemsSize(blocksize);
263  data.setTaskStatus(towerBad);
264 
265  result &= !towerBad;
266  }
267  }
268  }
269 
270  if (verbosity_ > 1)
271  edm::LogInfo("EcalDQM") << " Inserting data";
272 
273  try {
274  if (!crystalConsistencies.empty()) {
275  if (verbosity_ > 2)
276  edm::LogInfo("EcalDQM") << " crystalConsistencies";
277  _db->insertDataArraySet(&crystalConsistencies, &_iov);
278  }
279  if (!towerConsistencies.empty()) {
280  if (verbosity_ > 2)
281  edm::LogInfo("EcalDQM") << " towerConsistencies";
282  _db->insertDataArraySet(&towerConsistencies, &_iov);
283  }
284  if (!memChannelConsistencies.empty()) {
285  if (verbosity_ > 2)
286  edm::LogInfo("EcalDQM") << " memChannelConsistencies";
287  _db->insertDataArraySet(&memChannelConsistencies, &_iov);
288  }
289  if (!memTowerConsistencies.empty()) {
290  if (verbosity_ > 2)
291  edm::LogInfo("EcalDQM") << " memTowerConsistencies";
292  _db->insertDataArraySet(&memTowerConsistencies, &_iov);
293  }
294  } catch (std::runtime_error &e) {
295  if (std::string(e.what()).find("unique constraint") != std::string::npos)
296  edm::LogWarning("EcalDQM") << e.what();
297  else
298  throw cms::Exception("DBError") << e.what();
299  }
300 
301  return result;
302  }
303 
304  LaserWriter::LaserWriter(edm::ParameterSet const &_ps) : DBWriterWorker("Laser", _ps), wlToME_() {
305  std::vector<int> laserWavelengths(_ps.getUntrackedParameter<std::vector<int>>("laserWavelengths"));
306 
307  // wavelengths are not necessarily ordered
308  // create a map wl -> MESet index
309  // using Amplitude here but any multi-wavelength plot is fine
310 
312 
313  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
314  unsigned nWL(laserWavelengths.size());
315  for (unsigned iWL(0); iWL != nWL; ++iWL) {
316  int wl(laserWavelengths[iWL]);
317  if (wl <= 0 || wl >= 5)
318  throw cms::Exception("InvalidConfiguration") << "Laser Wavelength";
319  repl["wl"] = std::to_string(wl);
320  wlToME_[wl] = amplitude.getIndex(repl);
321  }
322  }
323 
325  /*
326  uses
327  LaserTask.Amplitude (h01, h03, h05, h07)
328  LaserTask.AOverP (h02, h04, h06, h08)
329  LaserTask.Timing (h09, h10, h11, h12)
330  LaserClient.Quality (meg01, meg02, meg03, meg04)
331  LaserTask.PNAmplitude (i09, i10, i11, i12)
332  LaserClient.PNQualitySummary (meg09, meg10, meg11, meg12)
333  PNDiodeTask.Pedestal (i13, i14, i15, i16)
334  */
335 
336  bool result(true);
337 
338  std::map<EcalLogicID, MonLaserBlueDat> l1Amp;
339  std::map<EcalLogicID, MonTimingLaserBlueCrystalDat> l1Time;
340  std::map<EcalLogicID, MonPNBlueDat> l1PN;
341  std::map<EcalLogicID, MonLaserGreenDat> l2Amp;
342  std::map<EcalLogicID, MonTimingLaserGreenCrystalDat> l2Time;
343  std::map<EcalLogicID, MonPNGreenDat> l2PN;
344  std::map<EcalLogicID, MonLaserIRedDat> l3Amp;
345  std::map<EcalLogicID, MonTimingLaserIRedCrystalDat> l3Time;
346  std::map<EcalLogicID, MonPNIRedDat> l3PN;
347  std::map<EcalLogicID, MonLaserRedDat> l4Amp;
348  std::map<EcalLogicID, MonTimingLaserRedCrystalDat> l4Time;
349  std::map<EcalLogicID, MonPNRedDat> l4PN;
350 
351  MESet const &ampME(source_.at("Amplitude"));
352  MESet const &aopME(source_.at("AOverP"));
353  MESet const &timeME(source_.at("Timing"));
354  MESet const &qualityME(source_.at("Quality"));
355 
356  MESet const &pnME(source_.at("PNAmplitude"));
357  MESet const &pnQualityME(source_.at("PNQuality"));
358  MESet const &pnPedestalME(source_.at("PNPedestal"));
359 
360  for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
361  int wl(wlItr->first);
362  unsigned iM(wlItr->second);
363 
364  static_cast<MESetMulti const &>(ampME).use(iM);
365  static_cast<MESetMulti const &>(aopME).use(iM);
366  static_cast<MESetMulti const &>(timeME).use(iM);
367  static_cast<MESetMulti const &>(qualityME).use(iM);
368  static_cast<MESetMulti const &>(pnME).use(iM);
369  static_cast<MESetMulti const &>(pnQualityME).use(iM);
370 
371  MESet::const_iterator aEnd(ampME.end());
372  MESet::const_iterator qItr(qualityME);
373  MESet::const_iterator oItr(aopME);
374  MESet::const_iterator tItr(timeME);
375  for (MESet::const_iterator aItr(ampME.beginChannel()); aItr != aEnd; aItr.toNextChannel()) {
376  float aEntries(aItr->getBinEntries());
377  if (aEntries < 1.)
378  continue;
379 
380  qItr = aItr;
381  oItr = aItr;
382  tItr = aItr;
383 
384  DetId id(aItr->getId());
385 
386  float ampMean(aItr->getBinContent());
387  float ampRms(aItr->getBinError() * std::sqrt(aEntries));
388 
389  float aopEntries(oItr->getBinEntries());
390  float aopMean(oItr->getBinContent());
391  float aopRms(oItr->getBinError() * std::sqrt(aopEntries));
392 
393  float timeEntries(tItr->getBinEntries());
394  float timeMean(tItr->getBinContent());
395  float timeRms(tItr->getBinError() * std::sqrt(timeEntries));
396 
397  int channelStatus(qItr->getBinContent());
398  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
399 
400  EcalLogicID logicID(crystalID(id));
401 
402  switch (wl) {
403  case 1: {
404  MonLaserBlueDat &aData(l1Amp[logicID]);
405  aData.setAPDMean(ampMean);
406  aData.setAPDRMS(ampRms);
407  aData.setAPDOverPNMean(aopMean);
408  aData.setAPDOverPNRMS(aopRms);
409  aData.setTaskStatus(channelBad);
410 
411  MonTimingLaserBlueCrystalDat &tData(l1Time[logicID]);
412  tData.setTimingMean(timeMean);
413  tData.setTimingRMS(timeRms);
414  tData.setTaskStatus(channelBad);
415  } break;
416  case 2: {
417  MonLaserGreenDat &aData(l2Amp[logicID]);
418  aData.setAPDMean(ampMean);
419  aData.setAPDRMS(ampRms);
420  aData.setAPDOverPNMean(aopMean);
421  aData.setAPDOverPNRMS(aopRms);
422  aData.setTaskStatus(channelBad);
423 
424  MonTimingLaserGreenCrystalDat &tData(l2Time[logicID]);
425  tData.setTimingMean(timeMean);
426  tData.setTimingRMS(timeRms);
427  tData.setTaskStatus(channelBad);
428  } break;
429  case 3: {
430  MonLaserIRedDat &aData(l3Amp[logicID]);
431  aData.setAPDMean(ampMean);
432  aData.setAPDRMS(ampRms);
433  aData.setAPDOverPNMean(aopMean);
434  aData.setAPDOverPNRMS(aopRms);
435  aData.setTaskStatus(channelBad);
436 
437  MonTimingLaserIRedCrystalDat &tData(l3Time[logicID]);
438  tData.setTimingMean(timeMean);
439  tData.setTimingRMS(timeRms);
440  tData.setTaskStatus(channelBad);
441  } break;
442  case 4: {
443  MonLaserRedDat &aData(l4Amp[logicID]);
444  aData.setAPDMean(ampMean);
445  aData.setAPDRMS(ampRms);
446  aData.setAPDOverPNMean(aopMean);
447  aData.setAPDOverPNRMS(aopRms);
448  aData.setTaskStatus(channelBad);
449 
450  MonTimingLaserRedCrystalDat &tData(l4Time[logicID]);
451  tData.setTimingMean(timeMean);
452  tData.setTimingRMS(timeRms);
453  tData.setTaskStatus(channelBad);
454  } break;
455  }
456  result &= qualityOK(channelStatus);
457  }
458 
459  for (unsigned iMD(0); iMD < memDCC.size(); ++iMD) {
460  unsigned iDCC(memDCC[iMD]);
461 
462  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
463 
464  for (unsigned iPN(1); iPN <= 10; ++iPN) {
465  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
466 
467  float entries(pnME.getBinEntries(pnid));
468  if (entries < 1.)
469  continue;
470 
471  float mean(pnME.getBinContent(pnid));
472  float rms(pnME.getBinError(pnid) * std::sqrt(entries));
473 
474  float pedestalEntries(pnPedestalME.getBinEntries(pnid));
475  float pedestalMean(pnPedestalME.getBinContent(pnid));
476  float pedestalRms(pnPedestalME.getBinError(pnid) * std::sqrt(pedestalEntries));
477 
478  int channelStatus(pnQualityME.getBinContent(pnid));
479  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
480 
481  switch (wl) {
482  case 1: {
483  MonPNBlueDat &data(l1PN[lmPNID(pnid)]);
484  data.setADCMeanG1(-1.);
485  data.setADCRMSG1(-1.);
486  data.setPedMeanG1(-1.);
487  data.setPedRMSG1(-1.);
488  data.setADCMeanG16(mean);
489  data.setADCRMSG16(rms);
490  data.setPedMeanG16(pedestalMean);
491  data.setPedRMSG16(pedestalRms);
492  data.setTaskStatus(channelBad);
493  } break;
494  case 2: {
495  MonPNGreenDat &data(l2PN[lmPNID(pnid)]);
496  data.setADCMeanG1(-1.);
497  data.setADCRMSG1(-1.);
498  data.setPedMeanG1(-1.);
499  data.setPedRMSG1(-1.);
500  data.setADCMeanG16(mean);
501  data.setADCRMSG16(rms);
502  data.setPedMeanG16(pedestalMean);
503  data.setPedRMSG16(pedestalRms);
504  data.setTaskStatus(channelBad);
505  } break;
506  case 3: {
507  MonPNIRedDat &data(l3PN[lmPNID(pnid)]);
508  data.setADCMeanG1(-1.);
509  data.setADCRMSG1(-1.);
510  data.setPedMeanG1(-1.);
511  data.setPedRMSG1(-1.);
512  data.setADCMeanG16(mean);
513  data.setADCRMSG16(rms);
514  data.setPedMeanG16(pedestalMean);
515  data.setPedRMSG16(pedestalRms);
516  data.setTaskStatus(channelBad);
517  } break;
518  case 4: {
519  MonPNRedDat &data(l4PN[lmPNID(pnid)]);
520  data.setADCMeanG1(-1.);
521  data.setADCRMSG1(-1.);
522  data.setPedMeanG1(-1.);
523  data.setPedRMSG1(-1.);
524  data.setADCMeanG16(mean);
525  data.setADCRMSG16(rms);
526  data.setPedMeanG16(pedestalMean);
527  data.setPedRMSG16(pedestalRms);
528  data.setTaskStatus(channelBad);
529  } break;
530  }
531 
532  result &= qualityOK(channelStatus);
533  }
534  }
535  }
536 
537  try {
538  if (!l1Amp.empty())
539  _db->insertDataArraySet(&l1Amp, &_iov);
540  if (!l1Time.empty())
541  _db->insertDataArraySet(&l1Time, &_iov);
542  if (!l1PN.empty())
543  _db->insertDataArraySet(&l1PN, &_iov);
544  if (!l2Amp.empty())
545  _db->insertDataArraySet(&l2Amp, &_iov);
546  if (!l2Time.empty())
547  _db->insertDataArraySet(&l2Time, &_iov);
548  if (!l2PN.empty())
549  _db->insertDataArraySet(&l2PN, &_iov);
550  if (!l3Amp.empty())
551  _db->insertDataArraySet(&l3Amp, &_iov);
552  if (!l3Time.empty())
553  _db->insertDataArraySet(&l3Time, &_iov);
554  if (!l3PN.empty())
555  _db->insertDataArraySet(&l3PN, &_iov);
556  if (!l4Amp.empty())
557  _db->insertDataArraySet(&l4Amp, &_iov);
558  if (!l4Time.empty())
559  _db->insertDataArraySet(&l4Time, &_iov);
560  if (!l4PN.empty())
561  _db->insertDataArraySet(&l4PN, &_iov);
562  } catch (std::runtime_error &e) {
563  if (std::string(e.what()).find("unique constraint") != std::string::npos)
564  edm::LogWarning("EcalDQM") << e.what();
565  else
566  throw cms::Exception("DBError") << e.what();
567  }
568 
569  return result;
570  }
571 
573  : DBWriterWorker("Pedestal", _ps), gainToME_(), pnGainToME_() {
574  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int>>("MGPAGains"));
575  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int>>("MGPAGainsPN"));
576 
578 
579  MESetMulti const &pedestal(static_cast<MESetMulti const &>(source_.at("Pedestal")));
580  unsigned nG(MGPAGains.size());
581  for (unsigned iG(0); iG != nG; ++iG) {
582  int gain(MGPAGains[iG]);
583  if (gain != 1 && gain != 6 && gain != 12)
584  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
585  repl["gain"] = std::to_string(gain);
586  gainToME_[gain] = pedestal.getIndex(repl);
587  }
588 
589  repl.clear();
590 
591  MESetMulti const &pnPedestal(static_cast<MESetMulti const &>(source_.at("PNPedestal")));
592  unsigned nGPN(MGPAGainsPN.size());
593  for (unsigned iG(0); iG != nGPN; ++iG) {
594  int gain(MGPAGainsPN[iG]);
595  if (gain != 1 && gain != 16)
596  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
597  repl["pngain"] = std::to_string(gain);
598  pnGainToME_[gain] = pnPedestal.getIndex(repl);
599  }
600  }
601 
603  /*
604  uses
605  PedestalTask.Pedestal (h01, h02, h03)
606  PedestalTask.PNPedestal (i01, i02)
607  PedestalClient.Quality (meg01, meg02, meg03)
608  PedestalClient.PNQualitySummary (meg04, meg05)
609  */
610 
611  bool result(true);
612 
613  std::map<EcalLogicID, MonPedestalsDat> pedestals;
614  std::map<EcalLogicID, MonPNPedDat> pnPedestals;
615 
616  MESet const &pedestalME(source_.at("Pedestal"));
617  MESet const &qualityME(source_.at("Quality"));
618 
619  MESet const &pnPedestalME(source_.at("PNPedestal"));
620  MESet const &pnQualityME(source_.at("PNQuality"));
621 
622  for (std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
623  int gain(gainItr->first);
624  int iM(gainItr->second);
625 
626  static_cast<MESetMulti const &>(pedestalME).use(iM);
627  static_cast<MESetMulti const &>(qualityME).use(iM);
628 
629  MESet::const_iterator pEnd(pedestalME.end());
630  MESet::const_iterator qItr(qualityME);
631  for (MESet::const_iterator pItr(pedestalME.beginChannel()); pItr != pEnd; pItr.toNextChannel()) {
632  float entries(pItr->getBinEntries());
633  if (entries < 1.)
634  continue;
635 
636  qItr = pItr;
637 
638  float mean(pItr->getBinContent());
639  float rms(pItr->getBinError() * std::sqrt(entries));
640 
641  EcalLogicID logicID(crystalID(pItr->getId()));
642  if (pedestals.find(logicID) == pedestals.end()) {
643  MonPedestalsDat &insertion(pedestals[logicID]);
644  insertion.setPedMeanG1(-1.);
645  insertion.setPedRMSG1(-1.);
646  insertion.setPedMeanG6(-1.);
647  insertion.setPedRMSG6(-1.);
648  insertion.setPedMeanG12(-1.);
649  insertion.setPedRMSG12(-1.);
650  insertion.setTaskStatus(false);
651  }
652 
653  MonPedestalsDat &data(pedestals[logicID]);
654  switch (gain) {
655  case 1:
656  data.setPedMeanG1(mean);
657  data.setPedRMSG1(rms);
658  break;
659  case 6:
660  data.setPedMeanG6(mean);
661  data.setPedRMSG6(rms);
662  break;
663  case 12:
664  data.setPedMeanG12(mean);
665  data.setPedRMSG12(rms);
666  break;
667  }
668 
669  int channelStatus(qItr->getBinContent());
670  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
671  if (channelBad)
672  data.setTaskStatus(true);
673 
674  result &= qualityOK(channelStatus);
675  }
676  }
677 
678  for (std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
679  int gain(gainItr->first);
680  int iM(gainItr->second);
681 
682  static_cast<MESetMulti const &>(pnPedestalME).use(iM);
683  static_cast<MESetMulti const &>(pnQualityME).use(iM);
684 
685  for (unsigned iMD(0); iMD < memDCC.size(); ++iMD) {
686  unsigned iDCC(memDCC[iMD]);
687 
688  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
689 
690  for (unsigned iPN(1); iPN <= 10; ++iPN) {
691  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
692 
693  float entries(pnPedestalME.getBinEntries(pnid));
694  if (entries < 1.)
695  continue;
696 
697  float mean(pnPedestalME.getBinContent(pnid));
698  float rms(pnPedestalME.getBinError(pnid) * std::sqrt(entries));
699 
700  EcalLogicID logicID(lmPNID(pnid));
701  if (pnPedestals.find(logicID) == pnPedestals.end()) {
702  MonPNPedDat &insertion(pnPedestals[logicID]);
703  insertion.setPedMeanG1(-1.);
704  insertion.setPedRMSG1(-1.);
705  insertion.setPedMeanG16(-1.);
706  insertion.setPedRMSG16(-1.);
707  insertion.setTaskStatus(false);
708  }
709 
710  MonPNPedDat &data(pnPedestals[lmPNID(pnid)]);
711  switch (gain) {
712  case 1:
713  data.setPedMeanG1(mean);
714  data.setPedRMSG1(rms);
715  break;
716  case 16:
717  data.setPedMeanG16(mean);
718  data.setPedRMSG16(rms);
719  break;
720  }
721 
722  int channelStatus(pnQualityME.getBinContent(pnid));
723  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
724  if (channelBad)
725  data.setTaskStatus(true);
726 
727  result &= qualityOK(channelStatus);
728  }
729  }
730  }
731 
732  try {
733  if (!pedestals.empty())
734  _db->insertDataArraySet(&pedestals, &_iov);
735  if (!pnPedestals.empty())
736  _db->insertDataArraySet(&pnPedestals, &_iov);
737  } catch (std::runtime_error &e) {
738  if (std::string(e.what()).find("unique constraint") != std::string::npos)
739  edm::LogWarning("EcalDQM") << e.what();
740  else
741  throw cms::Exception("DBError") << e.what();
742  }
743 
744  return result;
745  }
746 
748  /*
749  uses
750  PresampleTask.Pedestal (h03)
751  PresampleClient.Quality (meg03)
752  */
753 
754  bool result(true);
755 
756  std::map<EcalLogicID, MonPedestalsOnlineDat> pedestals;
757 
758  MESet const &pedestalME(source_.at("Pedestal"));
759  MESet const &qualityME(source_.at("Quality"));
760 
761  MESet::const_iterator pEnd(pedestalME.end());
762  MESet::const_iterator qItr(qualityME);
763  for (MESet::const_iterator pItr(pedestalME.beginChannel()); pItr != pEnd; pItr.toNextChannel()) {
764  float entries(pItr->getBinEntries());
765  if (entries < 1.)
766  continue;
767 
768  qItr = pItr;
769 
770  float mean(pItr->getBinContent());
771  float rms(pItr->getBinError() * std::sqrt(entries));
772 
773  MonPedestalsOnlineDat &data(pedestals[crystalID(pItr->getId())]);
774  data.setADCMeanG12(mean);
775  data.setADCRMSG12(rms);
776 
777  int channelStatus(qItr->getBinContent());
778  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
779  data.setTaskStatus(channelBad);
780 
781  result &= qualityOK(channelStatus);
782  }
783 
784  try {
785  if (!pedestals.empty())
786  _db->insertDataArraySet(&pedestals, &_iov);
787  } catch (std::runtime_error &e) {
788  if (std::string(e.what()).find("unique constraint") != std::string::npos)
789  edm::LogWarning("EcalDQM") << e.what();
790  else
791  throw cms::Exception("DBError") << e.what();
792  }
793 
794  return result;
795  }
796 
798  : DBWriterWorker("TestPulse", _ps), gainToME_(), pnGainToME_() {
799  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int>>("MGPAGains"));
800  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int>>("MGPAGainsPN"));
801 
803 
804  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
805  unsigned nG(MGPAGains.size());
806  for (unsigned iG(0); iG != nG; ++iG) {
807  int gain(MGPAGains[iG]);
808  if (gain != 1 && gain != 6 && gain != 12)
809  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
810  repl["gain"] = std::to_string(gain);
811  gainToME_[gain] = amplitude.getIndex(repl);
812  }
813 
814  repl.clear();
815 
816  MESetMulti const &pnAmplitude(static_cast<MESetMulti const &>(source_.at("PNAmplitude")));
817  unsigned nGPN(MGPAGainsPN.size());
818  for (unsigned iG(0); iG != nGPN; ++iG) {
819  int gain(MGPAGainsPN[iG]);
820  if (gain != 1 && gain != 16)
821  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
822  repl["pngain"] = std::to_string(gain);
823  pnGainToME_[gain] = pnAmplitude.getIndex(repl);
824  }
825  }
826 
828  /*
829  uses
830  TestPulseTask.Amplitude (ha01, ha02, ha03)
831  TestPulseTask.Shape (me_hs01, me_hs02, me_hs03)
832  TestPulseTask.PNAmplitude (i01, i02)
833  PNDiodeTask.Pedestal (i03, i04)
834  TestPulseClient.Quality (meg01, meg02, meg03)
835  TestPulseClient.PNQualitySummary (meg04, meg05)
836  */
837 
838  bool result(true);
839 
840  std::map<EcalLogicID, MonTestPulseDat> amplitude;
841  std::map<EcalLogicID, MonPulseShapeDat> shape;
842  std::map<EcalLogicID, MonPNMGPADat> pnAmplitude;
843 
844  MESet const &amplitudeME(source_.at("Amplitude"));
845  MESet const &shapeME(source_.at("Shape"));
846  MESet const &qualityME(source_.at("Quality"));
847 
848  MESet const &pnAmplitudeME(source_.at("PNAmplitude"));
849  MESet const &pnPedestalME(source_.at("PNPedestal"));
850  MESet const &pnQualityME(source_.at("PNQuality"));
851 
852  for (std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
853  int gain(gainItr->first);
854  int iM(gainItr->second);
855 
856  static_cast<MESetMulti const &>(amplitudeME).use(iM);
857  static_cast<MESetMulti const &>(shapeME).use(iM);
858  static_cast<MESetMulti const &>(qualityME).use(iM);
859 
860  MESet::const_iterator aEnd(amplitudeME.end());
861  MESet::const_iterator qItr(qualityME);
862  for (MESet::const_iterator aItr(amplitudeME.beginChannel()); aItr != aEnd; aItr.toNextChannel()) {
863  float entries(aItr->getBinEntries());
864  if (entries < 1.)
865  continue;
866 
867  qItr = aItr;
868 
869  float mean(aItr->getBinContent());
870  float rms(aItr->getBinError() * std::sqrt(entries));
871 
872  EcalLogicID logicID(crystalID(aItr->getId()));
873  if (amplitude.find(logicID) == amplitude.end()) {
874  MonTestPulseDat &insertion(amplitude[logicID]);
875  insertion.setADCMeanG1(-1.);
876  insertion.setADCRMSG1(-1.);
877  insertion.setADCMeanG6(-1.);
878  insertion.setADCRMSG6(-1.);
879  insertion.setADCMeanG12(-1.);
880  insertion.setADCRMSG12(-1.);
881  insertion.setTaskStatus(false);
882  }
883 
884  MonTestPulseDat &data(amplitude[logicID]);
885  switch (gain) {
886  case 1:
887  data.setADCMeanG1(mean);
888  data.setADCRMSG1(rms);
889  break;
890  case 6:
891  data.setADCMeanG6(mean);
892  data.setADCRMSG6(rms);
893  break;
894  case 12:
895  data.setADCMeanG12(mean);
896  data.setADCRMSG12(rms);
897  break;
898  }
899 
900  int channelStatus(qItr->getBinContent());
901  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
902  if (channelBad)
903  data.setTaskStatus(true);
904 
905  result &= qualityOK(channelStatus);
906  }
907 
908  for (unsigned iSM(0); iSM < 54; ++iSM) {
909  std::vector<float> samples(10, 0.);
910  std::vector<DetId> ids(getElectronicsMap()->dccConstituents(iSM + 1));
911  unsigned nId(ids.size());
912  unsigned nChannels(0);
913  EcalLogicID logicID;
914  for (unsigned iD(0); iD < nId; ++iD) {
915  DetId &id(ids[iD]);
916 
917  if (iD == 0)
918  logicID = crystalID(id);
919 
920  if (shapeME.getBinEntries(id, 1) < 1.)
921  continue;
922 
923  ++nChannels;
924 
925  for (int i(0); i < 10; ++i)
926  samples[i] += shapeME.getBinContent(id, i + 1);
927  }
928 
929  if (nChannels == 0)
930  continue;
931 
932  for (int i(0); i < 10; ++i)
933  samples[i] /= nChannels;
934 
935  if (shape.find(logicID) == shape.end()) {
936  MonPulseShapeDat &insertion(shape[logicID]);
937  std::vector<float> defval(10, -1.);
938  insertion.setSamples(defval, 1);
939  insertion.setSamples(defval, 6);
940  insertion.setSamples(defval, 12);
941  }
942 
943  MonPulseShapeDat &data(shape[logicID]);
944  data.setSamples(samples, gain);
945  }
946  }
947 
948  for (std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
949  int gain(gainItr->first);
950  int iM(gainItr->second);
951 
952  static_cast<MESetMulti const &>(pnAmplitudeME).use(iM);
953  static_cast<MESetMulti const &>(pnQualityME).use(iM);
954 
955  for (unsigned iMD(0); iMD < memDCC.size(); ++iMD) {
956  unsigned iDCC(memDCC[iMD]);
957 
958  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
959 
960  for (unsigned iPN(1); iPN <= 10; ++iPN) {
961  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
962 
963  float entries(pnAmplitudeME.getBinEntries(pnid));
964  if (entries < 1.)
965  continue;
966 
967  float mean(pnAmplitudeME.getBinContent(pnid));
968  float rms(pnAmplitudeME.getBinError(pnid) * std::sqrt(entries));
969  float pedestalEntries(pnPedestalME.getBinEntries(pnid));
970  float pedestalMean(pnPedestalME.getBinContent(pnid));
971  float pedestalRms(pnPedestalME.getBinError(pnid) * std::sqrt(pedestalEntries));
972 
973  EcalLogicID logicID(lmPNID(pnid));
974  if (pnAmplitude.find(logicID) == pnAmplitude.end()) {
975  MonPNMGPADat &insertion(pnAmplitude[logicID]);
976  insertion.setADCMeanG1(-1.);
977  insertion.setADCRMSG1(-1.);
978  insertion.setPedMeanG1(-1.);
979  insertion.setPedRMSG1(-1.);
980  insertion.setADCMeanG16(-1.);
981  insertion.setADCRMSG16(-1.);
982  insertion.setPedMeanG16(-1.);
983  insertion.setPedRMSG16(-1.);
984  insertion.setTaskStatus(false);
985  }
986 
987  MonPNMGPADat &data(pnAmplitude[lmPNID(pnid)]);
988  switch (gain) {
989  case 1:
990  data.setADCMeanG1(mean);
991  data.setADCRMSG1(rms);
992  // dynamic pedestal not measured for G1
993  // data.setPedMeanG1(pedestalMean);
994  // data.setPedRMSG1(pedestalRms);
995  break;
996  case 16:
997  data.setADCMeanG16(mean);
998  data.setADCRMSG16(rms);
999  data.setPedMeanG16(pedestalMean);
1000  data.setPedRMSG16(pedestalRms);
1001  break;
1002  }
1003 
1004  int channelStatus(pnQualityME.getBinContent(pnid));
1005  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
1006  if (channelBad)
1007  data.setTaskStatus(true);
1008 
1009  result &= qualityOK(channelStatus);
1010  }
1011  }
1012  }
1013 
1014  try {
1015  if (!amplitude.empty())
1016  _db->insertDataArraySet(&amplitude, &_iov);
1017  if (!shape.empty())
1018  _db->insertDataSet(&shape, &_iov);
1019  if (!pnAmplitude.empty())
1020  _db->insertDataArraySet(&pnAmplitude, &_iov);
1021  } catch (std::runtime_error &e) {
1022  if (std::string(e.what()).find("unique constraint") != std::string::npos)
1023  edm::LogWarning("EcalDQM") << e.what();
1024  else
1025  throw cms::Exception("DBError") << e.what();
1026  }
1027 
1028  return result;
1029  }
1030 
1032  /*
1033  uses
1034  TimingTask.TimeMap (h01)
1035  TimingClient.Quality (meg01)
1036  */
1037 
1038  bool result(true);
1039 
1040  std::map<EcalLogicID, MonTimingCrystalDat> timing;
1041 
1042  MESet const &timingME(source_.at("Timing"));
1043  MESet const &qualityME(source_.at("Quality"));
1044 
1045  MESet::const_iterator tEnd(timingME.end());
1046  MESet::const_iterator qItr(qualityME);
1047  for (MESet::const_iterator tItr(timingME.beginChannel()); tItr != tEnd; tItr.toNextChannel()) {
1048  float entries(tItr->getBinEntries());
1049  if (entries < 1.)
1050  continue;
1051 
1052  qItr = tItr;
1053 
1054  float mean(tItr->getBinContent());
1055  float rms(tItr->getBinError() * std::sqrt(entries));
1056 
1057  MonTimingCrystalDat &data(timing[crystalID(tItr->getId())]);
1058  data.setTimingMean(mean);
1059  data.setTimingRMS(rms);
1060 
1061  int channelStatus(qItr->getBinContent());
1062  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
1063  data.setTaskStatus(channelBad);
1064 
1065  result &= qualityOK(channelStatus);
1066  }
1067 
1068  try {
1069  if (!timing.empty())
1070  _db->insertDataArraySet(&timing, &_iov);
1071  } catch (std::runtime_error &e) {
1072  if (std::string(e.what()).find("unique constraint") != std::string::npos)
1073  edm::LogWarning("EcalDQM") << e.what();
1074  else
1075  throw cms::Exception("DBError") << e.what();
1076  }
1077 
1078  return result;
1079  }
1080 
1081  LedWriter::LedWriter(edm::ParameterSet const &_ps) : DBWriterWorker("Led", _ps), wlToME_() {
1082  std::vector<int> ledWavelengths(_ps.getUntrackedParameter<std::vector<int>>("ledWavelengths"));
1083 
1084  // wavelengths are not necessarily ordered
1085  // create a map wl -> MESet index
1086  // using Amplitude here but any multi-wavelength plot is fine
1087 
1089 
1090  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
1091  unsigned nWL(ledWavelengths.size());
1092  for (unsigned iWL(0); iWL != nWL; ++iWL) {
1093  int wl(ledWavelengths[iWL]);
1094  if (wl != 1 && wl != 2)
1095  throw cms::Exception("InvalidConfiguration") << "Led Wavelength";
1096  repl["wl"] = std::to_string(wl);
1097  wlToME_[wl] = amplitude.getIndex(repl);
1098  }
1099  }
1100 
1102  /*
1103  uses
1104  LedTask.Amplitude (h01, h03)
1105  LedTask.AOverP (h02, h04)
1106  LedTask.Timing (h09, h10)
1107  LedClient.Quality (meg01, meg02)
1108  LedTask.PNAmplitude (i09, i10)
1109 x LedClient.PNQualitySummary (meg09, meg10)
1110 x PNDiodeTask.Pedestal (i13, i14)
1111  */
1112 
1113  bool result(true);
1114 
1115  std::map<EcalLogicID, MonLed1Dat> l1Amp;
1116  std::map<EcalLogicID, MonTimingLed1CrystalDat> l1Time;
1117  // std::map<EcalLogicID, MonPNLed1Dat> l1PN;
1118  std::map<EcalLogicID, MonLed2Dat> l2Amp;
1119  std::map<EcalLogicID, MonTimingLed2CrystalDat> l2Time;
1120  // std::map<EcalLogicID, MonPNLed2Dat> l2PN;
1121 
1122  MESet const &ampME(source_.at("Amplitude"));
1123  MESet const &aopME(source_.at("AOverP"));
1124  MESet const &timeME(source_.at("Timing"));
1125  MESet const &qualityME(source_.at("Quality"));
1126 
1127  // MESet const& pnME(source_.at("PNAmplitude"));
1128  // MESet const& pnQualityME(source_.at("PNQuality"));
1129  // MESet const& pnPedestalME(source_.at("PNPedestal"));
1130 
1131  for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
1132  int wl(wlItr->first);
1133  unsigned iM(wlItr->second);
1134 
1135  static_cast<MESetMulti const &>(ampME).use(iM);
1136  static_cast<MESetMulti const &>(aopME).use(iM);
1137  static_cast<MESetMulti const &>(timeME).use(iM);
1138  static_cast<MESetMulti const &>(qualityME).use(iM);
1139  // static_cast<MESetMulti const&>(pnME).use(iM);
1140  // static_cast<MESetMulti const&>(pnQualityME).use(iM);
1141 
1142  MESet::const_iterator aEnd(ampME.end());
1143  MESet::const_iterator qItr(qualityME);
1144  MESet::const_iterator oItr(aopME);
1145  MESet::const_iterator tItr(timeME);
1146  for (MESet::const_iterator aItr(ampME.beginChannel()); aItr != aEnd; aItr.toNextChannel()) {
1147  float aEntries(aItr->getBinEntries());
1148  if (aEntries < 1.)
1149  continue;
1150 
1151  qItr = aItr;
1152  oItr = aItr;
1153  tItr = aItr;
1154 
1155  DetId id(aItr->getId());
1156 
1157  float ampMean(aItr->getBinContent());
1158  float ampRms(aItr->getBinError() * std::sqrt(aEntries));
1159 
1160  float aopEntries(oItr->getBinEntries());
1161  float aopMean(oItr->getBinContent());
1162  float aopRms(oItr->getBinError() * std::sqrt(aopEntries));
1163 
1164  float timeEntries(tItr->getBinEntries());
1165  float timeMean(tItr->getBinContent());
1166  float timeRms(tItr->getBinError() * std::sqrt(timeEntries));
1167 
1168  int channelStatus(qItr->getBinContent());
1169  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
1170 
1171  EcalLogicID logicID(crystalID(id));
1172 
1173  switch (wl) {
1174  case 1: {
1175  MonLed1Dat &aData(l1Amp[logicID]);
1176  aData.setVPTMean(ampMean);
1177  aData.setVPTRMS(ampRms);
1178  aData.setVPTOverPNMean(aopMean);
1179  aData.setVPTOverPNRMS(aopRms);
1180  aData.setTaskStatus(channelBad);
1181 
1182  MonTimingLed1CrystalDat &tData(l1Time[logicID]);
1183  tData.setTimingMean(timeMean);
1184  tData.setTimingRMS(timeRms);
1185  tData.setTaskStatus(channelBad);
1186  } break;
1187  case 2: {
1188  MonLed2Dat &aData(l2Amp[logicID]);
1189  aData.setVPTMean(ampMean);
1190  aData.setVPTRMS(ampRms);
1191  aData.setVPTOverPNMean(aopMean);
1192  aData.setVPTOverPNRMS(aopRms);
1193  aData.setTaskStatus(channelBad);
1194 
1195  MonTimingLed2CrystalDat &tData(l2Time[logicID]);
1196  tData.setTimingMean(timeMean);
1197  tData.setTimingRMS(timeRms);
1198  tData.setTaskStatus(channelBad);
1199  } break;
1200  }
1201  result &= qualityOK(channelStatus);
1202  }
1203 
1204  // for(unsigned iMD(0); iMD < memDCC.size(); ++iMD){
1205  // unsigned iDCC(memDCC[iMD]);
1206 
1207  // if(iDCC >= kEBmLow && iDCC <= kEBpHigh) continue;
1208 
1209  // for(unsigned iPN(1); iPN <= 10; ++iPN){
1210  // EcalPnDiodeDetId pnid(EcalEndcap, iDCC + 1, iPN);
1211 
1212  // float entries(pnME.getBinEntries(pnid));
1213  // if(entries < 1.) continue;
1214 
1215  // float mean(pnME.getBinContent(pnid));
1216  // float rms(pnME.getBinError(pnid) * std::sqrt(entries));
1217 
1218  // float pedestalEntries(pnPedestalME.getBinEntries(pnid));
1219  // float pedestalMean(pnPedestalME.getBinContent(pnid));
1220  // float pedestalRms(pnPedestalME.getBinError(pnid) *
1221  // std::sqrt(pedestalEntries));
1222 
1223  // int channelStatus(pnQualityME.getBinContent(pnid));
1224  // bool channelBad(channelStatus == kBad || channelStatus ==
1225  // kMBad);
1226 
1227  // switch(wl){
1228  // case 1:
1229  // {
1230  // MonPNLed1Dat& data(l1PN[lmPNID(pnid)]);
1231  // data.setADCMeanG1(-1.);
1232  // data.setADCRMSG1(-1.);
1233  // data.setPedMeanG1(-1.);
1234  // data.setPedRMSG1(-1.);
1235  // data.setADCMeanG16(mean);
1236  // data.setADCRMSG16(rms);
1237  // data.setPedMeanG16(pedestalMean);
1238  // data.setPedRMSG16(pedestalRms);
1239  // data.setTaskStatus(channelBad);
1240  // }
1241  // break;
1242  // case 2:
1243  // {
1244  // MonPNLed2Dat& data(l2PN[lmPNID(pnid)]);
1245  // data.setADCMeanG1(-1.);
1246  // data.setADCRMSG1(-1.);
1247  // data.setPedMeanG1(-1.);
1248  // data.setPedRMSG1(-1.);
1249  // data.setADCMeanG16(mean);
1250  // data.setADCRMSG16(rms);
1251  // data.setPedMeanG16(pedestalMean);
1252  // data.setPedRMSG16(pedestalRms);
1253  // data.setTaskStatus(channelBad);
1254  // }
1255  // break;
1256  // }
1257 
1258  // result &= qualityOK(channelStatus);
1259 
1260  // }
1261  // }
1262  }
1263 
1264  try {
1265  if (!l1Amp.empty())
1266  _db->insertDataArraySet(&l1Amp, &_iov);
1267  if (!l1Time.empty())
1268  _db->insertDataArraySet(&l1Time, &_iov);
1269  // if(l1PN.size() > 0)
1270  // _db->insertDataArraySet(&l1PN, &_iov);
1271  if (!l2Amp.empty())
1272  _db->insertDataArraySet(&l2Amp, &_iov);
1273  if (!l2Time.empty())
1274  _db->insertDataArraySet(&l2Time, &_iov);
1275  // if(l2PN.size() > 0)
1276  // _db->insertDataArraySet(&l2PN, &_iov);
1277  } catch (std::runtime_error &e) {
1278  if (std::string(e.what()).find("unique constraint") != std::string::npos)
1279  edm::LogWarning("EcalDQM") << e.what();
1280  else
1281  throw cms::Exception("DBError") << e.what();
1282  }
1283 
1284  return result;
1285  }
1286 
1288  /*
1289  uses
1290  OccupancyTask.Digi (i01)
1291  EnergyTask.HitMap (i02)
1292  */
1293  std::map<EcalLogicID, MonOccupancyDat> occupancy;
1294 
1295  MESet const &occupancyME(source_.at("Occupancy"));
1296  MESet const &energyME(source_.at("Energy"));
1297 
1298  MESet::const_iterator oEnd(occupancyME.end());
1299  MESet::const_iterator eItr(energyME);
1300  for (MESet::const_iterator oItr(occupancyME.beginChannel()); oItr != oEnd; oItr.toNextChannel()) {
1301  if (oItr->getME()->getTH1()->GetEntries() < 1000.)
1302  continue;
1303 
1304  int entries(oItr->getBinContent());
1305  if (entries < 10)
1306  continue;
1307 
1308  eItr = oItr;
1309 
1310  int eEntries(eItr->getBinEntries());
1311  float energy(eEntries > 10 ? eItr->getBinContent() : -1.);
1312 
1313  MonOccupancyDat &data(occupancy[crystalID(oItr->getId())]);
1314  data.setEventsOverLowThreshold(entries);
1315  data.setEventsOverHighThreshold(eEntries);
1316  data.setAvgEnergy(energy);
1317  }
1318 
1319  try {
1320  if (!occupancy.empty())
1321  _db->insertDataArraySet(&occupancy, &_iov);
1322  } catch (std::runtime_error &e) {
1323  if (std::string(e.what()).find("unique constraint") != std::string::npos)
1324  edm::LogWarning("EcalDQM") << e.what();
1325  else
1326  throw cms::Exception("DBError") << e.what();
1327  }
1328 
1329  return true;
1330  }
1331 
1333  std::map<EcalLogicID, MonRunDat> dataset;
1334  MonRunDat &runDat(dataset[ecalID()]);
1335 
1336  // CURRENTLY ONLY WRITING SUCCESS
1337  MonRunOutcomeDef outcomeDef;
1338  outcomeDef.setShortDesc("success");
1339 
1340  runDat.setNumEvents(processedEvents_);
1341  runDat.setMonRunOutcomeDef(outcomeDef);
1342  runDat.setTaskList(taskList_);
1343  runDat.setTaskOutcome(outcome_);
1344 
1345  try {
1346  _db->insertDataSet(&dataset, &_iov);
1347  } catch (std::runtime_error &e) {
1348  if (std::string(e.what()).find("unique constraint") != std::string::npos)
1349  edm::LogWarning("EcalDQM") << e.what();
1350  else
1351  throw cms::Exception("DBError") << e.what();
1352  }
1353 
1354  return true;
1355  }
1356 } // namespace ecaldqm
std::vector< unsigned > const memDCC
void setADCMeanG1(float mean)
Definition: MonPNBlueDat.h:21
T getUntrackedParameter(std::string const &, T const &) const
void setPedMeanG1(float mean)
void setTaskList(int list)
Definition: MonRunDat.h:30
void setADCRMSG16(float mean)
Definition: MonPNIRedDat.h:30
void setPedRMSG16(float mean)
Definition: MonPNIRedDat.h:42
void setPedRMSG1(float mean)
Definition: MonPNMGPADat.h:36
void setNumEvents(int num)
Definition: MonRunDat.h:21
bool run(EcalCondDBInterface *, MonRunIOV &) override
PedestalWriter(edm::ParameterSet const &)
void setMonRunOutcomeDef(const MonRunOutcomeDef &outcomeDef)
Definition: MonRunDat.h:24
DBWriterWorker(std::string const &, edm::ParameterSet const &)
void setProblematicEvents(int prob)
void setADCRMSG16(float mean)
Definition: MonPNBlueDat.h:30
void setADCRMSG1(float rms)
void setADCMeanG16(float mean)
Definition: MonPNBlueDat.h:27
void setAvgEnergy(float energy)
void setAPDOverPNRMS(float rms)
void setEventsOverLowThreshold(int events)
void setAPDOverPNMean(float mean)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
void setPedRMSG16(float mean)
Definition: MonPNPedDat.h:30
std::map< int, unsigned > wlToME_
void setAPDMean(float mean)
void setADCMeanG16(float mean)
Definition: MonPNIRedDat.h:27
void setADCMeanG1(float mean)
Definition: MonPNRedDat.h:21
EcalElectronicsMapping const * getElectronicsMap()
double getBinEntries() const
Definition: MESet.h:177
void setProblemsLV1(int LV1)
void setADCRMSG1(float mean)
Definition: MonPNRedDat.h:24
void setTaskStatus(bool status)
Definition: MonPNRedDat.h:45
std::map< int, unsigned > gainToME_
void setVPTOverPNMean(float mean)
Definition: MonLed2Dat.h:27
void setADCMeanG1(float mean)
void setADCRMSG1(float mean)
Definition: MonPNGreenDat.h:24
bool run(EcalCondDBInterface *, MonRunIOV &) override
std::string const name_
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void setADCMeanG6(float mean)
bool ccuExists(unsigned, unsigned)
void setSamples(std::vector< float > &samples, int gain) noexcept(false)
void setPedRMSG1(float mean)
Definition: MonPNPedDat.h:24
void setTaskStatus(bool status)
Definition: MonPNMGPADat.h:45
void setPedRMSG16(float mean)
Definition: MonPNBlueDat.h:42
void setTimingMean(float mean)
Definition: ITimingDat.h:45
void setPedMeanG1(float mean)
Definition: MonPNPedDat.h:21
void setProblemsSize(int size)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void setTaskStatus(bool status)
Definition: MonPNBlueDat.h:45
bool run(EcalCondDBInterface *, MonRunIOV &) override
void setPedRMSG6(float rms)
bool run(EcalCondDBInterface *, MonRunIOV &) override
void setShortDesc(std::string desc)
void setTaskStatus(bool status)
void setProcessedEvents(int proc)
void setVPTMean(float mean)
Definition: MonLed2Dat.h:21
void setADCMeanG12(float mean)
void setVPTOverPNRMS(float rms)
Definition: MonLed2Dat.h:30
void setVPTOverPNMean(float mean)
Definition: MonLed1Dat.h:27
LedWriter(edm::ParameterSet const &)
void setADCMeanG1(float mean)
Definition: MonPNIRedDat.h:21
LaserWriter(edm::ParameterSet const &)
void setADCMeanG16(float mean)
Definition: MonPNMGPADat.h:27
void setTaskStatus(bool status)
void setAPDMean(float mean)
T sqrt(T t)
Definition: SSEVec.h:18
void setTaskStatus(bool status)
void setTaskStatus(bool status)
Definition: MonLed1Dat.h:33
MESetCollection source_
void setPedMeanG6(float mean)
void setTaskStatus(bool status)
Definition: MonLed2Dat.h:33
bool run(EcalCondDBInterface *, MonRunIOV &) override
void setVPTRMS(float rms)
Definition: MonLed2Dat.h:24
double getBinError() const
Definition: MESet.h:171
void setPedMeanG1(float mean)
Definition: MonPNBlueDat.h:33
void setAPDMean(float mean)
void setTaskStatus(bool status)
Definition: MonPNGreenDat.h:45
bool run(EcalCondDBInterface *, MonRunIOV &) override
void setPedRMSG1(float mean)
Definition: MonPNGreenDat.h:36
void setPedRMSG1(float mean)
Definition: MonPNBlueDat.h:36
void setADCRMSG12(float rms)
void setPedRMSG1(float mean)
Definition: MonPNRedDat.h:36
void setPedMeanG16(float mean)
Definition: MonPNPedDat.h:27
EcalLogicID memChannelID(EcalPnDiodeDetId const &)
void setTaskOutcome(int outcome)
Definition: MonRunDat.h:33
void setProblemsBunchX(int bunchX)
void setADCMeanG1(float mean)
Definition: MonPNGreenDat.h:21
void setADCRMSG1(float mean)
Definition: MonPNIRedDat.h:24
void setPedRMSG1(float mean)
Definition: MonPNIRedDat.h:36
void setADCRMSG1(float mean)
Definition: MonPNBlueDat.h:24
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
void setTaskStatus(bool status)
std::map< int, unsigned > pnGainToME_
void setAPDRMS(float rms)
void setPedRMSG16(float mean)
Definition: MonPNRedDat.h:42
EcalLogicID ecalID()
void setADCRMSG16(float mean)
Definition: MonPNGreenDat.h:30
void setAPDOverPNRMS(float rms)
void setAPDRMS(float rms)
std::map< int, unsigned > pnGainToME_
Definition: DetId.h:18
void setTaskStatus(bool status)
Definition: ITimingDat.h:51
void setPedRMSG1(float rms)
void setAPDOverPNRMS(float rms)
void setVPTRMS(float rms)
Definition: MonLed1Dat.h:24
bool qualityOK(int _quality)
void setTaskStatus(bool status)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
bool run(EcalCondDBInterface *, MonRunIOV &) override
void setAPDOverPNMean(float mean)
void setTimingRMS(float rms)
Definition: ITimingDat.h:48
void setADCMeanG16(float mean)
Definition: MonPNRedDat.h:27
bool run(EcalCondDBInterface *, MonRunIOV &) override
void setADCRMSG6(float rms)
void setADCMeanG16(float mean)
Definition: MonPNGreenDat.h:27
void setTaskStatus(bool status)
void setPedMeanG16(float mean)
Definition: MonPNRedDat.h:39
void setPedMeanG16(float mean)
Definition: MonPNMGPADat.h:39
void setAPDOverPNRMS(float rms)
double getBinContent() const
Definition: MESet.h:165
void retrieveSource(DQMStore::IGetter &)
void setTaskStatus(bool status)
std::map< int, unsigned > gainToME_
void setPedMeanG1(float mean)
Definition: MonPNGreenDat.h:33
void setTaskStatus(bool status)
void setAPDOverPNMean(float mean)
void setAPDRMS(float rms)
void setPedMeanG16(float mean)
Definition: MonPNBlueDat.h:39
void setEventsOverHighThreshold(int events)
void setTaskStatus(bool status)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void setADCRMSG1(float mean)
Definition: MonPNMGPADat.h:24
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
void setPedMeanG1(float mean)
Definition: MonPNIRedDat.h:33
void setPedRMSG16(float mean)
Definition: MonPNGreenDat.h:42
void setPedMeanG12(float mean)
void setADCMeanG1(float mean)
Definition: MonPNMGPADat.h:21
void setTaskStatus(bool status)
Definition: MonPNPedDat.h:33
EcalLogicID towerID(EcalElectronicsId const &)
TestPulseWriter(edm::ParameterSet const &)
void setVPTMean(float mean)
Definition: MonLed1Dat.h:21
const_iterator & toNextChannel()
Definition: MESet.cc:424
void setPedMeanG16(float mean)
Definition: MonPNIRedDat.h:39
void setTaskStatus(bool status)
Definition: MonPNIRedDat.h:45
void setAPDMean(float mean)
std::map< int, unsigned > wlToME_
void setVPTOverPNRMS(float rms)
Definition: MonLed1Dat.h:30
void setADCRMSG16(float mean)
Definition: MonPNMGPADat.h:30
std::set< std::string > runTypes_
void setADCRMSG16(float mean)
Definition: MonPNRedDat.h:30
void setAPDOverPNMean(float mean)
EcalLogicID memTowerID(EcalElectronicsId const &)
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:30
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:17
bool run(EcalCondDBInterface *, MonRunIOV &) override
void setPedMeanG1(float mean)
Definition: MonPNMGPADat.h:33
void setPedMeanG1(float mean)
Definition: MonPNRedDat.h:33
EcalLogicID crystalID(DetId const &)
void setPedRMSG16(float mean)
Definition: MonPNMGPADat.h:42
void setAPDRMS(float rms)
unsigned getIndex(PathReplacements const &) const
Definition: MESetMulti.cc:137
void setPedMeanG16(float mean)
Definition: MonPNGreenDat.h:39
void setPedRMSG12(float rms)