CMS 3D CMS Logo

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

#include <DBWriterWorkers.h>

Inheritance diagram for ecaldqm::TestPulseWriter:
ecaldqm::DBWriterWorker

Public Member Functions

bool run (EcalCondDBInterface *, MonRunIOV &) override
 
 TestPulseWriter (edm::ParameterSet const &)
 
 ~TestPulseWriter () 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

- Public Types inherited from ecaldqm::DBWriterWorker
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- 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 80 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

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

Definition at line 797 of file DBWriterWorkers.cc.

References CustomPhysics_cfi::amplitude, Exception, PedestalClient_cfi::gain, gainToME_, ecaldqm::MESetMulti::getIndex(), edm::ParameterSet::getUntrackedParameter(), PedestalClient_cfi::MGPAGains, PedestalClient_cfi::MGPAGainsPN, pnGainToME_, and ecaldqm::DBWriterWorker::source_.

798  : DBWriterWorker("TestPulse", _ps), gainToME_(), pnGainToME_() {
799  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int>>("MGPAGains"));
800  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int>>("MGPAGainsPN"));
801 
803 
804  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
805  unsigned nG(MGPAGains.size());
806  for (unsigned iG(0); iG != nG; ++iG) {
807  int gain(MGPAGains[iG]);
808  if (gain != 1 && gain != 6 && gain != 12)
809  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
810  repl["gain"] = std::to_string(gain);
811  gainToME_[gain] = amplitude.getIndex(repl);
812  }
813 
814  repl.clear();
815 
816  MESetMulti const &pnAmplitude(static_cast<MESetMulti const &>(source_.at("PNAmplitude")));
817  unsigned nGPN(MGPAGainsPN.size());
818  for (unsigned iG(0); iG != nGPN; ++iG) {
819  int gain(MGPAGainsPN[iG]);
820  if (gain != 1 && gain != 16)
821  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
822  repl["pngain"] = std::to_string(gain);
823  pnGainToME_[gain] = pnAmplitude.getIndex(repl);
824  }
825  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
std::map< int, unsigned > gainToME_
MESetCollection source_
std::map< int, unsigned > pnGainToME_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:31
ecaldqm::TestPulseWriter::~TestPulseWriter ( )
inlineoverride

Definition at line 83 of file DBWriterWorkers.h.

References ecaldqm::DBWriterWorker::run().

83 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 827 of file DBWriterWorkers.cc.

References CustomPhysics_cfi::amplitude, ecaldqm::crystalID(), data, MillePedeFileConverter_cfg::e, EcalBarrel, EcalEndcap, Exception, spr::find(), PedestalClient_cfi::gain, gainToME_, ecaldqm::getElectronicsMap(), mps_fire::i, triggerObjects_cff::id, photons_cff::ids, EcalCondDBInterface::insertDataArraySet(), EcalCondDBInterface::insertDataSet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), SiStripPI::mean, ecaldqm::memDCC, ecaldqm::nChannels, pnGainToME_, ecaldqm::qualityOK(), mps_fire::result, SiStripPI::rms, EgammaValidation_cff::samples, MonPNMGPADat::setADCMeanG1(), MonTestPulseDat::setADCMeanG1(), MonTestPulseDat::setADCMeanG12(), MonPNMGPADat::setADCMeanG16(), MonTestPulseDat::setADCMeanG6(), MonPNMGPADat::setADCRMSG1(), MonTestPulseDat::setADCRMSG1(), MonTestPulseDat::setADCRMSG12(), MonPNMGPADat::setADCRMSG16(), MonTestPulseDat::setADCRMSG6(), MonPNMGPADat::setPedMeanG1(), MonPNMGPADat::setPedMeanG16(), MonPNMGPADat::setPedRMSG1(), MonPNMGPADat::setPedRMSG16(), MonPulseShapeDat::setSamples(), MonTestPulseDat::setTaskStatus(), MonPNMGPADat::setTaskStatus(), ecaldqm::DBWriterWorker::source_, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, and ecaldqm::MESet::const_iterator::toNextChannel().

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

