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

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)
 
virtual ~DBWriterWorker ()
 

Private Attributes

std::map< int, unsigned > gainToME_
 
std::map< int, unsigned > pnGainToME_
 

Additional Inherited Members

- Protected Attributes inherited from ecaldqm::DBWriterWorker
bool active_
 
std::string const name_
 
std::set< std::string > runTypes_
 
MESetCollection source_
 
int verbosity_
 

Detailed Description

Definition at line 60 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

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

Definition at line 572 of file DBWriterWorkers.cc.

References Exception, muonCSCDigis_cfi::gain, gainToME_, ecaldqm::MESetMulti::getIndex(), edm::ParameterSet::getUntrackedParameter(), muonCSCDigis_cfi::pedestal, pnGainToME_, and ecaldqm::DBWriterWorker::source_.

573  : DBWriterWorker("Pedestal", _ps), gainToME_(), pnGainToME_() {
574  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int>>("MGPAGains"));
575  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int>>("MGPAGainsPN"));
576 
578 
579  MESetMulti const &pedestal(static_cast<MESetMulti const &>(source_.at("Pedestal")));
580  unsigned nG(MGPAGains.size());
581  for (unsigned iG(0); iG != nG; ++iG) {
582  int gain(MGPAGains[iG]);
583  if (gain != 1 && gain != 6 && gain != 12)
584  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
585  repl["gain"] = std::to_string(gain);
586  gainToME_[gain] = pedestal.getIndex(repl);
587  }
588 
589  repl.clear();
590 
591  MESetMulti const &pnPedestal(static_cast<MESetMulti const &>(source_.at("PNPedestal")));
592  unsigned nGPN(MGPAGainsPN.size());
593  for (unsigned iG(0); iG != nGPN; ++iG) {
594  int gain(MGPAGainsPN[iG]);
595  if (gain != 1 && gain != 16)
596  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
597  repl["pngain"] = std::to_string(gain);
598  pnGainToME_[gain] = pnPedestal.getIndex(repl);
599  }
600  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
MESetCollection source_
std::map< int, unsigned > pnGainToME_
std::map< int, unsigned > gainToME_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:30
ecaldqm::PedestalWriter::~PedestalWriter ( )
inlineoverride

Definition at line 63 of file DBWriterWorkers.h.

References ecaldqm::DBWriterWorker::run().

63 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 602 of file DBWriterWorkers.cc.

References ecaldqm::crystalID(), data, MillePedeFileConverter_cfg::e, EcalBarrel, EcalEndcap, Exception, spr::find(), muonCSCDigis_cfi::gain, gainToME_, 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().

