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

#include <DBWriterWorkers.h>

Inheritance diagram for ecaldqm::TestPulseWriter:
ecaldqm::DBWriterWorker

Public Member Functions

bool run (EcalCondDBInterface *, MonRunIOV &) override
 
 TestPulseWriter (edm::ParameterSet const &)
 
 ~TestPulseWriter ()
 
- 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 > gainToME_
 
std::map< int, unsigned > pnGainToME_
 

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

Constructor & Destructor Documentation

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

Definition at line 828 of file DBWriterWorkers.cc.

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

828  :
829  DBWriterWorker("TestPulse", _ps),
830  gainToME_(),
831  pnGainToME_()
832  {
833  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int> >("MGPAGains"));
834  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int> >("MGPAGainsPN"));
835 
837 
838  MESetMulti const& amplitude(static_cast<MESetMulti const&>(source_.at("Amplitude")));
839  unsigned nG(MGPAGains.size());
840  for(unsigned iG(0); iG != nG; ++iG){
841  int gain(MGPAGains[iG]);
842  if(gain != 1 && gain != 6 && gain != 12) throw cms::Exception("InvalidConfiguration") << "MGPA gain";
843  repl["gain"] = std::to_string(gain);
844  gainToME_[gain] = amplitude.getIndex(repl);
845  }
846 
847  repl.clear();
848 
849  MESetMulti const& pnAmplitude(static_cast<MESetMulti const&>(source_.at("PNAmplitude")));
850  unsigned nGPN(MGPAGainsPN.size());
851  for(unsigned iG(0); iG != nGPN; ++iG){
852  int gain(MGPAGainsPN[iG]);
853  if(gain != 1 && gain != 16) throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
854  repl["pngain"] = std::to_string(gain);
855  pnGainToME_[gain] = pnAmplitude.getIndex(repl);
856  }
857  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
std::map< int, unsigned > gainToME_
std::string to_string(const T &t)
Definition: Logger.cc:26
MESetCollection source_
std::map< int, unsigned > pnGainToME_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:31
ecaldqm::TestPulseWriter::~TestPulseWriter ( )
inline

Definition at line 81 of file DBWriterWorkers.h.

81 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 860 of file DBWriterWorkers.cc.

References compareJSON::const, ecaldqm::crystalID(), data, alignCSCRings::e, EcalBarrel, EcalEndcap, python.tagInventory::entries, edm::hlt::Exception, spr::find(), gainToME_, ecaldqm::getElectronicsMap(), i, EcalCondDBInterface::insertDataArraySet(), EcalCondDBInterface::insertDataSet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), timingPdfMaker::mean, ecaldqm::memDCC, ecaldqm::nChannels, pnGainToME_, ecaldqm::qualityOK(), query::result, plotscripts::rms(), MonPNMGPADat::setADCMeanG1(), MonTestPulseDat::setADCMeanG1(), MonTestPulseDat::setADCMeanG12(), MonPNMGPADat::setADCMeanG16(), MonTestPulseDat::setADCMeanG6(), MonPNMGPADat::setADCRMSG1(), MonTestPulseDat::setADCRMSG1(), MonTestPulseDat::setADCRMSG12(), MonPNMGPADat::setADCRMSG16(), MonTestPulseDat::setADCRMSG6(), MonPNMGPADat::setPedMeanG1(), MonPNMGPADat::setPedMeanG16(), MonPNMGPADat::setPedRMSG1(), MonPNMGPADat::setPedRMSG16(), MonPulseShapeDat::setSamples(), MonTestPulseDat::setTaskStatus(), MonPNMGPADat::setTaskStatus(), ecaldqm::DBWriterWorker::source_, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, and ecaldqm::MESet::const_iterator::toNextChannel().

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

