-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuxiliary.cpp
executable file
·253 lines (235 loc) · 8.8 KB
/
Auxiliary.cpp
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
#ifndef Auxiliary_cpp
#define Auxiliary_cpp
#include <iostream>
#include"Histodef.cpp"
// inputs are: size of arrays GenID and GenPar
// the pointer at the start of the array of GenParticles_PDGID
// the pointer at the start of the array of GenParticles_Parent
// initialID: last index of the particle (ex: Electron_genPartIdx[j]=initialID)
// should be called from func as isFromW(MAX_ARRAY_SIZE,GenPart_pdgId,GenPart_genPartIdxMother,Electron_genPartIdx[j])
//arguments: (array of PdgID of Gen Particles (Int_t), array of GenParent of Gen Particles (Int_t, contains the index to the parent of the selected GenParticle
// InitialID is the index of the starting muon in the GenParticles array)
bool isFromW(int size, Int_t *GenId, Int_t *GenParent, int initialID)
{
if (initialID < 0)
{
return false;
}
// retrieve first PDG ID number
int startPdg = GenId[initialID];
int newID = initialID, newPdg = startPdg;
// look for the parent; if the parent is of same PDGID of starting particle, iterate until parent is different particle
while (newPdg == startPdg)
{
if (newID > size)
{
std::cout << "WARNING: index " << newID << " exceeding max size " << size << std::endl;
}
newID = GenParent[newID];
newPdg = GenId[newID];
if (abs(newPdg) == 24)
return true;
}
return false;
}
bool isFromTau(int size, Int_t *GenId, Int_t *GenParent, int initialID)
{
if (initialID < 0)
{
return false;
}
// retrieve first PDG ID number
int startPdg = GenId[initialID];
int newID = initialID, newPdg = startPdg;
// look for the parent; if the parent is of same PDGID of starting particle, iterate until parent is different particle
while (newPdg == startPdg)
{
if (newID > size)
{
std::cout << "WARNING: index " << newID << " exceeding max size " << size << std::endl;
}
newID = GenParent[newID];
newPdg = GenId[newID];
if (abs(newPdg) == 15)
return true;
}
return false;
}
double InvertPhi(double phi){
double invphi=phi+M_PI;
if (invphi>M_PI){invphi=invphi-2*M_PI;}
return invphi;
}
float getTopPtWeight(Int_t * pdgId,Int_t *statusFlags,Float_t * pt, Int_t Ngen) {
float wgt=1.0;
//lastcopy is signalled by the 13th bit: (statusFlags >> 13 ) & 0x1 == (statusFlags/8192)%2
//auto topquarks_lastcopy = ROOT::VecOps::Nonzero( abs(pdgId)==6 && ((statusFlags/8192)%2) );
vector<Int_t> topquarks_lastcopy;
for(Int_t i=0;i<Ngen;i++){
if(abs(pdgId[i])==6 && ((statusFlags[i]/8192)%2))
topquarks_lastcopy.push_back(i);
}
if(topquarks_lastcopy.size()!=2) return wgt;
//NNLO / NLO SF parameterization
for(auto i : topquarks_lastcopy) {
wgt *= 0.103 * exp(-0.0118 * pt[i]) - 0.000134 * pt[i] + 0.973;
}
return sqrt(wgt);
}
void HistIniz(){
// Define the histogram objects with TAU with 1 PRONG
h_Tau_pt_p1->Sumw2();
h_Tau_eta_p1->Sumw2();
h_Electron_pt_p1->Sumw2();
h_Electron_eta_p1->Sumw2();
h_Tau_pt_weighted_p1->Sumw2();
h_Tau_eta_weighted_p1->Sumw2();
h_Electron_pt_weighted_p1->Sumw2();
h_Electron_eta_weighted_p1->Sumw2();
h_Tau_Electron_invariant_mass_p1->Sumw2();
h_Tau_Electron_invariant_mass_weighted_p1->Sumw2();
h_leading_lepton_pt_p1->Sumw2();
h_leading_lepton_pt_weighted_p1->Sumw2();
h_NJets_p1->Sumw2();
h_LooseJets_p1->Sumw2();
h_MediumJets_p1->Sumw2();
h_TightJets_p1->Sumw2();
h_dR_allJets_p1->Sumw2();
h_dR_lbJets_p1->Sumw2();
h_dR_mbJets_p1->Sumw2();
h_Apl_allJets_p1->Sumw2();
h_Apl_lbJets_p1->Sumw2();
h_Apl_mbJets_p1->Sumw2();
h_Phi_allJets_p1->Sumw2();
h_Phi_lbJets_p1->Sumw2();
h_Phi_mbJets_p1->Sumw2();
h_acopla_etau_p1->Sumw2();
// Define the histogram objects with TAU with 3 PRONGS
h_Tau_pt_p3->Sumw2();
h_Tau_eta_p3->Sumw2();
h_Electron_pt_p3->Sumw2();
h_Electron_eta_p3->Sumw2();
h_Tau_pt_weighted_p3->Sumw2();
h_Tau_eta_weighted_p3->Sumw2();
h_Electron_pt_weighted_p3->Sumw2();
h_Electron_eta_weighted_p3->Sumw2();
h_Tau_Electron_invariant_mass_p3->Sumw2();
h_Tau_Electron_invariant_mass_weighted_p3->Sumw2();
h_leading_lepton_pt_p3->Sumw2();
h_leading_lepton_pt_weighted_p3->Sumw2();
h_NJets_p3->Sumw2();
h_LooseJets_p3->Sumw2();
h_MediumJets_p3->Sumw2();
h_TightJets_p3->Sumw2();
h_dR_allJets_p3->Sumw2();
h_dR_lbJets_p3->Sumw2();
h_dR_mbJets_p3->Sumw2();
h_Apl_allJets_p3->Sumw2();
h_Apl_lbJets_p3->Sumw2();
h_Apl_mbJets_p3->Sumw2();
h_Phi_allJets_p3->Sumw2();
h_Phi_lbJets_p3->Sumw2();
h_Phi_mbJets_p3->Sumw2();
h_acopla_etau_p3->Sumw2();
h_Electron_pt_from_W->Sumw2();
h_Electron_eta_from_W->Sumw2();
h_Electron_pt_weighted_from_W->Sumw2();
h_Electron_eta_weighted_from_W->Sumw2();
h_Tau_pt_from_W->Sumw2();
h_Tau_eta_from_W->Sumw2();
h_Tau_pt_weighted_from_W->Sumw2();
h_Tau_eta_weighted_from_W->Sumw2();
h_e_3dsig->Sumw2();
h_e_3d->Sumw2();
h_e_dxy->Sumw2();
b_pt_p1->Sumw2();
jethole_p1->Sumw2();
ehole_p1->Sumw2();
b_pt_p3->Sumw2();
jethole_p3->Sumw2();
ehole_p3->Sumw2();
tauhole_p1->Sumw2();
tauhole_p3->Sumw2();
}
void HistWrite(){
h_Electron_pt_weighted_p1->SetBinContent(h_Electron_pt_weighted_p1->GetNbinsX(), h_Electron_pt_weighted_p1->GetBinContent(h_Electron_pt_weighted_p1->GetNbinsX()) + h_Electron_pt_weighted_p1->GetBinContent(h_Electron_pt_weighted_p1->GetNbinsX() + 1));
h_Electron_pt_weighted_p3->SetBinContent(h_Electron_pt_weighted_p3->GetNbinsX(), h_Electron_pt_weighted_p3->GetBinContent(h_Electron_pt_weighted_p3->GetNbinsX()) + h_Electron_pt_weighted_p3->GetBinContent(h_Electron_pt_weighted_p3->GetNbinsX() + 1));
h_Tau_pt_weighted_p1->SetBinContent(h_Tau_pt_weighted_p1->GetNbinsX(), h_Tau_pt_weighted_p1->GetBinContent(h_Tau_pt_weighted_p1->GetNbinsX()) + h_Tau_pt_weighted_p1->GetBinContent(h_Tau_pt_weighted_p1->GetNbinsX() + 1));
h_Tau_pt_weighted_p3->SetBinContent(h_Tau_pt_weighted_p3->GetNbinsX(), h_Tau_pt_weighted_p3->GetBinContent(h_Tau_pt_weighted_p3->GetNbinsX()) + h_Tau_pt_weighted_p3->GetBinContent(h_Tau_pt_weighted_p3->GetNbinsX() + 1));
h_Tau_Electron_invariant_mass_weighted_p1->SetBinContent(h_Tau_Electron_invariant_mass_weighted_p1->GetNbinsX(), h_Tau_Electron_invariant_mass_weighted_p1->GetBinContent(h_Tau_Electron_invariant_mass_weighted_p1->GetNbinsX()) + h_Tau_Electron_invariant_mass_weighted_p1->GetBinContent(h_Tau_Electron_invariant_mass_weighted_p1->GetNbinsX() + 1));
h_Tau_Electron_invariant_mass_weighted_p3->SetBinContent(h_Tau_Electron_invariant_mass_weighted_p3->GetNbinsX(), h_Tau_Electron_invariant_mass_weighted_p3->GetBinContent(h_Tau_Electron_invariant_mass_weighted_p3->GetNbinsX()) + h_Tau_Electron_invariant_mass_weighted_p3->GetBinContent(h_Tau_Electron_invariant_mass_weighted_p3->GetNbinsX() + 1));
// Define the histogram objects with TAU with 1 PRONG
h_Tau_pt_p1->Write();
h_Tau_eta_p1->Write();
h_Electron_pt_p1->Write();
h_Electron_eta_p1->Write();
h_Tau_pt_weighted_p1->Write();
h_Tau_eta_weighted_p1->Write();
h_Electron_pt_weighted_p1->Write();
h_Electron_eta_weighted_p1->Write();
h_Tau_Electron_invariant_mass_p1->Write();
h_Tau_Electron_invariant_mass_weighted_p1->Write();
h_leading_lepton_pt_p1->Write();
h_leading_lepton_pt_weighted_p1->Write();
h_NJets_p1->Write();
h_LooseJets_p1->Write();
h_MediumJets_p1->Write();
h_TightJets_p1->Write();
h_dR_allJets_p1->Write();
h_dR_lbJets_p1->Write();
h_dR_mbJets_p1->Write();
h_Apl_allJets_p1->Write();
h_Apl_lbJets_p1->Write();
h_Apl_mbJets_p1->Write();
h_Phi_allJets_p1->Write();
h_Phi_lbJets_p1->Write();
h_Phi_mbJets_p1->Write();
h_acopla_etau_p1->Write();
// Define the histogram objects with TAU with 3 PRONGS
h_Tau_pt_p3->Write();
h_Tau_eta_p3->Write();
h_Electron_pt_p3->Write();
h_Electron_eta_p3->Write();
h_Tau_pt_weighted_p3->Write();
h_Tau_eta_weighted_p3->Write();
h_Electron_pt_weighted_p3->Write();
h_Electron_eta_weighted_p3->Write();
h_Tau_Electron_invariant_mass_p3->Write();
h_Tau_Electron_invariant_mass_weighted_p3->Write();
h_leading_lepton_pt_p3->Write();
h_leading_lepton_pt_weighted_p3->Write();
h_NJets_p3->Write();
h_LooseJets_p3->Write();
h_MediumJets_p3->Write();
h_TightJets_p3->Write();
h_dR_allJets_p3->Write();
h_dR_lbJets_p3->Write();
h_dR_mbJets_p3->Write();
h_Apl_allJets_p3->Write();
h_Apl_lbJets_p3->Write();
h_Apl_mbJets_p3->Write();
h_Phi_allJets_p3->Write();
h_Phi_lbJets_p3->Write();
h_Phi_mbJets_p3->Write();
h_acopla_etau_p3->Write();
h_Electron_pt_from_W->Write();
h_Electron_eta_from_W->Write();
h_Electron_pt_weighted_from_W->Write();
h_Electron_eta_weighted_from_W->Write();
h_Tau_pt_from_W->Write();
h_Tau_eta_from_W->Write();
h_Tau_pt_weighted_from_W->Write();
h_Tau_eta_weighted_from_W->Write();
h_e_3dsig->Write();
h_e_3d->Write();
h_e_dxy->Write();
b_pt_p1->Write();
jethole_p1->Write();
ehole_p1->Write();
tauhole_p1->Write();
b_pt_p3->Write();
jethole_p3->Write();
ehole_p3->Write();
tauhole_p3->Write();
}
#endif // Auxiliary_cpp