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  if(!checkElectronicsMap(false)){
72  // set up electronicsMap in EcalDQMCommonUtils
74  _es.get<EcalMappingRcd>().get(elecMapHandle);
75  setElectronicsMap(elecMapHandle.product());
76  }
77 
78  if(!checkTrigTowerMap(false)){
79  // set up trigTowerMap in EcalDQMCommonUtils
81  _es.get<IdealGeometryRecord>().get(ttMapHandle);
82  setTrigTowerMap(ttMapHandle.product());
83  }
84 
85  if(!checkGeometry(false)){
86  edm::ESHandle<CaloGeometry> geomHandle;
87  _es.get<CaloGeometryRecord>().get(geomHandle);
88  setGeometry(geomHandle.product());
89  }
90 
91  if(!checkTopology(false)){
92  // set up trigTowerMap in EcalDQMCommonUtils
93  edm::ESHandle<CaloTopology> topoHandle;
94  _es.get<CaloTopologyRecord>().get(topoHandle);
95  setTopology(topoHandle.product());
96  }
97  }
98 
99  void
101  {
102  executeOnWorkers_([&_run, &_es](DQWorker* worker){
103  if(worker->onlineMode()) worker->setTime(time(nullptr));
104  worker->setRunNumber(_run.run());
105  worker->beginRun(_run, _es);
106  }, "beginRun");
107 
108  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginRun";
109  }
110 
111  void
113  {
114  executeOnWorkers_([&_run, &_es](DQWorker* worker){
115  if(worker->onlineMode()) worker->setTime(time(nullptr));
116  worker->setRunNumber(_run.run());
117  worker->endRun(_run, _es);
118  }, "endRun");
119 
120  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndRun";
121  }
122 
123  void
125  {
126  executeOnWorkers_([&_lumi, &_es](DQWorker* worker){
127  if(worker->onlineMode()) worker->setTime(time(nullptr));
128  worker->setLumiNumber(_lumi.luminosityBlock());
129  worker->beginLuminosityBlock(_lumi, _es);
130  }, "beginLumi");
131 
132  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginLuminosityBlock";
133  }
134 
135  void
137  {
138  executeOnWorkers_([&_lumi, &_es](DQWorker* worker){
139  if(worker->onlineMode()) worker->setTime(time(nullptr));
140  worker->setLumiNumber(_lumi.luminosityBlock());
141  worker->endLuminosityBlock(_lumi, _es);
142  }, "endLumi");
143 
144  if(verbosity_ > 2) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndLuminosityBlock";
145  }
146 }
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
bool checkElectronicsMap(bool=true)
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 *)
bool checkTopology(bool=true)
const T & get() const
Definition: EventSetup.h:55
bool checkTrigTowerMap(bool=true)
void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
void setElectronicsMap(EcalElectronicsMapping const *)
void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
void setTrigTowerMap(EcalTrigTowerConstituentsMap const *)
bool checkGeometry(bool=true)
void setTime(time_t _t)
Definition: DQWorker.h:63
T const * product() const
Definition: ESHandle.h:86
Definition: Run.h:43