00001 #ifndef StarterKit_PhysicsHistograms_h
00002 #define StarterKit_PhysicsHistograms_h
00003
00004
00023
00024
00025
00026
00027
00028 #include <memory>
00029 #include <fstream>
00030
00031
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
00051
00052
00053
00054
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
00083
00084
00085
00086 virtual void beginJob();
00087 virtual void endJob();
00088
00089
00090
00091 virtual void configure( std::string & histos_to_disable,
00092 std::string & histos_to_enable );
00093
00094
00095
00096 virtual void select( std::string vars_to_select,
00097 std::vector< pat::PhysVarHisto * > & selectedHistos );
00098
00099
00100 virtual void clearVec();
00101
00102
00103
00104
00105
00106
00107
00108 inline void fillCollection( const std::vector<pat::Muon> & coll, double w = 1.0 )
00109 { muonHistograms_->fillCollection(coll,w); }
00110
00111
00112
00113 inline void fillCollection( const std::vector<pat::Electron> & coll, double w = 1.0 )
00114 { electronHistograms_->fillCollection(coll,w); }
00115
00116
00117
00118 inline void fillCollection( const std::vector<pat::Tau> & coll, double w = 1.0 )
00119 { tauHistograms_->fillCollection(coll,w); }
00120
00121
00122
00123 inline void fillCollection( const std::vector<pat::Jet> & coll, double w = 1.0 )
00124 { jetHistograms_->fillCollection(coll,w); }
00125
00126
00127
00128 inline void fillCollection( const std::vector<pat::MET> & coll, double w = 1.0 )
00129 { metHistograms_->fillCollection(coll,w); }
00130
00131
00132
00133 inline void fillCollection( const std::vector<pat::Photon> & coll, double w = 1.0 )
00134 { photonHistograms_->fillCollection(coll,w); }
00135
00136
00137
00138 inline void fillCollection( const std::vector<reco::RecoChargedCandidate> & coll, double w = 1.0 )
00139 { trackHistograms_->fillCollection(coll,w); }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
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
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
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
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
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
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
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
00200 inline void addHisto( pat::PhysVarHisto * h )
00201 { allVarHistos_.push_back( h ); }
00202
00203
00204
00205 private:
00206
00207
00208 std::string outputTextName_;
00209
00210
00211 edm::Service<TFileService> fs;
00212
00213
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
00223
00224 std::vector< pat::PhysVarHisto* > allVarHistos_ ;
00225 std::vector< pat::PhysVarHisto* > enabledVarHistos_ ;
00226
00227
00228 ofstream outputFile_;
00229 };
00230
00231 #endif