1 |
#include <TROOT.h>
|
2 |
#include <TChain.h>
|
3 |
#include <TFile.h>
|
4 |
#include <TString.h>
|
5 |
#include <TBenchmark.h>
|
6 |
#include <vector>
|
7 |
#include <iostream>
|
8 |
#include <fstream>
|
9 |
#include <string>
|
10 |
#include <assert.h>
|
11 |
#include <TKey.h>
|
12 |
#include <TH1F.h>
|
13 |
#include <TH2F.h>
|
14 |
#include "MitCommon/DataFormats/interface/TH2DAsymErr.h"
|
15 |
#include "EfficiencyUtils.h"
|
16 |
using namespace std;
|
17 |
|
18 |
vector<double> ptbins;
|
19 |
vector<double> etabins;
|
20 |
vector<double> phibins;
|
21 |
vector<double> nvtxbins;
|
22 |
vector<double> rhobins;
|
23 |
vector<double> ptbins2D;
|
24 |
vector<double> etabins2D;
|
25 |
|
26 |
string infilename = "/data/blue/anlevin/fr_muon_r12a-del_and_dmu-pr-v1.root";
|
27 |
string outfilename = "delete.root";
|
28 |
|
29 |
int main()
|
30 |
{
|
31 |
|
32 |
TFile * file = new TFile(TString(infilename));
|
33 |
|
34 |
TFile * outfile = new TFile(TString(outfilename),"RECREATE");
|
35 |
ptbins.push_back(0);
|
36 |
ptbins.push_back(5);
|
37 |
ptbins.push_back(7);
|
38 |
ptbins.push_back(10);
|
39 |
ptbins.push_back(15);
|
40 |
ptbins.push_back(20);
|
41 |
ptbins.push_back(25);
|
42 |
ptbins.push_back(30);
|
43 |
ptbins.push_back(40);
|
44 |
ptbins.push_back(50);
|
45 |
ptbins.push_back(80);
|
46 |
|
47 |
etabins.push_back(-3.0);
|
48 |
etabins.push_back(-2.5);
|
49 |
etabins.push_back(-2.25);
|
50 |
etabins.push_back(-2.0);
|
51 |
etabins.push_back(-1.75);
|
52 |
etabins.push_back(-1.479);
|
53 |
etabins.push_back(-1.25);
|
54 |
etabins.push_back(-1.0);
|
55 |
etabins.push_back(-0.75);
|
56 |
etabins.push_back(-0.5);
|
57 |
etabins.push_back(-0.25);
|
58 |
etabins.push_back(0.0);
|
59 |
etabins.push_back(0.25);
|
60 |
etabins.push_back(0.5);
|
61 |
etabins.push_back(0.75);
|
62 |
etabins.push_back(1.0);
|
63 |
etabins.push_back(1.25);
|
64 |
etabins.push_back(1.479);
|
65 |
etabins.push_back(1.75);
|
66 |
etabins.push_back(2.0);
|
67 |
etabins.push_back(2.25);
|
68 |
etabins.push_back(2.5);
|
69 |
etabins.push_back(3.0);
|
70 |
|
71 |
phibins.push_back(-3.25);
|
72 |
phibins.push_back(-2.75);
|
73 |
phibins.push_back(-2.25);
|
74 |
phibins.push_back(-1.75);
|
75 |
phibins.push_back(-1.25);
|
76 |
phibins.push_back(-0.75);
|
77 |
phibins.push_back(-0.25);
|
78 |
phibins.push_back(0.25);
|
79 |
phibins.push_back(0.75);
|
80 |
phibins.push_back(1.25);
|
81 |
phibins.push_back(1.75);
|
82 |
phibins.push_back(2.25);
|
83 |
phibins.push_back(2.75);
|
84 |
phibins.push_back(3.25);
|
85 |
|
86 |
nvtxbins.push_back(0);
|
87 |
nvtxbins.push_back(2);
|
88 |
nvtxbins.push_back(4);
|
89 |
nvtxbins.push_back(6);
|
90 |
nvtxbins.push_back(8);
|
91 |
nvtxbins.push_back(10);
|
92 |
nvtxbins.push_back(12);
|
93 |
nvtxbins.push_back(14);
|
94 |
nvtxbins.push_back(16);
|
95 |
nvtxbins.push_back(18);
|
96 |
nvtxbins.push_back(20);
|
97 |
nvtxbins.push_back(22);
|
98 |
nvtxbins.push_back(24);
|
99 |
nvtxbins.push_back(26);
|
100 |
|
101 |
rhobins.push_back(0);
|
102 |
rhobins.push_back(2);
|
103 |
rhobins.push_back(4);
|
104 |
rhobins.push_back(6);
|
105 |
rhobins.push_back(8);
|
106 |
rhobins.push_back(10);
|
107 |
rhobins.push_back(12);
|
108 |
rhobins.push_back(14);
|
109 |
rhobins.push_back(16);
|
110 |
rhobins.push_back(18);
|
111 |
rhobins.push_back(20);
|
112 |
rhobins.push_back(22);
|
113 |
rhobins.push_back(24);
|
114 |
rhobins.push_back(26);
|
115 |
|
116 |
ptbins2D.push_back(7);
|
117 |
ptbins2D.push_back(10);
|
118 |
ptbins2D.push_back(35);
|
119 |
ptbins2D.push_back(7000);
|
120 |
|
121 |
etabins2D.push_back(-2.5);
|
122 |
etabins2D.push_back(-1.5);
|
123 |
etabins2D.push_back(0.0);
|
124 |
etabins2D.push_back(1.5);
|
125 |
etabins2D.push_back(2.5);
|
126 |
|
127 |
TIterator * iter = file->GetListOfKeys()->MakeIterator();
|
128 |
TKey* tempKey=0;
|
129 |
|
130 |
while((tempKey=(TKey*)iter->Next())) {
|
131 |
|
132 |
string tmpstr(tempKey->GetName());
|
133 |
cout << "tmpstr = " << tmpstr << endl;
|
134 |
TTree * tree = (TTree*)file->Get(tmpstr.c_str());
|
135 |
assert(tree);
|
136 |
TH1F* DenominatorVector_Pt = new TH1F(("histDenominator_Pt_"+ tmpstr).c_str(), "; p_{T} [GeV/c] ; Number of Events ", 100, 0 , 100);;
|
137 |
TH1F* DenominatorVector_Eta = new TH1F(("histDenominator_Eta_"+ tmpstr).c_str(),"; #eta ; Number of Events ", 600, -2.5 , 2.5);;
|
138 |
TH1F* DenominatorVector_Phi = new TH1F(("histDenominator_Phi_"+ tmpstr).c_str() , "; #phi ; Number of Events ", 100, -3.2 , 3.2);;
|
139 |
TH1F* DenominatorVector_NVtx = new TH1F(("histDenominator_NVtx_"+ tmpstr).c_str() , "; Number of Primary Vertices ; Number of Events ", 30, -0.5 , 29.5);
|
140 |
TH2F* DenominatorVector_EtaPt = new TH2F(("histDenominator_EtaPt_"+ tmpstr).c_str(),"; #eta ; p_{T} [GeV/c] ; Number of Events ", 600, -2.5, 2.5, 100, 0 , 100);
|
141 |
TH1F* NumeratorVector_Pt = new TH1F(("histNumerator_Pt_"+ tmpstr).c_str() , "; p_{T} [GeV/c] ; Number of Events ", 100, 0 , 100);;
|
142 |
TH1F* NumeratorVector_Eta = new TH1F(("histNumerator_Eta_"+ tmpstr).c_str(),"; #eta ; Number of Events ", 600, -2.5 , 2.5);;
|
143 |
TH1F* NumeratorVector_Phi = new TH1F(("histNumerator_Phi_"+ tmpstr).c_str() , "; #phi ; Number of Events ", 100, -3.2 , 3.2);;
|
144 |
TH1F* NumeratorVector_NVtx = new TH1F(("histNumerator_NVtx_"+ tmpstr).c_str() , "; Number of Primary Vertices ; Number of Events ", 30, -0.5 , 29.5);
|
145 |
TH2F* NumeratorVector_EtaPt = new TH2F(("histNumerator_EtaPt_"+ tmpstr).c_str(),"; #eta ; p_{T} [GeV/c] ; Number of Events ", 600, -2.5, 2.5, 100, 0 , 100);
|
146 |
|
147 |
Float_t muon_fake_pt;
|
148 |
Float_t muon_fake_eta;
|
149 |
Float_t muon_fake_phi;
|
150 |
UInt_t muon_fake_nvtx;
|
151 |
UInt_t muon_fake_pass;
|
152 |
|
153 |
tree->SetBranchAddress("fake_muon_pt_DenominatorV1",&muon_fake_pt);
|
154 |
tree->SetBranchAddress("fake_muon_eta_DenominatorV1",&muon_fake_eta);
|
155 |
tree->SetBranchAddress("fake_muon_phi_DenominatorV1",&muon_fake_phi);
|
156 |
tree->SetBranchAddress("nvertices",&muon_fake_nvtx);
|
157 |
tree->SetBranchAddress("fake_muon_pass_DenominatorV1",&muon_fake_pass);
|
158 |
|
159 |
cout << "tree->GetEntries() = " << tree->GetEntries() << endl;
|
160 |
|
161 |
for(UInt_t ientry = 0; ientry < tree->GetEntries(); ientry++){
|
162 |
tree->GetEntry(ientry);
|
163 |
DenominatorVector_Pt->Fill(muon_fake_pt);
|
164 |
DenominatorVector_Eta->Fill(muon_fake_eta);
|
165 |
DenominatorVector_Phi->Fill(muon_fake_phi);
|
166 |
DenominatorVector_NVtx->Fill(muon_fake_nvtx);
|
167 |
DenominatorVector_EtaPt->Fill(muon_fake_eta,muon_fake_pt);
|
168 |
if(muon_fake_pass){
|
169 |
NumeratorVector_Pt->Fill(muon_fake_pt);
|
170 |
NumeratorVector_Eta->Fill(muon_fake_eta);
|
171 |
NumeratorVector_Phi->Fill(muon_fake_phi);
|
172 |
NumeratorVector_NVtx->Fill(muon_fake_nvtx);
|
173 |
NumeratorVector_EtaPt->Fill(muon_fake_eta,muon_fake_pt);
|
174 |
|
175 |
}
|
176 |
}
|
177 |
|
178 |
Int_t ErrorType = 2; //Clopper Pearson errors
|
179 |
TGraphAsymmErrors *efficiency_pt = createEfficiencyGraph(NumeratorVector_Pt,DenominatorVector_Pt,"efficiency_" + tmpstr + "_pt", ptbins, ErrorType, -99, -99, 0, 1);
|
180 |
|
181 |
TGraphAsymmErrors *efficiency_eta = createEfficiencyGraph(NumeratorVector_Eta, DenominatorVector_Eta, "efficiency_" + tmpstr + "_eta", etabins, ErrorType, -99, -99, 0, 1);
|
182 |
TGraphAsymmErrors *efficiency_phi = createEfficiencyGraph(NumeratorVector_Phi, DenominatorVector_Phi, "efficiency_" + tmpstr + "_phi", phibins, ErrorType, -99, -99, 0, 1);
|
183 |
TGraphAsymmErrors *efficiency_nvtx = createEfficiencyGraph(NumeratorVector_NVtx, DenominatorVector_NVtx, "efficiency_" + tmpstr + "_nvtx", nvtxbins, ErrorType, -99, -99, 0, 1);
|
184 |
|
185 |
mithep::TH2DAsymErr *efficiency_EtaPt =
|
186 |
createEfficiencyHist2D(NumeratorVector_EtaPt, DenominatorVector_EtaPt, "efficiency_" + tmpstr + "_eta_pt",etabins2D, ptbins2D, ErrorType, kTRUE);
|
187 |
|
188 |
//rebin hists
|
189 |
NumeratorVector_EtaPt =rebin(NumeratorVector_EtaPt,etabins2D, ptbins2D,string(NumeratorVector_EtaPt->GetName()) + "_rebinned");
|
190 |
|
191 |
DenominatorVector_EtaPt = rebin(DenominatorVector_EtaPt,etabins2D, ptbins2D, string(DenominatorVector_EtaPt->GetName()) + "_rebinned");
|
192 |
|
193 |
outfile->WriteTObject(efficiency_pt, efficiency_pt->GetName(), "WriteDelete");
|
194 |
outfile->WriteTObject(efficiency_eta, efficiency_eta->GetName(), "WriteDelete");
|
195 |
outfile->WriteTObject(efficiency_phi, efficiency_phi->GetName(), "WriteDelete");
|
196 |
outfile->WriteTObject(efficiency_nvtx, efficiency_nvtx->GetName(), "WriteDelete");
|
197 |
outfile->WriteTObject(efficiency_EtaPt, efficiency_EtaPt->GetName(), "WriteDelete");
|
198 |
|
199 |
outfile->WriteTObject(NumeratorVector_Pt,NumeratorVector_Pt->GetName(), "WriteDelete");
|
200 |
outfile->WriteTObject(DenominatorVector_Pt, DenominatorVector_Pt->GetName(), "WriteDelete");
|
201 |
outfile->WriteTObject(NumeratorVector_Eta,NumeratorVector_Eta->GetName(), "WriteDelete");
|
202 |
outfile->WriteTObject(DenominatorVector_Eta, DenominatorVector_Eta->GetName(), "WriteDelete");
|
203 |
outfile->WriteTObject(NumeratorVector_Phi,NumeratorVector_Phi->GetName(), "WriteDelete");
|
204 |
outfile->WriteTObject(DenominatorVector_Phi, DenominatorVector_Phi->GetName(), "WriteDelete");
|
205 |
outfile->WriteTObject(NumeratorVector_NVtx,NumeratorVector_NVtx->GetName(), "WriteDelete");
|
206 |
outfile->WriteTObject(DenominatorVector_NVtx, DenominatorVector_NVtx->GetName(), "WriteDelete");
|
207 |
outfile->WriteTObject(NumeratorVector_EtaPt, NumeratorVector_EtaPt->GetName(), "WriteDelete");
|
208 |
outfile->WriteTObject(DenominatorVector_EtaPt, DenominatorVector_EtaPt->GetName(), "WriteDelete");
|
209 |
|
210 |
|
211 |
}
|
212 |
|
213 |
|
214 |
|
215 |
}
|