CMS 3D CMS Logo

LogErrorHarvester.cc
Go to the documentation of this file.
1 //
2 // Package: LogErrorHarvester
3 // Class: LogErrorHarvester
4 
13 //
14 // Original Author: Giovanni Petrucciani
15 // Created: Thu Dec 4 16:22:40 CET 2008
16 //
17 
18 // user include files
30 
31 // system include files
32 #include <memory>
33 #include <unordered_set>
34 #include <string>
35 
36 //
37 // class decleration
38 //
39 
40 namespace edm {
42  public:
43  explicit LogErrorHarvester(ParameterSet const&);
44  static void fillDescriptions(ConfigurationDescriptions& descriptions);
45 
46  private:
47  void beginJob() override;
48  void produce(StreamID, Event&, EventSetup const&) const override;
49  void endJob() override;
51  };
52 
54  const edm::TypeID endPathStatusType{typeid(edm::EndPathStatus)};
55  const edm::TypeID pathStatusType{typeid(edm::PathStatus)};
56  const edm::TypeID triggerResultsType{typeid(edm::TriggerResults)};
57 
58  auto const& ignore = iPSet.getUntrackedParameter<std::vector<std::string>>("excludeModules");
59  const std::unordered_set<std::string> excludedModules(ignore.begin(), ignore.end());
60 
61  auto const& includeM = iPSet.getUntrackedParameter<std::vector<std::string>>("includeModules");
62  const std::unordered_set<std::string> includeModules(includeM.begin(), includeM.end());
63 
64  //Need to be sure to run only after all other EDProducers have run
65  callWhenNewProductsRegistered(
66  [this, endPathStatusType, pathStatusType, triggerResultsType, excludedModules, includeModules](
67  edm::BranchDescription const& iBD) {
68  if ((iBD.branchType() == edm::InEvent and moduleDescription().processName() == iBD.processName()) and
69  ((includeModules.empty() or includeModules.end() != includeModules.find(iBD.moduleLabel())) and
70  (iBD.unwrappedTypeID() != endPathStatusType and iBD.unwrappedTypeID() != pathStatusType and
71  iBD.unwrappedTypeID() != triggerResultsType))) {
72  if (excludedModules.end() == excludedModules.find(iBD.moduleLabel())) {
75  }
76  }
77  });
78  }
79 
80  void LogErrorHarvester::produce(StreamID const sid, Event& iEvent, EventSetup const&) const {
81  const auto index = sid.value();
82  if (!FreshErrorsExist(index)) {
83  //puts a default constructed product in the event
84  iEvent.emplace(token_);
85  } else {
86  auto mlSummary = LoggedErrorsSummary(index);
87  std::vector<edm::ErrorSummaryEntry> summary;
88  summary.reserve(mlSummary.size());
89  for (auto& entry : mlSummary) {
91  e.category = std::move(entry.category);
92  e.module = std::move(entry.module);
93  e.severity = edm::ELseverityLevel(entry.severity.getLevel());
94  e.count = entry.count;
95  summary.emplace_back(std::move(e));
96  }
97  iEvent.emplace(token_, summary);
98  }
99  }
100 
101  // ------------ method called once each job just before starting event loop ------------
103 
104  // ------------ method called once each job just after ending the event loop ------------
106 
107  // ------------ method called once each job for validation ------------
110  desc.addUntracked<std::vector<std::string>>("excludeModules", std::vector<std::string>{})
111  ->setComment("List of module labels to exclude from consumes.");
112  desc.addUntracked<std::vector<std::string>>("includeModules", std::vector<std::string>{})
113  ->setComment("List of the only module labels to include in consumes. The empty list will include all.");
114  descriptions.add("logErrorHarvester", desc);
115  }
116 } // namespace edm
117 
118 //define this as a plug-in
static void fillDescriptions(ConfigurationDescriptions &descriptions)
bool EnableLoggedErrorsSummary()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BranchType const & branchType() const
TypeID unwrappedTypeID() const
std::string const & processName() const
bool FreshErrorsExist(unsigned int iStreamID)
bool DisableLoggedErrorsSummary()
int iEvent
Definition: GenABIO.cc:224
std::string const & productInstanceName() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
EDPutTokenT< std::vector< ErrorSummaryEntry > > token_
def ignore(seq)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
std::vector< messagelogger::ErrorSummaryEntry > LoggedErrorsSummary(unsigned int iStreamID)
HLTPathStatus PathStatus
Definition: PathStatus.h:7
void produce(StreamID, Event &, EventSetup const &) const override
unsigned int value() const
Definition: StreamID.h:43
LogErrorHarvester(ParameterSet const &)
std::string const & moduleLabel() const
def move(src, dest)
Definition: eostools.py:511