CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HLTLogMonitorFilter Class Reference

#include <Work/HLTLogMonitorFilter/src/HLTLogMonitorFilter.cc>

Inheritance diagram for HLTLogMonitorFilter:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  CategoryEntry
 

Public Member Functions

 HLTLogMonitorFilter (const edm::ParameterSet &)
 
 ~HLTLogMonitorFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

typedef std::map< std::string,
CategoryEntry
CategoryMap
 

Private Member Functions

CategoryEntryaddCategory (const std::string &category, uint32_t threshold)
 create a new entry for the given category, with the given threshold value More...
 
virtual void beginJob (void)
 EDFilter beginJob method. More...
 
virtual void endJob (void)
 EDFilter endJob method. More...
 
virtual bool filter (edm::Event &, const edm::EventSetup &)
 EDFilter accept method. More...
 
CategoryEntrygetCategory (const std::string &category)
 return the entry for requested category, if it exists, or create a new one with the default threshold value More...
 
bool knownCategory (const std::string &category)
 check if the requested category has a valid entry More...
 
void summary (void)
 summarize to LogInfo More...
 

Private Attributes

CategoryMap m_data
 
uint32_t m_prescale
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: Accept events if any LogError or LogWarning was raised

Implementation: <Notes on="" implementation>="">

Definition at line 36 of file HLTLogMonitorFilter.cc.

Member Typedef Documentation

typedef std::map<std::string, CategoryEntry> HLTLogMonitorFilter::CategoryMap
private

Definition at line 79 of file HLTLogMonitorFilter.cc.

Constructor & Destructor Documentation

HLTLogMonitorFilter::HLTLogMonitorFilter ( const edm::ParameterSet config)
explicit

Definition at line 126 of file HLTLogMonitorFilter.cc.

References addCategory(), ecalBxOrbitNumberGrapher_cfg::categories, python.rootplot.argparse::category, edm::ParameterSet::getParameter(), m_prescale, mergeVDriftHistosByStation::name, and dtDQMClient_cfg::threshold.

126  :
127  m_prescale(),
128  m_data()
129 {
130  m_prescale = config.getParameter<uint32_t>("default_threshold");
131 
132  typedef std::vector<edm::ParameterSet> VPSet;
133  const VPSet & categories = config.getParameter<VPSet>("categories");
134  for (VPSet::const_iterator category = categories.begin(); category != categories.end(); ++category) {
135  const std::string & name = category->getParameter<std::string>("name");
136  uint32_t threshold = category->getParameter<uint32_t>("threshold");
137  addCategory(name, threshold);
138  }
139 
140  produces<std::vector<edm::ErrorSummaryEntry> >();
141 }
T getParameter(std::string const &) const
CategoryEntry & addCategory(const std::string &category, uint32_t threshold)
create a new entry for the given category, with the given threshold value
HLTLogMonitorFilter::~HLTLogMonitorFilter ( )

Definition at line 143 of file HLTLogMonitorFilter.cc.

144 {
145 }

Member Function Documentation

HLTLogMonitorFilter::CategoryEntry & HLTLogMonitorFilter::addCategory ( const std::string &  category,
uint32_t  threshold 
)
private

create a new entry for the given category, with the given threshold value

Definition at line 218 of file HLTLogMonitorFilter.cc.

References python.rootplot.argparse::category, edm::hlt::Exception, m_data, and query::result.

Referenced by HLTLogMonitorFilter().

218  {
219  // check after inserting, as either the new CategoryEntry is needed, or an error condition is raised
220  std::pair<CategoryMap::iterator, bool> result = m_data.insert( std::make_pair(category, CategoryEntry(threshold)) );
221  if (not result.second)
222  throw cms::Exception("Configuration") << "Duplicate entry for category " << category;
223  return result.first->second;
224 }
tuple result
Definition: query.py:137
void HLTLogMonitorFilter::beginJob ( void  )
privatevirtual

EDFilter beginJob method.

Reimplemented from edm::EDFilter.

Definition at line 203 of file HLTLogMonitorFilter.cc.

References edm::MessageSender::errorSummaryIsBeingKept.

203  {
205 }
static bool errorSummaryIsBeingKept
Definition: MessageSender.h:57
void HLTLogMonitorFilter::endJob ( void  )
privatevirtual

EDFilter endJob method.

Reimplemented from edm::EDFilter.

Definition at line 207 of file HLTLogMonitorFilter.cc.

References edm::MessageSender::errorSummaryIsBeingKept, and summary().

207  {
209  summary();
210 }
static bool errorSummaryIsBeingKept
Definition: MessageSender.h:57
void summary(void)
summarize to LogInfo
bool HLTLogMonitorFilter::filter ( edm::Event event,
const edm::EventSetup setup 
)
privatevirtual

EDFilter accept method.

Implements edm::EDFilter.

Definition at line 153 of file HLTLogMonitorFilter.cc.

References accept(), HLTLogMonitorFilter::CategoryEntry::accept(), python.rootplot.argparse::category, benchmark_cfg::errors, edm::MessageSender::errorSummaryMap, edm::MessageSender::freshError, getCategory(), i, m_data, findQualityFiles::size, and confdb::splitter().

