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::LaserWriter Class Reference

#include <DBWriterWorkers.h>

Inheritance diagram for ecaldqm::LaserWriter:
ecaldqm::DBWriterWorker

Public Member Functions

 LaserWriter (edm::ParameterSet const &)
 
bool run (EcalCondDBInterface *, MonRunIOV &) override
 
 ~LaserWriter ()
 
- 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 47 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

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

Definition at line 311 of file DBWriterWorkers.cc.

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

311  :
312  DBWriterWorker("Laser", _ps),
313  wlToME_()
314  {
315  std::vector<int> laserWavelengths(_ps.getUntrackedParameter<std::vector<int> >("laserWavelengths"));
316 
317  // wavelengths are not necessarily ordered
318  // create a map wl -> MESet index
319  // using Amplitude here but any multi-wavelength plot is fine
320 
322 
323  MESetMulti const& amplitude(static_cast<MESetMulti const&>(source_.at("Amplitude")));
324  unsigned nWL(laserWavelengths.size());
325  for(unsigned iWL(0); iWL != nWL; ++iWL){
326  int wl(laserWavelengths[iWL]);
327  if(wl <= 0 || wl >= 5) throw cms::Exception("InvalidConfiguration") << "Laser Wavelength";
328  repl["wl"] = std::to_string(wl);
329  wlToME_[wl] = amplitude.getIndex(repl);
330  }
331  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
std::map< int, unsigned > wlToME_
std::string to_string(const T &t)
Definition: Logger.cc:26
MESetCollection source_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:31
ecaldqm::LaserWriter::~LaserWriter ( )
inline

Definition at line 50 of file DBWriterWorkers.h.

50 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 334 of file DBWriterWorkers.cc.

References compareJSON::const, ecaldqm::crystalID(), data, alignCSCRings::e, EcalBarrel, EcalEndcap, python.tagInventory::entries, edm::hlt::Exception, spr::find(), ecaldqm::MESet::ConstBin::getBinContent(), ecaldqm::MESet::ConstBin::getBinEntries(), ecaldqm::MESet::ConstBin::getBinError(), EcalCondDBInterface::insertDataArraySet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), timingPdfMaker::mean, ecaldqm::memDCC, ecaldqm::qualityOK(), query::result, plotscripts::rms(), MonPNIRedDat::setADCMeanG1(), MonPNRedDat::setADCMeanG1(), MonPNBlueDat::setADCMeanG1(), MonPNGreenDat::setADCMeanG1(), MonPNIRedDat::setADCMeanG16(), MonPNRedDat::setADCMeanG16(), MonPNBlueDat::setADCMeanG16(), MonPNGreenDat::setADCMeanG16(), MonPNIRedDat::setADCRMSG1(), MonPNRedDat::setADCRMSG1(), MonPNBlueDat::setADCRMSG1(), MonPNGreenDat::setADCRMSG1(), MonPNIRedDat::setADCRMSG16(), MonPNRedDat::setADCRMSG16(), MonPNBlueDat::setADCRMSG16(), MonPNGreenDat::setADCRMSG16(), MonLaserGreenDat::setAPDMean(), MonLaserIRedDat::setAPDMean(), MonLaserBlueDat::setAPDMean(), MonLaserRedDat::setAPDMean(), MonLaserRedDat::setAPDOverPNMean(), MonLaserGreenDat::setAPDOverPNMean(), MonLaserIRedDat::setAPDOverPNMean(), MonLaserBlueDat::setAPDOverPNMean(), MonLaserBlueDat::setAPDOverPNRMS(), MonLaserRedDat::setAPDOverPNRMS(), MonLaserGreenDat::setAPDOverPNRMS(), MonLaserIRedDat::setAPDOverPNRMS(), MonLaserRedDat::setAPDRMS(), MonLaserIRedDat::setAPDRMS(), MonLaserGreenDat::setAPDRMS(), MonLaserBlueDat::setAPDRMS(), MonPNGreenDat::setPedMeanG1(), MonPNRedDat::setPedMeanG1(), MonPNBlueDat::setPedMeanG1(), MonPNIRedDat::setPedMeanG1(), MonPNGreenDat::setPedMeanG16(), MonPNIRedDat::setPedMeanG16(), MonPNRedDat::setPedMeanG16(), MonPNBlueDat::setPedMeanG16(), MonPNBlueDat::setPedRMSG1(), MonPNIRedDat::setPedRMSG1(), MonPNRedDat::setPedRMSG1(), MonPNGreenDat::setPedRMSG1(), MonPNIRedDat::setPedRMSG16(), MonPNRedDat::setPedRMSG16(), MonPNBlueDat::setPedRMSG16(), MonPNGreenDat::setPedRMSG16(), MonLaserBlueDat::setTaskStatus(), MonLaserRedDat::setTaskStatus(), MonLaserGreenDat::setTaskStatus(), MonLaserIRedDat::setTaskStatus(), MonPNIRedDat::setTaskStatus(), MonPNRedDat::setTaskStatus(), MonPNGreenDat::setTaskStatus(), MonPNBlueDat::setTaskStatus(), ITimingDat::setTaskStatus(), ITimingDat::setTimingMean(), ITimingDat::setTimingRMS(), ecaldqm::DBWriterWorker::source_, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, ecaldqm::MESet::const_iterator::toNextChannel(), and wlToME_.

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

