CMS 3D CMS Logo

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

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

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

Classes

struct  CategoryEntry
 

Public Types

typedef std::map< std::string,
CategoryEntry
CategoryMap
 
- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public 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) override
 EDFilter beginJob method. More...
 
virtual void endJob (void) override
 EDFilter endJob method. More...
 
virtual bool filter (edm::Event &, const edm::EventSetup &) override
 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...
 
 HLTLogMonitorFilter (const edm::ParameterSet &)
 
bool knownCategory (const std::string &category)
 check if the requested category has a valid entry More...
 
void summary (void)
 summarize to LogInfo More...
 
 ~HLTLogMonitorFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Public Attributes

CategoryMap m_data
 
uint32_t m_prescale
 

Additional Inherited Members

- 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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: Accept events if any LogError or LogWarning was raised

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

Definition at line 37 of file HLTLogMonitorFilter.cc.

Member Typedef Documentation

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

Definition at line 77 of file HLTLogMonitorFilter.cc.

Constructor & Destructor Documentation

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

Definition at line 124 of file HLTLogMonitorFilter.cc.

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

124  :
125  m_prescale(),
126  m_data()
127 {
128  m_prescale = config.getParameter<uint32_t>("default_threshold");
129 
130  typedef std::vector<edm::ParameterSet> VPSet;
131  const VPSet & categories = config.getParameter<VPSet>("categories");
132  for (VPSet::const_iterator category = categories.begin(); category != categories.end(); ++category) {
133  const std::string & name = category->getParameter<std::string>("name");
134  uint32_t threshold = category->getParameter<uint32_t>("threshold");
135  addCategory(name, threshold);
136  }
137 
138  produces<std::vector<edm::ErrorSummaryEntry> >();
139 }
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 141 of file HLTLogMonitorFilter.cc.

142 {
143 }

Member Function Documentation

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

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

Definition at line 207 of file HLTLogMonitorFilter.cc.

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

Referenced by HLTLogMonitorFilter().

207  {
208  // check after inserting, as either the new CategoryEntry is needed, or an error condition is raised
209  std::pair<CategoryMap::iterator, bool> result = m_data.insert( std::make_pair(category, CategoryEntry(threshold)) );
210  if (not result.second)
211  throw cms::Exception("Configuration") << "Duplicate entry for category " << category;
212  return result.first->second;
213 }
tuple result
Definition: query.py:137
void HLTLogMonitorFilter::beginJob ( void  )
overridevirtual

EDFilter beginJob method.

Reimplemented from edm::EDFilter.

Definition at line 192 of file HLTLogMonitorFilter.cc.

References edm::EnableLoggedErrorsSummary().

192  {
194 }
bool EnableLoggedErrorsSummary()
void HLTLogMonitorFilter::endJob ( void  )
overridevirtual

EDFilter endJob method.

Reimplemented from edm::EDFilter.

Definition at line 196 of file HLTLogMonitorFilter.cc.

References edm::DisableLoggedErrorsSummary(), and summary().

196  {
198  summary();
199 }
bool DisableLoggedErrorsSummary()
void summary(void)
summarize to LogInfo
bool HLTLogMonitorFilter::filter ( edm::Event event,
const edm::EventSetup setup 
)
overridevirtual

EDFilter accept method.

Implements edm::EDFilter.

Definition at line 150 of file HLTLogMonitorFilter.cc.

