CMS 3D CMS Logo

EcalCondDBReader.cc
Go to the documentation of this file.
1 #include <memory>
2 
4 
7 
11 
13 
15  : db_(nullptr),
16  monIOV_(),
17  worker_(nullptr),
18  formula_(_ps.getUntrackedParameter<std::string>("formula")),
19  meSet_(ecaldqm::createMESet(_ps.getUntrackedParameterSet("plot"))),
20  verbosity_(_ps.getUntrackedParameter<int>("verbosity")) {
22  edm::ParameterSet const &workerParams(_ps.getUntrackedParameterSet("workerParams"));
23 
24  if (table == "CrystalConsistency")
26  if (table == "TTConsistency")
28  if (table == "MemChConsistency")
30  if (table == "MemTTConsistency")
32  if (table == "LaserBlue")
34  if (table == "TimingLaserBlueCrystal")
36  if (table == "PNBlue")
38  if (table == "LaserGreen")
40  if (table == "TimingLaserGreenCrystal")
42  if (table == "PNGreen")
44  if (table == "LaserIRed")
46  if (table == "TimingLaserIRedCrystal")
48  if (table == "PNIRed")
50  if (table == "LaserRed")
52  if (table == "TimingLaserRedCrystal")
54  if (table == "PNRed")
56  if (table == "Pedestals")
58  if (table == "PNPed")
60  if (table == "PedestalsOnline")
62  if (table == "TestPulse")
64  if (table == "PulseShape")
66  if (table == "PNMGPA")
68  if (table == "TimingCrystal")
70  if (table == "Led1")
72  if (table == "TimingLed1Crystal")
74  if (table == "Led2")
76  if (table == "TimingLed2Crystal")
78  if (table == "Occupancy")
80 
81  if (!worker_)
82  throw cms::Exception("Configuration") << "Invalid worker type";
83 
86  int hostPort(_ps.getUntrackedParameter<int>("hostPort"));
89 
90  std::unique_ptr<EcalCondDBInterface> db(nullptr);
91 
92  if (verbosity_ > 0)
93  edm::LogInfo("EcalDQM") << "Establishing DB connection";
94 
95  try {
96  db = std::make_unique<EcalCondDBInterface>(DBName, userName, password);
97  } catch (std::runtime_error &re) {
98  if (!hostName.empty()) {
99  try {
100  db = std::make_unique<EcalCondDBInterface>(hostName, DBName, userName, password, hostPort);
101  } catch (std::runtime_error &re2) {
102  throw cms::Exception("DBError") << re2.what();
103  }
104  } else
105  throw cms::Exception("DBError") << re.what();
106  }
107 
108  db_ = db.release();
109 
111  int runNumber(_ps.getUntrackedParameter<int>("runNumber"));
113 
114  if (verbosity_ > 0)
115  edm::LogInfo("EcalDQM") << "Initializing DB entry";
116 
117  RunTag runTag;
118 
119  try {
121  } catch (std::exception &) {
122  edm::LogError("EcalDQM") << "Cannot fetch RunIOV for location=" << location << " runNumber=" << runNumber;
123  throw;
124  }
125 
126  MonVersionDef versionDef;
127  versionDef.setMonitoringVersion("test01"); // the only mon_ver in mon_version_def table as of September
128  // 2012
129  MonRunTag monTag;
130  monTag.setMonVersionDef(versionDef);
132 
133  try {
134  monIOV_ = db_->fetchMonRunIOV(&runTag, &monTag, runNumber, 1);
135  } catch (std::runtime_error &e) {
136  edm::LogError("EcalDQM") << "Cannot fetch MonRunIOV for location=" << location << " runNumber=" << runNumber
137  << " monVersion=test01 monRunGeneralTag=" << monRunGeneralTag;
138  throw;
139  }
140 
141  if (verbosity_ > 0)
142  edm::LogInfo("EcalDQM") << " Done.";
143 }
144 
146  delete worker_;
147  delete meSet_;
148 }
149 
152  edm::Run const &,
153  edm::EventSetup const &_es) {
154  setElectronicsMap(_es);
155  meSet_->book(_ibooker, GetElectronicsMap());
156 
157  std::map<DetId, double> values(worker_->run(db_, monIOV_, formula_));
158  for (std::map<DetId, double>::const_iterator vItr(values.begin()); vItr != values.end(); ++vItr)
159  meSet_->setBinContent(getEcalDQMSetupObjects(), vItr->first, vItr->second);
160 }
161 
164  _es.get<EcalMappingRcd>().get(elecMapHandle);
165  electronicsMap = elecMapHandle.product();
166 }
167 
169  if (!electronicsMap)
170  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
171  return electronicsMap;
172 }
173 
175  if (!electronicsMap)
176  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
177  ecaldqm::EcalDQMSetupObjects edso = {electronicsMap, nullptr, nullptr, nullptr};
178  return edso;
179 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
EcalCondDBReader::getEcalDQMSetupObjects
const ecaldqm::EcalDQMSetupObjects getEcalDQMSetupObjects()
Definition: EcalCondDBReader.cc:174
MonVersionDef::setMonitoringVersion
void setMonitoringVersion(std::string ver)
Definition: MonVersionDef.cc:21
EcalCondDBReader.h
MessageLogger.h
ecaldqm::TestPulseReader
Definition: DBReaderWorkers.h:183
ecaldqm
Definition: DQWorker.h:29
edm::ParameterSet::getUntrackedParameterSet
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Definition: ParameterSet.cc:2136
EcalCondDBReader::dqmEndRun
void dqmEndRun(DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &) override
Definition: EcalCondDBReader.cc:150
edm::Run
Definition: Run.h:45
EcalCondDBWriter_cfi.hostPort
hostPort
Definition: EcalCondDBWriter_cfi.py:60
ecaldqm::MESet::setBinContent
virtual void setBinContent(EcalDQMSetupObjects const, DetId const &, double)
Definition: MESet.h:79
ecaldqm::MESet::book
virtual void book(DQMStore::IBooker &, EcalElectronicsMapping const *)
Definition: MESet.h:57
RunTag
Definition: RunTag.h:13
EcalCondDBWriter_cfi.monRunGeneralTag
monRunGeneralTag
Definition: EcalCondDBWriter_cfi.py:66
ecaldqm::CrystalConsistencyReader
Definition: DBReaderWorkers.h:30
EcalCondDBReader::electronicsMap
const EcalElectronicsMapping * electronicsMap
Definition: EcalCondDBReader.h:17
EcalCondDBInterface::fetchMonRunIOV
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) noexcept(false)
Definition: EcalCondDBInterface.cc:674
EcalCondDBWriter_cfi.DBName
DBName
Definition: EcalCondDBWriter_cfi.py:58
DQMStore.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ecaldqm::TimingLed2CrystalReader
Definition: DBReaderWorkers.h:239
EcalCondDBReader::setElectronicsMap
void setElectronicsMap(edm::EventSetup const &)
Definition: EcalCondDBReader.cc:162
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
EcalCondDBReader::formula_
std::string formula_
Definition: EcalCondDBReader.h:44
MonRunTag::setGeneralTag
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:21
ecaldqm::TimingLaserGreenCrystalReader
Definition: DBReaderWorkers.h:94
EcalCondDBWriter_cfi.userName
userName
Definition: EcalCondDBWriter_cfi.py:61
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
dqmiodatasetharvest.db
db
Definition: dqmiodatasetharvest.py:119
EcalCondDBWriter_cfi.password
password
Definition: EcalCondDBWriter_cfi.py:62
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
EcalCondDBReader::EcalCondDBReader
EcalCondDBReader(edm::ParameterSet const &)
Definition: EcalCondDBReader.cc:14
Service.h
RunIOV::getRunTag
RunTag getRunTag() const
Definition: RunIOV.cc:58
ecaldqm::PNBlueReader
Definition: DBReaderWorkers.h:78
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
ecaldqm::Led2Reader
Definition: DBReaderWorkers.h:231
ecaldqm::LaserGreenReader
Definition: DBReaderWorkers.h:86
ecaldqm::PNRedReader
Definition: DBReaderWorkers.h:151
ecaldqm::DBReaderWorker::run
virtual std::map< DetId, double > run(EcalCondDBInterface *, MonRunIOV &, std::string const &)=0
EcalMappingRcd.h
edm::ESHandle< EcalElectronicsMapping >
ecaldqm::PedestalsReader
Definition: DBReaderWorkers.h:159
ecaldqm::PNPedReader
Definition: DBReaderWorkers.h:167
MonVersionDef
Definition: MonVersionDef.h:12
ecaldqm::TimingCrystalReader
Definition: DBReaderWorkers.h:207
ecaldqm::PNIRedReader
Definition: DBReaderWorkers.h:127
EcalCondDBReader::worker_
ecaldqm::DBReaderWorker * worker_
Definition: EcalCondDBReader.h:43
EcalCondDBReader::verbosity_
int verbosity_
Definition: EcalCondDBReader.h:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
EcalCondDBWriter_cfi.workerParams
workerParams
Definition: EcalCondDBWriter_cfi.py:68
ecaldqm::PedestalsOnlineReader
Definition: DBReaderWorkers.h:175
edm::ParameterSet
Definition: ParameterSet.h:47
EcalCondDBWriter_cfi.hostName
hostName
Definition: EcalCondDBWriter_cfi.py:59
ecaldqm::EcalDQMSetupObjects
Definition: MESet.h:33
ecaldqm::PNMGPAReader
Definition: DBReaderWorkers.h:199
ecaldqm::MemTTConsistencyReader
Definition: DBReaderWorkers.h:54
createfilelist.int
int
Definition: createfilelist.py:10
ecaldqm::Led1Reader
Definition: DBReaderWorkers.h:215
EcalCondDBReader::meSet_
ecaldqm::MESet * meSet_
Definition: EcalCondDBReader.h:45
edm::EventSetup
Definition: EventSetup.h:58
MonRunTag
Definition: MonRunTag.h:13
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
ecaldqm::TimingLaserIRedCrystalReader
Definition: DBReaderWorkers.h:119
get
#define get
ecaldqm::TimingLed1CrystalReader
Definition: DBReaderWorkers.h:223
EcalCondDBReader::GetElectronicsMap
const EcalElectronicsMapping * GetElectronicsMap()
Definition: EcalCondDBReader.cc:168
ecaldqm::TTConsistencyReader
Definition: DBReaderWorkers.h:38
std
Definition: JetResolutionObject.h:76
EcalCondDBReader::db_
EcalCondDBInterface * db_
Definition: EcalCondDBReader.h:41
EcalMappingRcd
Definition: EcalMappingRcd.h:15
ecaldqm::createMESet
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:18
ecaldqm::LaserIRedReader
Definition: DBReaderWorkers.h:111
ecaldqm::PulseShapeReader
Definition: DBReaderWorkers.h:191
dqm::implementation::IGetter
Definition: DQMStore.h:484
Exception
Definition: hltDiff.cc:245
MESetUtils.h
ecaldqm::PNGreenReader
Definition: DBReaderWorkers.h:103
ecaldqm::TimingLaserRedCrystalReader
Definition: DBReaderWorkers.h:143
ecaldqm::OccupancyReader
Definition: DBReaderWorkers.h:247
dqm::implementation::IBooker
Definition: DQMStore.h:43
ecaldqm::MemChConsistencyReader
Definition: DBReaderWorkers.h:46
EcalCondDBWriter_cfi.location
location
Definition: EcalCondDBWriter_cfi.py:63
MonRunTag::setMonVersionDef
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:30
ParameterSet.h
EcalCondDBReader::monIOV_
MonRunIOV monIOV_
Definition: EcalCondDBReader.h:42
ecaldqm::LaserBlueReader
Definition: DBReaderWorkers.h:62
TableParser.table
table
Definition: TableParser.py:111
EcalCondDBInterface::fetchRunIOV
RunIOV fetchRunIOV(RunTag *tag, run_t run) noexcept(false)
Definition: EcalCondDBInterface.cc:631
EcalCondDBReader::~EcalCondDBReader
~EcalCondDBReader() override
Definition: EcalCondDBReader.cc:145
ecaldqm::LaserRedReader
Definition: DBReaderWorkers.h:135
ecaldqm::TimingLaserBlueCrystalReader
Definition: DBReaderWorkers.h:70
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37