827  {
828  /*
829  uses
830  TestPulseTask.Amplitude (ha01, ha02, ha03)
831  TestPulseTask.Shape (me_hs01, me_hs02, me_hs03)
832  TestPulseTask.PNAmplitude (i01, i02)
833  PNDiodeTask.Pedestal (i03, i04)
834  TestPulseClient.Quality (meg01, meg02, meg03)
835  TestPulseClient.PNQualitySummary (meg04, meg05)
836  */
837 
838  bool result(true);
839 
840  std::map<EcalLogicID, MonTestPulseDat> amplitude;
841  std::map<EcalLogicID, MonPulseShapeDat> shape;
842  std::map<EcalLogicID, MonPNMGPADat> pnAmplitude;
843 
844  MESet const &amplitudeME(source_.at("Amplitude"));
845  MESet const &shapeME(source_.at("Shape"));
846  MESet const &qualityME(source_.at("Quality"));
847 
848  MESet const &pnAmplitudeME(source_.at("PNAmplitude"));
849  MESet const &pnPedestalME(source_.at("PNPedestal"));
850  MESet const &pnQualityME(source_.at("PNQuality"));
851 
852  for (std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr) {
853  int gain(gainItr->first);
854  int iM(gainItr->second);
855 
856  static_cast<MESetMulti const &>(amplitudeME).use(iM);
857  static_cast<MESetMulti const &>(shapeME).use(iM);
858  static_cast<MESetMulti const &>(qualityME).use(iM);
859 
860  MESet::const_iterator aEnd(amplitudeME.end());
861  MESet::const_iterator qItr(qualityME);
862  for (MESet::const_iterator aItr(amplitudeME.beginChannel()); aItr != aEnd; aItr.toNextChannel()) {
863  float entries(aItr->getBinEntries());
864  if (entries < 1.)
865  continue;
866 
867  qItr = aItr;
868 
869  float mean(aItr->getBinContent());
870  float rms(aItr->getBinError() * std::sqrt(entries));
871 
872  EcalLogicID logicID(crystalID(aItr->getId()));
873  if (amplitude.find(logicID) == amplitude.end()) {
874  MonTestPulseDat &insertion(amplitude[logicID]);
875  insertion.setADCMeanG1(-1.);
876  insertion.setADCRMSG1(-1.);
877  insertion.setADCMeanG6(-1.);
878  insertion.setADCRMSG6(-1.);
879  insertion.setADCMeanG12(-1.);
880  insertion.setADCRMSG12(-1.);
881  insertion.setTaskStatus(false);
882  }
883 
884  MonTestPulseDat &data(amplitude[logicID]);
885  switch (gain) {
886  case 1:
887  data.setADCMeanG1(mean);
888  data.setADCRMSG1(rms);
889  break;
890  case 6:
891  data.setADCMeanG6(mean);
892  data.setADCRMSG6(rms);
893  break;
894  case 12:
895  data.setADCMeanG12(mean);
896  data.setADCRMSG12(rms);
897  break;
898  }
899 
900  int channelStatus(qItr->getBinContent());
901  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
902  if (channelBad)
903  data.setTaskStatus(true);
904 
905  result &= qualityOK(channelStatus);
906  }
907 
908  for (unsigned iSM(0); iSM < 54; ++iSM) {
909  std::vector<float> samples(10, 0.);
910  std::vector<DetId> ids(getElectronicsMap()->dccConstituents(iSM + 1));
911  unsigned nId(ids.size());
912  unsigned nChannels(0);
913  EcalLogicID logicID;
914  for (unsigned iD(0); iD < nId; ++iD) {
915  DetId &id(ids[iD]);
916 
917  if (iD == 0)
918  logicID = crystalID(id);
919 
920  if (shapeME.getBinEntries(id, 1) < 1.)
921  continue;
922 
923  ++nChannels;
924 
925  for (int i(0); i < 10; ++i)
926  samples[i] += shapeME.getBinContent(id, i + 1);
927  }
928 
929  if (nChannels == 0)
930  continue;
931 
932  for (int i(0); i < 10; ++i)
933  samples[i] /= nChannels;
934 
935  if (shape.find(logicID) == shape.end()) {
936  MonPulseShapeDat &insertion(shape[logicID]);
937  std::vector<float> defval(10, -1.);
938  insertion.setSamples(defval, 1);
939  insertion.setSamples(defval, 6);
940  insertion.setSamples(defval, 12);
941  }
942 
943  MonPulseShapeDat &data(shape[logicID]);
944  data.setSamples(samples, gain);
945  }
946  }
947 
948  for (std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr) {
949  int gain(gainItr->first);
950  int iM(gainItr->second);
951 
952  static_cast<MESetMulti const &>(pnAmplitudeME).use(iM);
953  static_cast<MESetMulti const &>(pnQualityME).use(iM);
954 
955  for (unsigned iMD(0); iMD < memDCC.size(); ++iMD) {
956  unsigned iDCC(memDCC[iMD]);
957 
958  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
959 
960  for (unsigned iPN(1); iPN <= 10; ++iPN) {
961  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
962 
963  float entries(pnAmplitudeME.getBinEntries(pnid));
964  if (entries < 1.)
965  continue;
966 
967  float mean(pnAmplitudeME.getBinContent(pnid));
968  float rms(pnAmplitudeME.getBinError(pnid) * std::sqrt(entries));
969  float pedestalEntries(pnPedestalME.getBinEntries(pnid));
970  float pedestalMean(pnPedestalME.getBinContent(pnid));
971  float pedestalRms(pnPedestalME.getBinError(pnid) * std::sqrt(pedestalEntries));
972 
973  EcalLogicID logicID(lmPNID(pnid));
974  if (pnAmplitude.find(logicID) == pnAmplitude.end()) {
975  MonPNMGPADat &insertion(pnAmplitude[logicID]);
976  insertion.setADCMeanG1(-1.);
977  insertion.setADCRMSG1(-1.);
978  insertion.setPedMeanG1(-1.);
979  insertion.setPedRMSG1(-1.);
980  insertion.setADCMeanG16(-1.);
981  insertion.setADCRMSG16(-1.);
982  insertion.setPedMeanG16(-1.);
983  insertion.setPedRMSG16(-1.);
984  insertion.setTaskStatus(false);
985  }
986 
987  MonPNMGPADat &data(pnAmplitude[lmPNID(pnid)]);
988  switch (gain) {
989  case 1:
990  data.setADCMeanG1(mean);
991  data.setADCRMSG1(rms);
992  // dynamic pedestal not measured for G1
993  // data.setPedMeanG1(pedestalMean);
994  // data.setPedRMSG1(pedestalRms);
995  break;
996  case 16:
997  data.setADCMeanG16(mean);
998  data.setADCRMSG16(rms);
999  data.setPedMeanG16(pedestalMean);
1000  data.setPedRMSG16(pedestalRms);
1001  break;
1002  }
1003 
1004  int channelStatus(pnQualityME.getBinContent(pnid));
1005  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
1006  if (channelBad)
1007  data.setTaskStatus(true);
1008 
1009  result &= qualityOK(channelStatus);
1010  }
1011  }
1012  }
1013 
1014  try {
1015  if (!amplitude.empty())
1016  _db->insertDataArraySet(&amplitude, &_iov);
1017  if (!shape.empty())
1018  _db->insertDataSet(&shape, &_iov);
1019  if (!pnAmplitude.empty())
1020  _db->insertDataArraySet(&pnAmplitude, &_iov);
1021  } catch (std::runtime_error &e) {
1022  if (std::string(e.what()).find("unique constraint") != std::string::npos)
1023  edm::LogWarning("EcalDQM") << e.what();
1024  else
1025  throw cms::Exception("DBError") << e.what();
1026  }
1027 
1028  return result;
1029  }
std::vector< unsigned > const memDCC
EcalElectronicsMapping const * getElectronicsMap()
std::map< int, unsigned > gainToME_
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:19
MESetCollection source_
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
std::map< int, unsigned > pnGainToME_
Definition: DetId.h:17
bool qualityOK(int _quality)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
EcalLogicID crystalID(DetId const &)

Member Data Documentation

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

Definition at line 88 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().

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

Definition at line 89 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().