Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:24

0001 #ifndef PhysicsTools_UtilAlgos_interface_BasicAnalyzer_h
0002 #define PhysicsTools_UtilAlgos_interface_BasicAnalyzer_h
0003 
0004 #include "FWCore/Common/interface/EventBase.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 #include "FWCore/Utilities/interface/InputTag.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "CommonTools/Utils/interface/TFileDirectory.h"
0009 
0010 /**
0011    \class BasicAnalyzer BasicAnalyzer.h "PhysicsTools/UtilAlgos/interface/BasicAnalyzer.h"
0012    \brief Abstract base class for FWLite and EDM friendly analyzers
0013 
0014    Abstract base class for FWLite and EDM friendly analyzers. This class provides a proper
0015    interface needed for the EDAnalyzerWrapper and FWLiteAnalyzerWrapper template classes.
0016    Classes of type BasicAnalyzer can be wrapped into an EDAnalyzer as shown in the example
0017    below:
0018 
0019    #include "PhysicsTools/PatExamples/interface/BasicMuonAnalyzer.h"
0020    #include "PhysicsTools/UtilAlgos/interface/EDAnalyzerWrapper.h"
0021 
0022    typedef edm::AnalyzerWrapper<BasicMuonAnalyzer> WrappedEDAnalyzer;
0023 
0024    #include "FWCore/Framework/interface/MakerMacros.h"
0025    DEFINE_FWK_MODULE(WrappedEDAnalyzer);
0026 
0027    Alternatively they can be wrapped into a FWLiteAnalyzer which provides basic functionality
0028    of reading configuration files and event looping as shown in the example below:
0029 
0030    #include "PhysicsTools/PatExamples/interface/BasicMuonAnalyzer.h"
0031    #include "PhysicsTools/FWLite/interface/FWLiteAnalyzerWrapper.h"
0032 
0033    typedef fwlite::AnalyzerWrapper<BasicMuonAnalyzer> WrappedFWLiteAnalyzer;
0034    ...
0035 
0036    In both examples BasicMuonAnalyzer is derived from the BasicAnalyzer class. For more
0037    information have a look into the class description of the corresponding wrapper classes.
0038 */
0039 
0040 namespace edm {
0041 
0042   class BasicAnalyzer {
0043   public:
0044     /// default constructor
0045     BasicAnalyzer(const edm::ParameterSet& cfg, TFileDirectory& fileService){};
0046     BasicAnalyzer(const edm::ParameterSet& cfg, TFileDirectory& fileService, edm::ConsumesCollector&& iC){};
0047     /// default destructor
0048     virtual ~BasicAnalyzer(){};
0049 
0050     /**
0051        The following functions have to be implemented for any class
0052        derived from BasicAnalyzer; these functions are called in
0053        the EDAnalyzerWrapper class or in the FWLiteAnalyzerWrapper
0054        class.
0055     **/
0056 
0057     /// everything that needs to be done before the event loop
0058     virtual void beginJob() = 0;
0059     /// everything that needs to be done after the event loop
0060     virtual void endJob() = 0;
0061     /// everything that needs to be done during the event loop
0062     virtual void analyze(const edm::EventBase& event) = 0;
0063   };
0064 
0065 }  // namespace edm
0066 
0067 #endif