CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
ecaldqm::TestPulseWriter Class Reference

#include <DBWriterWorkers.h>

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

Public Member Functions

bool run (EcalCondDBInterface *, MonRunIOV &) override
 
 TestPulseWriter (edm::ParameterSet const &)
 
 ~TestPulseWriter () override
 
- 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)
 
 ~DBWriterWorker () override
 
- Public Member Functions inherited from ecaldqm::DQWorker
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
virtual void bookMEs (DQMStore::IBooker &)
 
 DQWorker ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
EcalDQMSetupObjects const getEcalDQMSetupObjects ()
 
EcalElectronicsMapping const * GetElectronicsMap ()
 
CaloGeometry const * GetGeometry ()
 
std::string const & getName () const
 
CaloTopology const * GetTopology ()
 
EcalTrigTowerConstituentsMap
const * 
GetTrigTowerMap ()
 
bool onlineMode () const
 
virtual void releaseMEs ()
 
void setEventNumber (edm::EventNumber_t _e)
 
void setLumiNumber (edm::LuminosityBlockNumber_t _l)
 
void setRunNumber (edm::RunNumber_t _r)
 
void setSetupObjects (edm::EventSetup const &)
 
void setSetupObjectsEndLumi (edm::EventSetup const &)
 
void setTime (time_t _t)
 
void setTokens (edm::ConsumesCollector &)
 
virtual ~DQWorker () noexcept(false)
 

Private Attributes

std::map< int, unsigned > gainToME_
 
std::map< int, unsigned > pnGainToME_
 

Additional Inherited Members

- Public Types inherited from ecaldqm::DBWriterWorker
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Static Public Member Functions inherited from ecaldqm::DQWorker
static void fillDescriptions (edm::ParameterSetDescription &_desc)
 
- Public Attributes inherited from ecaldqm::DQWorker
edm::ESGetToken
< EcalElectronicsMapping,
EcalMappingRcd
elecMapHandle
 
edm::ESGetToken
< EcalElectronicsMapping,
EcalMappingRcd
elecMapHandleEndLumi
 
edm::ESGetToken< CaloGeometry,
CaloGeometryRecord
geomHandle
 
edm::ESGetToken< CaloGeometry,
CaloGeometryRecord
geomHandleEndLumi
 
edm::ESGetToken< CaloTopology,
CaloTopologyRecord
topoHandle
 
edm::ESGetToken< CaloTopology,
CaloTopologyRecord
topoHandleEndLumi
 
edm::ESGetToken
< EcalTrigTowerConstituentsMap,
IdealGeometryRecord
ttMapHandle
 
edm::ESGetToken
< EcalTrigTowerConstituentsMap,
IdealGeometryRecord
ttMapHandleEndLumi
 
- Protected Types inherited from ecaldqm::DQWorker
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Protected Member Functions inherited from ecaldqm::DQWorker
void initialize (std::string const &_name, edm::ParameterSet const &)
 
void print_ (std::string const &, int=0) const
 
virtual void setME (edm::ParameterSet const &)
 
virtual void setParams (edm::ParameterSet const &)
 
virtual void setSource (edm::ParameterSet const &)
 
void setVerbosity (int _verbosity)
 
- Protected Attributes inherited from ecaldqm::DBWriterWorker
bool active_
 
std::string const name_
 
std::set< std::string > runTypes_
 
MESetCollection source_
 
int verbosity_
 
- Protected Attributes inherited from ecaldqm::DQWorker
bool booked_
 
MESetCollection MEs_
 
std::string name_
 
bool onlineMode_
 
Timestamp timestamp_
 
int verbosity_
 
bool willConvertToEDM_
 

Detailed Description

Definition at line 82 of file DBWriterWorkers.h.

Constructor & Destructor Documentation

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

Definition at line 801 of file DBWriterWorkers.cc.

References ecaldqm::MESetCollection::at(), Exception, gainToME_, ecaldqm::MESetMulti::getIndex(), edm::ParameterSet::getUntrackedParameter(), pnGainToME_, and ecaldqm::DBWriterWorker::source_.

802  : DBWriterWorker("TestPulse", _ps), gainToME_(), pnGainToME_() {
803  std::vector<int> MGPAGains(_ps.getUntrackedParameter<std::vector<int>>("MGPAGains"));
804  std::vector<int> MGPAGainsPN(_ps.getUntrackedParameter<std::vector<int>>("MGPAGainsPN"));
805 
807 
808  MESetMulti const &amplitude(static_cast<MESetMulti const &>(source_.at("Amplitude")));
809  unsigned nG(MGPAGains.size());
810  for (unsigned iG(0); iG != nG; ++iG) {
811  int gain(MGPAGains[iG]);
812  if (gain != 1 && gain != 6 && gain != 12)
813  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
814  repl["gain"] = std::to_string(gain);
815  gainToME_[gain] = amplitude.getIndex(repl);
816  }
817 
818  repl.clear();
819 
820  MESetMulti const &pnAmplitude(static_cast<MESetMulti const &>(source_.at("PNAmplitude")));
821  unsigned nGPN(MGPAGainsPN.size());
822  for (unsigned iG(0); iG != nGPN; ++iG) {
823  int gain(MGPAGainsPN[iG]);
824  if (gain != 1 && gain != 16)
825  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
826  repl["pngain"] = std::to_string(gain);
827  pnGainToME_[gain] = pnAmplitude.getIndex(repl);
828  }
829  }
DBWriterWorker(std::string const &, edm::ParameterSet const &)
MESet & at(const std::string &key)
Definition: MESet.h:399
std::map< int, unsigned > gainToME_
MESetCollection source_
std::map< int, unsigned > pnGainToME_
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:46
ecaldqm::TestPulseWriter::~TestPulseWriter ( )
inlineoverride

Definition at line 85 of file DBWriterWorkers.h.

85 {}

Member Function Documentation

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

Implements ecaldqm::DBWriterWorker.

Definition at line 831 of file DBWriterWorkers.cc.

References ecaldqm::MESetCollection::at(), ecaldqm::crystalID(), data, alignCSCRings::e, EcalBarrel, EcalEndcap, Exception, spr::find(), gainToME_, ecaldqm::DQWorker::getEcalDQMSetupObjects(), ecaldqm::DQWorker::GetElectronicsMap(), mps_fire::i, gpuClustering::id, EcalCondDBInterface::insertDataArraySet(), EcalCondDBInterface::insertDataSet(), ecaldqm::kBad, ecaldqm::kEEpLow, ecaldqm::kMBad, ecaldqm::lmPNID(), SiStripPI::mean, ecaldqm::memDCC, ecaldqm::nChannels, pnGainToME_, ecaldqm::qualityOK(), mps_fire::result, SiStripPI::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().

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

Member Data Documentation

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

Definition at line 90 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().

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

Definition at line 91 of file DBWriterWorkers.h.

Referenced by run(), and TestPulseWriter().