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 ()
 
- 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 1112 of file DBWriterWorkers.cc.

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

1112  :
1113  DBWriterWorker("Led", _ps),
1114  wlToME_()
1115  {
1116  std::vector<int> ledWavelengths(_ps.getUntrackedParameter<std::vector<int> >("ledWavelengths"));
1117 
1118  // wavelengths are not necessarily ordered
1119  // create a map wl -> MESet index
1120  // using Amplitude here but any multi-wavelength plot is fine
1121 
1123 
1124  MESetMulti const& amplitude(static_cast<MESetMulti const&>(source_.at("Amplitude")));
1125  unsigned nWL(ledWavelengths.size());
1126  for(unsigned iWL(0); iWL != nWL; ++iWL){
1127  int wl(ledWavelengths[iWL]);
1128  if(wl != 1 && wl != 2) throw cms::Exception("InvalidConfiguration") << "Led Wavelength";
1129  repl["wl"] = std::to_string(wl);
1130  wlToME_[wl] = amplitude.getIndex(repl);
1131  }
1132  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
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 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 1135 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().

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