CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- 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 598 of file DBWriterWorkers.cc.

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

598  :
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  }
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:31
ecaldqm::PedestalWriter::~PedestalWriter ( )
inline

Definition at line 63 of file DBWriterWorkers.h.

63 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 630 of file DBWriterWorkers.cc.

References compareJSON::const, ecaldqm::crystalID(), AlCaHLTBitMon_QueryRunRegistry::data, alignCSCRings::e, EcalBarrel, EcalEndcap, Exception, spr::find(), gainToME_, EcalCondDBInterface::insertDataArraySet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), timingPdfMaker::mean, ecaldqm::memDCC, pnGainToME_, ecaldqm::qualityOK(), mps_fire::result, plotscripts::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().

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  }
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:7
tuple result
Definition: mps_fire.py:95
T sqrt(T t)
Definition: SSEVec.h:18
MESetCollection source_
std::map< int, unsigned > pnGainToME_
bool qualityOK(int _quality)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
string const
Definition: compareJSON.py:14
std::map< int, unsigned > gainToME_
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov)
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().