602  {
603  /*
604  uses
605  PedestalTask.Pedestal (h01, h02, h03)
606  PedestalTask.PNPedestal (i01, i02)
607  PedestalClient.Quality (meg01, meg02, meg03)
608  PedestalClient.PNQualitySummary (meg04, meg05)
609  */
610 
611  bool result(true);
612 
613  std::map<EcalLogicID, MonPedestalsDat> pedestals;
614  std::map<EcalLogicID, MonPNPedDat> pnPedestals;
615 
616  MESet const &pedestalME(source_.at("Pedestal"));
617  MESet const &qualityME(source_.at("Quality"));
618 
619  MESet const &pnPedestalME(source_.at("PNPedestal"));
620  MESet const &pnQualityME(source_.at("PNQuality"));
621 
622  for (std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
623  int gain(gainItr->first);
624  int iM(gainItr->second);
625 
626  static_cast<MESetMulti const &>(pedestalME).use(iM);
627  static_cast<MESetMulti const &>(qualityME).use(iM);
628 
629  MESet::const_iterator pEnd(pedestalME.end());
630  MESet::const_iterator qItr(qualityME);
631  for (MESet::const_iterator pItr(pedestalME.beginChannel()); pItr != pEnd; pItr.toNextChannel()) {
632  float entries(pItr->getBinEntries());
633  if (entries < 1.)
634  continue;
635 
636  qItr = pItr;
637 
638  float mean(pItr->getBinContent());
639  float rms(pItr->getBinError() * std::sqrt(entries));
640 
641  EcalLogicID logicID(crystalID(pItr->getId()));
642  if (pedestals.find(logicID) == pedestals.end()) {
643  MonPedestalsDat &insertion(pedestals[logicID]);
644  insertion.setPedMeanG1(-1.);
645  insertion.setPedRMSG1(-1.);
646  insertion.setPedMeanG6(-1.);
647  insertion.setPedRMSG6(-1.);
648  insertion.setPedMeanG12(-1.);
649  insertion.setPedRMSG12(-1.);
650  insertion.setTaskStatus(false);
651  }
652 
653  MonPedestalsDat &data(pedestals[logicID]);
654  switch (gain) {
655  case 1:
656  data.setPedMeanG1(mean);
657  data.setPedRMSG1(rms);
658  break;
659  case 6:
660  data.setPedMeanG6(mean);
661  data.setPedRMSG6(rms);
662  break;
663  case 12:
664  data.setPedMeanG12(mean);
665  data.setPedRMSG12(rms);
666  break;
667  }
668 
669  int channelStatus(qItr->getBinContent());
670  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
671  if (channelBad)
672  data.setTaskStatus(true);
673 
674  result &= qualityOK(channelStatus);
675  }
676  }
677 
678  for (std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
679  int gain(gainItr->first);
680  int iM(gainItr->second);
681 
682  static_cast<MESetMulti const &>(pnPedestalME).use(iM);
683  static_cast<MESetMulti const &>(pnQualityME).use(iM);
684 
685  for (unsigned iMD(0); iMD < memDCC.size(); ++iMD) {
686  unsigned iDCC(memDCC[iMD]);
687 
688  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
689 
690  for (unsigned iPN(1); iPN <= 10; ++iPN) {
691  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
692 
693  float entries(pnPedestalME.getBinEntries(pnid));
694  if (entries < 1.)
695  continue;
696 
697  float mean(pnPedestalME.getBinContent(pnid));
698  float rms(pnPedestalME.getBinError(pnid) * std::sqrt(entries));
699 
700  EcalLogicID logicID(lmPNID(pnid));
701  if (pnPedestals.find(logicID) == pnPedestals.end()) {
702  MonPNPedDat &insertion(pnPedestals[logicID]);
703  insertion.setPedMeanG1(-1.);
704  insertion.setPedRMSG1(-1.);
705  insertion.setPedMeanG16(-1.);
706  insertion.setPedRMSG16(-1.);
707  insertion.setTaskStatus(false);
708  }
709 
710  MonPNPedDat &data(pnPedestals[lmPNID(pnid)]);
711  switch (gain) {
712  case 1:
713  data.setPedMeanG1(mean);
714  data.setPedRMSG1(rms);
715  break;
716  case 16:
717  data.setPedMeanG16(mean);
718  data.setPedRMSG16(rms);
719  break;
720  }
721 
722  int channelStatus(pnQualityME.getBinContent(pnid));
723  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
724  if (channelBad)
725  data.setTaskStatus(true);
726 
727  result &= qualityOK(channelStatus);
728  }
729  }
730  }
731 
732  try {
733  if (!pedestals.empty())
734  _db->insertDataArraySet(&pedestals, &_iov);
735  if (!pnPedestals.empty())
736  _db->insertDataArraySet(&pnPedestals, &_iov);
737  } catch (std::runtime_error &e) {
738  if (std::string(e.what()).find("unique constraint") != std::string::npos)
739  edm::LogWarning("EcalDQM") << e.what();
740  else
741  throw cms::Exception("DBError") << e.what();
742  }
743 
744  return result;
745  }
std::vector< unsigned > const memDCC
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
T sqrt(T t)
Definition: SSEVec.h:18
MESetCollection source_
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
std::map< int, unsigned > pnGainToME_
bool qualityOK(int _quality)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
std::map< int, unsigned > gainToME_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
EcalLogicID crystalID(DetId const &)

Member Data Documentation

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

Definition at line 68 of file DBWriterWorkers.h.

Referenced by PedestalWriter(), and run().

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

Definition at line 69 of file DBWriterWorkers.h.

Referenced by PedestalWriter(), and run().