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