File indexing completed on 2024-04-06 12:24:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/global/EDFilter.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030
0031 #include "DataFormats/Common/interface/ErrorSummaryEntry.h"
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033
0034
0035
0036
0037
0038 class ErrorSummaryFilter : public edm::global::EDFilter<> {
0039 public:
0040 explicit ErrorSummaryFilter(edm::ParameterSet const&);
0041
0042 private:
0043 bool filter(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0044
0045
0046 edm::EDGetTokenT<std::vector<edm::ErrorSummaryEntry> > srcToken_;
0047 std::vector<std::string> modules_;
0048 std::string severityName_;
0049 std::vector<std::string> avoidCategories_;
0050 typedef std::vector<edm::ErrorSummaryEntry> ErrorSummaryEntries;
0051 };
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 ErrorSummaryFilter::ErrorSummaryFilter(edm::ParameterSet const& iConfig)
0065 : srcToken_(consumes<std::vector<edm::ErrorSummaryEntry> >(iConfig.getParameter<edm::InputTag>("src"))),
0066 modules_(iConfig.getParameter<std::vector<std::string> >("modules")),
0067 severityName_(iConfig.getParameter<std::string>("severity")),
0068 avoidCategories_(iConfig.getParameter<std::vector<std::string> >("avoidCategories")) {
0069 if (!(severityName_ == "error" || severityName_ == "warning")) {
0070 throw edm::Exception(edm::errors::Configuration) << "Severity parameter needs to be 'error' or 'warning'.\n";
0071 }
0072 }
0073
0074
0075
0076
0077
0078
0079 bool ErrorSummaryFilter::filter(edm::StreamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const {
0080 edm::Handle<std::vector<edm::ErrorSummaryEntry> > errorSummaryEntry;
0081 iEvent.getByToken(srcToken_, errorSummaryEntry);
0082
0083 for (ErrorSummaryEntries::const_iterator i = errorSummaryEntry->begin(), end = errorSummaryEntry->end(); i != end;
0084 ++i) {
0085 if (std::find(modules_.begin(), modules_.end(), i->module) != modules_.end()) {
0086 if (std::find(avoidCategories_.begin(), avoidCategories_.end(), i->category) != avoidCategories_.end()) {
0087 continue;
0088 } else {
0089 edm::ELseverityLevel const& severity = i->severity;
0090 if (severityName_ == "error") {
0091 if (severity.getLevel() == edm::ELseverityLevel::ELsev_error ||
0092 severity.getLevel() == edm::ELseverityLevel::ELsev_warning) {
0093 return (false);
0094 }
0095 } else if (severityName_ == "warning") {
0096 if (severity.getLevel() == edm::ELseverityLevel::ELsev_warning) {
0097 return (false);
0098 }
0099 } else {
0100 continue;
0101 }
0102 }
0103 }
0104 }
0105 return (true);
0106 }
0107
0108
0109 DEFINE_FWK_MODULE(ErrorSummaryFilter);