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

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

Private Attributes

std::map< int, unsigned > wlToME_
 

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

Constructor & Destructor Documentation

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

Definition at line 1081 of file DBWriterWorkers.cc.

References CustomPhysics_cfi::amplitude, Exception, ecaldqm::MESetMulti::getIndex(), edm::ParameterSet::getUntrackedParameter(), ecaldqm::DBWriterWorker::source_, and wlToME_.

1081  : DBWriterWorker("Led", _ps), wlToME_() {
1082  std::vector<int> ledWavelengths(_ps.getUntrackedParameter<std::vector<int>>("ledWavelengths"));
1083 
1084  // wavelengths are not necessarily ordered
1085  // create a map wl -> MESet index
1086  // using Amplitude here but any multi-wavelength plot is fine
1087 
1089 
1090  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
1091  unsigned nWL(ledWavelengths.size());
1092  for (unsigned iWL(0); iWL != nWL; ++iWL) {
1093  int wl(ledWavelengths[iWL]);
1094  if (wl != 1 && wl != 2)
1095  throw cms::Exception("InvalidConfiguration") << "Led Wavelength";
1096  repl["wl"] = std::to_string(wl);
1097  wlToME_[wl] = amplitude.getIndex(repl);
1098  }
1099  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
MESetCollection source_
std::map< int, unsigned > wlToME_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:30
ecaldqm::LedWriter::~LedWriter ( )
inlineoverride

Definition at line 103 of file DBWriterWorkers.h.

References ecaldqm::DBWriterWorker::run().

103 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 1101 of file DBWriterWorkers.cc.

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

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

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

Member Data Documentation

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

Definition at line 108 of file DBWriterWorkers.h.

Referenced by LedWriter(), and run().