CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ecaldqm::LaserWriter Class Reference

#include <DBWriterWorkers.h>

Inheritance diagram for ecaldqm::LaserWriter:
ecaldqm::DBWriterWorker

Public Member Functions

 LaserWriter (edm::ParameterSet const &)
 
bool run (EcalCondDBInterface *, MonRunIOV &) override
 
 ~LaserWriter () override
 
- Public Member Functions inherited from ecaldqm::DBWriterWorker
 DBWriterWorker (std::string const &, edm::ParameterSet const &)
 
const std::string & getName () const
 
bool isActive () const
 
void retrieveSource (DQMStore::IGetter &)
 
bool runsOn (std::string const &_runType) const
 
void setVerbosity (int _v)
 
virtual ~DBWriterWorker ()
 

Private Attributes

std::map< int, unsigned > wlToME_
 

Additional Inherited Members

- Public Types inherited from ecaldqm::DBWriterWorker
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Protected Attributes inherited from ecaldqm::DBWriterWorker
bool active_
 
const std::string name_
 
std::set< std::string > runTypes_
 
MESetCollection source_
 
int verbosity_
 

Detailed Description

Definition at line 49 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

◆ LaserWriter()

ecaldqm::LaserWriter::LaserWriter ( edm::ParameterSet const &  _ps)

Definition at line 304 of file DBWriterWorkers.cc.

304  : DBWriterWorker("Laser", _ps), wlToME_() {
305  std::vector<int> laserWavelengths(_ps.getUntrackedParameter<std::vector<int>>("laserWavelengths"));
306 
307  // wavelengths are not necessarily ordered
308  // create a map wl -> MESet index
309  // using Amplitude here but any multi-wavelength plot is fine
310 
312 
313  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
314  unsigned nWL(laserWavelengths.size());
315  for (unsigned iWL(0); iWL != nWL; ++iWL) {
316  int wl(laserWavelengths[iWL]);
317  if (wl <= 0 || wl >= 5)
318  throw cms::Exception("InvalidConfiguration") << "Laser Wavelength";
319  repl["wl"] = std::to_string(wl);
320  wlToME_[wl] = amplitude.getIndex(repl);
321  }
322  }

References CustomPhysics_cfi::amplitude, ecaldqm::MESetCollection::at(), Exception, edm::ParameterSet::getUntrackedParameter(), CalibrationSummaryClient_cfi::laserWavelengths, ecaldqm::DBWriterWorker::source_, LaserClient_cfi::wl, and wlToME_.

◆ ~LaserWriter()

ecaldqm::LaserWriter::~LaserWriter ( )
inlineoverride

Definition at line 52 of file DBWriterWorkers.h.

52 {}

Member Function Documentation

◆ run()

bool ecaldqm::LaserWriter::run ( EcalCondDBInterface _db,
MonRunIOV _iov 
)
overridevirtual

Implements ecaldqm::DBWriterWorker.

Definition at line 324 of file DBWriterWorkers.cc.

