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 
28  : DQMOneEDAnalyzer<edm::LuminosityBlockCache<ecaldqm::EcalLSCache>>(),
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 
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 
122 std::shared_ptr<ecaldqm::EcalLSCache> EcalDQMonitorTask::globalBeginLuminosityBlock(edm::LuminosityBlock const& _lumi,
123  edm::EventSetup const& _es) const {
124  std::shared_ptr<ecaldqm::EcalLSCache> tmpCache = std::make_shared<ecaldqm::EcalLSCache>();
126  [&tmpCache](ecaldqm::DQWorker* worker) { (tmpCache->ByLumiPlotsResetSwitches)[worker->getName()] = true; },
127  "globalBeginLuminosityBlock");
128  if (this->verbosity_ > 2)
129  edm::LogInfo("EcalDQM") << "Set LS cache.";
130 
131  // Reset lhcStatusSet_ to false at the beginning of each LS; when LHC status is set in some event this variable will be set to tru
132  tmpCache->lhcStatusSet_ = false;
133  ecaldqmBeginLuminosityBlock(_lumi, _es);
134  return tmpCache;
135 }
136 
138  ecaldqmEndLuminosityBlock(_lumi, _es);
139 
140  if (lastResetTime_ != 0 && (time(nullptr) - lastResetTime_) / 3600. > resetInterval_) {
141  if (verbosity_ > 0)
142  edm::LogInfo("EcalDQM") << moduleName_ << ": Soft-resetting the histograms";
143  // TODO: soft-reset is no longer supported.
144  lastResetTime_ = time(nullptr);
145  }
146 }
147 
149  if (verbosity_ > 2)
150  edm::LogInfo("EcalDQM") << moduleName_ << "::analyze: Run " << _evt.id().run() << " Lumisection "
151  << _evt.id().luminosityBlock() << " Event " << _evt.id().event() << ": processed "
152  << processedEvents_;
153 
154  if (schedule_.empty())
155  return;
156 
157  std::set<ecaldqm::DQWorker*> enabledTasks;
158 
160  if (_evt.getByToken(collectionTokens_[ecaldqm::kEcalRawData], dcchsHndl)) {
161  // determine event type (called run type in DCCHeader for some reason) for each FED
162  std::stringstream ss;
163  if (verbosity_ > 2)
164  ss << moduleName_ << ": Event type ";
165 
166  short runType[ecaldqm::nDCC];
167  std::fill_n(runType, ecaldqm::nDCC, -1);
168  for (EcalRawDataCollection::const_iterator dcchItr = dcchsHndl->begin(); dcchItr != dcchsHndl->end(); ++dcchItr) {
169  if (verbosity_ > 2)
170  ss << dcchItr->getRunType() << " ";
171  runType[dcchItr->id() - 1] = dcchItr->getRunType();
172  }
173  if (verbosity_ > 2)
174  edm::LogInfo("EcalDQM") << ss.str();
175 
176  bool processEvent(false);
177 
179  [&enabledTasks, &runType, &processEvent, this](ecaldqm::DQWorker* worker) {
180  if (static_cast<ecaldqm::DQWorkerTask*>(worker)->filterRunType(runType)) {
181  if (this->verbosity_ > 2)
182  edm::LogInfo("EcalDQM") << worker->getName() << " will run on this event";
183  enabledTasks.insert(worker);
184  processEvent = true;
185  }
186  },
187  "filterRunType");
188 
189  if (!processEvent)
190  return;
191  } else {
192  edm::LogWarning("EcalDQM") << "EcalRawDataCollection does not exist. No event-type filtering will be applied";
193  executeOnWorkers_([&enabledTasks](ecaldqm::DQWorker* worker) { enabledTasks.insert(worker); }, "");
194  }
195 
197 
198  // start event processing
199  auto lumiCache = luminosityBlockCache(_evt.getLuminosityBlock().index());
201  [&_evt, &_es, &enabledTasks, &lumiCache](ecaldqm::DQWorker* worker) {
202  if (enabledTasks.find(worker) != enabledTasks.end()) {
203  if (worker->onlineMode())
204  worker->setTime(time(nullptr));
205  worker->setEventNumber(_evt.id().event());
206  bool ByLumiResetSwitch = (lumiCache->ByLumiPlotsResetSwitches).at(worker->getName());
207  bool lhcStatusSet = lumiCache->lhcStatusSet_;
208  static_cast<ecaldqm::DQWorkerTask*>(worker)->beginEvent(_evt, _es, ByLumiResetSwitch, lhcStatusSet);
209  (lumiCache->ByLumiPlotsResetSwitches)[worker->getName()] = false;
210  lumiCache->lhcStatusSet_ = lhcStatusSet;
211  }
212  },
213  "beginEvent");
214 
215  // run on collections
216  for (unsigned iSch(0); iSch < schedule_.size(); iSch++) {
217  Processor processor(schedule_[iSch].first);
218  (this->*processor)(_evt, schedule_[iSch].second, enabledTasks);
219  }
220 
221  // close event processing
223  [&_evt, &_es, &enabledTasks](ecaldqm::DQWorker* worker) {
224  if (enabledTasks.find(worker) != enabledTasks.end())
225  static_cast<ecaldqm::DQWorkerTask*>(worker)->endEvent(_evt, _es);
226  },
227  "endEvent");
228 
229  if (verbosity_ > 2)
230  edm::LogInfo("EcalDQM") << moduleName_ << "::analyze: Closing Event " << _evt.id().event();
231 }
232 
ConfigurationDescriptions.h
EcalDQMonitorTask::globalBeginLuminosityBlock
std::shared_ptr< ecaldqm::EcalLSCache > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const override
Definition: EcalDQMonitorTask.cc:122
Handle.h
EcalDQMonitorTask.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::Event::getLuminosityBlock
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:100
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:46
ecaldqm
Definition: DQWorker.h:24
EcalDQMonitorTask::globalEndLuminosityBlock
void globalEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:137
ecaldqm::collectionName
const std::string collectionName[nCollections]
Definition: Collections.h:47
edm::ParameterSet::getUntrackedParameterSet
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Definition: ParameterSet.cc:2136
edm::ParameterWildcard
Definition: ParameterWildcard.h:23
EcalDQMonitorTask::lastResetTime_
time_t lastResetTime_
Definition: EcalDQMonitorTask.h:53
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:47
ecaldqm::EcalDQMonitor::executeOnWorkers_
void executeOnWorkers_(FuncOnWorker, std::string const &, std::string const &="", int=1) const
Definition: EcalDQMonitor.h:51
edm::LuminosityBlock::index
LuminosityBlockIndex index() const
Definition: LuminosityBlock.cc:27
edm
HLT enums.
Definition: AlignableModifier.h:19
ecaldqm::EcalDQMonitor::verbosity_
const int verbosity_
Definition: EcalDQMonitor.h:47
ecaldqm::EcalDQMonitor::ecaldqmBeginRun
void ecaldqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: EcalDQMonitor.cc:87
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MESet.h
DQMOneEDAnalyzer
Definition: DQMOneEDAnalyzer.h:20
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:46
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
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
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
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ecaldqm::DQWorker::releaseMEs
virtual void releaseMEs()
Definition: DQWorker.cc:60
ecaldqm::DQWorker
Definition: DQWorker.h:28
EcalDQMonitorTask::processedEvents_
int processedEvents_
Definition: EcalDQMonitorTask.h:50
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:531
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::ParameterSet
Definition: ParameterSet.h:47
EcalDQMonitorTask::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: EcalDQMonitorTask.cc:148
Event.h
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ecaldqm::EcalDQMonitor::ecaldqmBeginLuminosityBlock
void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const
Definition: EcalDQMonitor.cc:115
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:36
edm::EventSetup
Definition: EventSetup.h:57
edm::ParameterSetDescription::addNode
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
Definition: ParameterSetDescription.cc:41
InputTag.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
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:48
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
dqm::implementation::IBooker
Definition: DQMStore.h:43
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
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::RequireZeroOrMore
Definition: ParameterWildcardBase.h:17
edm::Log
Definition: MessageLogger.h:70
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:45
EcalDQMonitorTask::resetInterval_
float resetInterval_
Definition: EcalDQMonitorTask.h:54
EcalDQMonitorTask
Definition: EcalDQMonitorTask.h:18
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
EcalDQMCommonUtils.h