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
 
virtual void retrieveSource (DQMStore const &)
 
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 58 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

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

Definition at line 599 of file DBWriterWorkers.cc.

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

599  :
600  DBWriterWorker("Pedestal", _ps),
601  gainToME_(),
602  pnGainToME_()
603  {
604  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int> >("MGPAGains"));
605  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int> >("MGPAGainsPN"));
606 
608 
609  MESetMulti const& pedestal(static_cast<MESetMulti const&>(source_.at("Pedestal")));
610  unsigned nG(MGPAGains.size());
611  for(unsigned iG(0); iG != nG; ++iG){
612  int gain(MGPAGains[iG]);
613  if(gain != 1 && gain != 6 && gain != 12) throw cms::Exception("InvalidConfiguration") << "MGPA gain";
614  repl["gain"] = std::to_string(gain);
615  gainToME_[gain] = pedestal.getIndex(repl);
616  }
617 
618  repl.clear();
619 
620  MESetMulti const& pnPedestal(static_cast<MESetMulti const&>(source_.at("PNPedestal")));
621  unsigned nGPN(MGPAGainsPN.size());
622  for(unsigned iG(0); iG != nGPN; ++iG){
623  int gain(MGPAGainsPN[iG]);
624  if(gain != 1 && gain != 16) throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
625  repl["pngain"] = std::to_string(gain);
626  pnGainToME_[gain] = pnPedestal.getIndex(repl);
627  }
628  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
std::string to_string(const T &t)
Definition: Logger.cc:26
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 61 of file DBWriterWorkers.h.

61 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 631 of file DBWriterWorkers.cc.

References compareJSON::const, ecaldqm::crystalID(), data, alignCSCRings::e, EcalBarrel, EcalEndcap, python.tagInventory::entries, edm::hlt::Exception, spr::find(), gainToME_, EcalCondDBInterface::insertDataArraySet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), timingPdfMaker::mean, ecaldqm::memDCC, pnGainToME_, ecaldqm::qualityOK(), query::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().

632  {
633  /*
634  uses
635  PedestalTask.Pedestal (h01, h02, h03)
636  PedestalTask.PNPedestal (i01, i02)
637  PedestalClient.Quality (meg01, meg02, meg03)
638  PedestalClient.PNQualitySummary (meg04, meg05)
639  */
640 
641  bool result(true);
642 
643  std::map<EcalLogicID, MonPedestalsDat> pedestals;
644  std::map<EcalLogicID, MonPNPedDat> pnPedestals;
645 
646  MESet const& pedestalME(source_.at("Pedestal"));
647  MESet const& qualityME(source_.at("Quality"));
648 
649  MESet const& pnPedestalME(source_.at("PNPedestal"));
650  MESet const& pnQualityME(source_.at("PNQuality"));
651 
652  for(std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr){
653  int gain(gainItr->first);
654  int iM(gainItr->second);
655 
656  static_cast<MESetMulti const&>(pedestalME).use(iM);
657  static_cast<MESetMulti const&>(qualityME).use(iM);
658 
659  MESet::const_iterator pEnd(pedestalME.end());
660  MESet::const_iterator qItr(qualityME);
661  for(MESet::const_iterator pItr(pedestalME.beginChannel()); pItr != pEnd; pItr.toNextChannel()){
662  float entries(pItr->getBinEntries());
663  if(entries < 1.) continue;
664 
665  qItr = pItr;
666 
667  float mean(pItr->getBinContent());
668  float rms(pItr->getBinError() * std::sqrt(entries));
669 
670  EcalLogicID logicID(crystalID(pItr->getId()));
671  if(pedestals.find(logicID) == pedestals.end()){
672  MonPedestalsDat& insertion(pedestals[logicID]);
673  insertion.setPedMeanG1(-1.);
674  insertion.setPedRMSG1(-1.);
675  insertion.setPedMeanG6(-1.);
676  insertion.setPedRMSG6(-1.);
677  insertion.setPedMeanG12(-1.);
678  insertion.setPedRMSG12(-1.);
679  insertion.setTaskStatus(false);
680  }
681 
682  MonPedestalsDat& data(pedestals[logicID]);
683  switch(gain){
684  case 1:
685  data.setPedMeanG1(mean);
686  data.setPedRMSG1(rms);
687  break;
688  case 6:
689  data.setPedMeanG6(mean);
690  data.setPedRMSG6(rms);
691  break;
692  case 12:
693  data.setPedMeanG12(mean);
694  data.setPedRMSG12(rms);
695  break;
696  }
697 
698  int channelStatus(qItr->getBinContent());
699  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
700  if(channelBad)
701  data.setTaskStatus(true);
702 
703  result &= qualityOK(channelStatus);
704  }
705  }
706 
707  for(std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr){
708  int gain(gainItr->first);
709  int iM(gainItr->second);
710 
711  static_cast<MESetMulti const&>(pnPedestalME).use(iM);
712  static_cast<MESetMulti const&>(pnQualityME).use(iM);
713 
714  for(unsigned iMD(0); iMD < memDCC.size(); ++iMD){
715  unsigned iDCC(memDCC[iMD]);
716 
717  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
718 
719  for(unsigned iPN(1); iPN <= 10; ++iPN){
720  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
721 
722  float entries(pnPedestalME.getBinEntries(pnid));
723  if(entries < 1.) continue;
724 
725  float mean(pnPedestalME.getBinContent(pnid));
726  float rms(pnPedestalME.getBinError(pnid) * std::sqrt(entries));
727 
728  EcalLogicID logicID(lmPNID(pnid));
729  if(pnPedestals.find(logicID) == pnPedestals.end()){
730  MonPNPedDat& insertion(pnPedestals[logicID]);
731  insertion.setPedMeanG1(-1.);
732  insertion.setPedRMSG1(-1.);
733  insertion.setPedMeanG16(-1.);
734  insertion.setPedRMSG16(-1.);
735  insertion.setTaskStatus(false);
736  }
737 
738  MonPNPedDat& data(pnPedestals[lmPNID(pnid)]);
739  switch(gain){
740  case 1:
741  data.setPedMeanG1(mean);
742  data.setPedRMSG1(rms);
743  break;
744  case 16:
745  data.setPedMeanG16(mean);
746  data.setPedRMSG16(rms);
747  break;
748  }
749 
750  int channelStatus(pnQualityME.getBinContent(pnid));
751  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
752  if(channelBad)
753  data.setTaskStatus(true);
754 
755  result &= qualityOK(channelStatus);
756  }
757  }
758  }
759 
760  try{
761  if(pedestals.size() > 0)
762  _db->insertDataArraySet(&pedestals, &_iov);
763  if(pnPedestals.size() > 0)
764  _db->insertDataArraySet(&pnPedestals, &_iov);
765  }
766  catch(std::runtime_error& e){
767  if(std::string(e.what()).find("unique constraint") != std::string::npos)
768  edm::LogWarning("EcalDQM") << e.what();
769  else
770  throw cms::Exception("DBError") << e.what();
771  }
772 
773  return result;
774  }
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
T sqrt(T t)
Definition: SSEVec.h:48
MESetCollection source_
tuple result
Definition: query.py:137
std::map< int, unsigned > pnGainToME_
bool qualityOK(int _quality)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
string const
Definition: compareJSON.py:14
std::map< int, unsigned > gainToME_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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 66 of file DBWriterWorkers.h.

Referenced by PedestalWriter(), and run().

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

Definition at line 67 of file DBWriterWorkers.h.

Referenced by PedestalWriter(), and run().