CMS 3D CMS Logo

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

#include <DBWriterWorkers.h>

Inheritance diagram for ecaldqm::LedWriter:
ecaldqm::DBWriterWorker ecaldqm::DQWorker

Public Member Functions

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

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

Constructor & Destructor Documentation

◆ LedWriter()

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

Definition at line 1087 of file DBWriterWorkers.cc.

References CustomPhysics_cfi::amplitude, ecaldqm::MESetCollection::at(), Exception, edm::ParameterSet::getUntrackedParameter(), CalibrationSummaryClient_cfi::ledWavelengths, ecaldqm::DBWriterWorker::source_, cond::impl::to_string(), LaserClient_cfi::wl, and wlToME_.

1087  : DBWriterWorker("Led", _ps), wlToME_() {
1088  std::vector<int> ledWavelengths(_ps.getUntrackedParameter<std::vector<int>>("ledWavelengths"));
1089 
1090  // wavelengths are not necessarily ordered
1091  // create a map wl -> MESet index
1092  // using Amplitude here but any multi-wavelength plot is fine
1093 
1095 
1096  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
1097  unsigned nWL(ledWavelengths.size());
1098  for (unsigned iWL(0); iWL != nWL; ++iWL) {
1099  int wl(ledWavelengths[iWL]);
1100  if (wl != 1 && wl != 2)
1101  throw cms::Exception("InvalidConfiguration") << "Led Wavelength";
1102  repl["wl"] = std::to_string(wl);
1103  wlToME_[wl] = amplitude.getIndex(repl);
1104  }
1105  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
MESet & at(const std::string &key)
Definition: MESet.h:399
std::string to_string(const V &value)
Definition: OMSAccess.h:71
MESetCollection source_
std::map< int, unsigned > wlToME_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:46

◆ ~LedWriter()

ecaldqm::LedWriter::~LedWriter ( )
inlineoverride

Definition at line 105 of file DBWriterWorkers.h.

105 {}

Member Function Documentation

◆ run()

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

Implements ecaldqm::DBWriterWorker.

Definition at line 1107 of file DBWriterWorkers.cc.

References ecaldqm::MESetCollection::at(), ecaldqm::crystalID(), MillePedeFileConverter_cfg::e, Exception, spr::find(), ecaldqm::MESet::ConstBin::getBinContent(), ecaldqm::MESet::ConstBin::getBinEntries(), ecaldqm::MESet::ConstBin::getBinError(), ecaldqm::DQWorker::GetElectronicsMap(), triggerObjects_cff::id, EcalCondDBInterface::insertDataArraySet(), ecaldqm::kBad, ecaldqm::kMBad, ecaldqm::qualityOK(), mps_fire::result, MonLed2Dat::setTaskStatus(), MonLed1Dat::setTaskStatus(), ITimingDat::setTaskStatus(), ITimingDat::setTimingMean(), ITimingDat::setTimingRMS(), MonLed1Dat::setVPTMean(), MonLed2Dat::setVPTMean(), MonLed1Dat::setVPTOverPNMean(), MonLed2Dat::setVPTOverPNMean(), MonLed1Dat::setVPTOverPNRMS(), MonLed2Dat::setVPTOverPNRMS(), MonLed1Dat::setVPTRMS(), MonLed2Dat::setVPTRMS(), ecaldqm::DBWriterWorker::source_, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, ecaldqm::MESet::const_iterator::toNextChannel(), LaserClient_cfi::wl, and wlToME_.

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

1107  {
1108  /*
1109  uses
1110  LedTask.Amplitude (h01, h03)
1111  LedTask.AOverP (h02, h04)
1112  LedTask.Timing (h09, h10)
1113  LedClient.Quality (meg01, meg02)
1114  LedTask.PNAmplitude (i09, i10)
1115 x LedClient.PNQualitySummary (meg09, meg10)
1116 x PNDiodeTask.Pedestal (i13, i14)
1117  */
1118 
1119  bool result(true);
1120 
1121  std::map<EcalLogicID, MonLed1Dat> l1Amp;
1122  std::map<EcalLogicID, MonTimingLed1CrystalDat> l1Time;
1123  // std::map<EcalLogicID, MonPNLed1Dat> l1PN;
1124  std::map<EcalLogicID, MonLed2Dat> l2Amp;
1125  std::map<EcalLogicID, MonTimingLed2CrystalDat> l2Time;
1126  // std::map<EcalLogicID, MonPNLed2Dat> l2PN;
1127 
1128  MESet const &ampME(source_.at("Amplitude"));
1129  MESet const &aopME(source_.at("AOverP"));
1130  MESet const &timeME(source_.at("Timing"));
1131  MESet const &qualityME(source_.at("Quality"));
1132 
1133  // MESet const& pnME(source_.at("PNAmplitude"));
1134  // MESet const& pnQualityME(source_.at("PNQuality"));
1135  // MESet const& pnPedestalME(source_.at("PNPedestal"));
1136 
1137  for (std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr) {
1138  int wl(wlItr->first);
1139  unsigned iM(wlItr->second);
1140 
1141  static_cast<MESetMulti const &>(ampME).use(iM);
1142  static_cast<MESetMulti const &>(aopME).use(iM);
1143  static_cast<MESetMulti const &>(timeME).use(iM);
1144  static_cast<MESetMulti const &>(qualityME).use(iM);
1145  // static_cast<MESetMulti const&>(pnME).use(iM);
1146  // static_cast<MESetMulti const&>(pnQualityME).use(iM);
1147 
1148  MESet::const_iterator aEnd(ampME.end(GetElectronicsMap()));
1149  MESet::const_iterator qItr(GetElectronicsMap(), qualityME);
1150  MESet::const_iterator oItr(GetElectronicsMap(), aopME);
1151  MESet::const_iterator tItr(GetElectronicsMap(), timeME);
1152  for (MESet::const_iterator aItr(ampME.beginChannel(GetElectronicsMap())); aItr != aEnd;
1153  aItr.toNextChannel(GetElectronicsMap())) {
1154  float aEntries(aItr->getBinEntries());
1155  if (aEntries < 1.)
1156  continue;
1157 
1158  qItr = aItr;
1159  oItr = aItr;
1160  tItr = aItr;
1161 
1162  DetId id(aItr->getId());
1163 
1164  float ampMean(aItr->getBinContent());
1165  float ampRms(aItr->getBinError() * std::sqrt(aEntries));
1166 
1167  float aopEntries(oItr->getBinEntries());
1168  float aopMean(oItr->getBinContent());
1169  float aopRms(oItr->getBinError() * std::sqrt(aopEntries));
1170 
1171  float timeEntries(tItr->getBinEntries());
1172  float timeMean(tItr->getBinContent());
1173  float timeRms(tItr->getBinError() * std::sqrt(timeEntries));
1174 
1175  int channelStatus(qItr->getBinContent());
1176  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
1177 
1178  EcalLogicID logicID(crystalID(id, GetElectronicsMap()));
1179 
1180  switch (wl) {
1181  case 1: {
1182  MonLed1Dat &aData(l1Amp[logicID]);
1183  aData.setVPTMean(ampMean);
1184  aData.setVPTRMS(ampRms);
1185  aData.setVPTOverPNMean(aopMean);
1186  aData.setVPTOverPNRMS(aopRms);
1187  aData.setTaskStatus(channelBad);
1188 
1189  MonTimingLed1CrystalDat &tData(l1Time[logicID]);
1190  tData.setTimingMean(timeMean);
1191  tData.setTimingRMS(timeRms);
1192  tData.setTaskStatus(channelBad);
1193  } break;
1194  case 2: {
1195  MonLed2Dat &aData(l2Amp[logicID]);
1196  aData.setVPTMean(ampMean);
1197  aData.setVPTRMS(ampRms);
1198  aData.setVPTOverPNMean(aopMean);
1199  aData.setVPTOverPNRMS(aopRms);
1200  aData.setTaskStatus(channelBad);
1201 
1202  MonTimingLed2CrystalDat &tData(l2Time[logicID]);
1203  tData.setTimingMean(timeMean);
1204  tData.setTimingRMS(timeRms);
1205  tData.setTaskStatus(channelBad);
1206  } break;
1207  }
1208  result &= qualityOK(channelStatus);
1209  }
1210 
1211  // for(unsigned iMD(0); iMD < memDCC.size(); ++iMD){
1212  // unsigned iDCC(memDCC[iMD]);
1213 
1214  // if(iDCC >= kEBmLow && iDCC <= kEBpHigh) continue;
1215 
1216  // for(unsigned iPN(1); iPN <= 10; ++iPN){
1217  // EcalPnDiodeDetId pnid(EcalEndcap, iDCC + 1, iPN);
1218 
1219  // float entries(pnME.getBinEntries(pnid));
1220  // if(entries < 1.) continue;
1221 
1222  // float mean(pnME.getBinContent(pnid));
1223  // float rms(pnME.getBinError(pnid) * std::sqrt(entries));
1224 
1225  // float pedestalEntries(pnPedestalME.getBinEntries(pnid));
1226  // float pedestalMean(pnPedestalME.getBinContent(pnid));
1227  // float pedestalRms(pnPedestalME.getBinError(pnid) *
1228  // std::sqrt(pedestalEntries));
1229 
1230  // int channelStatus(pnQualityME.getBinContent(pnid));
1231  // bool channelBad(channelStatus == kBad || channelStatus ==
1232  // kMBad);
1233 
1234  // switch(wl){
1235  // case 1:
1236  // {
1237  // MonPNLed1Dat& data(l1PN[lmPNID(pnid)]);
1238  // data.setADCMeanG1(-1.);
1239  // data.setADCRMSG1(-1.);
1240  // data.setPedMeanG1(-1.);
1241  // data.setPedRMSG1(-1.);
1242  // data.setADCMeanG16(mean);
1243  // data.setADCRMSG16(rms);
1244  // data.setPedMeanG16(pedestalMean);
1245  // data.setPedRMSG16(pedestalRms);
1246  // data.setTaskStatus(channelBad);
1247  // }
1248  // break;
1249  // case 2:
1250  // {
1251  // MonPNLed2Dat& data(l2PN[lmPNID(pnid)]);
1252  // data.setADCMeanG1(-1.);
1253  // data.setADCRMSG1(-1.);
1254  // data.setPedMeanG1(-1.);
1255  // data.setPedRMSG1(-1.);
1256  // data.setADCMeanG16(mean);
1257  // data.setADCRMSG16(rms);
1258  // data.setPedMeanG16(pedestalMean);
1259  // data.setPedRMSG16(pedestalRms);
1260  // data.setTaskStatus(channelBad);
1261  // }
1262  // break;
1263  // }
1264 
1265  // result &= qualityOK(channelStatus);
1266 
1267  // }
1268  // }
1269  }
1270 
1271  try {
1272  if (!l1Amp.empty())
1273  _db->insertDataArraySet(&l1Amp, &_iov);
1274  if (!l1Time.empty())
1275  _db->insertDataArraySet(&l1Time, &_iov);
1276  // if(l1PN.size() > 0)
1277  // _db->insertDataArraySet(&l1PN, &_iov);
1278  if (!l2Amp.empty())
1279  _db->insertDataArraySet(&l2Amp, &_iov);
1280  if (!l2Time.empty())
1281  _db->insertDataArraySet(&l2Time, &_iov);
1282  // if(l2PN.size() > 0)
1283  // _db->insertDataArraySet(&l2PN, &_iov);
1284  } catch (std::runtime_error &e) {
1285  if (std::string(e.what()).find("unique constraint") != std::string::npos)
1286  edm::LogWarning("EcalDQM") << e.what();
1287  else
1288  throw cms::Exception("DBError") << e.what();
1289  }
1290 
1291  return result;
1292  }
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:19
MESetCollection source_
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov) noexcept(false)
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
Definition: DetId.h:17
bool qualityOK(int _quality)
std::map< int, unsigned > wlToME_

Member Data Documentation

◆ wlToME_

std::map<int, unsigned> ecaldqm::LedWriter::wlToME_
private

Definition at line 110 of file DBWriterWorkers.h.

Referenced by LedWriter(), and run().