From a3077263ccc12ce6f61f831d113f6da70363cfe7 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 10 Nov 2009 10:44:40 +0000 Subject: [PATCH] --- yaml --- r: 77495 b: "refs/heads/CMSSW_7_1_X" c: 7839e2f303a3670d5ec30a5dbab466d129ac1e22 h: "refs/heads/CMSSW_7_1_X" i: 77493: ebf45df2049a004dd3e30ae2f121675bc7fd7bb5 77491: b1fb4c95403d5c42e1267b40f2262bfaf84d9f46 77487: 96e41ab16dd551156272a1dbadfcb20a62316c1d v: v3 --- [refs] | 2 +- .../special/src/HLTLogMonitorFilter.cc | 80 ++++++++++++++----- 2 files changed, 60 insertions(+), 22 deletions(-) diff --git a/[refs] b/[refs] index 8a3b83d32123d..8037d30564980 100644 --- a/[refs] +++ b/[refs] @@ -1,3 +1,3 @@ --- refs/heads/gh-pages: 09c786f70121f131b3715aaf3464996502bbeb7e -"refs/heads/CMSSW_7_1_X": c55cc700d527c920de8c2ae232d102f1ca55ca4f +"refs/heads/CMSSW_7_1_X": 7839e2f303a3670d5ec30a5dbab466d129ac1e22 diff --git a/trunk/HLTrigger/special/src/HLTLogMonitorFilter.cc b/trunk/HLTrigger/special/src/HLTLogMonitorFilter.cc index cf406a3db1bde..b26608582b555 100644 --- a/trunk/HLTrigger/special/src/HLTLogMonitorFilter.cc +++ b/trunk/HLTrigger/special/src/HLTLogMonitorFilter.cc @@ -13,7 +13,7 @@ // // Original Author: Andrea Bocci // Created: Thu Nov 5 15:16:46 CET 2009 -// $Id: HLTLogMonitorFilter.cc,v 1.1 2009/11/09 00:01:23 fwyzard Exp $ +// $Id: HLTLogMonitorFilter.cc,v 1.1 2009/11/09 14:04:30 fwyzard Exp $ // @@ -44,12 +44,29 @@ class HLTLogMonitorFilter : public HLTFilter { uint32_t threshold; // configurable threshold, after which messages in this Category start to be logarithmically prescaled uint32_t prescale; // current prescale for this Category uint64_t counter; // number of events that fired this Category + uint64_t accepted; // number of events acepted for this Category CategoryEntry(uint32_t t = 0) : - threshold(t), // default-constructed entries have the threshold set to 0, which means the associated category is disabled + threshold(t), // default-constructed entries have the threshold set to 0, which means the associated Category is disabled prescale(1), - counter(0) + counter(0), + accepted(0) { } + + bool accept() { + ++counter; + + // fail if the prescaler is disabled (threshold == 0), or if the counter is not a multiple of the prescale + if ((threshold == 0) or (counter % prescale)) + return false; + + // quasi-logarithmic increase in the prescale factor (should be safe even if threshold is 1) + if (counter == prescale * threshold) + prescale *= threshold; + + ++accepted; + return true; + } }; // ---------- private methods ----------------------- @@ -57,6 +74,9 @@ class HLTLogMonitorFilter : public HLTFilter { /// EDFilter accept method virtual bool filter(edm::Event&, const edm::EventSetup &); + /// EDFilter endJob method + virtual void endJob(void); + /// check if the requested category has a valid entry bool knownCategory(const std::string & category); @@ -66,18 +86,25 @@ class HLTLogMonitorFilter : public HLTFilter { /// return the entry for requested category, if it exists, or create a new one with the default threshold value CategoryEntry & getCategory(const std::string & category); + /// summarize to LogInfo + void summary(void); + + // ---------- member data --------------------------- - uint32_t m_prescale; // default threshold, after which messages in each Category start to be logarithmically prescaled + uint32_t m_prescale; // default threshold, after which messages in each Category start to be logarithmically prescaled std::map m_data; // map each category name to its prescale data }; // system include files +#include +#include #include #include #include // user include files +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/MessageLogger/interface/LoggedErrorsSummary.h" // @@ -108,8 +135,7 @@ HLTLogMonitorFilter::~HLTLogMonitorFilter() // // ------------ method called on each new Event ------------ -bool -HLTLogMonitorFilter::filter(edm::Event & event, const edm::EventSetup & setup) { +bool HLTLogMonitorFilter::filter(edm::Event & event, const edm::EventSetup & setup) { // no LogErrors or LogWarnings, skip processing and reject the event if (not edm::FreshErrorsExist()) return false; @@ -129,26 +155,19 @@ HLTLogMonitorFilter::filter(edm::Event & event, const edm::EventSetup & setup) { // FIXME: this can be avoided if the m_data map is keyed on boost::sub_range category.assign(i->begin(), i->end()); - // access the message category, or create a new one as needed - CategoryEntry & data = getCategory(category); - ++data.counter; - - // if this category is disabled (scale == 0), skip this event - // if the counter is not a multiple of the prescale, skip the event - if ((data.prescale == 0) or (data.counter % data.prescale)) - continue; - - // quasi-logarithmic increase in the prescale factor (should be safe even if threshold is 1) - if (data.counter == data.prescale * data.threshold) - data.prescale *= data.threshold; - - accept = true; + // access the message category, or create a new one as needed, and check the prescale + if (getCategory(category).accept()) + accept = true; } } - return accept; } +// ------------ method called at the end of the Job --------- +void HLTLogMonitorFilter::endJob(void) { + summary(); +} + /// check if the requested category has a valid entry bool HLTLogMonitorFilter::knownCategory(const std::string & category) { return (m_data.find( category ) != m_data.end()); @@ -173,6 +192,25 @@ HLTLogMonitorFilter::CategoryEntry & HLTLogMonitorFilter::getCategory(const std: return m_data.insert( std::make_pair(category, CategoryEntry(m_prescale)) ).first->second; } +/// summarize to LogInfo +void HLTLogMonitorFilter::summary(void) { + edm::LogVerbatim("Report") << "HLTLogMonitorFilter Summary:\n" + << std::setw(-48) << "Category" + << std::setw(8) << "Events" + << std::setw(8) << "Accept" + << std::setw(8) << "Thresh." + << std::setw(8) << "Final prescale" + << std::endl; + typedef std::map::value_type Entry; + BOOST_FOREACH(const Entry & entry, m_data) { + edm::LogVerbatim("Report") << std::setw(-48) << entry.first + << std::setw(8) << entry.second.counter + << std::setw(8) << entry.second.accepted + << std::setw(8) << entry.second.threshold + << std::setw(8) << entry.second.prescale + << std::endl; + } +} // define as a framework plug-in #include "FWCore/Framework/interface/MakerMacros.h"