CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/FWCore/Modules/src/LogErrorHarvester.cc

Go to the documentation of this file.
00001 //
00002 // Package:    LogErrorHarvester
00003 // Class:      LogErrorHarvester
00004 
00013 //
00014 // Original Author:  Giovanni Petrucciani
00015 //         Created:  Thu Dec  4 16:22:40 CET 2008
00016 //
00017 
00018 // user include files
00019 #include "FWCore/Framework/interface/EDProducer.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/Framework/interface/MakerMacros.h"
00022 #include "FWCore/MessageLogger/interface/ErrorSummaryEntry.h"
00023 #include "FWCore/MessageLogger/interface/LoggedErrorsSummary.h"
00024 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00025 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00026 
00027 // system include files
00028 #include <memory>
00029 
00030 //
00031 // class decleration
00032 //
00033 
00034 namespace edm {
00035   class LogErrorHarvester : public EDProducer {
00036     public:
00037       explicit LogErrorHarvester(ParameterSet const&);
00038       ~LogErrorHarvester();
00039       static void fillDescriptions(ConfigurationDescriptions& descriptions);
00040 
00041     private:
00042       virtual void beginJob();
00043       virtual void produce(Event&, EventSetup const&);
00044       virtual void endJob() ;
00045   };
00046 
00047   LogErrorHarvester::LogErrorHarvester(ParameterSet const&) {
00048      produces<std::vector<ErrorSummaryEntry> >();
00049   }
00050 
00051   LogErrorHarvester::~LogErrorHarvester() {
00052   }
00053 
00054   void
00055   LogErrorHarvester::produce(Event& iEvent, EventSetup const&) {
00056     if(!FreshErrorsExist()) {
00057       std::auto_ptr<std::vector<ErrorSummaryEntry> > errors(new std::vector<ErrorSummaryEntry>());
00058       iEvent.put(errors);
00059     } else {
00060       std::auto_ptr<std::vector<ErrorSummaryEntry> > errors(new std::vector<ErrorSummaryEntry>(LoggedErrorsSummary()));
00061       iEvent.put(errors);
00062     }
00063   }
00064 
00065   // ------------ method called once each job just before starting event loop  ------------
00066   void
00067   LogErrorHarvester::beginJob() {
00068     EnableLoggedErrorsSummary();
00069   }
00070 
00071   // ------------ method called once each job just after ending the event loop  ------------
00072   void
00073   LogErrorHarvester::endJob() {
00074     DisableLoggedErrorsSummary();
00075   }
00076 
00077 
00078   // ------------ method called once each job for validation  ------------
00079   void
00080   LogErrorHarvester::fillDescriptions(ConfigurationDescriptions& descriptions) {
00081     ParameterSetDescription desc;
00082     descriptions.add("logErrorHarvester", desc);
00083   }
00084 }
00085 
00086 //define this as a plug-in
00087 using edm::LogErrorHarvester;
00088 DEFINE_FWK_MODULE(LogErrorHarvester);