-
Notifications
You must be signed in to change notification settings - Fork 1
/
efficiency.h
executable file
·286 lines (248 loc) · 9.98 KB
/
efficiency.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#ifndef _EFFICIENCY_H_
#define _EFFICIENCY_H_
#include "makeHists.h"
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TMath.h>
#include <TH1F.h>
#include <TH1D.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TLorentzVector.h>
#include <TH3F.h>
#include <TRandom3.h>
#include <TMinuit.h>
#include <TApplication.h>
#include <TEnv.h>
#include <TComplex.h>
#include <TH2D.h>
#include "Math/LorentzVector.h"
using namespace std;
class efficiency
{
public:
/***************test variables*****************/
bool isRead;
/*****************Tree input*******************/
TTree *fChain;
TTree *runChain;
/***********Tree branch vairables**************/
Float_t genWeight;
Double_t genEventSumw;
Bool_t HLT_AK8PFHT800_TrimMass50;
Bool_t HLT_PFHT1050;
Bool_t HLT_PFJet500;
Bool_t HLT_AK8PFJet500;
Bool_t HLT_AK8PFJet400_TrimMass30;
Bool_t HLT_AK8PFJet420_TrimMass30;
UInt_t nGenPart;
UInt_t nFatJet;
UInt_t nJet;
UInt_t nElectron;
UInt_t nMuon;
Int_t GenPart_genPartIdxMother[200];
Int_t GenPart_pdgId[200];
Int_t GenPart_status[200];
Float_t GenPart_mass[200];
Float_t GenPart_pt[200];
Float_t GenPart_eta[200];
Float_t GenPart_phi[200];
Float_t FatJet_eta[200];
Float_t FatJet_pt[200];
Float_t FatJet_phi[200];
Float_t FatJet_mass[200];
Int_t FatJet_jetId[200];
Float_t FatJet_msoftdrop[200];
Float_t FatJet_particleNet_WvsQCD[200];
Float_t FatJet_particleNet_ZvsQCD[200];
Float_t FatJet_particleNet_HbbvsQCD[200];
Float_t FatJet_particleNet_mass[200];
Float_t FatJet_particleNetMD_Xbb[200];
Float_t FatJet_particleNetMD_Xcc[200];
Float_t FatJet_particleNetMD_Xqq[200];
Float_t FatJet_particleNetMD_QCD[200];
Float_t Jet_eta[200];
Float_t Jet_phi[200];
Float_t Jet_pt[200];
Float_t Jet_mass[200];
Float_t Jet_qgl[200];
Float_t Electron_mass[200];
Float_t Electron_pt[200];
Float_t Electron_eta[200];
Float_t Electron_phi[200];
Float_t Electron_deltaEtaSC[200];
Float_t Electron_dxy[200];
Float_t Electron_dz[200];
Float_t Electron_sip3d[200];
Float_t Electron_miniPFRelIso_all[200];
UChar_t Electron_lostHits[200];
Bool_t Electron_mvaFall17V2noIso_WPL[200];
Float_t Muon_mass[200];
Float_t Muon_pt[200];
Float_t Muon_eta[200];
Float_t Muon_phi[200];
Float_t Muon_dxy[200];
Float_t Muon_dz[200];
Float_t Muon_sip3d[200];
Float_t Muon_miniPFRelIso_all[200];
Bool_t Muon_looseId[200];
/***************particle variables***************/
TLorentzVector GenBquarkFromH;
TLorentzVector GenantiBquarkFromH;
TLorentzVector GenHiggs;
TLorentzVector GenVBFJets[2];
TLorentzVector FatJet[200];
TLorentzVector Jet[200];
TLorentzVector Electron[200];
TLorentzVector Muon[200];
/************statistical variables*************/
Int_t Sta_TotalNumber = 0;
Int_t Sta_FileEventNumber;
/*************sorting variables****************/
TLorentzVector FatJet_btagsort[200];
Float_t FatJet_msoftdrop_btagsort[200];
Float_t FatJet_WvsQCD_btagsort[200];
Float_t FatJet_ZvsQCD_btagsort[200];
Float_t FatJet_HbbvsQCD_btagsort[200];
Float_t FatJet_mass_btagsort[200];
Float_t FatJet_Xbb_modified_btagsort[200];
Float_t FatJet_Xcc_btagsort[200];
Float_t FatJet_Xqq_btagsort[200];
Float_t FatJet_QCD_btagsort[200];
Float_t FatJet_Xccqq_modified_btagsort[200];
TLorentzVector FatJet_allsort[200];
Float_t FatJet_msoftdrop_allsort[200];
Float_t FatJet_WvsQCD_allsort[200];
Float_t FatJet_ZvsQCD_allsort[200];
Float_t FatJet_HbbvsQCD_allsort[200];
Float_t FatJet_mass_allsort[200];
Float_t FatJet_Xbb_modified_allsort[200];
Float_t FatJet_Xcc_allsort[200];
Float_t FatJet_Xqq_allsort[200];
Float_t FatJet_QCD_allsort[200];
Float_t FatJet_Xccqq_modified_allsort[200];
/******************functions*******************/
efficiency(const char *infileName, const char *typeName, const char *fileNumber);
virtual ~efficiency();
virtual void Initial(const char *rootName, int rootNumber, const char *typeName);
virtual void Loop(const char *typeName);
virtual void End(int rootNumber);
virtual void Save(int rootNumber);
/********************plots*********************/
makeHists *myHists;
}; // class efficiency definition ends
#endif // end define _EFFICIENCY_H_
#ifdef _EFFICIENCY_C_ // if already defined, then add functions
efficiency::efficiency(const char *infileName, const char *typeName, const char *fileNumber)
{
myHists = new makeHists();
TString histName = "../outfiles/" + (TString)typeName + "_" + (TString)fileNumber + "_selected.root";
myHists->createHists(histName);
}
efficiency::~efficiency() {}
void efficiency::Initial(const char *rootName, int rootNumber, const char *typeName)
{
Sta_FileEventNumber = 0;
cout << "**Running starting Rootfile: " << rootNumber << endl;
TTree *tree;
TFile *file = (TFile *)gROOT->GetListOfFiles()->FindObject(rootName);
if (!file)
file = new TFile(rootName);
tree = (TTree *)gDirectory->Get("Events");
TTree *runtree;
runtree = (TTree *)gDirectory->Get("Runs");
fChain = tree;
runChain = runtree;
isRead = true;
double fileEntries = fChain->GetEntries();
if (fileEntries == 0)
isRead = false;
/***************set branches**************/
if (string(typeName).find(string("data")) == string::npos){
// if it's not data file
runChain->SetBranchAddress("genEventSumw", &genEventSumw);
fChain->SetBranchAddress("genWeight", &genWeight);
fChain->SetBranchAddress("nGenPart", &nGenPart);
fChain->SetBranchAddress("GenPart_pdgId", GenPart_pdgId);
fChain->SetBranchAddress("GenPart_genPartIdxMother", GenPart_genPartIdxMother);
fChain->SetBranchAddress("GenPart_status", GenPart_status);
fChain->SetBranchAddress("GenPart_mass", GenPart_mass);
fChain->SetBranchAddress("GenPart_pt", GenPart_pt);
fChain->SetBranchAddress("GenPart_eta", GenPart_eta);
fChain->SetBranchAddress("GenPart_phi", GenPart_phi);
}
fChain->SetBranchAddress("nFatJet", &nFatJet);
fChain->SetBranchAddress("nJet", &nJet);
fChain->SetBranchAddress("nElectron", &nElectron);
fChain->SetBranchAddress("nMuon", &nMuon);
fChain->SetBranchAddress("HLT_AK8PFHT800_TrimMass50",&HLT_AK8PFHT800_TrimMass50);
fChain->SetBranchAddress("HLT_PFHT1050",&HLT_PFHT1050);
fChain->SetBranchAddress("HLT_PFJet500",&HLT_PFJet500);
fChain->SetBranchAddress("HLT_AK8PFJet500",&HLT_AK8PFJet500);
fChain->SetBranchAddress("HLT_AK8PFJet400_TrimMass30",&HLT_AK8PFJet400_TrimMass30);
fChain->SetBranchAddress("HLT_AK8PFJet420_TrimMass30",&HLT_AK8PFJet420_TrimMass30);
fChain->SetBranchAddress("FatJet_eta", FatJet_eta);
fChain->SetBranchAddress("FatJet_phi", FatJet_phi);
fChain->SetBranchAddress("FatJet_pt", FatJet_pt);
fChain->SetBranchAddress("FatJet_mass", FatJet_mass);
fChain->SetBranchAddress("FatJet_jetId", FatJet_jetId);
fChain->SetBranchAddress("FatJet_msoftdrop", FatJet_msoftdrop);
fChain->SetBranchAddress("FatJet_particleNet_WvsQCD", FatJet_particleNet_WvsQCD);
fChain->SetBranchAddress("FatJet_particleNet_ZvsQCD", FatJet_particleNet_ZvsQCD);
fChain->SetBranchAddress("FatJet_particleNet_HbbvsQCD", FatJet_particleNet_HbbvsQCD);
fChain->SetBranchAddress("FatJet_particleNet_mass", FatJet_particleNet_mass);
fChain->SetBranchAddress("FatJet_particleNetMD_Xbb", FatJet_particleNetMD_Xbb);
fChain->SetBranchAddress("FatJet_particleNetMD_Xcc", FatJet_particleNetMD_Xcc);
fChain->SetBranchAddress("FatJet_particleNetMD_Xqq", FatJet_particleNetMD_Xqq);
fChain->SetBranchAddress("FatJet_particleNetMD_QCD", FatJet_particleNetMD_QCD);
fChain->SetBranchAddress("Jet_eta", Jet_eta);
fChain->SetBranchAddress("Jet_phi", Jet_phi);
fChain->SetBranchAddress("Jet_pt", Jet_pt);
fChain->SetBranchAddress("Jet_mass", Jet_mass);
fChain->SetBranchAddress("Jet_qgl", Jet_qgl);
fChain->SetBranchAddress("Electron_mass", Electron_mass);
fChain->SetBranchAddress("Electron_pt", Electron_pt);
fChain->SetBranchAddress("Electron_eta", Electron_eta);
fChain->SetBranchAddress("Electron_phi", Electron_phi);
fChain->SetBranchAddress("Electron_deltaEtaSC", Electron_deltaEtaSC);
fChain->SetBranchAddress("Electron_dxy", Electron_dxy);
fChain->SetBranchAddress("Electron_dz", Electron_dz);
fChain->SetBranchAddress("Electron_sip3d", Electron_sip3d);
fChain->SetBranchAddress("Electron_miniPFRelIso_all", Electron_miniPFRelIso_all);
fChain->SetBranchAddress("Electron_lostHits", Electron_lostHits);
fChain->SetBranchAddress("Electron_mvaFall17V2noIso_WPL", Electron_mvaFall17V2noIso_WPL);
fChain->SetBranchAddress("Muon_mass", Muon_mass);
fChain->SetBranchAddress("Muon_pt", Muon_pt);
fChain->SetBranchAddress("Muon_eta", Muon_eta);
fChain->SetBranchAddress("Muon_phi", Muon_phi);
fChain->SetBranchAddress("Muon_dxy", Muon_dxy);
fChain->SetBranchAddress("Muon_dz", Muon_dz);
fChain->SetBranchAddress("Muon_sip3d", Muon_sip3d);
fChain->SetBranchAddress("Muon_miniPFRelIso_all", Muon_miniPFRelIso_all);
fChain->SetBranchAddress("Muon_looseId", Muon_looseId);
}
void efficiency::End(int rootNumber)
{
cout << "**Running: Free Rootfile: " << rootNumber << endl;
cout << "*************************" << endl;
cout << "*********outputs*********" << endl;
cout << "Total event number in this file: " << Sta_FileEventNumber << endl;
delete fChain->GetCurrentFile();
}
void efficiency::Save(int rootNumber)
{
cout << "**Running: " << rootNumber << " rootfiles finished" << endl;
cout << "**The files contain " << Sta_TotalNumber << " events" << endl;
if (myHists)
{
myHists->saveHists();
delete myHists;
}
cout << "**Running histograms saved" << endl;
}
#endif // end ifdef _EFFICIENCY_C_