335  {
336  /*
337  uses
338  LaserTask.Amplitude (h01, h03, h05, h07)
339  LaserTask.AOverP (h02, h04, h06, h08)
340  LaserTask.Timing (h09, h10, h11, h12)
341  LaserClient.Quality (meg01, meg02, meg03, meg04)
342  LaserTask.PNAmplitude (i09, i10, i11, i12)
343  LaserClient.PNQualitySummary (meg09, meg10, meg11, meg12)
344  PNDiodeTask.Pedestal (i13, i14, i15, i16)
345  */
346 
347  bool result(true);
348 
349  std::map<EcalLogicID, MonLaserBlueDat> l1Amp;
350  std::map<EcalLogicID, MonTimingLaserBlueCrystalDat> l1Time;
351  std::map<EcalLogicID, MonPNBlueDat> l1PN;
352  std::map<EcalLogicID, MonLaserGreenDat> l2Amp;
353  std::map<EcalLogicID, MonTimingLaserGreenCrystalDat> l2Time;
354  std::map<EcalLogicID, MonPNGreenDat> l2PN;
355  std::map<EcalLogicID, MonLaserIRedDat> l3Amp;
356  std::map<EcalLogicID, MonTimingLaserIRedCrystalDat> l3Time;
357  std::map<EcalLogicID, MonPNIRedDat> l3PN;
358  std::map<EcalLogicID, MonLaserRedDat> l4Amp;
359  std::map<EcalLogicID, MonTimingLaserRedCrystalDat> l4Time;
360  std::map<EcalLogicID, MonPNRedDat> l4PN;
361 
362  MESet const& ampME(source_.at("Amplitude"));
363  MESet const& aopME(source_.at("AOverP"));
364  MESet const& timeME(source_.at("Timing"));
365  MESet const& qualityME(source_.at("Quality"));
366 
367  MESet const& pnME(source_.at("PNAmplitude"));
368  MESet const& pnQualityME(source_.at("PNQuality"));
369  MESet const& pnPedestalME(source_.at("PNPedestal"));
370 
371  for(std::map<int, unsigned>::iterator wlItr(wlToME_.begin()); wlItr != wlToME_.end(); ++wlItr){
372  int wl(wlItr->first);
373  unsigned iM(wlItr->second);
374 
375  static_cast<MESetMulti const&>(ampME).use(iM);
376  static_cast<MESetMulti const&>(aopME).use(iM);
377  static_cast<MESetMulti const&>(timeME).use(iM);
378  static_cast<MESetMulti const&>(qualityME).use(iM);
379  static_cast<MESetMulti const&>(pnME).use(iM);
380  static_cast<MESetMulti const&>(pnQualityME).use(iM);
381 
382  MESet::const_iterator aEnd(ampME.end());
383  MESet::const_iterator qItr(qualityME);
384  MESet::const_iterator oItr(aopME);
385  MESet::const_iterator tItr(timeME);
386  for(MESet::const_iterator aItr(ampME.beginChannel()); aItr != aEnd; aItr.toNextChannel()){
387  float aEntries(aItr->getBinEntries());
388  if(aEntries < 1.) continue;
389 
390  qItr = aItr;
391  oItr = aItr;
392  tItr = aItr;
393 
394  DetId id(aItr->getId());
395 
396  float ampMean(aItr->getBinContent());
397  float ampRms(aItr->getBinError() * std::sqrt(aEntries));
398 
399  float aopEntries(oItr->getBinEntries());
400  float aopMean(oItr->getBinContent());
401  float aopRms(oItr->getBinError() * std::sqrt(aopEntries));
402 
403  float timeEntries(tItr->getBinEntries());
404  float timeMean(tItr->getBinContent());
405  float timeRms(tItr->getBinError() * std::sqrt(timeEntries));
406 
407  int channelStatus(qItr->getBinContent());
408  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
409 
410  EcalLogicID logicID(crystalID(id));
411 
412  switch(wl){
413  case 1:
414  {
415  MonLaserBlueDat& aData(l1Amp[logicID]);
416  aData.setAPDMean(ampMean);
417  aData.setAPDRMS(ampRms);
418  aData.setAPDOverPNMean(aopMean);
419  aData.setAPDOverPNRMS(aopRms);
420  aData.setTaskStatus(channelBad);
421 
422  MonTimingLaserBlueCrystalDat& tData(l1Time[logicID]);
423  tData.setTimingMean(timeMean);
424  tData.setTimingRMS(timeRms);
425  tData.setTaskStatus(channelBad);
426  }
427  break;
428  case 2:
429  {
430  MonLaserGreenDat& aData(l2Amp[logicID]);
431  aData.setAPDMean(ampMean);
432  aData.setAPDRMS(ampRms);
433  aData.setAPDOverPNMean(aopMean);
434  aData.setAPDOverPNRMS(aopRms);
435  aData.setTaskStatus(channelBad);
436 
437  MonTimingLaserGreenCrystalDat& tData(l2Time[logicID]);
438  tData.setTimingMean(timeMean);
439  tData.setTimingRMS(timeRms);
440  tData.setTaskStatus(channelBad);
441  }
442  break;
443  case 3:
444  {
445  MonLaserIRedDat& aData(l3Amp[logicID]);
446  aData.setAPDMean(ampMean);
447  aData.setAPDRMS(ampRms);
448  aData.setAPDOverPNMean(aopMean);
449  aData.setAPDOverPNRMS(aopRms);
450  aData.setTaskStatus(channelBad);
451 
452  MonTimingLaserIRedCrystalDat& tData(l3Time[logicID]);
453  tData.setTimingMean(timeMean);
454  tData.setTimingRMS(timeRms);
455  tData.setTaskStatus(channelBad);
456  }
457  break;
458  case 4:
459  {
460  MonLaserRedDat& aData(l4Amp[logicID]);
461  aData.setAPDMean(ampMean);
462  aData.setAPDRMS(ampRms);
463  aData.setAPDOverPNMean(aopMean);
464  aData.setAPDOverPNRMS(aopRms);
465  aData.setTaskStatus(channelBad);
466 
467  MonTimingLaserRedCrystalDat& tData(l4Time[logicID]);
468  tData.setTimingMean(timeMean);
469  tData.setTimingRMS(timeRms);
470  tData.setTaskStatus(channelBad);
471  }
472  break;
473  }
474  result &= qualityOK(channelStatus);
475  }
476 
477  for(unsigned iMD(0); iMD < memDCC.size(); ++iMD){
478  unsigned iDCC(memDCC[iMD]);
479 
480  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
481 
482  for(unsigned iPN(1); iPN <= 10; ++iPN){
483  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
484 
485  float entries(pnME.getBinEntries(pnid));
486  if(entries < 1.) continue;
487 
488  float mean(pnME.getBinContent(pnid));
489  float rms(pnME.getBinError(pnid) * std::sqrt(entries));
490 
491  float pedestalEntries(pnPedestalME.getBinEntries(pnid));
492  float pedestalMean(pnPedestalME.getBinContent(pnid));
493  float pedestalRms(pnPedestalME.getBinError(pnid) * std::sqrt(pedestalEntries));
494 
495  int channelStatus(pnQualityME.getBinContent(pnid));
496  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
497 
498  switch(wl){
499  case 1:
500  {
501  MonPNBlueDat& data(l1PN[lmPNID(pnid)]);
502  data.setADCMeanG1(-1.);
503  data.setADCRMSG1(-1.);
504  data.setPedMeanG1(-1.);
505  data.setPedRMSG1(-1.);
506  data.setADCMeanG16(mean);
507  data.setADCRMSG16(rms);
508  data.setPedMeanG16(pedestalMean);
509  data.setPedRMSG16(pedestalRms);
510  data.setTaskStatus(channelBad);
511  }
512  break;
513  case 2:
514  {
515  MonPNGreenDat& data(l2PN[lmPNID(pnid)]);
516  data.setADCMeanG1(-1.);
517  data.setADCRMSG1(-1.);
518  data.setPedMeanG1(-1.);
519  data.setPedRMSG1(-1.);
520  data.setADCMeanG16(mean);
521  data.setADCRMSG16(rms);
522  data.setPedMeanG16(pedestalMean);
523  data.setPedRMSG16(pedestalRms);
524  data.setTaskStatus(channelBad);
525  }
526  break;
527  case 3:
528  {
529  MonPNIRedDat& data(l3PN[lmPNID(pnid)]);
530  data.setADCMeanG1(-1.);
531  data.setADCRMSG1(-1.);
532  data.setPedMeanG1(-1.);
533  data.setPedRMSG1(-1.);
534  data.setADCMeanG16(mean);
535  data.setADCRMSG16(rms);
536  data.setPedMeanG16(pedestalMean);
537  data.setPedRMSG16(pedestalRms);
538  data.setTaskStatus(channelBad);
539  }
540  break;
541  case 4:
542  {
543  MonPNRedDat& data(l4PN[lmPNID(pnid)]);
544  data.setADCMeanG1(-1.);
545  data.setADCRMSG1(-1.);
546  data.setPedMeanG1(-1.);
547  data.setPedRMSG1(-1.);
548  data.setADCMeanG16(mean);
549  data.setADCRMSG16(rms);
550  data.setPedMeanG16(pedestalMean);
551  data.setPedRMSG16(pedestalRms);
552  data.setTaskStatus(channelBad);
553  }
554  break;
555  }
556 
557  result &= qualityOK(channelStatus);
558 
559  }
560  }
561  }
562 
563  try{
564  if(l1Amp.size() > 0)
565  _db->insertDataArraySet(&l1Amp, &_iov);
566  if(l1Time.size() > 0)
567  _db->insertDataArraySet(&l1Time, &_iov);
568  if(l1PN.size() > 0)
569  _db->insertDataArraySet(&l1PN, &_iov);
570  if(l2Amp.size() > 0)
571  _db->insertDataArraySet(&l2Amp, &_iov);
572  if(l2Time.size() > 0)
573  _db->insertDataArraySet(&l2Time, &_iov);
574  if(l2PN.size() > 0)
575  _db->insertDataArraySet(&l2PN, &_iov);
576  if(l3Amp.size() > 0)
577  _db->insertDataArraySet(&l3Amp, &_iov);
578  if(l3Time.size() > 0)
579  _db->insertDataArraySet(&l3Time, &_iov);
580  if(l3PN.size() > 0)
581  _db->insertDataArraySet(&l3PN, &_iov);
582  if(l4Amp.size() > 0)
583  _db->insertDataArraySet(&l4Amp, &_iov);
584  if(l4Time.size() > 0)
585  _db->insertDataArraySet(&l4Time, &_iov);
586  if(l4PN.size() > 0)
587  _db->insertDataArraySet(&l4PN, &_iov);
588  }
589  catch(std::runtime_error& e){
590  if(std::string(e.what()).find("unique constraint") != std::string::npos)
591  edm::LogWarning("EcalDQM") << e.what();
592  else
593  throw cms::Exception("DBError") << e.what();
594  }
595 
596  return result;
597  }
std::vector< unsigned > const memDCC
std::map< int, unsigned > wlToME_
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)
EcalLogicID lmPNID(EcalPnDiodeDetId const &)
string const
Definition: compareJSON.py:14
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void insertDataArraySet(const std::map< EcalLogicID, DATT > *data, IOVT *iov)
EcalLogicID crystalID(DetId const &)

Member Data Documentation

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

Definition at line 55 of file DBWriterWorkers.h.

Referenced by LaserWriter(), and run().