324  {
325  /*
326  uses
327  LaserTask.Amplitude (h01, h03, h05, h07)
328  LaserTask.AOverP (h02, h04, h06, h08)
329  LaserTask.Timing (h09, h10, h11, h12)
330  LaserClient.Quality (meg01, meg02, meg03, meg04)
331  LaserTask.PNAmplitude (i09, i10, i11, i12)
332  LaserClient.PNQualitySummary (meg09, meg10, meg11, meg12)
333  PNDiodeTask.Pedestal (i13, i14, i15, i16)
334  */
335 
336  bool result(true);
337 
338  std::map<EcalLogicID, MonLaserBlueDat> l1Amp;
339  std::map<EcalLogicID, MonTimingLaserBlueCrystalDat> l1Time;
340  std::map<EcalLogicID, MonPNBlueDat> l1PN;
341  std::map<EcalLogicID, MonLaserGreenDat> l2Amp;
342  std::map<EcalLogicID, MonTimingLaserGreenCrystalDat> l2Time;
343  std::map<EcalLogicID, MonPNGreenDat> l2PN;
344  std::map<EcalLogicID, MonLaserIRedDat> l3Amp;
345  std::map<EcalLogicID, MonTimingLaserIRedCrystalDat> l3Time;
346  std::map<EcalLogicID, MonPNIRedDat> l3PN;
347  std::map<EcalLogicID, MonLaserRedDat> l4Amp;
348  std::map<EcalLogicID, MonTimingLaserRedCrystalDat> l4Time;
349  std::map<EcalLogicID, MonPNRedDat> l4PN;
350 
351  MESet const &ampME(source_.at("Amplitude"));
352  MESet const &aopME(source_.at("AOverP"));
353  MESet const &timeME(source_.at("Timing"));
354  MESet const &qualityME(source_.at("Quality"));
355 
356  MESet const &pnME(source_.at("PNAmplitude"));
357  MESet const &pnQualityME(source_.at("PNQuality"));
358  MESet const &pnPedestalME(source_.at("PNPedestal"));
359 
360  for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
361  int wl(wlItr->first);
362  unsigned iM(wlItr->second);
363 
364  static_cast<MESetMulti const &>(ampME).use(iM);
365  static_cast<MESetMulti const &>(aopME).use(iM);
366  static_cast<MESetMulti const &>(timeME).use(iM);
367  static_cast<MESetMulti const &>(qualityME).use(iM);
368  static_cast<MESetMulti const &>(pnME).use(iM);
369  static_cast<MESetMulti const &>(pnQualityME).use(iM);
370 
371  MESet::const_iterator aEnd(ampME.end());
372  MESet::const_iterator qItr(qualityME);
373  MESet::const_iterator oItr(aopME);
374  MESet::const_iterator tItr(timeME);
375  for (MESet::const_iterator aItr(ampME.beginChannel()); aItr != aEnd; aItr.toNextChannel()) {
376  float aEntries(aItr->getBinEntries());
377  if (aEntries < 1.)
378  continue;
379 
380  qItr = aItr;
381  oItr = aItr;
382  tItr = aItr;
383 
384  DetId id(aItr->getId());
385 
386  float ampMean(aItr->getBinContent());
387  float ampRms(aItr->getBinError() * std::sqrt(aEntries));
388 
389  float aopEntries(oItr->getBinEntries());
390  float aopMean(oItr->getBinContent());
391  float aopRms(oItr->getBinError() * std::sqrt(aopEntries));
392 
393  float timeEntries(tItr->getBinEntries());
394  float timeMean(tItr->getBinContent());
395  float timeRms(tItr->getBinError() * std::sqrt(timeEntries));
396 
397  int channelStatus(qItr->getBinContent());
398  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
399 
400  EcalLogicID logicID(crystalID(id));
401 
402  switch (wl) {
403  case 1: {
404  MonLaserBlueDat &aData(l1Amp[logicID]);
405  aData.setAPDMean(ampMean);
406  aData.setAPDRMS(ampRms);
407  aData.setAPDOverPNMean(aopMean);
408  aData.setAPDOverPNRMS(aopRms);
409  aData.setTaskStatus(channelBad);
410 
411  MonTimingLaserBlueCrystalDat &tData(l1Time[logicID]);
412  tData.setTimingMean(timeMean);
413  tData.setTimingRMS(timeRms);
414  tData.setTaskStatus(channelBad);
415  } break;
416  case 2: {
417  MonLaserGreenDat &aData(l2Amp[logicID]);
418  aData.setAPDMean(ampMean);
419  aData.setAPDRMS(ampRms);
420  aData.setAPDOverPNMean(aopMean);
421  aData.setAPDOverPNRMS(aopRms);
422  aData.setTaskStatus(channelBad);
423 
424  MonTimingLaserGreenCrystalDat &tData(l2Time[logicID]);
425  tData.setTimingMean(timeMean);
426  tData.setTimingRMS(timeRms);
427  tData.setTaskStatus(channelBad);
428  } break;
429  case 3: {
430  MonLaserIRedDat &aData(l3Amp[logicID]);
431  aData.setAPDMean(ampMean);
432  aData.setAPDRMS(ampRms);
433  aData.setAPDOverPNMean(aopMean);
434  aData.setAPDOverPNRMS(aopRms);
435  aData.setTaskStatus(channelBad);
436 
437  MonTimingLaserIRedCrystalDat &tData(l3Time[logicID]);
438  tData.setTimingMean(timeMean);
439  tData.setTimingRMS(timeRms);
440  tData.setTaskStatus(channelBad);
441  } break;
442  case 4: {
443  MonLaserRedDat &aData(l4Amp[logicID]);
444  aData.setAPDMean(ampMean);
445  aData.setAPDRMS(ampRms);
446  aData.setAPDOverPNMean(aopMean);
447  aData.setAPDOverPNRMS(aopRms);
448  aData.setTaskStatus(channelBad);
449 
450  MonTimingLaserRedCrystalDat &tData(l4Time[logicID]);
451  tData.setTimingMean(timeMean);
452  tData.setTimingRMS(timeRms);
453  tData.setTaskStatus(channelBad);
454  } break;
455  }
456  result &= qualityOK(channelStatus);
457  }
458 
459  for (unsigned iMD(0); iMD < memDCC.size(); ++iMD) {
460  unsigned iDCC(memDCC[iMD]);
461 
462  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
463 
464  for (unsigned iPN(1); iPN <= 10; ++iPN) {
465  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
466 
467  float entries(pnME.getBinEntries(pnid));
468  if (entries < 1.)
469  continue;
470 
471  float mean(pnME.getBinContent(pnid));
472  float rms(pnME.getBinError(pnid) * std::sqrt(entries));
473 
474  float pedestalEntries(pnPedestalME.getBinEntries(pnid));
475  float pedestalMean(pnPedestalME.getBinContent(pnid));
476  float pedestalRms(pnPedestalME.getBinError(pnid) * std::sqrt(pedestalEntries));
477 
478  int channelStatus(pnQualityME.getBinContent(pnid));
479  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
480 
481  switch (wl) {
482  case 1: {
483  MonPNBlueDat &data(l1PN[lmPNID(pnid)]);
484  data.setADCMeanG1(-1.);
485  data.setADCRMSG1(-1.);
486  data.setPedMeanG1(-1.);
487  data.setPedRMSG1(-1.);
488  data.setADCMeanG16(mean);
489  data.setADCRMSG16(rms);
490  data.setPedMeanG16(pedestalMean);
491  data.setPedRMSG16(pedestalRms);
492  data.setTaskStatus(channelBad);
493  } break;
494  case 2: {
495  MonPNGreenDat &data(l2PN[lmPNID(pnid)]);
496  data.setADCMeanG1(-1.);
497  data.setADCRMSG1(-1.);
498  data.setPedMeanG1(-1.);
499  data.setPedRMSG1(-1.);
500  data.setADCMeanG16(mean);
501  data.setADCRMSG16(rms);
502  data.setPedMeanG16(pedestalMean);
503  data.setPedRMSG16(pedestalRms);
504  data.setTaskStatus(channelBad);
505  } break;
506  case 3: {
507  MonPNIRedDat &data(l3PN[lmPNID(pnid)]);
508  data.setADCMeanG1(-1.);
509  data.setADCRMSG1(-1.);
510  data.setPedMeanG1(-1.);
511  data.setPedRMSG1(-1.);
512  data.setADCMeanG16(mean);
513  data.setADCRMSG16(rms);
514  data.setPedMeanG16(pedestalMean);
515  data.setPedRMSG16(pedestalRms);
516  data.setTaskStatus(channelBad);
517  } break;
518  case 4: {
519  MonPNRedDat &data(l4PN[lmPNID(pnid)]);
520  data.setADCMeanG1(-1.);
521  data.setADCRMSG1(-1.);
522  data.setPedMeanG1(-1.);
523  data.setPedRMSG1(-1.);
524  data.setADCMeanG16(mean);
525  data.setADCRMSG16(rms);
526  data.setPedMeanG16(pedestalMean);
527  data.setPedRMSG16(pedestalRms);
528  data.setTaskStatus(channelBad);
529  } break;
530  }
531 
532  result &= qualityOK(channelStatus);
533  }
534  }
535  }
536 
537  try {
538  if (!l1Amp.empty())
539  _db->insertDataArraySet(&l1Amp, &_iov);
540  if (!l1Time.empty())
541  _db->insertDataArraySet(&l1Time, &_iov);
542  if (!l1PN.empty())
543  _db->insertDataArraySet(&l1PN, &_iov);
544  if (!l2Amp.empty())
545  _db->insertDataArraySet(&l2Amp, &_iov);
546  if (!l2Time.empty())
547  _db->insertDataArraySet(&l2Time, &_iov);
548  if (!l2PN.empty())
549  _db->insertDataArraySet(&l2PN, &_iov);
550  if (!l3Amp.empty())
551  _db->insertDataArraySet(&l3Amp, &_iov);
552  if (!l3Time.empty())
553  _db->insertDataArraySet(&l3Time, &_iov);
554  if (!l3PN.empty())
555  _db->insertDataArraySet(&l3PN, &_iov);
556  if (!l4Amp.empty())
557  _db->insertDataArraySet(&l4Amp, &_iov);
558  if (!l4Time.empty())
559  _db->insertDataArraySet(&l4Time, &_iov);
560  if (!l4PN.empty())
561  _db->insertDataArraySet(&l4PN, &_iov);
562  } catch (std::runtime_error &e) {
563  if (std::string(e.what()).find("unique constraint") != std::string::npos)
564  edm::LogWarning("EcalDQM") << e.what();
565  else
566  throw cms::Exception("DBError") << e.what();
567  }
568 
569  return result;
570  }

