1 |
dkralph |
1.1 |
#ifndef FAKE_DEFS
|
2 |
|
|
#define FAKE_DEFS
|
3 |
|
|
|
4 |
|
|
//
|
5 |
|
|
// System headers
|
6 |
|
|
//
|
7 |
|
|
#include <vector> // STL vector class
|
8 |
|
|
#include <iostream> // standard I/O
|
9 |
|
|
#include <iomanip> // functions to format standard I/O
|
10 |
|
|
#include <fstream> // functions for file I/O
|
11 |
|
|
#include <string> // C++ string class
|
12 |
dkralph |
1.6 |
#include <iomanip>
|
13 |
|
|
#include <iostream>
|
14 |
dkralph |
1.1 |
#include <sstream> // class for parsing strings
|
15 |
|
|
#include <assert.h>
|
16 |
|
|
#include <stdlib.h>
|
17 |
|
|
#include <getopt.h>
|
18 |
|
|
using namespace std;
|
19 |
|
|
|
20 |
|
|
//
|
21 |
|
|
// ROOT headers
|
22 |
|
|
//
|
23 |
|
|
#include <TROOT.h> // access to gROOT, entry point to ROOT system
|
24 |
|
|
#include <TSystem.h> // interface to OS
|
25 |
|
|
#include <TFile.h> // file handle class
|
26 |
|
|
#include <TNtuple.h>
|
27 |
|
|
#include <TTree.h> // class to access ntuples
|
28 |
|
|
#include <TChain.h> //
|
29 |
|
|
#include <TBranch.h> // class to access branches in TTree
|
30 |
|
|
#include <TClonesArray.h> // ROOT array class
|
31 |
|
|
#include <TCanvas.h> // class for drawing
|
32 |
|
|
#include <TH1D.h> // 1D histograms
|
33 |
|
|
#include <TBenchmark.h> // class to track macro running statistics
|
34 |
|
|
#include <TLorentzVector.h> // 4-vector class
|
35 |
|
|
#include <TVector3.h> // 3D vector class
|
36 |
|
|
#include <TRandom.h>
|
37 |
|
|
|
38 |
|
|
//
|
39 |
|
|
// bambu format headers
|
40 |
|
|
//
|
41 |
|
|
#include "EventHeader.h"
|
42 |
|
|
#include "Electron.h"
|
43 |
|
|
#include "PFJet.h"
|
44 |
|
|
#include "Muon.h"
|
45 |
|
|
#include "Vertex.h"
|
46 |
|
|
#include "PFCandidate.h"
|
47 |
|
|
#include "PFCandidateCol.h"
|
48 |
|
|
#include "TriggerMask.h"
|
49 |
|
|
#include "TriggerTable.h"
|
50 |
|
|
#include "Names.h"
|
51 |
|
|
#include "BaseMod.h"
|
52 |
dkralph |
1.6 |
#include "TH2DAsymErr.h"
|
53 |
dkralph |
1.1 |
|
54 |
|
|
//
|
55 |
|
|
// utility headers
|
56 |
|
|
//
|
57 |
|
|
#include "ParseArgs.h"
|
58 |
|
|
#include "SampleWeight.h"
|
59 |
|
|
// #include "GlobalDataAndFuncs.h"
|
60 |
|
|
#include "MuonSelection.h"
|
61 |
|
|
#include "ElectronSelection.h"
|
62 |
|
|
#include "MathUtils.h"
|
63 |
|
|
#include "IsolationSelectionDefs.h"
|
64 |
|
|
#include "IsolationSelection.h"
|
65 |
|
|
#include "SimpleLepton.h"
|
66 |
|
|
#include "CEffUser2D.h"
|
67 |
|
|
#include "InfoStruct.h"
|
68 |
dkralph |
1.5 |
#include "KinematicsStruct.h"
|
69 |
dkralph |
1.1 |
#include "SelectionDefs.h"
|
70 |
dkralph |
1.6 |
#include "SelectionFuncs.h"
|
71 |
|
|
#include "FOArgs.h"
|
72 |
|
|
#include "CPlot.h"
|
73 |
dkralph |
1.1 |
|
74 |
|
|
// class to hold files and graphs with FR info
|
75 |
|
|
class FR_struct {
|
76 |
|
|
public:
|
77 |
|
|
TFile *mufrfile,*elefrfile;
|
78 |
|
|
TH2D *hFRmu,*hFRele;
|
79 |
|
|
TH2D *hFRmuErrl,*hFReleErrl;
|
80 |
|
|
TH2D *hFRmuErrh,*hFReleErrh;
|
81 |
|
|
CEffUser2D mufr, elefr;
|
82 |
dkralph |
1.6 |
bool absEtaMu,absEtaEle;
|
83 |
dkralph |
1.1 |
};
|
84 |
dkralph |
1.6 |
|
85 |
|
|
void printSiEff(TH2DAsymErr *h, TH2DAsymErr::EErrType errType)
|
86 |
|
|
{
|
87 |
|
|
const Int_t nx = h->GetNbinsX();
|
88 |
|
|
const Int_t ny = h->GetNbinsY();
|
89 |
|
|
|
90 |
|
|
for(Int_t iy=0; iy<=ny; iy++) {
|
91 |
|
|
for(Int_t ix=0; ix<=nx; ix++) {
|
92 |
|
|
if(ix==0 && iy==0) {
|
93 |
|
|
cout << setw(11) << "";
|
94 |
|
|
} else if(ix==0) {
|
95 |
|
|
cout << "[" << setw(4) << h->GetYaxis()->GetBinLowEdge(iy) << "," << setw(4) << h->GetYaxis()->GetBinLowEdge(iy+1) << "]";
|
96 |
|
|
} else if(iy==0) {
|
97 |
|
|
cout << "[" << setw(4) << h->GetXaxis()->GetBinLowEdge(ix) << "," << setw(4) << h->GetXaxis()->GetBinLowEdge(ix+1) << "]";
|
98 |
|
|
} else {
|
99 |
|
|
ios_base::fmtflags flags = cout.flags();
|
100 |
|
|
cout.precision(7);
|
101 |
|
|
cout << " " << setw(9) << fixed << h->GetBinError(ix,iy,errType) << " ";
|
102 |
|
|
cout.flags(flags);
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
cout << endl;
|
106 |
|
|
}
|
107 |
|
|
}
|
108 |
|
|
//----------------------------------------------------------------------------------------
|
109 |
|
|
void setErrors(TH2DAsymErr *h, CEffUser2D *fr)
|
110 |
|
|
{
|
111 |
|
|
assert(fr->getHerrl() && fr->getHerrl());
|
112 |
dkralph |
1.7 |
for(int xbin=0; xbin<h->GetXaxis()->GetNbins()+2; xbin++) {
|
113 |
|
|
for(int ybin=0; ybin<h->GetYaxis()->GetNbins()+2; ybin++) {
|
114 |
dkralph |
1.6 |
int ncell = h->GetBin(xbin,ybin);
|
115 |
|
|
int ncellChk = fr->getHerrl()->GetBin(xbin,ybin);
|
116 |
|
|
assert(ncell==ncellChk);
|
117 |
|
|
|
118 |
|
|
double errl = h->GetBinError(xbin,ybin,TH2DAsymErr::kStatErrLow);
|
119 |
|
|
fr->getHerrl()->SetBinContent(ncell,errl);
|
120 |
|
|
double errh = h->GetBinError(xbin,ybin,TH2DAsymErr::kStatErrHigh);
|
121 |
|
|
fr->getHerrh()->SetBinContent(ncell,errh);
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
|
|
}
|
125 |
dkralph |
1.1 |
//----------------------------------------------------------------------------------------
|
126 |
|
|
FR_struct initFRs(TString mufile, TString elefile)
|
127 |
|
|
{
|
128 |
|
|
FR_struct fr;
|
129 |
|
|
cout << "loading fake file: " << mufile << endl;
|
130 |
dkralph |
1.6 |
// kevin's format
|
131 |
dkralph |
1.1 |
fr.mufrfile = TFile::Open(mufile); assert(fr.mufrfile->IsOpen());
|
132 |
|
|
fr.hFRmu = (TH2D*)fr.mufrfile->Get("frEtaPt");
|
133 |
|
|
fr.hFRmuErrl = (TH2D*)fr.mufrfile->Get("errlEtaPt");
|
134 |
|
|
fr.hFRmuErrh = (TH2D*)fr.mufrfile->Get("errhEtaPt");
|
135 |
|
|
cout << "loading fake file: " << elefile << endl;
|
136 |
|
|
fr.elefrfile = TFile::Open(elefile); assert(fr.elefrfile->IsOpen());
|
137 |
|
|
fr.hFRele = (TH2D*)fr.elefrfile->Get("frEtaPt");
|
138 |
|
|
fr.hFReleErrl = (TH2D*)fr.elefrfile->Get("errlEtaPt");
|
139 |
|
|
fr.hFReleErrh = (TH2D*)fr.elefrfile->Get("errhEtaPt");
|
140 |
dkralph |
1.6 |
// si's format
|
141 |
|
|
if(!fr.hFRmu) {
|
142 |
|
|
TH2DAsymErr *hAsymMu = (TH2DAsymErr*)fr.mufrfile->Get("MuonFakeRateDenominatorV1_EtaPt");
|
143 |
|
|
fr.hFRmu = (TH2D*)hAsymMu;
|
144 |
|
|
fr.hFRmuErrl = new TH2D(*fr.hFRmu); fr.hFRmuErrl->Reset();
|
145 |
|
|
fr.hFRmuErrh = new TH2D(*fr.hFRmu); fr.hFRmuErrh->Reset();
|
146 |
|
|
fr.mufr.loadEff(fr.hFRmu,fr.hFRmuErrl,fr.hFRmuErrh);
|
147 |
|
|
setErrors(hAsymMu,&fr.mufr);
|
148 |
|
|
}
|
149 |
dkralph |
1.1 |
if(!fr.hFRele) {
|
150 |
dkralph |
1.6 |
TH2DAsymErr *hAsymEle = (TH2DAsymErr*)fr.elefrfile->Get("ElectronFakeRateDenominatorV1_EtaPt");
|
151 |
|
|
fr.hFRele = (TH2D*)hAsymEle;
|
152 |
|
|
fr.hFReleErrl = new TH2D(*fr.hFRele); fr.hFReleErrl->Reset();
|
153 |
|
|
fr.hFReleErrh = new TH2D(*fr.hFRele); fr.hFReleErrh->Reset();
|
154 |
|
|
fr.elefr.loadEff(fr.hFRele,fr.hFReleErrl,fr.hFReleErrh);
|
155 |
|
|
setErrors(hAsymEle,&fr.elefr);
|
156 |
dkralph |
1.1 |
}
|
157 |
dkralph |
1.6 |
fr.mufr.loadEff(fr.hFRmu,fr.hFRmuErrl,fr.hFRmuErrh);
|
158 |
dkralph |
1.1 |
fr.elefr.loadEff(fr.hFRele,fr.hFReleErrl,fr.hFReleErrh);
|
159 |
|
|
|
160 |
dkralph |
1.6 |
// figure out whether to use abs eta
|
161 |
|
|
if(fr.hFRmu->GetXaxis()->GetBinLowEdge(1) < 0) fr.absEtaMu = false;
|
162 |
|
|
else fr.absEtaMu = true;
|
163 |
|
|
if(fr.hFRele->GetXaxis()->GetBinLowEdge(1) < 0) fr.absEtaEle = false;
|
164 |
|
|
else fr.absEtaEle = true;
|
165 |
|
|
if(fr.absEtaEle) cout << "\nUsing abs eta in electron fake rates\n" << endl;
|
166 |
|
|
else cout << "\nNot using abs eta in electron fake rates\n" << endl;
|
167 |
|
|
|
168 |
|
|
fr.mufr.printEff(cout);
|
169 |
|
|
fr.elefr.printEff(cout);
|
170 |
|
|
fr.mufr.printErrLow(cout);
|
171 |
|
|
fr.elefr.printErrLow(cout);
|
172 |
|
|
fr.mufr.printErrHigh(cout);
|
173 |
|
|
fr.elefr.printErrHigh(cout);
|
174 |
dkralph |
1.3 |
|
175 |
dkralph |
1.1 |
return fr;
|
176 |
|
|
}
|
177 |
|
|
//----------------------------------------------------------------------------------------
|
178 |
|
|
class foinfo {
|
179 |
|
|
public:
|
180 |
|
|
UInt_t nDenom,nNumer,nEvents;
|
181 |
dkralph |
1.7 |
Int_t npu;
|
182 |
dkralph |
1.1 |
Float_t fopt,foeta,fophi,fopass,jpt;
|
183 |
|
|
TTree *outTree;
|
184 |
|
|
};
|
185 |
|
|
#endif
|