CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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(0));
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_([](DQWorker* worker){
103  worker->releaseMEs();
104  }, "releaseMEs", "releasing histograms");
105  }
106 
107  void
109  {
110  executeOnWorkers_([&_run, &_es](DQWorker* worker){
111  if(worker->onlineMode()) worker->setTime(time(0));
112  worker->setRunNumber(_run.run());
113  worker->beginRun(_run, _es);
114  }, "beginRun");
115 
116  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginRun";
117  }
118 
119  void
121  {
122  executeOnWorkers_([&_run, &_es](DQWorker* worker){
123  if(worker->onlineMode()) worker->setTime(time(0));
124  worker->setRunNumber(_run.run());
125  worker->endRun(_run, _es);
126  }, "endRun");
127 
128  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndRun";
129  }
130 
131  void
133  {
134  executeOnWorkers_([&_lumi, &_es](DQWorker* worker){
135  if(worker->onlineMode()) worker->setTime(time(0));
136  worker->setLumiNumber(_lumi.luminosityBlock());
137  worker->beginLuminosityBlock(_lumi, _es);
138  }, "beginLumi");
139 
140  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginLuminosityBlock";
141  }
142 
143  void
145  {
146  executeOnWorkers_([&_lumi, &_es](DQWorker* worker){
147  if(worker->onlineMode()) worker->setTime(time(0));
148  worker->setLumiNumber(_lumi.luminosityBlock());
149  worker->endLuminosityBlock(_lumi, _es);
150  }, "endLumi");
151 
152  if(verbosity_ > 2) edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndLuminosityBlock";
153  }
154 }
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:42
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< DQWorker * > workers_
Definition: EcalDQMonitor.h:39
void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &)
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:126
virtual void releaseMEs()
Definition: DQWorker.cc:76
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:66
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:65
void setGeometry(CaloGeometry const *)
std::string const moduleName_
Definition: EcalDQMonitor.h:40
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1)
Definition: EcalDQMonitor.h:56
bool onlineMode() const
Definition: DQWorker.h:70
void setTopology(CaloTopology const *)
bool checkTopology(bool=true)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
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:64
Definition: Run.h:41