References ecaldqm::MESetCollection::at(), ecaldqm::crystalID(), data, MillePedeFileConverter_cfg::e, EcalBarrel, EcalEndcap, Exception, spr::find(), ecaldqm::MESet::ConstBin::getBinContent(), ecaldqm::MESet::ConstBin::getBinEntries(), ecaldqm::MESet::ConstBin::getBinError(), triggerObjects_cff::id, EcalCondDBInterface::insertDataArraySet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), SiStripPI::mean, ecaldqm::memDCC, ecaldqm::qualityOK(), mps_fire::result, SiStripPI::rms, MonLaserRedDat::setAPDMean(), MonLaserGreenDat::setAPDMean(), MonLaserIRedDat::setAPDMean(), MonLaserBlueDat::setAPDMean(), MonLaserIRedDat::setAPDOverPNMean(), MonLaserBlueDat::setAPDOverPNMean(), MonLaserRedDat::setAPDOverPNMean(), MonLaserGreenDat::setAPDOverPNMean(), MonLaserIRedDat::setAPDOverPNRMS(), MonLaserRedDat::setAPDOverPNRMS(), MonLaserBlueDat::setAPDOverPNRMS(), MonLaserGreenDat::setAPDOverPNRMS(), MonLaserBlueDat::setAPDRMS(), MonLaserRedDat::setAPDRMS(), MonLaserGreenDat::setAPDRMS(), MonLaserIRedDat::setAPDRMS(), MonLaserIRedDat::setTaskStatus(), MonLaserBlueDat::setTaskStatus(), MonLaserGreenDat::setTaskStatus(), MonLaserRedDat::setTaskStatus(), ITimingDat::setTaskStatus(), ITimingDat::setTimingMean(), ITimingDat::setTimingRMS(), ecaldqm::DBWriterWorker::source_, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, ecaldqm::MESet::const_iterator::toNextChannel(), LaserClient_cfi::wl, and wlToME_.

