CMS 3D CMS Logo

EcalDQMonitor.cc
Go to the documentation of this file.
2 
4 
11 
16 
17 #include <ctime>
18 #include <sstream>
19 
20 namespace ecaldqm {
22  : workers_(),
23  moduleName_(_ps.getUntrackedParameter<std::string>("moduleName")),
24  verbosity_(_ps.getUntrackedParameter<int>("verbosity")) {
25  std::vector<std::string> workerNames(_ps.getUntrackedParameter<std::vector<std::string>>("workers"));
26  edm::ParameterSet const &workerParams(_ps.getUntrackedParameterSet("workerParameters"));
27  edm::ParameterSet const &commonParams(_ps.getUntrackedParameterSet("commonParameters"));
28 
29  std::for_each(workerNames.begin(), workerNames.end(), [&](std::string const &name) {
30  if (verbosity_ > 0)
31  edm::LogInfo("EcalDQM") << moduleName_ << ": Setting up " << name << std::endl;
32  try {
33  DQWorker *worker(WorkerFactoryStore::singleton()->getWorker(
34  name, verbosity_, commonParams, workerParams.getUntrackedParameterSet(name)));
35  if (worker->onlineMode())
36  worker->setTime(time(nullptr));
37  workers_.push_back(worker);
38  } catch (std::exception &) {
39  edm::LogError("EcalDQM") << "Worker " << name << " not defined";
40  throw;
41  }
42  });
43  }
44 
46  if (verbosity_ > 2)
47  edm::LogInfo("EcalDQM") << moduleName_ << ": Deleting workers";
48 
49  executeOnWorkers_([](DQWorker *worker) { delete worker; }, "Dtor");
50  }
51 
52  /*static*/
54  _desc.addUntracked<std::string>("moduleName", "Ecal Monitor Module");
55  _desc.addUntracked<std::vector<std::string>>("workers");
56  _desc.addUntracked<int>("verbosity", 0);
57 
59  commonParameters.addUntracked<bool>("onlineMode", false);
60  commonParameters.addUntracked<bool>("willConvertToEDM", true);
61  _desc.addUntracked("commonParameters", commonParameters);
62  }
63 
65  // NB: a more minimal solution may rely on ESWatchers
66  // but then here the cost is rather minimal
67  // set up electronicsMap in EcalDQMCommonUtils
69  _es.get<EcalMappingRcd>().get(elecMapHandle);
70  setElectronicsMap(elecMapHandle.product());
71 
72  // set up trigTowerMap in EcalDQMCommonUtils
74  _es.get<IdealGeometryRecord>().get(ttMapHandle);
75  setTrigTowerMap(ttMapHandle.product());
76 
77  edm::ESHandle<CaloGeometry> geomHandle;
78  _es.get<CaloGeometryRecord>().get(geomHandle);
79  setGeometry(geomHandle.product());
80 
81  // set up trigTowerMap in EcalDQMCommonUtils
82  edm::ESHandle<CaloTopology> topoHandle;
83  _es.get<CaloTopologyRecord>().get(topoHandle);
84  setTopology(topoHandle.product());
85  }
86 
89  [&_run, &_es](DQWorker *worker) {
90  if (worker->onlineMode())
91  worker->setTime(time(nullptr));
92  worker->setRunNumber(_run.run());
93  worker->beginRun(_run, _es);
94  },
95  "beginRun");
96 
97  if (verbosity_ > 0)
98  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginRun";
99  }
100 
101  void EcalDQMonitor::ecaldqmEndRun(edm::Run const &_run, edm::EventSetup const &_es) {
103  [&_run, &_es](DQWorker *worker) {
104  if (worker->onlineMode())
105  worker->setTime(time(nullptr));
106  worker->setRunNumber(_run.run());
107  worker->endRun(_run, _es);
108  },
109  "endRun");
110 
111  if (verbosity_ > 0)
112  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndRun";
113  }
114 
117  [&_lumi, &_es](DQWorker *worker) {
118  if (worker->onlineMode())
119  worker->setTime(time(nullptr));
120  worker->setLumiNumber(_lumi.luminosityBlock());
121  worker->beginLuminosityBlock(_lumi, _es);
122  },
123  "beginLumi");
124 
125  if (verbosity_ > 1)
126  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginLuminosityBlock";
127  }
128 
131  [&_lumi, &_es](DQWorker *worker) {
132  if (worker->onlineMode())
133  worker->setTime(time(nullptr));
134  worker->setLumiNumber(_lumi.luminosityBlock());
135  worker->endLuminosityBlock(_lumi, _es);
136  },
137  "endLumi");
138 
139  if (verbosity_ > 2)
140  edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndLuminosityBlock";
141  }
142 } // namespace ecaldqm
T getUntrackedParameter(std::string const &, T const &) const
EcalDQMonitor(edm::ParameterSet const &)
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:58
RunNumber_t run() const
Definition: RunBase.h:40
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual ~EcalDQMonitor()(false)
void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &)
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:95
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void ecaldqmGetSetupObjects(edm::EventSetup const &)
static void fillDescriptions(edm::ParameterSetDescription &)
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:57
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:60
void setLumiNumber(edm::LuminosityBlockNumber_t _l)
Definition: DQWorker.h:68
LuminosityBlockNumber_t luminosityBlock() const
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:61
void ecaldqmBeginRun(edm::Run const &, edm::EventSetup const &)
void setRunNumber(edm::RunNumber_t _r)
Definition: DQWorker.h:67
void setGeometry(CaloGeometry const *)
std::string const moduleName_
Definition: EcalDQMonitor.h:41
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1)
Definition: EcalDQMonitor.h:46
bool onlineMode() const
Definition: DQWorker.h:72
#define noexcept
void setTopology(CaloTopology const *)
void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
void setElectronicsMap(EcalElectronicsMapping const *)
T get() const
Definition: EventSetup.h:73
void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< DQWorker * > workers_
Definition: EcalDQMonitor.h:40
void setTrigTowerMap(EcalTrigTowerConstituentsMap const *)
void setTime(time_t _t)
Definition: DQWorker.h:66
T const * product() const
Definition: ESHandle.h:86
Definition: Run.h:45