ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/interface/ntupleReader.hpp
(Generate patch)

Comparing UserCode/VHbb/interface/ntupleReader.hpp (file contents):
Revision 1.2 by bortigno, Wed May 2 19:20:07 2012 UTC vs.
Revision 1.5 by bortigno, Fri Jun 22 15:50:09 2012 UTC

# Line 7 | Line 7
7   #include "TLorentzVector.h"
8   #include "ntupleLoader.hpp"
9  
10 +
11   class ntupleReader : public ntupleLoader {
12   public :
13  
14    ntupleReader(const char * infile) : ntupleLoader( infile ){};
15    //  virtual ~ntupleReader();
16 <   virtual std::vector<TLorentzVector> SimBs();
17 <   virtual std::vector<TLorentzVector> SVs();
18 <   virtual int CountJets();
19 <   virtual int CountAddJets();
20 <   virtual int CountAddForwardJets();
21 <   virtual int CountAddJets_jec( double sign );
22 <   virtual int CountAddLeptons();
23 <   virtual bool TriggerBit();
24 <   virtual TLorentzVector VectorBoson(); //vector boson TLorentz vector
25 <   virtual double hJet_PT( int idx, int sign ); //higgs jet energy correction
26 <   virtual double aJet_PT( int idx, int sign ); //addtional jet energy correction
27 <   virtual TLorentzVector Higgs( int sign ); //higgs candidate jet energy correction
28 <   virtual double hJet_CSV( int idx, int sign ); //higgs jet energy correction
29 <   virtual double hJet_pt_jec( int idx, double sign ); //higgs jet energy correction
30 <   virtual double aJet_pt_jec( int idx, double sign ); //addtional jet energy correction
31 <   virtual TLorentzVector H_jec( double sign ); //higgs candidate jet energy correction
32 <   virtual double hJet_csv_cUP( int idx );
33 <   virtual double hJet_csv_cDOWN( int idx );
34 <   virtual double hJet_csv_cFUP( int idx );
35 <   virtual double hJet_csv_cFDOWN( int idx );
36 <   virtual double hJet_pt_jecUP( int idx );
37 <   virtual double hJet_pt_jecDOWN( int idx );
38 <   virtual double aJet_pt_jecUP( int idx );
39 <   virtual double aJet_pt_jecDOWN( int idx );
40 <   virtual TLorentzVector H_jecUP();
41 <   virtual TLorentzVector H_jecDOWN();
42 <
16 >  virtual int GetSign(int v);
17 >  virtual std::vector<TLorentzVector> SimBs();
18 >  virtual std::vector<TLorentzVector> SVs();
19 >  virtual double typeIcorrMET( double sign );
20 >  virtual int CountJets();
21 >  virtual int CountAddJets();
22 >  virtual int CountAddForwardJets();
23 >  virtual int CountAddJets_jec( double sign );
24 >  virtual int CountAddLeptons();
25 >  virtual bool TriggerBit();
26 >  virtual TLorentzVector VectorBoson(); //vector boson TLorentz vector
27 >  virtual double resolution(double eta); //smearing for the jet energy resolution
28 >  virtual TLorentzVector hJet_jer( int idx, double sign );
29 >  virtual TLorentzVector H_jer( double sing );
30 >  virtual double hJet_PT( int idx, int sign ); //higgs jet energy correction
31 >  virtual double aJet_PT( int idx, int sign ); //addtional jet energy correction
32 >  virtual double hJet_E( int idx, int sign ); //higgs jet energy correction
33 >  virtual double aJet_E( int idx, int sign ); //addtional jet energy correction
34 >  virtual TLorentzVector Higgs( int sign ); //higgs candidate jet energy correction
35 >  virtual double hJet_CSV( int idx, int sign ); //higgs jet energy correction
36 >  virtual double hJet_pt_jec( int idx, double sign ); //higgs jet energy correction
37 >  virtual double aJet_pt_jec( int idx, double sign ); //addtional jet energy correction
38 >  virtual double hJet_e_jec( int idx, double sign );
39 >  virtual double aJet_e_jec( int idx, double sign );
40 >  virtual TLorentzVector H_jec( double sign ); //higgs candidate jet energy correction
41 >  virtual double hJet_csv_cUP( int idx );
42 >  virtual double hJet_csv_cDOWN( int idx );
43 >  virtual double hJet_csv_cFUP( int idx );
44 >  virtual double hJet_csv_cFDOWN( int idx );
45 >  virtual double hJet_pt_jecUP( int idx );
46 >  virtual double hJet_pt_jecDOWN( int idx );
47 >  virtual double aJet_pt_jecUP( int idx );
48 >  virtual double aJet_pt_jecDOWN( int idx );
49 >  virtual TLorentzVector H_jecUP();
50 >  virtual TLorentzVector H_jecDOWN();
51 >  
52   };
53  
54 + int ntupleReader::GetSign(int v){
55 +  return v > 0 ? 1 : (v < 0 ? -1 : 0);
56 + }
57  
58   std::vector<TLorentzVector> ntupleReader::SimBs(){
59    TLorentzVector simB;
# Line 62 | Line 75 | std::vector<TLorentzVector> ntupleReader
75    return iSVs;
76   }
77  
78 + double ntupleReader::typeIcorrMET( double sign = 0 ){
79 +  double met_et;
80 +  TLorentzVector sumPt;
81 +  TLorentzVector sumPtRaw;
82 +  TLorentzVector rawMet, jet, rawJet;
83 +  for(int i=0; i<nhJets; ++i){
84 +    jet.SetPtEtaPhiE( hJet_PT(i, sign) , hJet_eta[i], hJet_phi[i], hJet_E(i, sign));
85 +    rawJet.SetPtEtaPhiE( hJet_ptRaw[i] , hJet_eta[i], hJet_phi[i], (hJet_ptRaw[i]/hJet_PT(i,sign)) * hJet_E(i,sign));
86 +    sumPt += jet;
87 +    sumPtRaw += rawJet;
88 +  }
89 +  rawMet.SetPtEtaPhiE(MET_et, 0., MET_phi, MET_et);
90 +  met_et = (rawMet - (sumPt - sumPtRaw)).Pt();
91 +  return met_et;
92 + }
93   TLorentzVector ntupleReader::VectorBoson(){
94    TLorentzVector l1, l2;
95    l1.SetPtEtaPhiM(vLepton_pt[0],vLepton_eta[0],vLepton_phi[0],vLepton_mass[0] );
# Line 69 | Line 97 | TLorentzVector ntupleReader::VectorBoson
97    return (l1+l2);
98   }
99  
100 < double ntupleReader::hJet_PT( int idx, int sign ){ return  hJet_pt[idx]*(1 + (sign)*hJet_JECUnc[idx]); }
100 > //JER
101 > double ntupleReader::resolution(double eta){
102 >  double inner = 0.06;
103 >  double outer = 0.1;
104 >  double eta_tracker = 1.1;
105 >  if(abs(eta) < eta_tracker) return inner; else return outer;
106 > }
107 >
108 > TLorentzVector ntupleReader::hJet_jer( int idx, double sign ){
109 >  TLorentzVector tmp;
110 >  double hJet_pt_jer = hJet_pt[idx] + sign * resolution(hJet_eta[idx])*TMath::Abs(hJet_pt[idx]-hJet_genPt[idx]);
111 >  tmp.SetPtEtaPhiE(  hJet_pt_jer,
112 >                     hJet_eta[idx],
113 >                     hJet_phi[idx],
114 >                     hJet_e[idx]*(hJet_pt_jer/hJet_pt[idx]) );
115 > return tmp;
116 > }
117 >
118 > TLorentzVector ntupleReader::H_jer( double sign ){
119 >  TLorentzVector h;
120 >  h = hJet_jer( 0, sign ) + hJet_jer( 1, sign );
121 >  return h;
122 > }
123 >
124 > double ntupleReader::hJet_PT( int idx, int sign ){
125 >  if( TMath::Abs(sign) < 2 )
126 >    return  hJet_pt[idx]*(1 + (sign)*hJet_JECUnc[idx]);
127 >  else // +- 2 are for jet energy corrections
128 >    return (hJet_jer( idx, sign - GetSign(sign)*1 )).Pt() ;
129 > }
130   double ntupleReader::aJet_PT( int idx, int sign ){ return  aJet_pt[idx]*(1 + (sign)*aJet_JECUnc[idx]); }
131 + double ntupleReader::hJet_E( int idx, int sign ){  return  hJet_e[idx] * hJet_PT(idx, sign)/hJet_pt[idx]; }
132 + double ntupleReader::aJet_E( int idx, int sign ){ return aJet_e[idx] * aJet_PT(idx, sign)/aJet_pt[idx]; }
133   TLorentzVector ntupleReader::Higgs( int sign ){
134    TLorentzVector j1,j2,H;
135 <  j1.SetPtEtaPhiE( hJet_pt_jec(0,sign), hJet_eta[0], hJet_phi[0], hJet_e[0] );
136 <  j2.SetPtEtaPhiE( hJet_pt_jec(1,sign), hJet_eta[1], hJet_phi[1], hJet_e[1] );
135 >  j1.SetPtEtaPhiE( hJet_PT(0,sign), hJet_eta[0], hJet_phi[0], hJet_E(0,sign) );
136 >  j2.SetPtEtaPhiE( hJet_PT(1,sign), hJet_eta[1], hJet_phi[1], hJet_E(1,sign) );
137    return  H=j1+j2;
138   }
139   double ntupleReader::hJet_CSV( int idx, int sign ){
140 <  if(sign == 1) return (hJet_csvUp[idx]);
141 <  else if(sign == -1) return (hJet_csvDown[idx]);
142 <  else if( sign == 2 ) return (hJet_csvFUp[idx]);
143 <  else if( sign == -2 ) return (hJet_csvFDown[idx]) ;
144 <  else return (hJet_csv[idx]);
140 >  //this is not reshaped
141 >  //else return (hJet_csv[idx]);
142 >  //this is reshaped using my framework
143 >  //  else return (sh.reshape( hJet_eta[idx], hJet_pt[idx], hJet_csv[idx], hJet_flavour[idx] ));
144 >  //using Niklas framework the csv not reshaped is called csvOld
145 >  if( hJet_flavour[0] < 1 ) // stupid check if it is data. In niklas framework there is no csvOld for data. reshaping knows about data for flavour 0
146 >    return (reshape.reshape( hJet_eta[idx], hJet_pt[idx], hJet_csv[idx], hJet_flavour[idx] ));
147 >  else{ //MC
148 >    if(sign == 1) return (reshape_bTagUp.reshape( hJet_eta[idx], hJet_pt[idx], hJet_csvOld[idx], hJet_flavour[idx] ));
149 >    else if(sign == -1) return (reshape_bTagDown.reshape( hJet_eta[idx], hJet_pt[idx], hJet_csvOld[idx], hJet_flavour[idx] ));
150 >    else if( sign == 2 ) return (reshape_misTagUp.reshape( hJet_eta[idx], hJet_pt[idx], hJet_csvOld[idx], hJet_flavour[idx] ));  
151 >    else if( sign == -2 ) return (reshape_misTagDown.reshape( hJet_eta[idx], hJet_pt[idx], hJet_csvOld[idx], hJet_flavour[idx] ));  
152 >    else return (reshape.reshape( hJet_eta[idx], hJet_pt[idx], hJet_csvOld[idx], hJet_flavour[idx] ));
153 >  }
154   }
155  
156  
157   //for jet energy correction variation
158   double ntupleReader::hJet_pt_jec( int idx, double sign ){ return  hJet_pt[idx]*(1 + (sign)*hJet_JECUnc[idx]); }
159   double ntupleReader::aJet_pt_jec( int idx, double sign ){ return  aJet_pt[idx]*(1 + (sign)*aJet_JECUnc[idx]); }
160 +
161 + double ntupleReader::hJet_e_jec( int idx, double sign ){ return  hJet_e[idx]*(1 + (sign)*hJet_JECUnc[idx]); }
162 + double ntupleReader::aJet_e_jec( int idx, double sign ){ return  aJet_e[idx]*(1 + (sign)*aJet_JECUnc[idx]); }
163 +
164   TLorentzVector ntupleReader::H_jec( double sign ){
165    TLorentzVector j1,j2,H;
166 <  j1.SetPtEtaPhiE( hJet_pt_jec(0,sign), hJet_eta[0], hJet_phi[0], hJet_e[0] );
167 <  j2.SetPtEtaPhiE( hJet_pt_jec(1,sign), hJet_eta[1], hJet_phi[1], hJet_e[1] );
166 >  j1.SetPtEtaPhiE( hJet_pt_jec(0,sign), hJet_eta[0], hJet_phi[0], hJet_e_jec(0,sign) );
167 >  j2.SetPtEtaPhiE( hJet_pt_jec(1,sign), hJet_eta[1], hJet_phi[1], hJet_e_jec(1,sign) );
168    return  H=j1+j2;
169   }
170   double ntupleReader::hJet_csv_cUP( int idx ){ return ( hJet_csvUp[idx] ); }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines