CMS 3D CMS Logo

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

#include <FWCore/LogErrorFilter/src/LogErrorFilter.cc>

Inheritance diagram for LogErrorFilter:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LogErrorFilter (edm::ParameterSet const &)
 
 ~LogErrorFilter ()
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilterBase ()
 
- 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 ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
virtual bool filter (edm::Event &, edm::EventSetup const &) override
 

Private Attributes

bool atLeastOneEntry_
 
bool atLeastOneError_
 
bool atLeastOneWarning_
 
std::vector< std::string > avoidCategories_
 
std::map< std::string,
unsigned int > 
errorCounts_
 
edm::EDGetTokenT< std::vector
< edm::ErrorSummaryEntry > > 
harvesterToken_
 
unsigned int maxErrorKindsPerLumi_
 
unsigned int maxWarningKindsPerLumi_
 
bool useThresholdsPerKind_
 
std::map< std::string,
unsigned int > 
warningCounts_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 35 of file LogErrorFilter.cc.

Constructor & Destructor Documentation

LogErrorFilter::LogErrorFilter ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 73 of file LogErrorFilter.cc.

References atLeastOneError_, atLeastOneWarning_, edm::errors::Configuration, Exception, edm::ParameterSet::getParameter(), harvesterToken_, maxErrorKindsPerLumi_, maxWarningKindsPerLumi_, and useThresholdsPerKind_.

73  :
74  atLeastOneError_(iConfig.getParameter<bool>("atLeastOneError")),
75  atLeastOneWarning_(iConfig.getParameter<bool>("atLeastOneWarning")),
77  useThresholdsPerKind_(iConfig.getParameter<bool>("useThresholdsPerKind")),
78  avoidCategories_(iConfig.getParameter<std::vector<std::string> >("avoidCategories")) {
81  "Useless configuration of the error/warning filter. Need to select on an error or a warning or both.\n";
82  }
83  harvesterToken_ = consumes<std::vector<edm::ErrorSummaryEntry>>(iConfig.getParameter<edm::InputTag>("harvesterTag"));
84  maxErrorKindsPerLumi_ = 999999;
85  maxWarningKindsPerLumi_ = 999999;
87  maxErrorKindsPerLumi_ = iConfig.getParameter<unsigned int>("maxErrorKindsPerLumi");
88  maxWarningKindsPerLumi_ = iConfig.getParameter<unsigned int>("maxWarningKindsPerLumi");
89  }
90 }
bool useThresholdsPerKind_
std::vector< std::string > avoidCategories_
unsigned int maxErrorKindsPerLumi_
unsigned int maxWarningKindsPerLumi_
edm::EDGetTokenT< std::vector< edm::ErrorSummaryEntry > > harvesterToken_
LogErrorFilter::~LogErrorFilter ( )

Definition at line 92 of file LogErrorFilter.cc.

92  {
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 }

Member Function Documentation

void LogErrorFilter::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::stream::EDFilterBase.

Definition at line 184 of file LogErrorFilter.cc.

References errorCounts_, useThresholdsPerKind_, and warningCounts_.

184  {
186  typedef std::map<std::string, unsigned int>::iterator msIter;
187  msIter errorMI = errorCounts_.begin();
188  msIter errorMIEnd = errorCounts_.end();
189  for (;errorMI != errorMIEnd; ++errorMI) errorMI->second = 0;
190  msIter warningMI = warningCounts_.begin();
191  msIter warningMIEnd = warningCounts_.end();
192  for (;warningMI != warningMIEnd; ++warningMI) warningMI->second = 0;
193  }
194 
195  return;
196 }
bool useThresholdsPerKind_
std::map< std::string, unsigned int > errorCounts_
std::map< std::string, unsigned int > warningCounts_
void LogErrorFilter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 200 of file LogErrorFilter.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

