CMS 3D CMS Logo

EcalCondDBReader.cc
Go to the documentation of this file.
1 #include <memory>
2 
4 
7 
11 
13  : db_(nullptr),
14  monIOV_(),
15  worker_(nullptr),
16  formula_(_ps.getUntrackedParameter<std::string>("formula")),
17  meSet_(ecaldqm::createMESet(_ps.getUntrackedParameterSet("plot"))),
18  verbosity_(_ps.getUntrackedParameter<int>("verbosity")),
19  elecMapHandle(esConsumes<edm::Transition::EndRun>()) {
21  edm::ParameterSet const &workerParams(_ps.getUntrackedParameterSet("workerParams"));
22 
23  if (table == "CrystalConsistency")
25  if (table == "TTConsistency")
27  if (table == "MemChConsistency")
29  if (table == "MemTTConsistency")
31  if (table == "LaserBlue")
33  if (table == "TimingLaserBlueCrystal")
35  if (table == "PNBlue")
37  if (table == "LaserGreen")
39  if (table == "TimingLaserGreenCrystal")
41  if (table == "PNGreen")
43  if (table == "LaserIRed")
45  if (table == "TimingLaserIRedCrystal")
47  if (table == "PNIRed")
49  if (table == "LaserRed")
51  if (table == "TimingLaserRedCrystal")
53  if (table == "PNRed")
55  if (table == "Pedestals")
57  if (table == "PNPed")
59  if (table == "PedestalsOnline")
61  if (table == "TestPulse")
63  if (table == "PulseShape")
65  if (table == "PNMGPA")
67  if (table == "TimingCrystal")
69  if (table == "Led1")
71  if (table == "TimingLed1Crystal")
73  if (table == "Led2")
75  if (table == "TimingLed2Crystal")
77  if (table == "Occupancy")
79 
80  if (!worker_)
81  throw cms::Exception("Configuration") << "Invalid worker type";
82 
85  int hostPort(_ps.getUntrackedParameter<int>("hostPort"));
88 
89  std::unique_ptr<EcalCondDBInterface> db(nullptr);
90 
91  if (verbosity_ > 0)
92  edm::LogInfo("EcalDQM") << "Establishing DB connection";
93 
94  try {
95  db = std::make_unique<EcalCondDBInterface>(DBName, userName, password);
96  } catch (std::runtime_error &re) {
97  if (!hostName.empty()) {
98  try {
99  db = std::make_unique<EcalCondDBInterface>(hostName, DBName, userName, password, hostPort);
100  } catch (std::runtime_error &re2) {
101  throw cms::Exception("DBError") << re2.what();
102  }
103  } else
104  throw cms::Exception("DBError") << re.what();
105  }
106 
107  db_ = db.release();
108 
110  int runNumber(_ps.getUntrackedParameter<int>("runNumber"));
112 
113  if (verbosity_ > 0)
114  edm::LogInfo("EcalDQM") << "Initializing DB entry";
115 
116  RunTag runTag;
117 
118  try {
120  } catch (std::exception &) {
121  edm::LogError("EcalDQM") << "Cannot fetch RunIOV for location=" << location << " runNumber=" << runNumber;
122  throw;
123  }
124 
125  MonVersionDef versionDef;
126  versionDef.setMonitoringVersion("test01"); // the only mon_ver in mon_version_def table as of September
127  // 2012
128  MonRunTag monTag;
129  monTag.setMonVersionDef(versionDef);
131 
132  try {
133  monIOV_ = db_->fetchMonRunIOV(&runTag, &monTag, runNumber, 1);
134  } catch (std::runtime_error &e) {
135  edm::LogError("EcalDQM") << "Cannot fetch MonRunIOV for location=" << location << " runNumber=" << runNumber
136  << " monVersion=test01 monRunGeneralTag=" << monRunGeneralTag;
137  throw;
138  }
139 
140  if (verbosity_ > 0)
141  edm::LogInfo("EcalDQM") << " Done.";
142 }
143 
145  delete worker_;
146  delete meSet_;
147 }
148 
151  edm::Run const &,
152  edm::EventSetup const &_es) {
153  setElectronicsMap(_es);
154  meSet_->book(_ibooker, GetElectronicsMap());
155 
156  std::map<DetId, double> values(worker_->run(db_, monIOV_, formula_));
157  for (std::map<DetId, double>::const_iterator vItr(values.begin()); vItr != values.end(); ++vItr)
158  meSet_->setBinContent(getEcalDQMSetupObjects(), vItr->first, vItr->second);
159 }
160 
162 
164  if (!electronicsMap)
165  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
166  return electronicsMap;
167 }
168 
170  if (!electronicsMap)
171  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
172  ecaldqm::EcalDQMSetupObjects edso = {electronicsMap, nullptr, nullptr, nullptr};
173  return edso;
174 }
virtual void setBinContent(EcalDQMSetupObjects const, DetId const &, double)
Definition: MESet.h:79
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
ecaldqm::MESet * meSet_
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) noexcept(false)
ecaldqm::DBReaderWorker * worker_
Definition: RunTag.h:13
EcalElectronicsMapping const * GetElectronicsMap()
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Log< level::Error, false > LogError
EcalCondDBInterface * db_
~EcalCondDBReader() override
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:21
EcalElectronicsMapping const * electronicsMap
T getUntrackedParameter(std::string const &, T const &) const
RunIOV fetchRunIOV(RunTag *tag, run_t run) noexcept(false)
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > elecMapHandle
Transition
Definition: Transition.h:12
virtual void book(DQMStore::IBooker &, EcalElectronicsMapping const *)
Definition: MESet.h:57
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void dqmEndRun(DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &) override
RunTag getRunTag() const
Definition: RunIOV.cc:58
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:30
void setElectronicsMap(edm::EventSetup const &)
Log< level::Info, false > LogInfo
std::string formula_
void setMonitoringVersion(std::string ver)
HLT enums.
EcalCondDBReader(edm::ParameterSet const &)
virtual std::map< DetId, double > run(EcalCondDBInterface *, MonRunIOV &, std::string const &)=0
MESet * createMESet(edm::ParameterSet const &)
Definition: MESetUtils.cc:18
ecaldqm::EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: Run.h:45