861  {
862  /*
863  uses
864  TestPulseTask.Amplitude (ha01, ha02, ha03)
865  TestPulseTask.Shape (me_hs01, me_hs02, me_hs03)
866  TestPulseTask.PNAmplitude (i01, i02)
867  PNDiodeTask.Pedestal (i03, i04)
868  TestPulseClient.Quality (meg01, meg02, meg03)
869  TestPulseClient.PNQualitySummary (meg04, meg05)
870  */
871 
872  bool result(true);
873 
874  std::map<EcalLogicID, MonTestPulseDat> amplitude;
875  std::map<EcalLogicID, MonPulseShapeDat> shape;
876  std::map<EcalLogicID, MonPNMGPADat> pnAmplitude;
877 
878  MESet const& amplitudeME(source_.at("Amplitude"));
879  MESet const& shapeME(source_.at("Shape"));
880  MESet const& qualityME(source_.at("Quality"));
881 
882  MESet const& pnAmplitudeME(source_.at("PNAmplitude"));
883  MESet const& pnPedestalME(source_.at("PNPedestal"));
884  MESet const& pnQualityME(source_.at("PNQuality"));
885 
886  for(std::map<int, unsigned>::iterator gainItr(gainToME_.begin()); gainItr != gainToME_.end(); ++gainItr){
887  int gain(gainItr->first);
888  int iM(gainItr->second);
889 
890  static_cast<MESetMulti const&>(amplitudeME).use(iM);
891  static_cast<MESetMulti const&>(shapeME).use(iM);
892  static_cast<MESetMulti const&>(qualityME).use(iM);
893 
894  MESet::const_iterator aEnd(amplitudeME.end());
895  MESet::const_iterator qItr(qualityME);
896  for(MESet::const_iterator aItr(amplitudeME.beginChannel()); aItr != aEnd; aItr.toNextChannel()){
897  float entries(aItr->getBinEntries());
898  if(entries < 1.) continue;
899 
900  qItr = aItr;
901 
902  float mean(aItr->getBinContent());
903  float rms(aItr->getBinError() * std::sqrt(entries));
904 
905  EcalLogicID logicID(crystalID(aItr->getId()));
906  if(amplitude.find(logicID) == amplitude.end()){
907  MonTestPulseDat& insertion(amplitude[logicID]);
908  insertion.setADCMeanG1(-1.);
909  insertion.setADCRMSG1(-1.);
910  insertion.setADCMeanG6(-1.);
911  insertion.setADCRMSG6(-1.);
912  insertion.setADCMeanG12(-1.);
913  insertion.setADCRMSG12(-1.);
914  insertion.setTaskStatus(false);
915  }
916 
917  MonTestPulseDat& data(amplitude[logicID]);
918  switch(gain){
919  case 1:
920  data.setADCMeanG1(mean);
921  data.setADCRMSG1(rms);
922  break;
923  case 6:
924  data.setADCMeanG6(mean);
925  data.setADCRMSG6(rms);
926  break;
927  case 12:
928  data.setADCMeanG12(mean);
929  data.setADCRMSG12(rms);
930  break;
931  }
932 
933  int channelStatus(qItr->getBinContent());
934  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
935  if(channelBad)
936  data.setTaskStatus(true);
937 
938  result &= qualityOK(channelStatus);
939  }
940 
941  for(unsigned iSM(0); iSM < 54; ++iSM){
942  std::vector<float> samples(10, 0.);
943  std::vector<DetId> ids(getElectronicsMap()->dccConstituents(iSM + 1));
944  unsigned nId(ids.size());
945  unsigned nChannels(0);
946  EcalLogicID logicID;
947  for(unsigned iD(0); iD < nId; ++iD){
948  DetId& id(ids[iD]);
949 
950  if(iD == 0) logicID = crystalID(id);
951 
952  if(shapeME.getBinEntries(id, 1) < 1.) continue;
953 
954  ++nChannels;
955 
956  for(int i(0); i < 10; ++i)
957  samples[i] += shapeME.getBinContent(id, i + 1);
958  }
959 
960  if(nChannels == 0) continue;
961 
962  for(int i(0); i < 10; ++i)
963  samples[i] /= nChannels;
964 
965  if(shape.find(logicID) == shape.end()){
966  MonPulseShapeDat& insertion(shape[logicID]);
967  std::vector<float> defval(10, -1.);
968  insertion.setSamples(defval, 1);
969  insertion.setSamples(defval, 6);
970  insertion.setSamples(defval, 12);
971  }
972 
973  MonPulseShapeDat& data(shape[logicID]);
974  data.setSamples(samples, gain);
975  }
976  }
977 
978  for(std::map<int, unsigned>::iterator gainItr(pnGainToME_.begin()); gainItr != pnGainToME_.end(); ++gainItr){
979  int gain(gainItr->first);
980  int iM(gainItr->second);
981 
982  static_cast<MESetMulti const&>(pnAmplitudeME).use(iM);
983  static_cast<MESetMulti const&>(pnQualityME).use(iM);
984 
985  for(unsigned iMD(0); iMD < memDCC.size(); ++iMD){
986  unsigned iDCC(memDCC[iMD]);
987 
988  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
989 
990  for(unsigned iPN(1); iPN <= 10; ++iPN){
991  EcalPnDiodeDetId pnid(subdet, iDCC + 1, iPN);
992 
993  float entries(pnAmplitudeME.getBinEntries(pnid));
994  if(entries < 1.) continue;
995 
996  float mean(pnAmplitudeME.getBinContent(pnid));
997  float rms(pnAmplitudeME.getBinError(pnid) * std::sqrt(entries));
998  float pedestalEntries(pnPedestalME.getBinEntries(pnid));
999  float pedestalMean(pnPedestalME.getBinContent(pnid));
1000  float pedestalRms(pnPedestalME.getBinError(pnid) * std::sqrt(pedestalEntries));
1001 
1002  EcalLogicID logicID(lmPNID(pnid));
1003  if(pnAmplitude.find(logicID) == pnAmplitude.end()){
1004  MonPNMGPADat& insertion(pnAmplitude[logicID]);
1005  insertion.setADCMeanG1(-1.);
1006  insertion.setADCRMSG1(-1.);
1007  insertion.setPedMeanG1(-1.);
1008  insertion.setPedRMSG1(-1.);
1009  insertion.setADCMeanG16(-1.);
1010  insertion.setADCRMSG16(-1.);
1011  insertion.setPedMeanG16(-1.);
1012  insertion.setPedRMSG16(-1.);
1013  insertion.setTaskStatus(false);
1014  }
1015 
1016  MonPNMGPADat& data(pnAmplitude[lmPNID(pnid)]);
1017  switch(gain){
1018  case 1:
1019  data.setADCMeanG1(mean);
1020  data.setADCRMSG1(rms);
1021  // dynamic pedestal not measured for G1
1022 // data.setPedMeanG1(pedestalMean);
1023 // data.setPedRMSG1(pedestalRms);
1024  break;
1025  case 16:
1026  data.setADCMeanG16(mean);
1027  data.setADCRMSG16(rms);
1028  data.setPedMeanG16(pedestalMean);
1029  data.setPedRMSG16(pedestalRms);
1030  break;
1031  }
1032 
1033  int channelStatus(pnQualityME.getBinContent(pnid));
1034  bool channelBad(channelStatus == kBad || channelStatus == kMBad);
1035  if(channelBad)
1036  data.setTaskStatus(true);
1037 
1038  result &= qualityOK(channelStatus);
1039  }
1040  }
1041  }
1042 
1043  try{
1044  if(amplitude.size() > 0)
1045  _db->insertDataArraySet(&amplitude, &_iov);
1046  if(shape.size() > 0)
1047  _db->insertDataSet(&shape, &_iov);
1048  if(pnAmplitude.size() > 0)
1049  _db->insertDataArraySet(&pnAmplitude, &_iov);
1050  }
1051  catch(std::runtime_error& e){
1052  if(std::string(e.what()).find("unique constraint") != std::string::npos)
1053  edm::LogWarning("EcalDQM") << e.what();
1054  else
1055  throw cms::Exception("DBError") << e.what();
1056  }
1057 
1058  return result;
1059  }
std::vector< unsigned > const memDCC
int i
Definition: DBlmapReader.cc:9
EcalElectronicsMapping const * getElectronicsMap()
std::map< int, unsigned > gainToME_
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
std::map< int, unsigned > pnGainToME_
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)
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov)
EcalLogicID crystalID(DetId const &)

Member Data Documentation

std::map<int, unsigned> ecaldqm::TestPulseWriter::gainToME_
private

Definition at line 86 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().

std::map<int, unsigned> ecaldqm::TestPulseWriter::pnGainToME_
private

Definition at line 87 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().