200  {
202  desc.add<edm::InputTag>("harvesterTag");
203  desc.add<bool>("atLeastOneError");
204  desc.add<bool>("atLeastOneWarning");
205  desc.add<bool>("useThresholdsPerKind");
206  desc.add<unsigned int>("maxErrorKindsPerLumi", 999999);
207  desc.add<unsigned int>("maxWarningKindsPerLumi", 999999);
208  desc.add<std::vector<std::string> >("avoidCategories");
209  descriptions.add("logErrorFilter", desc);
210 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool LogErrorFilter::filter ( edm::Event iEvent,
edm::EventSetup const &   
)
overrideprivatevirtual

Implements edm::stream::EDFilterBase.

Definition at line 103 of file LogErrorFilter.cc.

References atLeastOneEntry_, atLeastOneError_, atLeastOneWarning_, avoidCategories_, edm::ErrorSummaryEntry::category, python.rootplot.argparse::category, edm::ELseverityLevel::ELsev_error, edm::ELseverityLevel::ELsev_warning, errorCounts_, edm::HandleBase::failedToGet(), spr::find(), edm::Event::getByToken(), edm::ELseverityLevel::getLevel(), harvesterToken_, class-composition::kind, maxErrorKindsPerLumi_, maxWarningKindsPerLumi_, edm::ErrorSummaryEntry::module, edm::ErrorSummaryEntry::severity, HLT_25ns14e33_v1_cff::severity, AlCaHLTBitMon_QueryRunRegistry::string, useThresholdsPerKind_, and warningCounts_.

103  {
105  iEvent.getByToken(harvesterToken_,errorsAndWarnings);
106 
107  if(errorsAndWarnings.failedToGet()) {
108  return false;
109  } else {
111  unsigned int errorsBelowThreshold = 0;
112  unsigned int warningsBelowThreshold = 0;
113  // update counters here
114  for(unsigned int iE = 0; iE != errorsAndWarnings->size(); ++iE) {
115  const edm::ErrorSummaryEntry& iSummary = (*errorsAndWarnings)[iE];
116  if (std::find(avoidCategories_.begin(),avoidCategories_.end(), iSummary.category) != avoidCategories_.end() )
117  continue;
118  std::string kind= iSummary.category + ":" + iSummary.module;
119  int iSeverity = iSummary.severity.getLevel();
120  if (iSeverity == edm::ELseverityLevel::ELsev_error){
121  unsigned int& iCount = errorCounts_[kind];
122  iCount++;
123  if (iCount <= maxErrorKindsPerLumi_) errorsBelowThreshold++;
124  }
125  if (iSeverity == edm::ELseverityLevel::ELsev_warning){
126  unsigned int& iCount = warningCounts_[kind];
127  iCount++;
128  if (iCount <= maxWarningKindsPerLumi_) warningsBelowThreshold++;
129  }
130  }
131  return ( (atLeastOneEntry_ && (errorsBelowThreshold > 0 || warningsBelowThreshold > 0))
132  || (atLeastOneError_ && errorsBelowThreshold > 0)
133  || (atLeastOneWarning_ && warningsBelowThreshold > 0));
134  } else {
135  //no separation by kind, just count any errors/warnings
136  if(atLeastOneEntry_) {
137  if(avoidCategories_.size() != 0) {
138  for(unsigned int iE = 0; iE != errorsAndWarnings->size(); ++iE) {
139  //veto categories from user input.
140  if(std::find(avoidCategories_.begin(),avoidCategories_.end(), ((*errorsAndWarnings)[iE]).category) != avoidCategories_.end()) {
141  continue;
142  } else {
143  return true;
144  }
145  }
146  return false;
147  } else {
148  return (errorsAndWarnings->size() != 0);
149  }
150  } else {
152  unsigned int nError = 0;
153  unsigned int nWarning = 0;
154  for(unsigned int iE = 0; iE != errorsAndWarnings->size(); ++iE) {
155  //veto categories from user input.
156  if(avoidCategories_.size() != 0) {
157  if(std::find(avoidCategories_.begin(),avoidCategories_.end(), ((*errorsAndWarnings)[iE]).category) != avoidCategories_.end()) {
158  continue;
159  }
160  }
161  edm::ELseverityLevel const& severity = ((*errorsAndWarnings)[iE]).severity;
162  //count errors
163  if(severity.getLevel() == edm::ELseverityLevel::ELsev_error) {
164  ++nError;
165  }
166  //count warnings
168  ++nWarning;
169  }
170  }
171  if(atLeastOneError_ && nError != 0) {
172  return (true);
173  }
174  if(atLeastOneWarning_ && nWarning != 0) {
175  return (true);
176  }
177  }
178  }
179  }
180  }
181  return (false);
182 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
ELseverityLevel severity
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool useThresholdsPerKind_
std::vector< std::string > avoidCategories_
unsigned int maxErrorKindsPerLumi_
std::map< std::string, unsigned int > errorCounts_
unsigned int maxWarningKindsPerLumi_
bool failedToGet() const
Definition: HandleBase.h:79
edm::EDGetTokenT< std::vector< edm::ErrorSummaryEntry > > harvesterToken_
std::map< std::string, unsigned int > warningCounts_

Member Data Documentation

bool LogErrorFilter::atLeastOneEntry_
private

Definition at line 50 of file LogErrorFilter.cc.

Referenced by filter().

bool LogErrorFilter::atLeastOneError_
private

Definition at line 48 of file LogErrorFilter.cc.

Referenced by filter(), and LogErrorFilter().

bool LogErrorFilter::atLeastOneWarning_
private

Definition at line 49 of file LogErrorFilter.cc.

Referenced by filter(), and LogErrorFilter().

std::vector<std::string> LogErrorFilter::avoidCategories_
private

Definition at line 56 of file LogErrorFilter.cc.

Referenced by filter().

std::map<std::string, unsigned int> LogErrorFilter::errorCounts_
private

Definition at line 58 of file LogErrorFilter.cc.

Referenced by beginLuminosityBlock(), and filter().

edm::EDGetTokenT<std::vector<edm::ErrorSummaryEntry> > LogErrorFilter::harvesterToken_
private

Definition at line 47 of file LogErrorFilter.cc.

Referenced by filter(), and LogErrorFilter().

unsigned int LogErrorFilter::maxErrorKindsPerLumi_
private

Definition at line 53 of file LogErrorFilter.cc.

Referenced by filter(), and LogErrorFilter().

unsigned int LogErrorFilter::maxWarningKindsPerLumi_
private

Definition at line 54 of file LogErrorFilter.cc.

Referenced by filter(), and LogErrorFilter().

bool LogErrorFilter::useThresholdsPerKind_
private

Definition at line 51 of file LogErrorFilter.cc.

Referenced by beginLuminosityBlock(), filter(), and LogErrorFilter().

std::map<std::string, unsigned int> LogErrorFilter::warningCounts_
private

Definition at line 59 of file LogErrorFilter.cc.

Referenced by beginLuminosityBlock(), and filter().