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 
64 
67 //
68 // constants, enums and typedefs
69 //
70 
71 //
72 // static data member definitions
73 //
74 
75 //
76 // constructors and destructor
77 //
79  : dqmStore_(edm::Service<DQMStore>().operator->()),
80  conf_(iConfig),
81  pluginsMonName_(iConfig.getParameter<std::string>("pluginsMonName")),
82  modules_vector_(iConfig.getParameter<std::vector<std::string> >("modules")),
83  categories_vector_(iConfig.getParameter<std::vector<std::string> >("categories")),
84  doWarningsPlots_(iConfig.getParameter<bool>("doWarningsPlots")),
85  doPUmonitoring_(iConfig.getParameter<bool>("doPUmonitoring")) {
86  errorToken_ = consumes<std::vector<edm::ErrorSummaryEntry> >(edm::InputTag("logErrorHarvester"));
87 
89  //now do what ever initialization is needed
90  lumiDetails_ = new GetLumi(iConfig.getParameter<edm::ParameterSet>("BXlumiSetup"), c);
92  iConfig.getParameter<edm::ParameterSet>("genericTriggerEventPSet"), consumesCollector(), *this);
93 }
94 
96  // do anything here that needs to be done at desctruction time
97  // (e.g. close files, deallocate resources etc.)
98  // if ( lumiDetails_ ) delete lumiDetails_;
100  delete genTriggerEventFlag_;
101 }
102 
103 //
104 // member functions
105 //
106 
107 // ------------ method called for each event ------------
109  // Filter out events if Trigger Filtering is requested
111  return;
112 
113  double BXlumi = -1.;
114  if (doPUmonitoring_)
116 
117  // Take the ErrorSummaryEntry container
119  iEvent.getByToken(errorToken_, errors);
120  // Check that errors is valid
121  if (!errors.isValid())
122  return;
123  // Compare severity level of error with ELseveritylevel instance el : "-e" should be the lowest error
124  edm::ELseverityLevel el("-e");
125 
126  // Find the total number of errors in iEvent
127  if (errors->empty()) {
128  if (doPUmonitoring_) {
129  for (size_t i = 0; i < modulesMap.size(); i++) {
130  ModulesErrorsVsBXlumi[i]->Fill(BXlumi, 0.);
131  if (doWarningsPlots_)
132  ModulesWarningsVsBXlumi[i]->Fill(BXlumi, 0.);
133  }
134  }
135  } else {
136  size_t nCategories = categories_vector_.size();
137 
138  for (size_t i = 0, n = errors->size(); i < n; i++) {
139  // std::cout << "LogMessageMonitor::analyze] Severity for error/warning: " << (*errors)[i].severity << " " <<(*errors)[i].module << std::endl;
140  // remove the first part of the module string, what is before ":"
141  std::string s = (*errors)[i].module;
142  size_t pos = s.find(':');
143  std::string s_module = s.substr(pos + 1, s.size());
144  std::map<std::string, int>::const_iterator it = modulesMap.find(s_module);
145  if (it != modulesMap.end()) {
146  // std::cout << "LogMessageMonitor::analyze] it: " << " --> " << s_module << std::endl;
147 
148  // IF THIS IS AN ERROR on the ELseverityLevel SCALE, FILL ERROR HISTS
149  if ((*errors)[i].severity.getLevel() >= edm::ELseverityLevel::ELsev_error) {
150  if (doPUmonitoring_)
151  ModulesErrorsVsBXlumi[it->second]->Fill(BXlumi, (*errors)[i].count);
152 
153  // loop over the different categories of errors
154  // defined by configuration file
155  // if the category is not in the given list
156  // it fills the bin "others"
157  TString module = it->first;
158  TString category = (*errors)[i].category;
159  int ibinX = CategoriesVsModules->getTH1()->GetXaxis()->FindBin(module);
160  int ibinY = CategoriesVsModules->getTH1()->GetYaxis()->FindBin(category);
161  /*
162  std::cout << "LogMessageMonitor::analyze] ibinX: " << ibinX << " it->second: " << it->second << " it->first: " << it->first << std::endl;
163  std::cout << "LogMessageMonitor::analyze] ibinY: " << ibinY << " (*errors)[i].category: " << (*errors)[i].category << std::endl;
164  size_t nbinsX = CategoriesVsModules->getTH1()->GetNbinsX();
165  for (size_t bin = 1; bin<=nbinsX; bin++) {
166  std::cout << "binX" << bin << ": " << CategoriesVsModules->getTH1()->GetXaxis()->GetBinLabel(bin) << std::endl;
167  }
168  size_t nbinsY = CategoriesVsModules->getTH1()->GetNbinsY();
169  for (size_t bin = 1; bin<=nbinsY; bin++) {
170  std::cout << "binY" << bin << ": " << CategoriesVsModules->getTH1()->GetYaxis()->GetBinLabel(bin) << std::endl;
171  }
172  */
173  if (ibinY > 0) {
174  int ncount = CategoriesVsModules->getTH1()->GetBinContent(ibinX, ibinY) + 1;
175  CategoriesVsModules->getTH1()->SetBinContent(ibinX, ibinY, ncount);
176  } else {
177  int ncount = CategoriesVsModules->getTH1()->GetBinContent(ibinX, nCategories) + 1;
178  CategoriesVsModules->getTH1()->SetBinContent(ibinX, nCategories, ncount);
179  }
180  } else {
181  // IF ONLY WARNING, FILL WARNING HISTS
182  if (doWarningsPlots_)
183  if (doPUmonitoring_)
184  ModulesWarningsVsBXlumi[it->second]->Fill(BXlumi, (*errors)[i].count);
185  }
186  }
187  }
188  }
189 }
190 
191 void LogMessageMonitor::bookHistograms(DQMStore::IBooker& ibooker,
192  edm::Run const& iRun,
193  edm::EventSetup const& iSetup) {
194  if (genTriggerEventFlag_->on())
195  genTriggerEventFlag_->initRun(iRun, iSetup);
196 
197  std::string MEFolderName = conf_.getParameter<std::string>("LogFolderName");
198 
199  ibooker.setCurrentFolder(MEFolderName);
200 
201  categories_vector_.push_back("others");
202  size_t nModules = modules_vector_.size();
203  size_t nCategories = categories_vector_.size();
204 
205  histname = pluginsMonName_ + "ErrorsVsModules";
207  ibooker.book2D(histname, histname, nModules, 0., double(nModules), nCategories, 0., double(nCategories));
208  CategoriesVsModules->getTH1()->GetXaxis()->SetNoAlphanumeric();
209  CategoriesVsModules->getTH1()->GetYaxis()->SetNoAlphanumeric();
210  CategoriesVsModules->setAxisTitle("modules", 1);
211  for (size_t imodule = 0; imodule < nModules; imodule++)
212  CategoriesVsModules->setBinLabel(imodule + 1, modules_vector_[imodule], 1);
213  CategoriesVsModules->setAxisTitle("categories", 2);
214  // CategoriesVsModules->getTH1()->GetXaxis()->LabelsOption("v");
215  for (size_t icategories = 0; icategories < nCategories; icategories++)
216  CategoriesVsModules->setBinLabel(icategories + 1, categories_vector_[icategories], 2);
217 
218  // MAKE MODULEMAP USING INPUT FROM CFG FILE
219  for (size_t i = 0; i < modules_vector_.size(); i++) {
220  modulesMap.insert(std::pair<std::string, int>(modules_vector_[i], i));
221  }
222 
223  if (doPUmonitoring_) {
224  // BOOK THE HISTOGRAMS
225  // get binning from the configuration
226  edm::ParameterSet BXlumiParameters = conf_.getParameter<edm::ParameterSet>("BXlumiSetup");
227  int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
228  double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
229  double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");
230 
231  size_t i = 0;
232  for (std::map<std::string, int>::const_iterator it = modulesMap.begin(); it != modulesMap.end(); ++it, i++) {
233  ibooker.setCurrentFolder(MEFolderName + "/PUmonitoring/Errors");
234 
235  histname = "errorsVsBXlumi_" + it->first;
236  ModulesErrorsVsBXlumi.push_back(dynamic_cast<MonitorElement*>(
237  ibooker.bookProfile(histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, 0., 100, "")));
238  ModulesErrorsVsBXlumi[i]->setAxisTitle("BXlumi [10^{30} Hz cm^{-2}]", 1);
239  ModulesErrorsVsBXlumi[i]->setAxisTitle("Mean number of errors", 2);
240 
241  if (doWarningsPlots_) {
242  ibooker.setCurrentFolder(MEFolderName + "/PUmonitoring/Warnings");
243 
244  histname = "warningVsBXlumi_" + it->first;
245  ModulesWarningsVsBXlumi.push_back(dynamic_cast<MonitorElement*>(
246  ibooker.bookProfile(histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, 0., 100, "")));
247  ModulesWarningsVsBXlumi[i]->setAxisTitle("BXlumi [10^{30} Hz cm^{-2}]", 1);
248  ModulesWarningsVsBXlumi[i]->setAxisTitle("Mean number of warnings", 2);
249  }
250  }
251  }
252 }
253 
254 /*
255 // ------------ method called once each job just before starting event loop ------------
256 void
257 LogMessageMonitor::beginJob()
258 {
259 
260 }
261 */
262 // ------------ method called once each job just after ending the event loop ------------
264  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
266  if (outputMEsInRootFile) {
268  }
269 }
270 
271 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
273  //The following says we do not know what parameters are allowed so do no validation
274  // Please change this to state exactly what you do use, even if it is no parameters
276  desc.setUnknown();
277  descriptions.addDefault(desc);
278 }
279 
LogMessageMonitor.h
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:30
Handle.h
LogMessageMonitor::ModulesWarningsVsBXlumi
std::vector< MonitorElement * > ModulesWarningsVsBXlumi
Definition: LogMessageMonitor.h:83
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
LogMessageMonitor::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LogMessageMonitor.cc:272
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:78
pos
Definition: PixelAliasList.h:18
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MessageLogger_cfi.errors
errors
Definition: MessageLogger_cfi.py:18
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
LogMessageMonitor::conf_
edm::ParameterSet conf_
Definition: LogMessageMonitor.h:69
DQMStore.h
LogMessageMonitor::endJob
void endJob() override
Definition: LogMessageMonitor.cc:263
LogMessageMonitor::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: LogMessageMonitor.cc:191
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
Service
LogMessageMonitor::lumiDetails_
GetLumi * lumiDetails_
Definition: LogMessageMonitor.h:78
LogMessageMonitor::modulesMap
std::map< std::string, int > modulesMap
Definition: LogMessageMonitor.h:71
reco_skim_cfg_mod.outputFileName
outputFileName
Definition: reco_skim_cfg_mod.py:15
ErrorSummaryEntry.h
edm::ELseverityLevel::ELsev_error
Definition: ELseverityLevel.h:112
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:760
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:264
BXlumiParameters_cfi.BXlumiBin
BXlumiBin
Definition: BXlumiParameters_cfi.py:17
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
LogMessageMonitor::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: LogMessageMonitor.cc:108
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
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
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
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
LogMessageMonitor::doWarningsPlots_
bool doWarningsPlots_
Definition: LogMessageMonitor.h:87
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
module
Definition: vlib.h:198
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
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
LogMessageMonitor::doPUmonitoring_
bool doPUmonitoring_
Definition: LogMessageMonitor.h:88
std
Definition: JetResolutionObject.h:76
edm::ELseverityLevel
Definition: ELseverityLevel.h:96
GenericTriggerEventFlag::initRun
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
Definition: GenericTriggerEventFlag.cc:151
LogMessageMonitor::genTriggerEventFlag_
GenericTriggerEventFlag * genTriggerEventFlag_
Definition: LogMessageMonitor.h:79
ELstring.h
LogMessageMonitor::dqmStore_
DQMStore * dqmStore_
Definition: LogMessageMonitor.h:68
edm::Event
Definition: Event.h:73
LogMessageMonitor::~LogMessageMonitor
~LogMessageMonitor() override
Definition: LogMessageMonitor.cc:95
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:39
BXlumiParameters_cfi.BXlumiMax
BXlumiMax
Definition: BXlumiParameters_cfi.py:19