CMS 3D CMS Logo

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
 
void retrieveSource (DQMStore::IGetter &)
 
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 80 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

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

Definition at line 827 of file DBWriterWorkers.cc.

References CustomPhysics_cfi::amplitude, Exception, muonCSCDigis_cfi::gain, gainToME_, ecaldqm::MESetMulti::getIndex(), edm::ParameterSet::getUntrackedParameter(), pnGainToME_, and ecaldqm::DBWriterWorker::source_.

827  :
828  DBWriterWorker("TestPulse", _ps),
829  gainToME_(),
830  pnGainToME_()
831  {
832  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int> >("MGPAGains"));
833  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int> >("MGPAGainsPN"));
834 
836 
837  MESetMulti const& amplitude(static_cast<MESetMulti const&>(source_.at("Amplitude")));
838  unsigned nG(MGPAGains.size());
839  for(unsigned iG(0); iG != nG; ++iG){
840  int gain(MGPAGains[iG]);
841  if(gain != 1 && gain != 6 && gain != 12) throw cms::Exception("InvalidConfiguration") << "MGPA gain";
842  repl["gain"] = std::to_string(gain);
843  gainToME_[gain] = amplitude.getIndex(repl);
844  }
845 
846  repl.clear();
847 
848  MESetMulti const& pnAmplitude(static_cast<MESetMulti const&>(source_.at("PNAmplitude")));
849  unsigned nGPN(MGPAGainsPN.size());
850  for(unsigned iG(0); iG != nGPN; ++iG){
851  int gain(MGPAGainsPN[iG]);
852  if(gain != 1 && gain != 16) throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
853  repl["pngain"] = std::to_string(gain);
854  pnGainToME_[gain] = pnAmplitude.getIndex(repl);
855  }
856  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
std::map< int, unsigned > gainToME_
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 83 of file DBWriterWorkers.h.

References ecaldqm::DBWriterWorker::run().

83 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 859 of file DBWriterWorkers.cc.

References CustomPhysics_cfi::amplitude, ecaldqm::crystalID(), data, MillePedeFileConverter_cfg::e, EcalBarrel, EcalEndcap, Exception, spr::find(), muonCSCDigis_cfi::gain, gainToME_, ecaldqm::getElectronicsMap(), mps_fire::i, hcalTTPDigis_cfi::id, EcalCondDBInterface::insertDataArraySet(), EcalCondDBInterface::insertDataSet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), RecoTauDiscriminantConfiguration::mean, ecaldqm::memDCC, ecaldqm::nChannels, pnGainToME_, ecaldqm::qualityOK(), mps_fire::result, RecoTauDiscriminantConfiguration::rms, hcalTTPDigis_cfi::samples, 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().

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

Member Data Documentation

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

Definition at line 88 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().

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

Definition at line 89 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().