CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GammaJetAnalysis.h
Go to the documentation of this file.
1 #ifndef Calibration_HcalCalibAlgos_GammaJetAnalysis_H_
2 #define Calibration_HcalCalibAlgos_GammaJetAnalysis_H_
3 
4 // system include files
5 #include <memory>
6 #include <string>
7 
8 // user include files
11 
41 
51 
53 
54 // forward declarations
55 class TH1D;
56 class TH2D;
57 class TFile;
58 class TTree;
59 
60 //
61 // class declarations
62 //
63 
64 class PhotonPair : protected std::pair<const reco::Photon*, double> {
65 
66 public:
68  first=0;
69  second=0.0;
70  fIdx=-1;
71  }
72  PhotonPair(const reco::Photon* ph, double pt, int setIdx=-1) {
73  first=ph;
74  second=pt;
75  fIdx=setIdx;
76  }
78 
79  inline const reco::Photon* photon(void) const { return first; }
80  inline void photon(const reco::Photon* ph) { first=ph; return; }
81  inline double pt(void) const { return second; }
82  inline void pt(double d) { second=d; return; }
83  void idx(int set_idx) { fIdx=set_idx; };
84  int idx() const { return fIdx; }
85  bool isValid() const { return (first!=NULL) ? true:false; }
86 
87 private:
88  int fIdx; // index in the photon collection
89 };
90 
91 class PFJetCorretPair : protected std::pair<const reco::PFJet*, double> {
92 public:
94  first=0;
95  second=1.0;
96  }
97  PFJetCorretPair(const reco::PFJet* j, double s) {
98  first=j;
99  second=s;
100  }
102 
103  inline const reco::PFJet* jet(void) const { return first; }
104  inline void jet(const reco::PFJet* j) { first=j; return; }
105  inline double scale(void) const { return second; }
106  inline void scale(double d) { second=d; return; }
107  double scaledEt() const { return first->et() * second; }
108  bool isValid() const { return (first!=NULL) ? true:false; }
109 
110 private:
111 
112 };
113 
114 // --------------------------------------------
115 // Main class
116 // --------------------------------------------
117 
119 public:
120  explicit GammaJetAnalysis(const edm::ParameterSet&);
122 
123  float pfEcalIso(const reco::Photon* localPho1, edm::Handle<reco::PFCandidateCollection> pfHandle, float dRmax, float dRVetoBarrel, float dRVetoEndcap, float etaStripBarrel, float etaStripEndcap, float energyBarrel, float energyEndcap, reco::PFCandidate::ParticleType pfToUse);
124 
125  float pfHcalIso(const reco::Photon* localPho,edm::Handle<reco::PFCandidateCollection> pfHandle,float dRmax, float dRveto,reco::PFCandidate::ParticleType pfToUse);
126 
127  std::vector<float> pfTkIsoWithVertex(const reco::Photon* localPho1, edm::Handle<reco::PFCandidateCollection> pfHandle, edm::Handle<reco::VertexCollection> vtxHandle, float dRmax, float dRvetoBarrel, float dRvetoEndcap, float ptMin, float dzMax, float dxyMax, reco::PFCandidate::ParticleType pfToUse);
128 
129 private:
130  virtual void beginJob();//(const edm::EventSetup&);
131  virtual void analyze(const edm::Event&, const edm::EventSetup&);
132  virtual void endJob();
133  void beginRun(const edm::Run&, const edm::EventSetup&);
134 
135 
136  // parameters
137  int debug_; // print debug statements
138  unsigned int debugEvent;
140 
143 
144  std::string photonCollName_; // label for the photon collection
145  std::string pfJetCollName_; // label for the PF jet collection
146  std::string pfJetCorrName_; // label for the PF jet correction service
147  std::string genJetCollName_; // label for the genjet collection
148  std::string genParticleCollName_; // label for the genparticle collection
149  std::string genEventInfoName_; // label for the generator event info collection
150  std::string hbheRecHitName_; // label for HBHERecHits collection
151  std::string hfRecHitName_; // label for HFRecHit collection
152  std::string hoRecHitName_; // label for HORecHit collection
153  std::string rootHistFilename_; // name of the histogram file
154  std::string pvCollName_; // label for primary vertex collection
155  std::string prodProcess_; // the producer process for AOD=2
156 
157  bool allowNoPhoton_; // whether module is used for dijet analysis
158  double photonPtMin_; // lowest value of the leading photon pT
159  double photonJetDPhiMin_; // phi angle between the leading photon and the leading jet
160  double jetEtMin_; // lowest value of the leading jet ET
161  double jet2EtMax_; // largest value of the subleading jet ET
162  double jet3EtMax_; // largest value of the third jet ET
163  std::vector<std::string> photonTrigNamesV_; // photon trigger names
164  std::vector<std::string> jetTrigNamesV_; // jet trigger names
165  bool writeTriggerPrescale_; // whether attempt to record the prescale
166 
167  //Tokens
190  bool doPFJets_; // use PFJets
191  bool doGenJets_; // use GenJets
194 
195  // root file/histograms
196  TFile* rootfile_;
197 
198  TTree* misc_tree_; // misc.information. Will be filled only once
199  TTree* calo_tree_;
200  TTree* pf_tree_;
201 
202  // trigger info
203  HLTConfigProvider hltConfig_; // variable for the access
204  std::vector<int> photonTrigFired_;
205  std::vector<int> photonTrigPrescale_;
206  std::vector<int> jetTrigFired_;
207  std::vector<int> jetTrigPrescale_;
208 
209  // Event info
213  int nPFJets_;
214  ULong64_t nProcessed_;
215  int pf_NPV_;
216 
220 
221  // photon info
222  float rho2012_;
226  std::vector<std::vector<float> > tagPho_pfiso_mycharged03 ;
232 
233  // Particle-flow jets
234  // leading Et jet info
256 
257  // subleading Et jet info
279 
283 
284  // helper functions
285  template<class JetPair_type>
286  float calc_dPhi(const PhotonPair &pho, const JetPair_type &jet) {
287  if (!pho.isValid() || !jet.isValid()) return 9999.;
288  float phi1=pho.photon()->phi();
289  float phi2=jet.jet()->phi();
290  float dphi=fabs(phi1-phi2);
291  const float cPi= 4*atan(1);
292  while (dphi>cPi) dphi = fabs(2*cPi - dphi);
293  return dphi;
294  }
295 
296  double deltaR(const reco::Jet* j1, const reco::Jet* j2);
297  double deltaR(const double eta1, const double phi1, const double eta2, const double phi2);
298  int getEtaPhi(const DetId id);
299  int getEtaPhi(const HcalDetId id);
300 
301  void clear_leadingPfJetVars();
303 
304  template<class Jet_type>
305  double deltaR(const PhotonPair &photon, const Jet_type *jet) {
306  if (!photon.isValid()) return 9999.;
307  return deltaR(photon.photon()->eta(),photon.photon()->phi(),
308  jet->eta(), jet->phi());
309  }
310 
312  inline bool operator() ( const PFJetCorretPair& a, const PFJetCorretPair& b) {
313  return (a.jet()->pt()*a.scale()) > (b.jet()->pt()*b.scale());
314  }
315  };
316 
317  struct PhotonPairComp {
318  inline bool operator() ( const PhotonPair& a, const PhotonPair& b) {
319  return ( (a.photon()->pt()) > (b.photon()->pt()) );
320  }
321  };
322 
323 };
324 
325 #endif
void copy_leadingPfJetVars_to_pfJet2()
std::vector< float > ppfjet_cluster_phi_
bool isValid() const
std::vector< int > pfjet2_twr_ieta_
std::vector< int > pfjet2_had_id_
edm::EDGetTokenT< std::vector< Bool_t > > tok_tightPhotonV_
std::vector< int > pfjet2_twr_iphi_
void idx(int set_idx)
ParticleType
particle types
Definition: PFCandidate.h:44
std::vector< float > pfjet2_candtrack_px_
std::vector< float > ppfjet_had_py_
std::vector< float > ppfjet_candtrack_px_
edm::EDGetTokenT< reco::ConversionCollection > tok_Conv_
edm::EDGetTokenT< GenEventInfoProduct > tok_GenEvInfo_
std::vector< int > pfjet2_twr_hadind_
std::vector< float > ppfjet_candtrack_pz_
std::vector< int > pfjet2_twr_elmttype_
edm::EDGetTokenT< reco::PFCandidateCollection > tok_PFCand_
PhotonPair(const reco::Photon *ph, double pt, int setIdx=-1)
std::vector< int > photonTrigFired_
PFJetCorretPair(const reco::PFJet *j, double s)
std::vector< float > pfjet2_cluster_dR_
edm::EDGetTokenT< edm::SortedCollection< HFRecHit, edm::StrictWeakOrdering< HFRecHit > > > tok_HF_
Base class for all types of Jets.
Definition: Jet.h:20
std::vector< float > ppfjet_had_E_
edm::EDGetTokenT< double > tok_Rho_
edm::EDGetTokenT< edm::TriggerResults > tok_TrigRes_
std::vector< int > ppfjet_twr_ieta_
std::vector< int > ppfjet_twr_hadind_
std::string hoRecHitName_
std::vector< int > ppfjet_twr_subdet_
std::vector< int > ppfjet_had_candtrackind_
#define NULL
Definition: scimark2.h:8
const reco::PFJet * jet(void) const
std::vector< float > pfTkIsoWithVertex(const reco::Photon *localPho1, edm::Handle< reco::PFCandidateCollection > pfHandle, edm::Handle< reco::VertexCollection > vtxHandle, float dRmax, float dRvetoBarrel, float dRvetoEndcap, float ptMin, float dzMax, float dxyMax, reco::PFCandidate::ParticleType pfToUse)
std::string prodProcess_
std::string hbheRecHitName_
std::vector< float > pfjet2_had_E_
edm::EDGetTokenT< reco::PFMETCollection > tok_PFMET_
edm::EDGetTokenT< reco::VertexCollection > tok_Vertex_
std::vector< float > pfjet2_had_EcalE_
std::vector< float > pfjet2_cluster_eta_
unsigned int debugEvent
edm::EDGetTokenT< reco::BeamSpot > tok_BS_
std::vector< float > pfjet2_candtrack_py_
Jets made from PFObjects.
Definition: PFJet.h:21
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
std::vector< int > pfjet2_twr_candtrackind_
std::string photonCollName_
std::vector< int > pfjet2_twr_clusterind_
std::vector< int > pfjet2_twr_depth_
std::vector< int > pfjet2_had_candtrackind_
std::vector< float > ppfjet_twr_frac_
U second(std::pair< T, U > const &p)
tuple d
Definition: ztail.py:151
edm::EDGetTokenT< std::vector< reco::GenParticle > > tok_GenPart_
std::vector< int > ppfjet_had_id_
float met_value_
MET info.
std::vector< int > jetTrigPrescale_
bool operator()(const PhotonPair &a, const PhotonPair &b)
std::vector< int > ppfjet_twr_clusterind_
edm::EDGetTokenT< edm::SortedCollection< HORecHit, edm::StrictWeakOrdering< HORecHit > > > tok_HO_
std::string rootHistFilename_
std::string hfRecHitName_
std::vector< float > pfjet2_had_E_mctruth_
std::vector< float > ppfjet_candtrack_py_
float pfEcalIso(const reco::Photon *localPho1, edm::Handle< reco::PFCandidateCollection > pfHandle, float dRmax, float dRVetoBarrel, float dRVetoEndcap, float etaStripBarrel, float etaStripEndcap, float energyBarrel, float energyEndcap, reco::PFCandidate::ParticleType pfToUse)
std::vector< float > pfjet2_had_py_
float pfHcalIso(const reco::Photon *localPho, edm::Handle< reco::PFCandidateCollection > pfHandle, float dRmax, float dRveto, reco::PFCandidate::ParticleType pfToUse)
std::vector< float > ppfjet_cluster_dR_
edm::EDGetTokenT< reco::PhotonCollection > tok_Photon_
void photon(const reco::Photon *ph)
double scale(void) const
float ppfjet_ChargedMultiplicity_
bool isValid() const
std::vector< float > ppfjet_twr_hade_
std::vector< int > ppfjet_twr_elmttype_
std::vector< float > ppfjet_had_rawHcalE_
edm::InputTag rhoCollection_
edm::EDGetTokenT< std::vector< Bool_t > > tok_loosePhotonV_
std::vector< int > ppfjet_twr_depth_
edm::EDGetTokenT< edm::ValueMap< Bool_t > > tok_tightPhoton_
int j
Definition: DBlmapReader.cc:9
const reco::Photon * photon(void) const
std::vector< float > pfjet2_candtrack_pz_
double deltaR(const PhotonPair &photon, const Jet_type *jet)
std::vector< float > pfjet2_twr_frac_
edm::InputTag pfMETColl
edm::InputTag pfType1METColl
int idx() const
bool operator()(const PFJetCorretPair &a, const PFJetCorretPair &b)
std::vector< float > pfjet2_had_rawHcalE_
HLTConfigProvider hltConfig_
void beginRun(const edm::Run &, const edm::EventSetup &)
std::string genParticleCollName_
virtual void beginJob()
std::vector< float > ppfjet_twr_dR_
std::vector< float > ppfjet_candtrack_EcalE_
std::vector< float > ppfjet_cluster_eta_
std::vector< float > pfjet2_cluster_phi_
std::string pfJetCollName_
Definition: DetId.h:18
std::vector< std::string > photonTrigNamesV_
std::vector< int > jetTrigFired_
edm::EDGetTokenT< reco::PFJetCollection > tok_PFJet_
std::vector< float > ppfjet_had_E_mctruth_
edm::EDGetTokenT< edm::ValueMap< Bool_t > > tok_loosePhoton_
std::vector< std::string > jetTrigNamesV_
edm::EDGetTokenT< std::vector< reco::Vertex > > tok_PV_
double b
Definition: hdecay.h:120
void jet(const reco::PFJet *j)
std::vector< int > pfjet2_had_ntwrs_
std::string genEventInfoName_
double deltaR(const reco::Jet *j1, const reco::Jet *j2)
int getEtaPhi(const DetId id)
std::vector< float > pfjet2_twr_hade_
edm::EDGetTokenT< edm::SortedCollection< HBHERecHit, edm::StrictWeakOrdering< HBHERecHit > > > tok_HBHE_
std::string genJetCollName_
double scaledEt() const
std::string pvCollName_
std::vector< float > pfjet2_had_emf_
std::vector< float > ppfjet_had_px_
std::vector< int > ppfjet_had_mcpdgId_
double a
Definition: hdecay.h:121
std::vector< float > pfjet2_twr_dR_
GammaJetAnalysis(const edm::ParameterSet &)
std::vector< float > pfjet2_had_pz_
edm::EDGetTokenT< reco::GsfElectronCollection > tok_GsfElec_
float pfjet2_ChargedMultiplicity_
double pt(void) const
std::vector< int > pfjet2_twr_subdet_
std::vector< int > ppfjet_twr_iphi_
std::vector< int > photonTrigPrescale_
std::vector< int > ppfjet_had_ntwrs_
edm::EDGetTokenT< std::vector< reco::GenJet > > tok_GenJet_
std::vector< float > ppfjet_had_pz_
std::vector< float > pfjet2_candtrack_EcalE_
std::vector< int > pfjet2_had_mcpdgId_
edm::EDGetTokenT< reco::PFMETCollection > tok_PFType1MET_
void pt(double d)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< float > ppfjet_had_emf_
virtual double phi() const
momentum azimuthal angle
std::vector< int > ppfjet_twr_candtrackind_
virtual void endJob()
float calc_dPhi(const PhotonPair &pho, const JetPair_type &jet)
std::vector< std::vector< float > > tagPho_pfiso_mycharged03
std::vector< float > ppfjet_had_EcalE_
void scale(double d)
std::vector< float > pfjet2_had_px_
std::string pfJetCorrName_
Definition: Run.h:41