CMS 3D CMS Logo

EcalCondDBReader.cc
Go to the documentation of this file.
2 
5 
9 
11  : db_(nullptr),
12  monIOV_(),
13  worker_(nullptr),
14  formula_(_ps.getUntrackedParameter<std::string>("formula")),
15  meSet_(ecaldqm::createMESet(_ps.getUntrackedParameterSet("plot"))),
16  verbosity_(_ps.getUntrackedParameter<int>("verbosity")) {
18  edm::ParameterSet const &workerParams(_ps.getUntrackedParameterSet("workerParams"));
19 
20  if (table == "CrystalConsistency")
22  if (table == "TTConsistency")
24  if (table == "MemChConsistency")
26  if (table == "MemTTConsistency")
28  if (table == "LaserBlue")
30  if (table == "TimingLaserBlueCrystal")
32  if (table == "PNBlue")
34  if (table == "LaserGreen")
36  if (table == "TimingLaserGreenCrystal")
38  if (table == "PNGreen")
40  if (table == "LaserIRed")
42  if (table == "TimingLaserIRedCrystal")
44  if (table == "PNIRed")
46  if (table == "LaserRed")
48  if (table == "TimingLaserRedCrystal")
50  if (table == "PNRed")
52  if (table == "Pedestals")
54  if (table == "PNPed")
56  if (table == "PedestalsOnline")
58  if (table == "TestPulse")
60  if (table == "PulseShape")
62  if (table == "PNMGPA")
64  if (table == "TimingCrystal")
66  if (table == "Led1")
68  if (table == "TimingLed1Crystal")
70  if (table == "Led2")
72  if (table == "TimingLed2Crystal")
74  if (table == "Occupancy")
76 
77  if (!worker_)
78  throw cms::Exception("Configuration") << "Invalid worker type";
79 
82  int hostPort(_ps.getUntrackedParameter<int>("hostPort"));
85 
86  std::unique_ptr<EcalCondDBInterface> db(nullptr);
87 
88  if (verbosity_ > 0)
89  edm::LogInfo("EcalDQM") << "Establishing DB connection";
90 
91  try {
92  db = std::unique_ptr<EcalCondDBInterface>(new EcalCondDBInterface(DBName, userName, password));
93  } catch (std::runtime_error &re) {
94  if (!hostName.empty()) {
95  try {
96  db = std::unique_ptr<EcalCondDBInterface>(
97  new EcalCondDBInterface(hostName, DBName, userName, password, hostPort));
98  } catch (std::runtime_error &re2) {
99  throw cms::Exception("DBError") << re2.what();
100  }
101  } else
102  throw cms::Exception("DBError") << re.what();
103  }
104 
105  db_ = db.release();
106 
108  int runNumber(_ps.getUntrackedParameter<int>("runNumber"));
110 
111  if (verbosity_ > 0)
112  edm::LogInfo("EcalDQM") << "Initializing DB entry";
113 
114  RunTag runTag;
115 
116  try {
117  runTag = db_->fetchRunIOV(location, runNumber).getRunTag();
118  } catch (std::exception &) {
119  edm::LogError("EcalDQM") << "Cannot fetch RunIOV for location=" << location << " runNumber=" << runNumber;
120  throw;
121  }
122 
123  MonVersionDef versionDef;
124  versionDef.setMonitoringVersion("test01"); // the only mon_ver in mon_version_def table as of September
125  // 2012
126  MonRunTag monTag;
127  monTag.setMonVersionDef(versionDef);
128  monTag.setGeneralTag(monRunGeneralTag);
129 
130  try {
131  monIOV_ = db_->fetchMonRunIOV(&runTag, &monTag, runNumber, 1);
132  } catch (std::runtime_error &e) {
133  edm::LogError("EcalDQM") << "Cannot fetch MonRunIOV for location=" << location << " runNumber=" << runNumber
134  << " monVersion=test01 monRunGeneralTag=" << monRunGeneralTag;
135  throw;
136  }
137 
138  if (verbosity_ > 0)
139  edm::LogInfo("EcalDQM") << " Done.";
140 }
141 
143  delete worker_;
144  delete meSet_;
145 }
146 
148  meSet_->book(_ibooker);
149 
150  std::map<DetId, double> values(worker_->run(db_, monIOV_, formula_));
151  for (std::map<DetId, double>::const_iterator vItr(values.begin()); vItr != values.end(); ++vItr)
152  meSet_->setBinContent(vItr->first, vItr->second);
153 }
T getUntrackedParameter(std::string const &, T const &) const
ecaldqm::MESet * meSet_
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun) noexcept(false)
virtual void book(DQMStore::IBooker &)
Definition: MESet.h:42
ecaldqm::DBReaderWorker * worker_
Definition: RunTag.h:13
#define nullptr
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
EcalCondDBInterface * db_
~EcalCondDBReader() override
virtual void setBinContent(DetId const &, double)
Definition: MESet.h:51
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:21
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
RunTag getRunTag() const
Definition: RunIOV.cc:58
RunIOV fetchRunIOV(RunTag *tag, run_t run) noexcept(false)
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:30
std::string formula_
void setMonitoringVersion(std::string ver)
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