CMS 3D CMS Logo

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