References accept(), HLTLogMonitorFilter::CategoryEntry::accept(), python.rootplot.argparse::category, benchmark_cfg::errors, edm::FreshErrorsExist(), getCategory(), i, edm::LoggedErrorsSummary(), m_data, confdb::splitter(), edm::Event::streamID(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::StreamID::value().

150  {
151  // no LogErrors or LogWarnings, skip processing and reject the event
152  if (not edm::FreshErrorsExist(event.streamID().value()))
153  return false;
154 
155  // clear "done" flag in all Categories
156  BOOST_FOREACH(CategoryMap::value_type & entry, m_data)
157  entry.second.done = false;
158 
159  // look at the LogErrors and LogWarnings, and accept the event if at least one is under threshold or matches the prescale
160  bool accept = false;
161  std::string category;
162 
163  std::vector<edm::ErrorSummaryEntry> errorSummary{ edm::LoggedErrorsSummary(event.streamID().value()) };
164  for( auto const& entry : errorSummary ) {
165  // split the message category
166  typedef boost::split_iterator<std::string::const_iterator> splitter;
167  for (splitter i = boost::make_split_iterator(entry.category, boost::first_finder("|", boost::is_equal()));
168  i != splitter();
169  ++i)
170  {
171  // extract the substring corresponding to the split_iterator
172  // FIXME: this can be avoided if the m_data map is keyed on boost::sub_range<std::string>
173  category.assign(i->begin(), i->end());
174 
175  // access the message category, or create a new one as needed, and check the prescale
176  if (getCategory(category).accept())
177  accept = true;
178  }
179  }
180 
181  // harvest the errors, but only if the filter will accept the event
182  std::auto_ptr<std::vector<edm::ErrorSummaryEntry> > errors(new std::vector<edm::ErrorSummaryEntry>());
183  if (accept) {
184  errors->swap(errorSummary);
185  }
186  event.put(errors);
187 
188  return accept;
189 }
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:24
bool FreshErrorsExist(unsigned int iStreamID)
def splitter
Definition: confdb.py:11
U second(std::pair< T, U > const &p)
Container::value_type value_type
unsigned int value() const
Definition: StreamID.h:46
StreamID streamID() const
Definition: Event.h:79
std::vector< ErrorSummaryEntry > LoggedErrorsSummary(unsigned int iStreamID)
volatile std::atomic< bool > shutdown_flag false
HLTLogMonitorFilter::CategoryEntry & HLTLogMonitorFilter::getCategory ( const std::string &  category)

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

Definition at line 216 of file HLTLogMonitorFilter.cc.

References i, m_data, and m_prescale.

Referenced by filter().

216  {
217  // check before inserting, to avoid the construction of a CategoryEntry object
218  CategoryMap::iterator i = m_data.find(category);
219  if (i != m_data.end())
220  return i->second;
221  else
222  return m_data.insert( std::make_pair(category, CategoryEntry(m_prescale)) ).first->second;
223 }
int i
Definition: DBlmapReader.cc:9
bool HLTLogMonitorFilter::knownCategory ( const std::string &  category)

check if the requested category has a valid entry

Definition at line 202 of file HLTLogMonitorFilter.cc.

References m_data.

202  {
203  return (m_data.find( category ) != m_data.end());
204 }
void HLTLogMonitorFilter::summary ( void  )

summarize to LogInfo

Definition at line 226 of file HLTLogMonitorFilter.cc.

References m_data, and dbtoconf::out.

Referenced by endJob().

226  {
227  std::stringstream out;
228  out << "Log-Report ---------- HLTLogMonitorFilter Summary ------------\n"
229  << "Log-Report Threshold Prescale Issued Accepted Rejected Category\n";
230  BOOST_FOREACH(const CategoryMap::value_type & entry, m_data) {
231  out << "Log-Report "
232  << std::right
233  << std::setw(10) << entry.second.threshold << ' '
234  << std::setw(10) << entry.second.prescale << ' '
235  << std::setw(10) << entry.second.counter << ' '
236  << std::setw(10) << entry.second.accepted << ' '
237  << std::setw(10) << (entry.second.counter - entry.second.accepted) << ' '
238  << std::left << entry.first << '\n';
239  }
240  edm::LogVerbatim("Report") << out.str();
241 }
Container::value_type value_type
tuple out
Definition: dbtoconf.py:99

Member Data Documentation

CategoryMap HLTLogMonitorFilter::m_data

Definition at line 105 of file HLTLogMonitorFilter.cc.

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

uint32_t HLTLogMonitorFilter::m_prescale

Definition at line 104 of file HLTLogMonitorFilter.cc.

Referenced by getCategory(), and HLTLogMonitorFilter().