153  {
154  // no LogErrors or LogWarnings, skip processing and reject the event
156  return false;
157 
158  // clear "done" flag in all Categories
159  BOOST_FOREACH(CategoryMap::value_type & entry, m_data)
160  entry.second.done = false;
161 
162  // look at the LogErrors and LogWarnings, and accept the event if at least one is under threshold or matches the prescale
163  bool accept = false;
164  std::string category;
165 
166  typedef std::map<edm::ErrorSummaryMapKey, unsigned int> ErrorSummaryMap;
167  BOOST_FOREACH(const ErrorSummaryMap::value_type & entry, edm::MessageSender::errorSummaryMap) {
168  // split the message category
169  typedef boost::split_iterator<std::string::const_iterator> splitter;
170  for (splitter i = boost::make_split_iterator(entry.first.category, boost::first_finder("|", boost::is_equal()));
171  i != splitter();
172  ++i)
173  {
174  // extract the substring corresponding to the split_iterator
175  // FIXME: this can be avoided if the m_data map is keyed on boost::sub_range<std::string>
176  category.assign(i->begin(), i->end());
177 
178  // access the message category, or create a new one as needed, and check the prescale
179  if (getCategory(category).accept())
180  accept = true;
181  }
182  }
183 
184  // harvest the errors, but only if the filter will accept the event
185  std::auto_ptr<std::vector<edm::ErrorSummaryEntry> > errors(new std::vector<edm::ErrorSummaryEntry>());
186  if (accept) {
189  errors->push_back(entry.first); // sets category, module and severity
190  errors->back().count = entry.second; // count is 0 in key; set it to correct value (see FWCore/MessageLogger/src/LoggedErrorsSummary.cc)
191  }
192  }
193  event.put(errors);
194 
195  // clear the errorSummaryMap
197  edm::MessageSender::freshError = false;
198 
199  return accept;
200 }
ErrorSummaryEntry ErrorSummaryMapKey
Definition: MessageSender.h:28
CategoryEntry & getCategory(const std::string &category)
return the entry for requested category, if it exists, or create a new one with the default threshold...
int i
Definition: DBlmapReader.cc:9
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
def splitter
Definition: confdb.py:11
U second(std::pair< T, U > const &p)
static bool freshError
Definition: MessageSender.h:58
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
static std::map< ErrorSummaryMapKey, unsigned int > errorSummaryMap
Definition: MessageSender.h:59
Container::value_type value_type
string const
Definition: compareJSON.py:14
tuple size
Write out results.
HLTLogMonitorFilter::CategoryEntry & HLTLogMonitorFilter::getCategory ( const std::string &  category)
private

return the entry for requested category, if it exists, or create a new one with the default threshold value

Definition at line 227 of file HLTLogMonitorFilter.cc.

References i, m_data, and m_prescale.

Referenced by filter().

227  {
228  // check before inserting, to avoid the construction of a CategoryEntry object
229  CategoryMap::iterator i = m_data.find(category);
230  if (i != m_data.end())
231  return i->second;
232  else
233  return m_data.insert( std::make_pair(category, CategoryEntry(m_prescale)) ).first->second;
234 }
int i
Definition: DBlmapReader.cc:9
bool HLTLogMonitorFilter::knownCategory ( const std::string &  category)
private

check if the requested category has a valid entry

Definition at line 213 of file HLTLogMonitorFilter.cc.

References m_data.

213  {
214  return (m_data.find( category ) != m_data.end());
215 }
void HLTLogMonitorFilter::summary ( void  )
private

summarize to LogInfo

Definition at line 237 of file HLTLogMonitorFilter.cc.

References m_data, and dbtoconf::out.

Referenced by endJob().

237  {
238  std::stringstream out;
239  out << "Log-Report ---------- HLTLogMonitorFilter Summary ------------\n"
240  << "Log-Report Threshold Prescale Issued Accepted Rejected Category\n";
241  BOOST_FOREACH(const CategoryMap::value_type & entry, m_data) {
242  out << "Log-Report "
243  << std::right
244  << std::setw(10) << entry.second.threshold << ' '
245  << std::setw(10) << entry.second.prescale << ' '
246  << std::setw(10) << entry.second.counter << ' '
247  << std::setw(10) << entry.second.accepted << ' '
248  << std::setw(10) << (entry.second.counter - entry.second.accepted) << ' '
249  << std::left << entry.first << '\n';
250  }
251  edm::LogVerbatim("Report") << out.str();
252 }
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
Container::value_type value_type
tuple out
Definition: dbtoconf.py:99

Member Data Documentation

CategoryMap HLTLogMonitorFilter::m_data
private

Definition at line 107 of file HLTLogMonitorFilter.cc.

Referenced by addCategory(), filter(), getCategory(), knownCategory(), and summary().

uint32_t HLTLogMonitorFilter::m_prescale
private

Definition at line 106 of file HLTLogMonitorFilter.cc.

Referenced by getCategory(), and HLTLogMonitorFilter().