CMS 3D CMS Logo

PhysicsHistograms.h

Go to the documentation of this file.
00001 #ifndef StarterKit_PhysicsHistograms_h
00002 #define StarterKit_PhysicsHistograms_h
00003 
00004 //------------------------------------------------------------------------
00023 //------------------------------------------------------------------------
00024 
00025 
00026 
00027 // system include files
00028 #include <memory>
00029 #include <fstream>
00030 
00031 // user include files
00032 #include "PhysicsTools/StarterKit/interface/HistoMuon.h"
00033 #include "PhysicsTools/StarterKit/interface/HistoElectron.h"
00034 #include "PhysicsTools/StarterKit/interface/HistoTau.h"
00035 #include "PhysicsTools/StarterKit/interface/HistoJet.h"
00036 #include "PhysicsTools/StarterKit/interface/HistoMET.h"
00037 #include "PhysicsTools/StarterKit/interface/HistoPhoton.h"
00038 #include "PhysicsTools/StarterKit/interface/HistoTrack.h"
00039 
00040 #include "FWCore/Framework/interface/Frameworkfwd.h"
00041 #include "FWCore/Framework/interface/Event.h"
00042 #include "FWCore/Framework/interface/MakerMacros.h"
00043 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00044 #include "FWCore/ServiceRegistry/interface/Service.h"
00045 
00046 #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
00047 #include "PhysicsTools/UtilAlgos/interface/TFileDirectory.h"
00048 
00049 //
00050 //--- Class declaration.
00051 //
00052 
00053 
00054 // Function to print out candidates
00055 std::ostream & operator<<( std::ostream & out, const reco::Candidate & cand );
00056 
00057 class PhysicsHistograms  {
00058 public:
00059 
00060   struct KinAxisLimits {
00061   
00062     double pt1, pt2, m1, m2;
00063 
00064     KinAxisLimits( double apt1=0, double apt2=0, double am1=0, double am2=0 ) :
00065       pt1(apt1), pt2(apt2), m1(am1), m2(am2)
00066     {
00067     }
00068     ~KinAxisLimits() {}
00069   };
00070 
00071 
00072   explicit PhysicsHistograms ( KinAxisLimits const & muonAxis, 
00073                                KinAxisLimits const & electronAxis, 
00074                                KinAxisLimits const & tauAxis, 
00075                                KinAxisLimits const & jetAxis, 
00076                                KinAxisLimits const & METAxis, 
00077                                KinAxisLimits const & photonAxis,
00078                                KinAxisLimits const & trackAxis 
00079                                );
00080   virtual ~PhysicsHistograms();
00081 
00082   //--- Standard methods used in the event processing, called either by ED analyzer
00083   //    (from the methods of the same name), or by the FWLite macro which does the
00084   //    event loop).
00085   //
00086   virtual void beginJob();  
00087   virtual void   endJob();  
00088 
00089 
00090   //--- Configuration.
00091   virtual void configure( std::string & histos_to_disable,   // comma separated list of names
00092                           std::string & histos_to_enable );  // comma separated list of names
00093 
00094 
00095   //--- Selection of a subset of PhysVarHistos.
00096   virtual void select( std::string  vars_to_select,   // comma separated list of names
00097                        std::vector< pat::PhysVarHisto * > & selectedHistos );
00098 
00099   //--- Clear cache vector for PhysVarHisto
00100   virtual void clearVec();
00101 
00102   //--- Specific actions for the event.
00103   // &&& Design note: we could have used overloaded fill() everywhere, but
00104   // &&&              the novices may find it confusing.
00105 
00106   //--- Process a whole collection of Muons...
00107   //
00108   inline void fillCollection( const std::vector<pat::Muon> & coll, double w = 1.0 )
00109     { muonHistograms_->fillCollection(coll,w); }
00110 
00111   //--- ... or Electrons...
00112   //
00113   inline void fillCollection( const std::vector<pat::Electron> & coll, double w = 1.0 )
00114     { electronHistograms_->fillCollection(coll,w); }
00115 
00116   //--- ... or Taus...
00117   //
00118   inline void fillCollection( const std::vector<pat::Tau> & coll, double w = 1.0 )
00119     { tauHistograms_->fillCollection(coll,w); }
00120 
00121   //--- ... or Jets...
00122   //
00123   inline void fillCollection( const std::vector<pat::Jet> & coll, double w = 1.0 )
00124     { jetHistograms_->fillCollection(coll,w); }
00125 
00126   //--- ... or MET.
00127   //
00128   inline void fillCollection( const std::vector<pat::MET> & coll, double w = 1.0 )
00129     { metHistograms_->fillCollection(coll,w); }
00130 
00131   //--- ... or Photon.
00132   //
00133   inline void fillCollection( const std::vector<pat::Photon> & coll, double w = 1.0 )
00134     { photonHistograms_->fillCollection(coll,w); }
00135 
00136   //--- ... or Track.
00137   //
00138   inline void fillCollection( const std::vector<reco::RecoChargedCandidate> & coll, double w = 1.0 )
00139     { trackHistograms_->fillCollection(coll,w); }
00140 
00141 
00142 
00143   // &&& Design note: again, let's be explicit.  This could be compressed into
00144   // &&&              fewer functions, but at the expense of more complicated
00145   // &&&              code under the hood, and also an interface which is a teeny
00146   // &&&              harder to master (and we are trying to avoid that; the
00147   // &&&              interface should be as dumb as possible).
00148 
00149   //--- Add one histo to muon group, or a whole group of muon histograms
00150   //
00151   inline void addMuonHisto ( pat::PhysVarHisto * h )
00152     { muonHistograms_->addHisto(h); }
00153   inline void addMuonHistoGroup( pat::HistoMuon * hgr )
00154     { muonHistograms_->addHistoGroup(hgr); }
00155 
00156   //--- Add one histo to electron group, or a whole group of electron histograms
00157   //
00158   inline void addElectronHisto ( pat::PhysVarHisto * h )
00159     { electronHistograms_->addHisto(h); }
00160   inline void addElectronHistoGroup( pat::HistoElectron * hgr )
00161     { electronHistograms_->addHistoGroup(hgr); }
00162 
00163   //--- Add one histo to tau group, or a whole group of tau histograms
00164   //
00165   inline void addTauHisto ( pat::PhysVarHisto * h )
00166     { tauHistograms_->addHisto(h); }
00167   inline void addTauHistoGroup( pat::HistoTau * hgr )
00168     { tauHistograms_->addHistoGroup(hgr); }
00169 
00170   //--- Add one histo to jet group, or a whole group of jet histograms
00171   //
00172   inline void addJetHisto ( pat::PhysVarHisto * h )
00173     { jetHistograms_->addHisto(h); }
00174   inline void addJetHistoGroup( pat::HistoJet * hgr )
00175     { jetHistograms_->addHistoGroup(hgr); }
00176 
00177   //--- Add one histo to MET group, or a whole group of MET histograms
00178   //
00179   inline void addMetHisto ( pat::PhysVarHisto * h )
00180     { metHistograms_->addHisto(h); }
00181   inline void addMetHistoGroup( pat::HistoMET * hgr )
00182     { metHistograms_->addHistoGroup(hgr); }
00183 
00184   //--- Add one histo to photon group, or a whole group of photon histograms
00185   //
00186   inline void addPhotonHisto ( pat::PhysVarHisto * h )
00187     { photonHistograms_->addHisto(h); }
00188   inline void addPhotonHistoGroup( pat::HistoPhoton * hgr )
00189     { photonHistograms_->addHistoGroup(hgr); }
00190 
00191 
00192   //--- Add one histo to track group, or a whole group of track histograms
00193   //
00194   inline void addTrackHisto ( pat::PhysVarHisto * h )
00195     { trackHistograms_->addHisto(h); }
00196   inline void addTrackHistoGroup( pat::HistoTrack * hgr )
00197     { trackHistograms_->addHistoGroup(hgr); }
00198 
00199   //--- Add one generic histo to list
00200   inline void addHisto( pat::PhysVarHisto * h )
00201     { allVarHistos_.push_back( h ); }
00202 
00203 
00204 
00205 private:
00206 
00207   // Parameters for running
00208   std::string     outputTextName_;
00209 
00210   // Histogram server
00211   edm::Service<TFileService> fs;
00212 
00213   // Histogram objects that make "standard" plots for each object
00214   pat::HistoMuon     * muonHistograms_;
00215   pat::HistoElectron * electronHistograms_;
00216   pat::HistoTau      * tauHistograms_;
00217   pat::HistoMET      * metHistograms_;
00218   pat::HistoJet      * jetHistograms_;
00219   pat::HistoPhoton   * photonHistograms_;
00220   pat::HistoTrack    * trackHistograms_;
00221 
00222   //--- The summary of all PhysVarHistos.
00223   // &&& Is this still needed?
00224   std::vector< pat::PhysVarHisto* > allVarHistos_ ;
00225   std::vector< pat::PhysVarHisto* > enabledVarHistos_ ;
00226 
00227   //--- This is a nice feature but let's not worry about it for now. &&&
00228   ofstream        outputFile_;
00229 };
00230 
00231 #endif

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