Referenced by Types.EventID::cppID(), and Types.LuminosityBlockID::cppID().

Member Data Documentation

◆ wlToME_

std::map<int, unsigned> ecaldqm::LaserWriter::wlToME_
private

Definition at line 57 of file DBWriterWorkers.h.

Referenced by LaserWriter(), and run().

CustomPhysics_cfi.amplitude
amplitude
Definition: CustomPhysics_cfi.py:12
EcalCondDBInterface::insertDataArraySet
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
Definition: EcalCondDBInterface.h:298
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
MonPNBlueDat
Definition: MonPNBlueDat.h:12
MonTimingLaserIRedCrystalDat
Definition: MonTimingLaserIRedCrystalDat.h:6
MonLaserBlueDat
Definition: MonLaserBlueDat.h:12
MonTimingLaserGreenCrystalDat
Definition: MonTimingLaserGreenCrystalDat.h:6
LaserClient_cfi.wl
wl
Definition: LaserClient_cfi.py:46
ecaldqm::LaserWriter::wlToME_
std::map< int, unsigned > wlToME_
Definition: DBWriterWorkers.h:57
ecaldqm::MESet::PathReplacements
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:31
MonLaserRedDat
Definition: MonLaserRedDat.h:12
EcalPnDiodeDetId
Definition: EcalPnDiodeDetId.h:22
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
EcalBarrel
Definition: EcalSubdetector.h:10
MonTimingLaserBlueCrystalDat
Definition: MonTimingLaserBlueCrystalDat.h:6
DetId
Definition: DetId.h:17
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
EcalLogicID
Definition: EcalLogicID.h:7
ecaldqm::kBad
Definition: DBWriterWorkers.cc:55
MonPNIRedDat
Definition: MonPNIRedDat.h:12
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
CalibrationSummaryClient_cfi.laserWavelengths
laserWavelengths
Definition: CalibrationSummaryClient_cfi.py:15
ecaldqm::kMBad
Definition: DBWriterWorkers.cc:55
ecaldqm::MESetCollection::at
MESet & at(const std::string &key)
Definition: MESet.h:362
MonTimingLaserRedCrystalDat
Definition: MonTimingLaserRedCrystalDat.h:6
ecaldqm::qualityOK
bool qualityOK(int _quality)
Definition: DBWriterWorkers.cc:57
MonLaserGreenDat
Definition: MonLaserGreenDat.h:12
MonPNRedDat
Definition: MonPNRedDat.h:12
ecaldqm::memDCC
const std::vector< unsigned > memDCC
MonLaserIRedDat
Definition: MonLaserIRedDat.h:12
ecaldqm::DBWriterWorker::DBWriterWorker
DBWriterWorker(std::string const &, edm::ParameterSet const &)
Definition: DBWriterWorkers.cc:59
ecaldqm::lmPNID
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
Definition: LogicIDTranslation.cc:71
ecaldqm::crystalID
EcalLogicID crystalID(DetId const &)
Definition: LogicIDTranslation.cc:21
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ecaldqm::kEEpLow
Definition: EcalDQMCommonUtils.h:83
Exception
Definition: hltDiff.cc:246
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
mps_fire.result
result
Definition: mps_fire.py:311
ecaldqm::DBWriterWorker::source_
MESetCollection source_
Definition: DBWriterWorkers.h:36
edm::Log
Definition: MessageLogger.h:70
MonPNGreenDat
Definition: MonPNGreenDat.h:12
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37