CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalDQMonitorClient.cc
Go to the documentation of this file.
2 
4 
9 
14 
16 
18 
19 #include <ctime>
20 #include <fstream>
21 
23  : DQMEDHarvester(),
24  ecaldqm::EcalDQMonitor(_ps),
25  iEvt_(0),
26  cStHndl(esConsumes<edm::Transition::BeginRun>()),
27  tStHndl(esConsumes<edm::Transition::BeginRun>()),
28  statusManager_() {
31  [this, &collector](ecaldqm::DQWorker* worker) {
32  ecaldqm::DQWorkerClient* client(dynamic_cast<ecaldqm::DQWorkerClient*>(worker));
33  if (!client)
34  throw cms::Exception("InvalidConfiguration") << "Non-client DQWorker " << worker->getName() << " passed";
35  client->setStatusManager(this->statusManager_);
36  client->setTokens(collector);
37  worker->setTokens(collector);
38  },
39  "initialization");
40 
41  // This is no longer used since run 2
42  //
43  //if (_ps.existsAs<edm::FileInPath>("PNMaskFile", false)) {
44  // std::ifstream maskFile(_ps.getUntrackedParameter<edm::FileInPath>("PNMaskFile").fullPath());
45  // if (maskFile.is_open())
46  // statusManager_.readFromStream(maskFile);
47  //}
48 }
49 
51 
52 /*static*/
56 
57  edm::ParameterSetDescription clientParameters;
60  allWorkers.addNode(
62  desc.addUntracked("workerParameters", allWorkers);
63 
64  desc.addOptionalUntracked<edm::FileInPath>("PNMaskFile");
65 
66  _descs.addDefault(desc);
67 }
68 
70  executeOnWorkers_([&_es](ecaldqm::DQWorker* worker) { worker->setSetupObjects(_es); },
71  "ecaldqmGetSetupObjects",
72  "Getting EventSetup Objects");
73 
74  if (_es.find(edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMChannelStatusRcd>()) &&
75  _es.find(edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMTowerStatusRcd>())) {
76  const EcalDQMChannelStatus* ChStatus = &_es.getData(cStHndl);
77  const EcalDQMTowerStatus* TStatus = &_es.getData(tStHndl);
78 
79  statusManager_.readFromObj(*ChStatus, *TStatus);
80  }
81 
82  ecaldqmBeginRun(_run, _es);
83 }
84 
85 void EcalDQMonitorClient::endRun(edm::Run const& _run, edm::EventSetup const& _es) { ecaldqmEndRun(_run, _es); }
86 
88  DQMStore::IGetter& _igetter,
89  edm::LuminosityBlock const& _lumi,
90  edm::EventSetup const& _es) {
92  [&_ibooker](ecaldqm::DQWorker* worker) {
93  ecaldqm::DQWorkerClient* client(static_cast<ecaldqm::DQWorkerClient*>(worker));
94  if (!client->onlineMode() && !client->runsOn(ecaldqm::DQWorkerClient::kLumi))
95  return;
96  client->bookMEs(_ibooker);
97  },
98  "bookMEs",
99  "Booking MEs");
100 
101  ecaldqmEndLuminosityBlock(_lumi, _es);
102 
104 
106  [](ecaldqm::DQWorker* worker) {
107  ecaldqm::DQWorkerClient* client(static_cast<ecaldqm::DQWorkerClient*>(worker));
108  client->resetPerLumi();
109  },
110  "dqmEndLuminosityBlock",
111  "Reset per-lumi MEs");
112 }
113 
116  [&_ibooker](ecaldqm::DQWorker* worker) {
117  worker->bookMEs(_ibooker); // worker returns if already booked
118  },
119  "bookMEs",
120  "Booking MEs");
121 
123 
124  executeOnWorkers_([](ecaldqm::DQWorker* worker) { worker->releaseMEs(); }, "releaseMEs", "releasing histograms");
125 }
126 
128  if (verbosity_ > 0)
129  edm::LogInfo("EcalDQM") << moduleName_ << ": Starting worker modules..";
130 
132  [&_igetter, &_type](ecaldqm::DQWorker* worker) {
133  ecaldqm::DQWorkerClient* client(static_cast<ecaldqm::DQWorkerClient*>(worker));
134  if (!client->onlineMode() && !client->runsOn(_type))
135  return;
136  client->releaseSource();
137  client->resetMEs();
138  if (!client->retrieveSource(_igetter, _type))
139  return;
140  if (client->onlineMode())
141  client->setTime(time(nullptr));
142  client->producePlots(_type);
143  },
144  "retrieveAndRun",
145  "producing plots");
146 
147  if (verbosity_ > 0)
148  edm::LogInfo("EcalDQM") << " done." << std::endl;
149 }
150 
ecaldqm::StatusManager statusManager_
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:178
static void fillDescriptions(edm::ConfigurationDescriptions &)
void runWorkers(DQMStore::IGetter &, ecaldqm::DQWorkerClient::ProcessType)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setStatusManager(StatusManager const &_manager)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual void setTokens(edm::ConsumesCollector &)
void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
bool retrieveSource(DQMStore::IGetter &, ProcessType)
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1) const
Definition: EcalDQMonitor.h:50
virtual void releaseMEs()
Definition: DQWorker.cc:90
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
static void fillDescriptions(edm::ParameterSetDescription &)
EcalDQMonitorClient(edm::ParameterSet const &)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void endRun(edm::Run const &, edm::EventSetup const &) override
virtual void producePlots(ProcessType)=0
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ParameterSetDescription &)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void ecaldqmBeginRun(edm::Run const &, edm::EventSetup const &)
edm::ESGetToken< EcalDQMChannelStatus, EcalDQMChannelStatusRcd > cStHndl
Transition
Definition: Transition.h:12
edm::ESGetToken< EcalDQMTowerStatus, EcalDQMTowerStatusRcd > tStHndl
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:96
std::string const moduleName_
Definition: EcalDQMonitor.h:45
bool onlineMode() const
Definition: DQWorker.h:119
Log< level::Info, false > LogInfo
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::string const & getName() const
Definition: DQWorker.h:118
bool runsOn(ProcessType _type) const
void bookMEs(DQMStore::IBooker &) override
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void setTokens(edm::ConsumesCollector &)
Definition: DQWorker.cc:53
void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
void setSetupObjects(edm::EventSetup const &)
Definition: DQWorker.cc:104
void setTime(time_t _t)
Definition: DQWorker.h:113
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void readFromObj(EcalDQMChannelStatus const &, EcalDQMTowerStatus const &)
Definition: Run.h:45