CMS 3D CMS Logo

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>())) {
77  const EcalDQMTowerStatus* TStatus = &_es.getData(tStHndl);
78 
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  if (!worker->checkElectronicsMap(false)) // to avoid crashes on empty runs
118  return;
119  worker->bookMEs(_ibooker); // worker returns if already booked
120  },
121  "bookMEs",
122  "Booking MEs");
123 
125 
126  executeOnWorkers_([](ecaldqm::DQWorker* worker) { worker->releaseMEs(); }, "releaseMEs", "releasing histograms");
127 }
128 
130  if (verbosity_ > 0)
131  edm::LogInfo("EcalDQM") << moduleName_ << ": Starting worker modules..";
132 
134  [&_igetter, &_type](ecaldqm::DQWorker* worker) {
135  if (!worker->checkElectronicsMap(false)) // to avoid crashes on empty runs
136  return;
137  ecaldqm::DQWorkerClient* client(static_cast<ecaldqm::DQWorkerClient*>(worker));
138  if (!client->onlineMode() && !client->runsOn(_type))
139  return;
140  client->releaseSource();
141  client->resetMEs();
142  if (!client->retrieveSource(_igetter, _type))
143  return;
144  if (client->onlineMode())
145  client->setTime(time(nullptr));
146  client->producePlots(_type);
147  },
148  "retrieveAndRun",
149  "producing plots");
150 
151  if (verbosity_ > 0)
152  edm::LogInfo("EcalDQM") << " done." << std::endl;
153 }
154 
ecaldqm::StatusManager statusManager_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
static void fillDescriptions(edm::ConfigurationDescriptions &)
void runWorkers(DQMStore::IGetter &, ecaldqm::DQWorkerClient::ProcessType)
bool checkElectronicsMap(bool=true)
Definition: DQWorker.cc:118
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual void setTokens(edm::ConsumesCollector &)
std::string const & getName() const
Definition: DQWorker.h:124
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1) const
Definition: EcalDQMonitor.h:50
void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
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 &)
void endRun(edm::Run const &, edm::EventSetup const &) override
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
bool getData(T &iHolder) const
Definition: EventSetup.h:122
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:96
std::string const moduleName_
Definition: EcalDQMonitor.h:45
Log< level::Info, false > LogInfo
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:172
HLT enums.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void setTokens(edm::ConsumesCollector &)
Definition: DQWorker.cc:53
void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
void setSetupObjects(edm::EventSetup const &)
Definition: DQWorker.cc:104
void readFromObj(EcalDQMChannelStatus const &, EcalDQMTowerStatus const &)
Definition: Run.h:45