CMS 3D CMS Logo

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, CategoryEntryCategoryMap
 
- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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...
 
void beginJob () override
 EDFilter beginJob method. More...
 
void endJob () override
 EDFilter endJob method. More...
 
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 ()
 summarize to LogInfo More...
 
 ~HLTLogMonitorFilter () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 123 of file HLTLogMonitorFilter.cc.

References addCategory(), myMessageLogger_cff::categories, edm::ParameterSet::getParameter(), m_prescale, dataset::name, AlCaHLTBitMon_QueryRunRegistry::string, electronIdCutBased_cfi::threshold, HistogramManager_cfi::VPSet(), and ~HLTLogMonitorFilter().

123  :
124  m_prescale(),
125  m_data()
126 {
127  m_prescale = config.getParameter<uint32_t>("default_threshold");
128 
129  typedef std::vector<edm::ParameterSet> VPSet;
130  const VPSet & categories = config.getParameter<VPSet>("categories");
131  for (auto const & categorie : categories) {
132  const std::string & name = categorie.getParameter<std::string>("name");
133  uint32_t threshold = categorie.getParameter<uint32_t>("threshold");
134  addCategory(name, threshold);
135  }
136 
137  produces<std::vector<edm::ErrorSummaryEntry> >();
138 }
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 ( )
overridedefault

Referenced by HLTLogMonitorFilter().

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 204 of file HLTLogMonitorFilter.cc.

References taus_updatedMVAIds_cff::category, Exception, m_data, and mps_fire::result.

Referenced by HLTLogMonitorFilter().

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

EDFilter beginJob method.

Reimplemented from edm::EDFilter.

Definition at line 189 of file HLTLogMonitorFilter.cc.

References edm::EnableLoggedErrorsSummary().

189  {
191 }
bool EnableLoggedErrorsSummary()
void HLTLogMonitorFilter::endJob ( void  )
overridevirtual

EDFilter endJob method.

Reimplemented from edm::EDFilter.

Definition at line 193 of file HLTLogMonitorFilter.cc.

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

193  {
195  summary();
196 }
bool DisableLoggedErrorsSummary()
void summary()
summarize to LogInfo
bool HLTLogMonitorFilter::filter ( edm::Event event,
const edm::EventSetup setup 
)
override

EDFilter accept method.

Definition at line 147 of file HLTLogMonitorFilter.cc.

References accept(), HLTLogMonitorFilter::CategoryEntry::accept(), taus_updatedMVAIds_cff::category, mps_splice::entry, benchmark_cfg::errors, edm::FreshErrorsExist(), getCategory(), mps_fire::i, edm::LoggedErrorsSummary(), m_data, eostools::move(), confdb::splitter(), edm::Event::streamID(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::StreamID::value().

147  {
148  // no LogErrors or LogWarnings, skip processing and reject the event
149  if (not edm::FreshErrorsExist(event.streamID().value()))
150  return false;
151 
152  // clear "done" flag in all Categories
153  for(auto& entry : m_data)
154  entry.second.done = false;
155 
156  // look at the LogErrors and LogWarnings, and accept the event if at least one is under threshold or matches the prescale
157  bool accept = false;
159 
160  std::vector<edm::ErrorSummaryEntry> errorSummary{ edm::LoggedErrorsSummary(event.streamID().value()) };
161  for( auto const& entry : errorSummary ) {
162  // split the message category
163  typedef boost::split_iterator<std::string::const_iterator> splitter;
164  for (splitter i = boost::make_split_iterator(entry.category, boost::first_finder("|", boost::is_equal()));
165  i != splitter();
166  ++i)
167  {
168  // extract the substring corresponding to the split_iterator
169  // FIXME: this can be avoided if the m_data map is keyed on boost::sub_range<std::string>
170  category.assign(i->begin(), i->end());
171 
172  // access the message category, or create a new one as needed, and check the prescale
173  if (getCategory(category).accept())
174  accept = true;
175  }
176  }
177 
178  // harvest the errors, but only if the filter will accept the event
179  std::unique_ptr<std::vector<edm::ErrorSummaryEntry> > errors(new std::vector<edm::ErrorSummaryEntry>());
180  if (accept) {
181  errors->swap(errorSummary);
182  }
183  event.put(std::move(errors));
184 
185  return accept;
186 }
def splitter(iterator, n)
Definition: confdb.py:13
CategoryEntry & getCategory(const std::string &category)
return the entry for requested category, if it exists, or create a new one with the default threshold...
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
bool FreshErrorsExist(unsigned int iStreamID)
unsigned int value() const
Definition: StreamID.h:42
StreamID streamID() const
Definition: Event.h:95
std::vector< ErrorSummaryEntry > LoggedErrorsSummary(unsigned int iStreamID)
Definition: errors.py:1
def move(src, dest)
Definition: eostools.py:511
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 213 of file HLTLogMonitorFilter.cc.

References mps_fire::i, m_data, and m_prescale.

Referenced by filter().

213  {
214  // check before inserting, to avoid the construction of a CategoryEntry object
215  auto i = m_data.find(category);
216  if (i != m_data.end())
217  return i->second;
218  else
219  return m_data.insert( std::make_pair(category, CategoryEntry(m_prescale)) ).first->second;
220 }
bool HLTLogMonitorFilter::knownCategory ( const std::string &  category)

check if the requested category has a valid entry

Definition at line 199 of file HLTLogMonitorFilter.cc.

References m_data.

199  {
200  return (m_data.find( category ) != m_data.end());
201 }
void HLTLogMonitorFilter::summary ( )

summarize to LogInfo

Definition at line 223 of file HLTLogMonitorFilter.cc.

References DEFINE_FWK_MODULE, mps_splice::entry, m_data, and MillePedeFileConverter_cfg::out.

Referenced by endJob().

223  {
224  std::stringstream out;
225  out << "Log-Report ---------- HLTLogMonitorFilter Summary ------------\n"
226  << "Log-Report Threshold Prescale Issued Accepted Rejected Category\n";
227  for(auto const& entry : m_data) {
228  out << "Log-Report "
229  << std::right
230  << std::setw(10) << entry.second.threshold << ' '
231  << std::setw(10) << entry.second.prescale << ' '
232  << std::setw(10) << entry.second.counter << ' '
233  << std::setw(10) << entry.second.accepted << ' '
234  << std::setw(10) << (entry.second.counter - entry.second.accepted) << ' '
235  << std::left << entry.first << '\n';
236  }
237  edm::LogVerbatim("Report") << out.str();
238 }

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().