CMS 3D CMS Logo

EcalDQMonitorTask.cc
Go to the documentation of this file.
2 
4 
7 
11 
16 
18 
21 
22 #include <iomanip>
23 #include <ctime>
24 #include <bitset>
25 #include <sstream>
26 
29  ecaldqm::EcalDQMonitor(_ps),
30  schedule_(),
31  allowMissingCollections_(_ps.getUntrackedParameter<bool>("allowMissingCollections")),
32  processedEvents_(0),
33  lastResetTime_(0),
34  resetInterval_(_ps.getUntrackedParameter<double>("resetInterval")) {
36  std::bitset<ecaldqm::nCollections> hasTaskToRun;
38 
40  [&dependencies, &hasTaskToRun, &collector](ecaldqm::DQWorker* worker) {
41  ecaldqm::DQWorkerTask* task(dynamic_cast<ecaldqm::DQWorkerTask*>(worker));
42  if (!task)
43  throw cms::Exception("InvalidConfiguration") << "Non-task DQWorker " << worker->getName() << " passed";
44 
45  task->addDependencies(dependencies);
46  for (unsigned iCol(0); iCol < ecaldqm::nCollections; ++iCol) {
47  if (task->analyze(nullptr, ecaldqm::Collections(iCol))) // "dry run" mode
48  hasTaskToRun.set(iCol);
49  }
50 
51  task->setTokens(collector);
52  },
53  "initialization");
54 
55  edm::ParameterSet const& collectionTags(_ps.getParameterSet("collectionTags"));
56 
57  for (unsigned iCol(0); iCol < ecaldqm::nCollections; iCol++) {
58  if (hasTaskToRun[iCol])
60  }
61  if (collectionTags.existsAs<edm::InputTag>("EcalRawData", false))
63 
64  formSchedule(dependencies.formSequence(), collectionTags);
65 
66  if (verbosity_ > 0) {
67  std::stringstream ss;
68  ss << moduleName_ << ": Using collections" << std::endl;
69  for (unsigned iCol(0); iCol < schedule_.size(); iCol++)
70  ss << ecaldqm::collectionName[schedule_[iCol].second] << std::endl;
71  edm::LogInfo("EcalDQM") << ss.str();
72  }
73 
74  edm::ParameterSet const& commonParams(_ps.getUntrackedParameterSet("commonParameters"));
75  if (commonParams.getUntrackedParameter<bool>("onlineMode"))
76  lastResetTime_ = time(nullptr);
77 }
78 
79 /*static*/
83 
84  edm::ParameterSetDescription taskParameters;
87  allWorkers.addNode(
89  desc.addUntracked("workerParameters", allWorkers);
90 
92  collectionTags.addWildcardUntracked<edm::InputTag>("*");
93  desc.add("collectionTags", collectionTags);
94 
95  desc.addUntracked<bool>("allowMissingCollections", true);
96  desc.addUntracked<double>("resetInterval", 0.);
97 
98  _descs.addDefault(desc);
99 }
100 
101 void EcalDQMonitorTask::bookHistograms(DQMStore::IBooker& _ibooker, edm::Run const&, edm::EventSetup const& _es) {
103 
104  executeOnWorkers_([&_ibooker](ecaldqm::DQWorker* worker) { worker->bookMEs(_ibooker); }, "bookMEs", "Booking MEs");
105 }
106 
108  ecaldqmBeginRun(_run, _es);
109 
110  processedEvents_ = 0;
111 
112  if (lastResetTime_ != 0)
113  lastResetTime_ = time(nullptr);
114 }
115 
117  ecaldqmEndRun(_run, _es);
118 
119  executeOnWorkers_([](ecaldqm::DQWorker* worker) { worker->releaseMEs(); }, "releaseMEs", "releasing histograms");
120 }
121 
123  ecaldqmBeginLuminosityBlock(_lumi, _es);
124 }
125 
127  ecaldqmEndLuminosityBlock(_lumi, _es);
128 
129  if (lastResetTime_ != 0 && (time(nullptr) - lastResetTime_) / 3600. > resetInterval_) {
130  if (verbosity_ > 0)
131  edm::LogInfo("EcalDQM") << moduleName_ << ": Soft-resetting the histograms";
132  // TODO: soft-reset is no longer supported.
133  lastResetTime_ = time(nullptr);
134  }
135 }
136 
138  if (verbosity_ > 2)
139  edm::LogInfo("EcalDQM") << moduleName_ << "::analyze: Run " << _evt.id().run() << " Lumisection "
140  << _evt.id().luminosityBlock() << " Event " << _evt.id().event() << ": processed "
141  << processedEvents_;
142 
143  if (schedule_.empty())
144  return;
145 
146  std::set<ecaldqm::DQWorker*> enabledTasks;
147 
149  if (_evt.getByToken(collectionTokens_[ecaldqm::kEcalRawData], dcchsHndl)) {
150  // determine event type (called run type in DCCHeader for some reason) for each FED
151  std::stringstream ss;
152  if (verbosity_ > 2)
153  ss << moduleName_ << ": Event type ";
154 
155  short runType[ecaldqm::nDCC];
156  std::fill_n(runType, ecaldqm::nDCC, -1);
157  for (EcalRawDataCollection::const_iterator dcchItr = dcchsHndl->begin(); dcchItr != dcchsHndl->end(); ++dcchItr) {
158  if (verbosity_ > 2)
159  ss << dcchItr->getRunType() << " ";
160  runType[dcchItr->id() - 1] = dcchItr->getRunType();
161  }
162  if (verbosity_ > 2)
163  edm::LogInfo("EcalDQM") << ss.str();
164 
165  bool processEvent(false);
166 
168  [&enabledTasks, &runType, &processEvent, this](ecaldqm::DQWorker* worker) {
169  if (static_cast<ecaldqm::DQWorkerTask*>(worker)->filterRunType(runType)) {
170  if (this->verbosity_ > 2)
171  edm::LogInfo("EcalDQM") << worker->getName() << " will run on this event";
172  enabledTasks.insert(worker);
173  processEvent = true;
174  }
175  },
176  "filterRunType");
177 
178  if (!processEvent)
179  return;
180  } else {
181  edm::LogWarning("EcalDQM") << "EcalRawDataCollection does not exist. No event-type filtering will be applied";
182  executeOnWorkers_([&enabledTasks](ecaldqm::DQWorker* worker) { enabledTasks.insert(worker); }, "");
183  }
184 
186 
187  // start event processing
189  [&_evt, &_es, &enabledTasks](ecaldqm::DQWorker* worker) {
190  if (enabledTasks.find(worker) != enabledTasks.end()) {
191  if (worker->onlineMode())
192  worker->setTime(time(nullptr));
193  worker->setEventNumber(_evt.id().event());
194  static_cast<ecaldqm::DQWorkerTask*>(worker)->beginEvent(_evt, _es);
195  }
196  },
197  "beginEvent");
198 
199  // run on collections
200  for (unsigned iSch(0); iSch < schedule_.size(); iSch++) {
201  Processor processor(schedule_[iSch].first);
202  (this->*processor)(_evt, schedule_[iSch].second, enabledTasks);
203  }
204 
205  // close event processing
207  [&_evt, &_es, &enabledTasks](ecaldqm::DQWorker* worker) {
208  if (enabledTasks.find(worker) != enabledTasks.end())
209  static_cast<ecaldqm::DQWorkerTask*>(worker)->endEvent(_evt, _es);
210  },
211  "endEvent");
212 
213  if (verbosity_ > 2)
214  edm::LogInfo("EcalDQM") << moduleName_ << "::analyze: Closing Event " << _evt.id().event();
215 }
216 
ConfigurationDescriptions.h
Handle.h
EcalDQMonitorTask.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
ecaldqm::EcalDQMonitor::moduleName_
const std::string moduleName_
Definition: EcalDQMonitor.h:41
ecaldqm
Definition: DQWorker.h:24
ecaldqm::collectionName
const std::string collectionName[nCollections]
Definition: Collections.h:47
ecaldqm::EcalDQMonitor::ecaldqmBeginLuminosityBlock
void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: EcalDQMonitor.cc:115
edm::ParameterSet::getUntrackedParameterSet
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Definition: ParameterSet.cc:2129
edm::ParameterWildcard
Definition: ParameterWildcard.h:23
EcalDQMonitorTask::lastResetTime_
time_t lastResetTime_
Definition: EcalDQMonitorTask.h:51
ecaldqm::DependencySet
Definition: DQWorkerTask.h:44
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
EcalDQMonitorTask::collectionTokens_
edm::EDGetToken collectionTokens_[ecaldqm::nCollections]
Definition: EcalDQMonitorTask.h:45
ecaldqm::EcalDQMonitor::verbosity_
const int verbosity_
Definition: EcalDQMonitor.h:42
ecaldqm::EcalDQMonitor::ecaldqmBeginRun
void ecaldqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: EcalDQMonitor.cc:87
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MESet.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
ecaldqm::Dependency
Definition: DQWorkerTask.h:19
ecaldqm::EcalDQMonitor::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &)
Definition: EcalDQMonitor.cc:53
ecaldqm::DQWorker::bookMEs
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:66
ecaldqm::kEcalRawData
Definition: Collections.h:10
edm::EventID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
edm::Handle
Definition: AssociativeIterator.h:50
EcalDQMonitorTask::formSchedule
void formSchedule(std::vector< ecaldqm::Collections > const &, edm::ParameterSet const &)
Definition: EcalDQMonitorTask2.cc:46
dqmdumpme.first
first
Definition: dqmdumpme.py:55
ecaldqm::EcalDQMonitor::executeOnWorkers_
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1)
Definition: EcalDQMonitor.h:46
ecaldqm::DQWorker::releaseMEs
virtual void releaseMEs()
Definition: DQWorker.cc:60
ecaldqm::DQWorker
Definition: DQWorker.h:28
EcalDQMonitorTask::processedEvents_
int processedEvents_
Definition: EcalDQMonitorTask.h:48
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
EcalRawDataCollections.h
MakerMacros.h
ecaldqm::DQWorker::setEventNumber
void setEventNumber(edm::EventNumber_t _e)
Definition: DQWorker.h:69
ecaldqm::DQWorkerTask
Definition: DQWorkerTask.h:71
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:252
dependencies
Definition: dependencies.py:1
symbols.dependencies
dependencies
Definition: symbols.py:20
ecaldqm::DQWorker::onlineMode
bool onlineMode() const
Definition: DQWorker.h:72
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
ParameterSetDescription.h
processEvent
dispatcher processEvent(e, inputTag, standby)
EcalDQMonitorTask::dqmEndRun
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:116
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ecaldqm::EcalDQMonitor::ecaldqmEndLuminosityBlock
void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: EcalDQMonitor.cc:129
ecaldqm::nCollections
Definition: Collections.h:44
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::ParameterSet
Definition: ParameterSet.h:36
EcalDQMonitorTask::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:137
Event.h
DQMOneLumiEDAnalyzer
Definition: DQMOneEDAnalyzer.h:90
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
ecaldqm::Collections
Collections
Definition: Collections.h:8
EcalCalibMonitorTasks_cfi.collectionTags
collectionTags
Definition: EcalCalibMonitorTasks_cfi.py:21
EcalDQMonitorTask::Processor
void(EcalDQMonitorTask::* Processor)(edm::Event const &, ecaldqm::Collections, std::set< ecaldqm::DQWorker * > const &)
Definition: EcalDQMonitorTask.h:34
edm::EventSetup
Definition: EventSetup.h:57
edm::ParameterSetDescription::addNode
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
Definition: ParameterSetDescription.cc:41
InputTag.h
EcalDQMonitorTask::dqmBeginLuminosityBlock
void dqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:122
ecaldqm::EcalDQMonitor::ecaldqmEndRun
void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &)
Definition: EcalDQMonitor.cc:101
ecaldqm::DQWorker::getName
const std::string & getName() const
Definition: DQWorker.h:71
EcalDQMonitorTask::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:101
EcalDQMonitorTask::schedule_
std::vector< std::pair< Processor, ecaldqm::Collections > > schedule_
Definition: EcalDQMonitorTask.h:46
DQWorkerTask.h
Exception
Definition: hltDiff.cc:246
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
EcalDQMonitorTask::dqmBeginRun
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:107
ecaldqm::DQWorkerTask::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &)
Definition: DQWorkerTask.cc:11
EcalDQMonitorTask::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: EcalDQMonitorTask.cc:80
ecaldqm::nDCC
Definition: EcalDQMCommonUtils.h:92
ConsumesCollector.h
ParameterSet.h
EcalCondDBWriter_cfi.runType
runType
Definition: EcalCondDBWriter_cfi.py:64
ecaldqm::DQWorker::setTime
void setTime(time_t _t)
Definition: DQWorker.h:66
ntuplemaker.time
time
Definition: ntuplemaker.py:310
edm::Event
Definition: Event.h:73
EcalDQMonitorTask::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:126
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::RequireZeroOrMore
Definition: ParameterWildcardBase.h:17
EcalDQMonitorTask::EcalDQMonitorTask
EcalDQMonitorTask(edm::ParameterSet const &)
Definition: EcalDQMonitorTask.cc:27
ecaldqm::EcalDQMonitor::ecaldqmGetSetupObjects
void ecaldqmGetSetupObjects(edm::EventSetup const &)
Definition: EcalDQMonitor.cc:64
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
EcalDQMonitorTask::resetInterval_
float resetInterval_
Definition: EcalDQMonitorTask.h:52
EcalDQMonitorTask
Definition: EcalDQMonitorTask.h:18
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2121
EcalDQMCommonUtils.h