CMS 3D CMS Logo

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

#include <DBWriterWorkers.h>

Inheritance diagram for ecaldqm::PedestalWriter:
ecaldqm::DBWriterWorker ecaldqm::DQWorker

Public Member Functions

 PedestalWriter (edm::ParameterSet const &)
 
bool run (EcalCondDBInterface *, MonRunIOV &) override
 
 ~PedestalWriter () 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 > gainToME_
 
std::map< int, unsigned > pnGainToME_
 

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 62 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

◆ PedestalWriter()

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

Definition at line 574 of file DBWriterWorkers.cc.

References ecaldqm::MESetCollection::at(), Exception, PedestalClient_cfi::gain, gainToME_, ecaldqm::MESetMulti::getIndex(), edm::ParameterSet::getUntrackedParameter(), PedestalClient_cfi::MGPAGains, PedestalClient_cfi::MGPAGainsPN, EcalCondDBWriter_cfi::pedestal, pnGainToME_, ecaldqm::DBWriterWorker::source_, and to_string().

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

◆ ~PedestalWriter()

ecaldqm::PedestalWriter::~PedestalWriter ( )
inlineoverride

Definition at line 65 of file DBWriterWorkers.h.

65 {}

Member Function Documentation

◆ run()

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

Implements ecaldqm::DBWriterWorker.

Definition at line 604 of file DBWriterWorkers.cc.

References ecaldqm::MESetCollection::at(), ecaldqm::crystalID(), data, MillePedeFileConverter_cfg::e, EcalBarrel, EcalEndcap, Exception, spr::find(), PedestalClient_cfi::gain, gainToME_, ecaldqm::DQWorker::getEcalDQMSetupObjects(), ecaldqm::DQWorker::GetElectronicsMap(), EcalCondDBInterface::insertDataArraySet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), SiStripPI::mean, ecaldqm::memDCC, pnGainToME_, ecaldqm::qualityOK(), mps_fire::result, SiStripPI::rms, MonPedestalsDat::setPedMeanG1(), MonPNPedDat::setPedMeanG1(), MonPedestalsDat::setPedMeanG12(), MonPNPedDat::setPedMeanG16(), MonPedestalsDat::setPedMeanG6(), MonPNPedDat::setPedRMSG1(), MonPedestalsDat::setPedRMSG1(), MonPedestalsDat::setPedRMSG12(), MonPNPedDat::setPedRMSG16(), MonPedestalsDat::setPedRMSG6(), MonPNPedDat::setTaskStatus(), MonPedestalsDat::setTaskStatus(), ecaldqm::DBWriterWorker::source_, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, and ecaldqm::MESet::const_iterator::toNextChannel().

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

604  {
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;
634  pItr.toNextChannel(GetElectronicsMap())) {
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  }
std::vector< unsigned > const memDCC
EcalLogicID crystalID(DetId const &, EcalElectronicsMapping const *)
MESet & at(const std::string &key)
Definition: MESet.h:399
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
std::map< int, unsigned > pnGainToME_
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
bool qualityOK(int _quality)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
std::map< int, unsigned > gainToME_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

Member Data Documentation

◆ gainToME_

std::map<int, unsigned> ecaldqm::PedestalWriter::gainToME_
private

Definition at line 70 of file DBWriterWorkers.h.

Referenced by PedestalWriter(), and run().

◆ pnGainToME_

std::map<int, unsigned> ecaldqm::PedestalWriter::pnGainToME_
private

Definition at line 71 of file DBWriterWorkers.h.

Referenced by PedestalWriter(), and run().