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 ecaldqm::DQWorker

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 &)
 
std::string const & getName () const
 
bool isActive () const
 
void retrieveSource (DQMStore::IGetter &)
 
bool runsOn (std::string const &_runType) const
 
void setVerbosity (int _v)
 
 ~DBWriterWorker () override
 
- Public Member Functions inherited from ecaldqm::DQWorker
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
virtual void bookMEs (DQMStore::IBooker &)
 
bool checkElectronicsMap (bool=true)
 
bool checkGeometry (bool=true)
 
bool checkTopology (bool=true)
 
bool checkTrigTowerMap (bool=true)
 
 DQWorker ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
EcalDQMSetupObjects const getEcalDQMSetupObjects ()
 
EcalElectronicsMapping const * GetElectronicsMap ()
 
CaloGeometry const * GetGeometry ()
 
std::string const & getName () const
 
CaloTopology const * GetTopology ()
 
EcalTrigTowerConstituentsMap const * GetTrigTowerMap ()
 
bool onlineMode () const
 
virtual void releaseMEs ()
 
void setEventNumber (edm::EventNumber_t _e)
 
void setLumiNumber (edm::LuminosityBlockNumber_t _l)
 
void setRunNumber (edm::RunNumber_t _r)
 
void setSetupObjects (edm::EventSetup const &)
 
void setSetupObjectsEndLumi (edm::EventSetup const &)
 
void setTime (time_t _t)
 
void setTokens (edm::ConsumesCollector &)
 
virtual ~DQWorker () noexcept(false)
 

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
 
- Static Public Member Functions inherited from ecaldqm::DQWorker
static void fillDescriptions (edm::ParameterSetDescription &_desc)
 
- Public Attributes inherited from ecaldqm::DQWorker
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcdelecMapHandle
 
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcdelecMapHandleEndLumi
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeomHandle
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeomHandleEndLumi
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordtopoHandle
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordtopoHandleEndLumi
 
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecordttMapHandle
 
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecordttMapHandleEndLumi
 
- Protected Types inherited from ecaldqm::DQWorker
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Protected Member Functions inherited from ecaldqm::DQWorker
void initialize (std::string const &_name, edm::ParameterSet const &)
 
void print_ (std::string const &, int=0) const
 
virtual void setME (edm::ParameterSet const &)
 
virtual void setParams (edm::ParameterSet const &)
 
virtual void setSource (edm::ParameterSet const &)
 
void setVerbosity (int _verbosity)
 
- Protected Attributes inherited from ecaldqm::DBWriterWorker
bool active_
 
std::string const name_
 
std::set< std::string > runTypes_
 
MESetCollection source_
 
int verbosity_
 
- Protected Attributes inherited from ecaldqm::DQWorker
bool booked_
 
MESetCollection MEs_
 
std::string name_
 
bool onlineMode_
 
Timestamp timestamp_
 
int verbosity_
 
bool willConvertToEDM_
 

Detailed Description

Definition at line 51 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

◆ LaserWriter()

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

Definition at line 305 of file DBWriterWorkers.cc.

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

305  : 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  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
MESet & at(const std::string &key)
Definition: MESet.h:399
std::map< int, unsigned > wlToME_
static std::string to_string(const XMLCh *ch)
MESetCollection source_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:46

◆ ~LaserWriter()

ecaldqm::LaserWriter::~LaserWriter ( )
inlineoverride

Definition at line 54 of file DBWriterWorkers.h.

54 {}

Member Function Documentation

◆ run()

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

Implements ecaldqm::DBWriterWorker.

Definition at line 325 of file DBWriterWorkers.cc.

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(), ecaldqm::DQWorker::getEcalDQMSetupObjects(), ecaldqm::DQWorker::GetElectronicsMap(), l1ctLayer2EG_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(), MonLaserBlueDat::setAPDMean(), MonLaserGreenDat::setAPDMean(), MonLaserIRedDat::setAPDMean(), MonLaserIRedDat::setAPDOverPNMean(), MonLaserRedDat::setAPDOverPNMean(), MonLaserBlueDat::setAPDOverPNMean(), MonLaserGreenDat::setAPDOverPNMean(), MonLaserIRedDat::setAPDOverPNRMS(), MonLaserRedDat::setAPDOverPNRMS(), MonLaserGreenDat::setAPDOverPNRMS(), MonLaserBlueDat::setAPDOverPNRMS(), MonLaserBlueDat::setAPDRMS(), MonLaserIRedDat::setAPDRMS(), MonLaserRedDat::setAPDRMS(), MonLaserGreenDat::setAPDRMS(), MonLaserGreenDat::setTaskStatus(), MonLaserIRedDat::setTaskStatus(), MonLaserRedDat::setTaskStatus(), MonLaserBlueDat::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().

325  {
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);
374  MESet::const_iterator oItr(GetElectronicsMap(), aopME);
375  MESet::const_iterator tItr(GetElectronicsMap(), timeME);
376  for (MESet::const_iterator aItr(ampME.beginChannel(GetElectronicsMap())); aItr != aEnd;
377  aItr.toNextChannel(GetElectronicsMap())) {
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  }
std::vector< unsigned > const memDCC
EcalLogicID crystalID(DetId const &, EcalElectronicsMapping const *)
MESet & at(const std::string &key)
Definition: MESet.h:399
std::map< int, unsigned > wlToME_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
T sqrt(T t)
Definition: SSEVec.h:23
MESetCollection source_
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
bool qualityOK(int _quality)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

Member Data Documentation

◆ wlToME_

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

Definition at line 59 of file DBWriterWorkers.h.

Referenced by LaserWriter(), and run().