CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/PhysicsTools/UtilAlgos/interface/EDAnalyzerWrapper.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_UtilAlgos_interface_EDAnalyzerWrapper_h
00002 #define PhysicsTools_UtilAlgos_interface_EDAnalyzerWrapper_h
00003 
00004 #include <boost/shared_ptr.hpp>
00005 
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/EDAnalyzer.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00010 
00011 
00045 namespace edm {
00046 
00047   template<class T>
00048   class AnalyzerWrapper : public EDAnalyzer {
00049 
00050   public:
00052     AnalyzerWrapper(const edm::ParameterSet& cfg);
00054     virtual ~AnalyzerWrapper(){};
00056     virtual void beginJob() { analyzer_->beginJob(); }
00058     virtual void analyze(edm::Event const & event, const edm::EventSetup& eventSetup){ analyzer_->analyze(event); }
00060     virtual void endJob() { analyzer_->endJob(); }
00061       
00062   protected:
00064     boost::shared_ptr<T> analyzer_;
00065   };
00066   
00068   template<class T>
00069   AnalyzerWrapper<T>::AnalyzerWrapper(const edm::ParameterSet& cfg){
00070     // defined TFileService
00071     edm::Service<TFileService> fileService;
00072     // create analysis class of type BasicAnalyzer
00073     analyzer_ = boost::shared_ptr<T>( new T( cfg, *fileService) );
00074   }
00075 
00076 }
00077 
00078 #endif