-
Notifications
You must be signed in to change notification settings - Fork 1
/
nanoFakes.h
312 lines (251 loc) · 12.1 KB
/
nanoFakes.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Mon Jul 23 15:59:15 2018 by ROOT version 6.10/09
// from TTree Events/Events
// found on file: /eos/cms/store/group/phys_higgs/cmshww/amassiro/HWWNano/Run2017_nAOD_v1_Study2017/DATAl1loose2017/nanoLatino_DoubleMuon_Run2017C-31Mar2018-v1__part0.root
//////////////////////////////////////////////////////////
#ifndef nanoFakes_h
#define nanoFakes_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TSelector.h>
#include <TTreeReader.h>
#include <TTreeReaderValue.h>
#include <TTreeReaderArray.h>
#include <TH1.h>
#include <TH2.h>
#include <TLorentzVector.h>
enum {
e,
m,
l,
nchannel // This line should be always last
};
const TString schannel[nchannel] = {
"e",
"m",
"l",
};
const TString lchannel[nchannel] = {
"e",
"#mu",
"l",
};
const int njetet = 7;
const Double_t muonjetet[njetet] = {10, 15, 20, 25, 30, 35, 45};
const Double_t elejetet [njetet] = {10, 15, 20, 25, 30, 35, 45};
const int nptbin = 8;
const Double_t ptbins[nptbin+1] = {10, 15, 20, 25, 30, 35, 40, 45, 50};
const int netabin = 5;
const Double_t etabins[netabin+1] = {0, 0.5, 1.0, 1.5, 2.0, 2.5};
//Btag division
const int nbtag = 4;
const TString btags[nbtag] = {"", "bveto", "loose", "mediumtight"};
float btagDown = 0.0;
float btagUp = 1.0;
TString btagDirectory = "";
// Z candidate
int Zlepton1type;
int Zlepton2type;
float Zlepton1idisoW;
float Zlepton2idisoW;
int Zdecayflavour;
float m2l;
enum {Loose, Tight};
enum {
FR_00_QCD,
FR_01_Zpeak,
ncutFR
};
const TString scutFR[ncutFR] = {
"FR/00_QCD",
"FR/01_Zpeak",
};
enum {
PR_00,
ncutPR
};
const TString scutPR[ncutPR] = {
"PR/00",
};
//------------------------------------------------------------------------------
// nanoFakes constructor
//------------------------------------------------------------------------------
class nanoFakes : public TSelector
{
public :
TTreeReader fReader; //!the tree reader
TTree* fChain = 0; //!pointer to the analyzed TTree or TChain
void FillAnalysisHistograms(int icut,
int i);
void FillLevelHistograms (int icut,
int i,
bool pass);
// Fake rate histograms
//---------------------------------------------------------------------------
TH2D* h_Muon_loose_pt_eta_bin[ncutFR][njetet][nbtag];
TH2D* h_Muon_tight_pt_eta_bin[ncutFR][njetet][nbtag];
TH2D* h_Ele_loose_pt_eta_bin [ncutFR][njetet][nbtag];
TH2D* h_Ele_tight_pt_eta_bin [ncutFR][njetet][nbtag];
TH1D* h_Muon_loose_pt_bin[ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_pt_bin[ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_pt_bin [ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_pt_bin [ncutFR][njetet][nbtag];
TH1D* h_Muon_loose_conv_bin[ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_conv_bin[ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_conv_bin [ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_conv_bin [ncutFR][njetet][nbtag];
TH1D* h_Muon_loose_eta_bin[ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_eta_bin[ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_eta_bin [ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_eta_bin [ncutFR][njetet][nbtag];
// Effective luminosity estimation histograms
//---------------------------------------------------------------------------
TH1D* h_Muon_loose_m2l[ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_m2l[ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_m2l [ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_m2l [ncutFR][njetet][nbtag];
TH2D* h_Muon_loose_pt_m2l[ncutFR][njetet][nbtag];
TH2D* h_Muon_tight_pt_m2l[ncutFR][njetet][nbtag];
TH2D* h_Ele_loose_pt_m2l [ncutFR][njetet][nbtag];
TH2D* h_Ele_tight_pt_m2l [ncutFR][njetet][nbtag];
// Yields histograms for getYields.C
//---------------------------------------------------------------------------
TH1D* h_Muon_loose_lowpt [ncutFR][njetet][nbtag];
TH1D* h_Muon_loose_highpt[ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_lowpt [ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_highpt[ncutFR][njetet][nbtag];
TH1D* h_Muon_loose_lowpt_weighted [ncutFR][njetet][nbtag];
TH1D* h_Muon_loose_highpt_weighted[ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_lowpt_weighted [ncutFR][njetet][nbtag];
TH1D* h_Muon_tight_highpt_weighted[ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_lowpt [ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_highpt[ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_lowpt [ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_highpt[ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_lowpt_weighted [ncutFR][njetet][nbtag];
TH1D* h_Ele_loose_highpt_weighted[ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_lowpt_weighted [ncutFR][njetet][nbtag];
TH1D* h_Ele_tight_highpt_weighted[ncutFR][njetet][nbtag];
// Prompt rate histograms
//---------------------------------------------------------------------------
TH2D* h_Muon_loose_pt_eta_PR[ncutPR];
TH2D* h_Muon_tight_pt_eta_PR[ncutPR];
TH2D* h_Ele_loose_pt_eta_PR[ncutPR];
TH2D* h_Ele_tight_pt_eta_PR[ncutPR];
TH1D* h_Muon_loose_pt_PR[ncutPR];
TH1D* h_Muon_tight_pt_PR[ncutPR];
TH1D* h_Ele_loose_pt_PR[ncutPR];
TH1D* h_Ele_tight_pt_PR[ncutPR];
TH1D* h_Muon_loose_eta_PR[ncutPR];
TH1D* h_Muon_tight_eta_PR[ncutPR];
TH1D* h_Ele_loose_eta_PR[ncutPR];
TH1D* h_Ele_tight_eta_PR[ncutPR];
// Readers to access the data (delete the ones you do not need)
//---------------------------------------------------------------------------
TTreeReaderValue<Float_t> baseW;
TTreeReaderValue<Float_t> Xsec;
TTreeReaderValue<Float_t> puWeight;
TTreeReaderValue<Float_t> Generator_weight;
// Common variables for 2016, 2017 and 2018
//---------------------------------------------------------------------------
TTreeReaderValue<UInt_t> nLepton = {fReader, "nLepton"};
TTreeReaderArray<Int_t> Lepton_pdgId = {fReader, "Lepton_pdgId"};
TTreeReaderArray<Float_t> Lepton_pt = {fReader, "Lepton_pt"};
//TTreeReaderArray<Float_t> Electron_lostHits = {fReader, "Electron_lostHits"};
TTreeReaderArray<Float_t> Lepton_eta = {fReader, "Lepton_eta"};
TTreeReaderArray<Float_t> Lepton_phi = {fReader, "Lepton_phi"};
TTreeReaderArray<Float_t> Jet_btagDeepB = {fReader, "Jet_btagDeepB"};
TTreeReaderArray<Int_t> Lepton_muonIdx = {fReader, "Lepton_muonIdx"};
TTreeReaderArray<Int_t> Muon_jetIdx = {fReader, "Muon_jetIdx"};
TTreeReaderArray<Int_t> Lepton_electronIdx = {fReader, "Lepton_electronIdx"};
TTreeReaderArray<Int_t> Electron_jetIdx = {fReader, "Electron_jetIdx"};
TTreeReaderValue<UInt_t> nCleanJet = {fReader, "nCleanJet"};
TTreeReaderArray<Float_t> CleanJet_pt = {fReader, "CleanJet_pt"};
TTreeReaderArray<Float_t> CleanJet_eta = {fReader, "CleanJet_eta"};
TTreeReaderArray<Float_t> CleanJet_phi = {fReader, "CleanJet_phi"};
TTreeReaderValue<Float_t> mtw1 = {fReader, "mtw1"};
TTreeReaderValue<Float_t> PuppiMET_pt = {fReader, "PuppiMET_pt"};
TTreeReaderValue<Float_t> dphilep1jet1 = {fReader, "dphilep1jet1"};
TTreeReaderValue<Float_t> Electron_pfRelIso03_all = {fReader, "Electron_pfRelIso03_all"};
TTreeReaderValue<Bool_t> HLT_Mu8_TrkIsoVVL = {fReader, "HLT_Mu8_TrkIsoVVL"};
TTreeReaderValue<Bool_t> HLT_Mu17_TrkIsoVVL = {fReader, "HLT_Mu17_TrkIsoVVL"};
TTreeReaderValue<Bool_t> HLT_Ele8_CaloIdL_TrackIdL_IsoVL_PFJet30 = {fReader, "HLT_Ele8_CaloIdL_TrackIdL_IsoVL_PFJet30"};
TTreeReaderValue<Bool_t> HLT_Ele12_CaloIdL_TrackIdL_IsoVL_PFJet30 = {fReader, "HLT_Ele12_CaloIdL_TrackIdL_IsoVL_PFJet30"};
TTreeReaderValue<Bool_t> HLT_Ele23_CaloIdL_TrackIdL_IsoVL_PFJet30 = {fReader, "HLT_Ele23_CaloIdL_TrackIdL_IsoVL_PFJet30"};
//Different electron and muon working points
//---------------------------------------------------------------------------
// 2016
TTreeReaderArray<Int_t> muonTightWP = {fReader, "Lepton_isTightMuon_cut_Tight80x"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_cut_WP_Tight80X"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_cut_WP_Tight80X_SS"};
TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_mva_90p_Iso2016_SS"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_cut_WP_Tight80X"};
//TTreeReaderArray<Bool_t> Lepton_isTightElectron_cut_WP_Tight80X_SS;
//TTreeReaderArray<Bool_t> Lepton_isTightElectron_mva_90p_Iso2016;
// 2017
//TTreeReaderArray<Int_t> Lepton_isTightMuon_cut_Tight_HWWW = {fReader, "Lepton_isTightMuon_cut_Tight_HWWW"};
//TTreeReaderArray<Int_t> Lepton_isTightMuon_cut_Tight_HWWW;
//TTreeReaderArray<Int_t> Lepton_isTightElectron_mvaFall17Iso_WP90 = {fReader, "Lepton_isTightElectron_mvaFall17Iso_WP90"};
//TTreeReaderArray<Int_t> Lepton_isTightElectron_mvaFall17Iso_WP90;
//TTreeReaderArray<Int_t> muonTightWP = {fReader, "Lepton_isTightMuon_cut_Tight_HWWW"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_mvaFall17Iso_WP90"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Electron_cutBased_Fall17_V1"};
// 2018
//TTreeReaderArray<Int_t> muonTightWP = {fReader, "Lepton_isTightMuon_cut_Tight_HWWW"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_mvaFall17V1Iso_WP90"};
//TTreeReaderArray<Int_t> muonTightWP = {fReader, "Lepton_isTightMuon_cut_Tight_HWWW"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_mvaFall17V1Iso_WP90"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_mvaFall17V1Iso_WP90_SS"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_mvaFall17V2Iso_WP90"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_mvaFall17V2Iso_WP90_SS"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_cutFall17V1Iso_Tight"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_cutFall17V1Iso_Tight_SS"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_cutFall17V2Iso_Tight"};
//TTreeReaderArray<Int_t> eleTightWP = {fReader, "Lepton_isTightElectron_cutFall17V2Iso_Tight_SS"};
nanoFakes(TTree * /*tree*/ =0) { }
virtual ~nanoFakes() { }
virtual Int_t Version() const { return 2; }
virtual void Begin(TTree *tree);
virtual void SlaveBegin(TTree *tree);
virtual void Init(TTree *tree);
virtual Bool_t Notify();
virtual Bool_t Process(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
virtual void SetOption(const char *option) { fOption = option; }
virtual void SetObject(TObject *obj) { fObject = obj; }
virtual void SetInputList(TList *input) { fInput = input; }
virtual TList *GetOutputList() const { return fOutput; }
virtual void SlaveTerminate();
virtual void Terminate();
ClassDef(nanoFakes,0);
};
#endif
#ifdef nanoFakes_cxx
//------------------------------------------------------------------------------
// Init
//------------------------------------------------------------------------------
void nanoFakes::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the reader is initialized.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
fReader.SetTree(tree);
}
//------------------------------------------------------------------------------
// Notify
//------------------------------------------------------------------------------
Bool_t nanoFakes::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
return kTRUE;
}
#endif // #ifdef nanoFakes_cxx