CMS 3D CMS Logo

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