CMS 3D CMS Logo

LogMessageMonitor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: LogMessageMonitor
4 // Class: LogMessageMonitor
5 //
49 //
50 // Original Author: Mia Tosi,40 3-B32,+41227671609,
51 // Created: Thu Mar 8 14:34:13 CET 2012
52 //
53 //
54 
56 
59 
63 
66 //
67 // constants, enums and typedefs
68 //
69 
70 //
71 // static data member definitions
72 //
73 
74 //
75 // constructors and destructor
76 //
78  : dqmStore_(edm::Service<DQMStore>().operator->()),
79  conf_(iConfig),
80  pluginsMonName_(iConfig.getParameter<std::string>("pluginsMonName")),
81  modules_vector_(iConfig.getParameter<std::vector<std::string> >("modules")),
82  categories_vector_(iConfig.getParameter<std::vector<std::string> >("categories")),
83  doWarningsPlots_(iConfig.getParameter<bool>("doWarningsPlots")),
84  doPUmonitoring_(iConfig.getParameter<bool>("doPUmonitoring")) {
85  errorToken_ = consumes<std::vector<edm::ErrorSummaryEntry> >(edm::InputTag("logErrorHarvester"));
86 
88  //now do what ever initialization is needed
89  lumiDetails_ = new GetLumi(iConfig.getParameter<edm::ParameterSet>("BXlumiSetup"), c);
91  iConfig.getParameter<edm::ParameterSet>("genericTriggerEventPSet"), consumesCollector(), *this);
92 }
93 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97  // if ( lumiDetails_ ) delete lumiDetails_;
99  delete genTriggerEventFlag_;
100 }
101 
102 //
103 // member functions
104 //
105 
106 // ------------ method called for each event ------------
108  // Filter out events if Trigger Filtering is requested
110  return;
111 
112  double BXlumi = -1.;
113  if (doPUmonitoring_)
115 
116  // Take the ErrorSummaryEntry container
118  iEvent.getByToken(errorToken_, errors);
119  // Check that errors is valid
120  if (!errors.isValid())
121  return;
122  // Compare severity level of error with ELseveritylevel instance el : "-e" should be the lowest error
123  edm::ELseverityLevel el("-e");
124 
125  // Find the total number of errors in iEvent
126  if (errors->empty()) {
127  if (doPUmonitoring_) {
128  for (size_t i = 0; i < modulesMap.size(); i++) {
129  ModulesErrorsVsBXlumi[i]->Fill(BXlumi, 0.);
130  if (doWarningsPlots_)
131  ModulesWarningsVsBXlumi[i]->Fill(BXlumi, 0.);
132  }
133  }
134  } else {
135  size_t nCategories = categories_vector_.size();
136 
137  for (size_t i = 0, n = errors->size(); i < n; i++) {
138  // std::cout << "LogMessageMonitor::analyze] Severity for error/warning: " << (*errors)[i].severity << " " <<(*errors)[i].module << std::endl;
139  // remove the first part of the module string, what is before ":"
140  std::string s = (*errors)[i].module;
141  size_t pos = s.find(':');
142  std::string s_module = s.substr(pos + 1, s.size());
143  std::map<std::string, int>::const_iterator it = modulesMap.find(s_module);
144  if (it != modulesMap.end()) {
145  // std::cout << "LogMessageMonitor::analyze] it: " << " --> " << s_module << std::endl;
146 
147  // IF THIS IS AN ERROR on the ELseverityLevel SCALE, FILL ERROR HISTS
148  if ((*errors)[i].severity.getLevel() >= edm::ELseverityLevel::ELsev_error) {
149  if (doPUmonitoring_)
150  ModulesErrorsVsBXlumi[it->second]->Fill(BXlumi, (*errors)[i].count);
151 
152  // loop over the different categories of errors
153  // defined by configuration file
154  // if the category is not in the given list
155  // it fills the bin "others"
156  TString module = it->first;
157  TString category = (*errors)[i].category;
158  int ibinX = CategoriesVsModules->getTH1()->GetXaxis()->FindBin(module);
159  int ibinY = CategoriesVsModules->getTH1()->GetYaxis()->FindBin(category);
160  /*
161  std::cout << "LogMessageMonitor::analyze] ibinX: " << ibinX << " it->second: " << it->second << " it->first: " << it->first << std::endl;
162  std::cout << "LogMessageMonitor::analyze] ibinY: " << ibinY << " (*errors)[i].category: " << (*errors)[i].category << std::endl;
163  size_t nbinsX = CategoriesVsModules->getTH1()->GetNbinsX();
164  for (size_t bin = 1; bin<=nbinsX; bin++) {
165  std::cout << "binX" << bin << ": " << CategoriesVsModules->getTH1()->GetXaxis()->GetBinLabel(bin) << std::endl;
166  }
167  size_t nbinsY = CategoriesVsModules->getTH1()->GetNbinsY();
168  for (size_t bin = 1; bin<=nbinsY; bin++) {
169  std::cout << "binY" << bin << ": " << CategoriesVsModules->getTH1()->GetYaxis()->GetBinLabel(bin) << std::endl;
170  }
171  */
172  if (ibinY > 0) {
173  int ncount = CategoriesVsModules->getTH1()->GetBinContent(ibinX, ibinY) + 1;
174  CategoriesVsModules->getTH1()->SetBinContent(ibinX, ibinY, ncount);
175  } else {
176  int ncount = CategoriesVsModules->getTH1()->GetBinContent(ibinX, nCategories) + 1;
177  CategoriesVsModules->getTH1()->SetBinContent(ibinX, nCategories, ncount);
178  }
179  } else {
180  // IF ONLY WARNING, FILL WARNING HISTS
181  if (doWarningsPlots_)
182  if (doPUmonitoring_)
183  ModulesWarningsVsBXlumi[it->second]->Fill(BXlumi, (*errors)[i].count);
184  }
185  }
186  }
187  }
188 }
189 
191  edm::Run const& iRun,
192  edm::EventSetup const& iSetup) {
193  if (genTriggerEventFlag_->on())
194  genTriggerEventFlag_->initRun(iRun, iSetup);
195 
196  std::string MEFolderName = conf_.getParameter<std::string>("LogFolderName");
197 
198  ibooker.setCurrentFolder(MEFolderName);
199 
200  categories_vector_.push_back("others");
201  size_t nModules = modules_vector_.size();
202  size_t nCategories = categories_vector_.size();
203 
204  histname = pluginsMonName_ + "ErrorsVsModules";
206  ibooker.book2D(histname, histname, nModules, 0., double(nModules), nCategories, 0., double(nCategories));
207  CategoriesVsModules->getTH1()->GetXaxis()->SetNoAlphanumeric();
208  CategoriesVsModules->getTH1()->GetYaxis()->SetNoAlphanumeric();
209  CategoriesVsModules->setAxisTitle("modules", 1);
210  for (size_t imodule = 0; imodule < nModules; imodule++)
211  CategoriesVsModules->setBinLabel(imodule + 1, modules_vector_[imodule], 1);
212  CategoriesVsModules->setAxisTitle("categories", 2);
213  // CategoriesVsModules->getTH1()->GetXaxis()->LabelsOption("v");
214  for (size_t icategories = 0; icategories < nCategories; icategories++)
215  CategoriesVsModules->setBinLabel(icategories + 1, categories_vector_[icategories], 2);
216 
217  // MAKE MODULEMAP USING INPUT FROM CFG FILE
218  for (size_t i = 0; i < modules_vector_.size(); i++) {
219  modulesMap.insert(std::pair<std::string, int>(modules_vector_[i], i));
220  }
221 
222  if (doPUmonitoring_) {
223  // BOOK THE HISTOGRAMS
224  // get binning from the configuration
225  edm::ParameterSet BXlumiParameters = conf_.getParameter<edm::ParameterSet>("BXlumiSetup");
226  int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
227  double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
228  double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");
229 
230  size_t i = 0;
231  for (std::map<std::string, int>::const_iterator it = modulesMap.begin(); it != modulesMap.end(); ++it, i++) {
232  ibooker.setCurrentFolder(MEFolderName + "/PUmonitoring/Errors");
233 
234  histname = "errorsVsBXlumi_" + it->first;
235  ModulesErrorsVsBXlumi.push_back(dynamic_cast<MonitorElement*>(
236  ibooker.bookProfile(histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, 0., 100, "")));
237  ModulesErrorsVsBXlumi[i]->setAxisTitle("BXlumi [10^{30} Hz cm^{-2}]", 1);
238  ModulesErrorsVsBXlumi[i]->setAxisTitle("Mean number of errors", 2);
239 
240  if (doWarningsPlots_) {
241  ibooker.setCurrentFolder(MEFolderName + "/PUmonitoring/Warnings");
242 
243  histname = "warningVsBXlumi_" + it->first;
244  ModulesWarningsVsBXlumi.push_back(dynamic_cast<MonitorElement*>(
245  ibooker.bookProfile(histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, 0., 100, "")));
246  ModulesWarningsVsBXlumi[i]->setAxisTitle("BXlumi [10^{30} Hz cm^{-2}]", 1);
247  ModulesWarningsVsBXlumi[i]->setAxisTitle("Mean number of warnings", 2);
248  }
249  }
250  }
251 }
252 
253 /*
254 // ------------ method called once each job just before starting event loop ------------
255 void
256 LogMessageMonitor::beginJob()
257 {
258 
259 }
260 */
261 // ------------ method called once each job just after ending the event loop ------------
263  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
265  if (outputMEsInRootFile) {
267  }
268 }
269 
270 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
272  //The following says we do not know what parameters are allowed so do no validation
273  // Please change this to state exactly what you do use, even if it is no parameters
275  desc.setUnknown();
276  descriptions.addDefault(desc);
277 }
278 
LogMessageMonitor.h
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
Handle.h
LogMessageMonitor::ModulesWarningsVsBXlumi
std::vector< MonitorElement * > ModulesWarningsVsBXlumi
Definition: LogMessageMonitor.h:83
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
LogMessageMonitor::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LogMessageMonitor.cc:271
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
LogMessageMonitor::LogMessageMonitor
LogMessageMonitor(const edm::ParameterSet &)
Definition: LogMessageMonitor.cc:77
pos
Definition: PixelAliasList.h:18
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:46
LogMessageMonitor::conf_
edm::ParameterSet conf_
Definition: LogMessageMonitor.h:69
DQMStore.h
LogMessageMonitor::endJob
void endJob() override
Definition: LogMessageMonitor.cc:262
LogMessageMonitor::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: LogMessageMonitor.cc:190
BXlumiParameters_cfi.BXlumiMin
BXlumiMin
Definition: BXlumiParameters_cfi.py:18
edm::Handle
Definition: AssociativeIterator.h:50
LogMessageMonitor::CategoriesVsModules
MonitorElement * CategoriesVsModules
Definition: LogMessageMonitor.h:85
LogMessageMonitor::categories_vector_
std::vector< std::string > categories_vector_
Definition: LogMessageMonitor.h:76
LogMessageMonitor::ModulesErrorsVsBXlumi
std::vector< MonitorElement * > ModulesErrorsVsBXlumi
Definition: LogMessageMonitor.h:82
Utilities.operator
operator
Definition: Utilities.py:24
alignCSCRings.s
s
Definition: alignCSCRings.py:92
GetLumi
Definition: GetLumi.h:21
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:727
errors
Definition: errors.py:1
LogMessageMonitor::histname
std::string histname
Definition: LogMessageMonitor.h:66
GenericTriggerEventFlag.h
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
Service
LogMessageMonitor::lumiDetails_
GetLumi * lumiDetails_
Definition: LogMessageMonitor.h:78
LogMessageMonitor::modulesMap
std::map< std::string, int > modulesMap
Definition: LogMessageMonitor.h:71
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
reco_skim_cfg_mod.outputFileName
outputFileName
Definition: reco_skim_cfg_mod.py:15
ErrorSummaryEntry.h
edm::ELseverityLevel::ELsev_error
Definition: ELseverityLevel.h:44
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:761
dqm::impl::MonitorElement::getTH1
virtual TH1 * getTH1()
Definition: MonitorElement.cc:969
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GenericTriggerEventFlag::accept
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
Definition: GenericTriggerEventFlag.cc:266
BXlumiParameters_cfi.BXlumiBin
BXlumiBin
Definition: BXlumiParameters_cfi.py:17
edm::ParameterSet
Definition: ParameterSet.h:47
LogMessageMonitor::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: LogMessageMonitor.cc:107
LogMessageMonitor::modules_vector_
std::vector< std::string > modules_vector_
Definition: LogMessageMonitor.h:75
GenericTriggerEventFlag
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Definition: GenericTriggerEventFlag.h:42
iEvent
int iEvent
Definition: GenABIO.cc:224
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:771
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
LogMessageMonitor::doWarningsPlots_
bool doWarningsPlots_
Definition: LogMessageMonitor.h:87
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
LogMessageMonitor
Definition: LogMessageMonitor.h:49
ELseverityLevel.h
GetLumi::getValue
double getValue(const edm::Event &)
Definition: GetLumi.cc:49
mvaElectronID_Fall17_iso_V1_cff.nCategories
nCategories
Definition: mvaElectronID_Fall17_iso_V1_cff.py:86
LogMessageMonitor::errorToken_
edm::EDGetTokenT< std::vector< edm::ErrorSummaryEntry > > errorToken_
Definition: LogMessageMonitor.h:64
GetLumi.h
LogMessageMonitor::pluginsMonName_
std::string pluginsMonName_
Definition: LogMessageMonitor.h:74
GenericTriggerEventFlag::on
bool on()
Definition: GenericTriggerEventFlag.h:135
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
LogMessageMonitor::doPUmonitoring_
bool doPUmonitoring_
Definition: LogMessageMonitor.h:88
std
Definition: JetResolutionObject.h:76
edm::ELseverityLevel
Definition: ELseverityLevel.h:26
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
GenericTriggerEventFlag::initRun
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
Definition: GenericTriggerEventFlag.cc:153
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
LogMessageMonitor::genTriggerEventFlag_
GenericTriggerEventFlag * genTriggerEventFlag_
Definition: LogMessageMonitor.h:79
LogMessageMonitor::dqmStore_
DQMStore * dqmStore_
Definition: LogMessageMonitor.h:68
edm::Event
Definition: Event.h:73
LogMessageMonitor::~LogMessageMonitor
~LogMessageMonitor() override
Definition: LogMessageMonitor.cc:94
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
BXlumiParameters_cfi.BXlumiMax
BXlumiMax
Definition: BXlumiParameters_cfi.py:19
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54