CMS 3D CMS Logo

PatKitHelper.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_StarterKit_interface_PatKitHelper_h
00002 #define PhysicsTools_StarterKit_interface_PatKitHelper_h
00003 
00004 
00005 
00006 
00007 //-------------------------------------------------------------------------------------
00008 //
00009 // Original Author:  Salvatore Rappoccio
00010 //         Created:  Mon Jul  7 10:37:27 CDT 2008
00011 // $Id: PatKitHelper.h,v 1.2 2008/07/08 21:53:11 srappocc Exp $
00012 //
00013 // Revision History:
00014 //       -  Sal Rappoccio, Mon Jul  7 10:37:27 CDT 2008
00015 //          Creation of object to make SK more inline with Framework advice.
00016 //          This includes removing PatAnalyzerKit as a base class, and anything that
00017 //          needs that functionality should use this class instead of deriving from
00018 //          PatAnalyzerKit. 
00019 //-------------------------------------------------------------------------------------
00020 #include "PhysicsTools/StarterKit/interface/PhysicsHistograms.h"
00021 
00022 #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
00023 #include "PhysicsTools/UtilAlgos/interface/TFileDirectory.h"
00024 #include "FWCore/Framework/interface/Event.h"
00025 #include "FWCore/Framework/interface/MakerMacros.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027 #include "FWCore/ServiceRegistry/interface/Service.h"
00028 #include "FWCore/Framework/interface/EDProducer.h"
00029 
00030 
00031 namespace pat {
00032 
00033   class PatKitHelper {
00034   public:
00035 
00036     PatKitHelper(edm::ParameterSet const & parameters);
00037     ~PatKitHelper();
00038 
00039     // Pull out a struct for the axis limits from the config file
00040     PhysicsHistograms::KinAxisLimits getAxisLimits( std::string name );
00041                                                     
00042 
00043     // Book histograms
00044     void bookHistos( edm::EDProducer * producer );
00045 
00046     // Get handles
00047     void getHandles( edm::Event  & event,
00048                      edm::Handle<std::vector<pat::Muon> > &     muonHandle,
00049                      edm::Handle<std::vector<pat::Electron> > & electronHandle,
00050                      edm::Handle<std::vector<pat::Tau> > &      tauHandle,
00051                      edm::Handle<std::vector<pat::Jet> > &      jetHandle,
00052                      edm::Handle<std::vector<pat::MET> > &      METHandle,
00053                      edm::Handle<std::vector<pat::Photon> > &   photonHandle
00054                      );
00055 
00056     
00057     // fill histograms
00058     void fillHistograms( edm::Event & event,
00059                          edm::Handle<std::vector<pat::Muon> > &     muonHandle,
00060                          edm::Handle<std::vector<pat::Electron> > & electronHandle,
00061                          edm::Handle<std::vector<pat::Tau> > &      tauHandle,
00062                          edm::Handle<std::vector<pat::Jet> > &      jetHandle,
00063                          edm::Handle<std::vector<pat::MET> > &      METHandle,
00064                          edm::Handle<std::vector<pat::Photon> > &   photonHandle
00065                          );
00066     
00067     
00068     // Function to add ntuple variables to the EDProducer
00069     void addNtupleVar ( edm::EDProducer * prod, std::string name, std::string type );
00070 
00071     // Save ntuple variables to event evt
00072     void saveNtuple (  edm::Event & event,
00073                        const std::vector<pat::PhysVarHisto*> & ntvars);
00074     
00075     // Helper function template to write objects to event
00076     template <class T>
00077       void saveNtupleVar(  edm::Event & event,
00078                            std::string name, T value);
00079 
00080     // Helper function template to write vectors of objects to event
00081     template <class T>
00082       void saveNtupleVec(  edm::Event & event,
00083                            std::string name, const std::vector<T> & invec);
00084 
00085     
00086     // verbose switch
00087     int verboseLevel_;
00088 
00089     // Keep a version of the parameter set in question
00090     edm::ParameterSet         parameters_;
00091 
00092     // Here is where the histograms go
00093     PhysicsHistograms  *      physHistos_;
00094 
00095     // File service for histograms
00096     edm::Service<TFileService> fs_;
00097     
00098     // List of ntuple variables
00099     std::vector< pat::PhysVarHisto* > ntVars_ ;
00100 
00101     
00102     
00103     // run and event numbers
00104     pat::PhysVarHisto *  h_runNumber_;
00105     pat::PhysVarHisto *  h_eventNumber_;
00106     
00107   };
00108 
00109 }
00110 
00111 
00112 #endif

Generated on Tue Jun 9 17:41:52 2009 for CMSSW by  doxygen 1.5.4