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

Constructor & Destructor Documentation

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

Definition at line 310 of file DBWriterWorkers.cc.

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

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

Definition at line 52 of file DBWriterWorkers.h.

52 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 333 of file DBWriterWorkers.cc.

References compareJSON::const, ecaldqm::crystalID(), AlCaHLTBitMon_QueryRunRegistry::data, alignCSCRings::e, EcalBarrel, EcalEndcap, 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(), mps_fire::result, plotscripts::rms(), MonPNRedDat::setADCMeanG1(), MonPNBlueDat::setADCMeanG1(), MonPNGreenDat::setADCMeanG1(), MonPNIRedDat::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(), MonLaserIRedDat::setAPDOverPNRMS(), MonLaserGreenDat::setAPDOverPNRMS(), MonLaserRedDat::setAPDRMS(), MonLaserGreenDat::setAPDRMS(), MonLaserIRedDat::setAPDRMS(), MonLaserBlueDat::setAPDRMS(), MonPNRedDat::setPedMeanG1(), MonPNIRedDat::setPedMeanG1(), MonPNBlueDat::setPedMeanG1(), MonPNGreenDat::setPedMeanG1(), MonPNIRedDat::setPedMeanG16(), MonPNRedDat::setPedMeanG16(), MonPNBlueDat::setPedMeanG16(), MonPNGreenDat::setPedMeanG16(), MonPNIRedDat::setPedRMSG1(), MonPNBlueDat::setPedRMSG1(), MonPNRedDat::setPedRMSG1(), MonPNGreenDat::setPedRMSG1(), MonPNIRedDat::setPedRMSG16(), MonPNGreenDat::setPedRMSG16(), MonPNRedDat::setPedRMSG16(), MonPNBlueDat::setPedRMSG16(), MonLaserIRedDat::setTaskStatus(), MonLaserRedDat::setTaskStatus(), MonLaserBlueDat::setTaskStatus(), MonLaserGreenDat::setTaskStatus(), MonPNRedDat::setTaskStatus(), MonPNBlueDat::setTaskStatus(), MonPNIRedDat::setTaskStatus(), MonPNGreenDat::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().

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

Referenced by LaserWriter(), and run().