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::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 ()
 
- 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 > 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 98 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

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

Definition at line 1113 of file DBWriterWorkers.cc.

References edm::hlt::Exception, ecaldqm::MESetMulti::getIndex(), edm::ParameterSet::getUntrackedParameter(), ecaldqm::DBWriterWorker::source_, cond::to_string(), and wlToME_.

1113  :
1114  DBWriterWorker("Led", _ps),
1115  wlToME_()
1116  {
1117  std::vector<int> ledWavelengths(_ps.getUntrackedParameter<std::vector<int> >("ledWavelengths"));
1118 
1119  // wavelengths are not necessarily ordered
1120  // create a map wl -> MESet index
1121  // using Amplitude here but any multi-wavelength plot is fine
1122 
1124 
1125  MESetMulti const& amplitude(static_cast<MESetMulti const&>(source_.at("Amplitude")));
1126  unsigned nWL(ledWavelengths.size());
1127  for(unsigned iWL(0); iWL != nWL; ++iWL){
1128  int wl(ledWavelengths[iWL]);
1129  if(wl != 1 && wl != 2) throw cms::Exception("InvalidConfiguration") << "Led Wavelength";
1130  repl["wl"] = std::to_string(wl);
1131  wlToME_[wl] = amplitude.getIndex(repl);
1132  }
1133  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
std::string to_string(const T &t)
Definition: Logger.cc:26
MESetCollection source_
std::map< int, unsigned > wlToME_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:31
ecaldqm::LedWriter::~LedWriter ( )
inline

Definition at line 101 of file DBWriterWorkers.h.

101 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 1136 of file DBWriterWorkers.cc.

References compareJSON::const, ecaldqm::crystalID(), alignCSCRings::e, edm::hlt::Exception, spr::find(), ecaldqm::MESet::ConstBin::getBinContent(), ecaldqm::MESet::ConstBin::getBinEntries(), ecaldqm::MESet::ConstBin::getBinError(), EcalCondDBInterface::insertDataArraySet(), ecaldqm::kBad, ecaldqm::kMBad, ecaldqm::qualityOK(), query::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().

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

Member Data Documentation

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

Definition at line 106 of file DBWriterWorkers.h.

Referenced by LedWriter(), and run().