CMS 3D CMS Logo

EcalDQMonitor.cc
Go to the documentation of this file.
2 
4 
11 
16 
18 
19 #include <ctime>
20 #include <sstream>
21 
22 namespace ecaldqm {
24  : workers_(),
25  moduleName_(_ps.getUntrackedParameter<std::string>("moduleName")),
26  verbosity_(_ps.getUntrackedParameter<int>("verbosity")) {
27  std::vector<std::string> workerNames(_ps.getUntrackedParameter<std::vector<std::string>>("workers"));
28  edm::ParameterSet const &workerParams(_ps.getUntrackedParameterSet("workerParameters"));
29  edm::ParameterSet const &commonParams(_ps.getUntrackedParameterSet("commonParameters"));
30 
31  std::for_each(workerNames.begin(), workerNames.end(), [&](std::string const &name) {
32  if (verbosity_ > 0)
33  edm::LogInfo("EcalDQM") << moduleName_ << ": Setting up " << name << std::endl;
34  try {
35  DQWorker *worker(WorkerFactoryStore::singleton()->getWorker(
36  name, verbosity_, commonParams, workerParams.getUntrackedParameterSet(name)));
37  if (worker->onlineMode())
38  worker->setTime(time(nullptr));
39  workers_.push_back(worker);
40  } catch (std::exception &) {
41  edm::LogError("EcalDQM") << "Worker " << name << " not defined";
42  throw;
43  }
44  });
45  }
46 
48  if (verbosity_ > 2)
49  edm::LogInfo("EcalDQM") << moduleName_ << ": Deleting workers";
50 
51  executeOnWorkers_([](DQWorker *worker) { delete worker; }, "Dtor");
52  }
53 
54  /*static*/
56  _desc.addUntracked<std::string>("moduleName", "Ecal Monitor Module");
57  _desc.addUntracked<std::vector<std::string>>("workers");
58  _desc.addUntracked<int>("verbosity", 0);
59 
61  commonParameters.addUntracked<bool>("onlineMode", false);
62  commonParameters.addUntracked<bool>("willConvertToEDM", true);
63  _desc.addUntracked("commonParameters", commonParameters);
64  }
65 
68  [&_run, &_es](DQWorker *worker) {
69  if (worker->onlineMode())
70  worker->setTime(time(nullptr));
71  worker->setRunNumber(_run.run());
72  worker->beginRun(_run, _es);
73  },
74  "beginRun");
75 
76  if (verbosity_ > 0)
77  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginRun";
78  }
79 
80  void EcalDQMonitor::ecaldqmEndRun(edm::Run const &_run, edm::EventSetup const &_es) {
82  [&_run, &_es](DQWorker *worker) {
83  if (worker->onlineMode())
84  worker->setTime(time(nullptr));
85  worker->setRunNumber(_run.run());
86  worker->endRun(_run, _es);
87  },
88  "endRun");
89 
90  if (verbosity_ > 0)
91  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndRun";
92  }
93 
96  [&_lumi, &_es](DQWorker *worker) {
97  if (worker->onlineMode())
98  worker->setTime(time(nullptr));
99  worker->setLumiNumber(_lumi.luminosityBlock());
100  worker->beginLuminosityBlock(_lumi, _es);
101  },
102  "beginLumi");
103 
104  if (verbosity_ > 1)
105  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginLuminosityBlock";
106  }
107 
110  [&_lumi, &_es](DQWorker *worker) {
111  if (worker->onlineMode())
112  worker->setTime(time(nullptr));
113  worker->setLumiNumber(_lumi.luminosityBlock());
114  worker->endLuminosityBlock(_lumi, _es);
115  },
116  "endLumi");
117 
118  if (verbosity_ > 2)
119  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndLuminosityBlock";
120  }
121 } // namespace ecaldqm
EcalDQMonitor(edm::ParameterSet const &)
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:72
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool onlineMode() const
Definition: DQWorker.h:125
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1) const
Definition: EcalDQMonitor.h:50
void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &)
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:199
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
static void fillDescriptions(edm::ParameterSetDescription &)
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:71
Log< level::Error, false > LogError
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:74
void setLumiNumber(edm::LuminosityBlockNumber_t _l)
Definition: DQWorker.h:121
T getUntrackedParameter(std::string const &, T const &) const
RunNumber_t run() const
Definition: RunBase.h:40
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:75
void ecaldqmBeginRun(edm::Run const &, edm::EventSetup const &)
void setRunNumber(edm::RunNumber_t _r)
Definition: DQWorker.h:120
std::string const moduleName_
Definition: EcalDQMonitor.h:45
void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const
Log< level::Info, false > LogInfo
void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< DQWorker * > workers_
Definition: EcalDQMonitor.h:44
virtual ~EcalDQMonitor() noexcept(false)
void setTime(time_t _t)
Definition: DQWorker.h:119
LuminosityBlockNumber_t luminosityBlock() const
Definition: Run.h:45