-
Notifications
You must be signed in to change notification settings - Fork 3
/
Stop_TopChi0_Reweighting.C
455 lines (358 loc) · 18.4 KB
/
Stop_TopChi0_Reweighting.C
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/////// ##### Stop -> top neutralino reweighting and utilitites #####
/////// J. Alcaraz, B. De La Cruz (CMS, June 2013)
#include "TROOT.h"
#include "TLorentzVector.h"
struct SUSYGenParticle { // To be filled with status-3 genParticles
int pdgId; // PDG identifier (with sign, please)
int firstMother; // first mother, set to <0 if no mothers
double energy; // energy [GeV]
double pt; // pt [GeV]
double eta; // eta
double phi; // phi
};
///////////////////////////////////////////////////////
// RECOMMENDED CODE ---------------------------------->
///////////////////////////////////////////////////////
// Get theta effective mixing for a given top polarization hypothesis
// The result also depends on the stop, top and chi0 mass hypotheses
// Also valid for an off-shell scenario
double GetThetaMixing(double topPol, double m_stop, double m_top, double m_chi0) {
double p_chi0 = sqrt(pow(m_top*m_top+m_chi0*m_chi0-m_stop*m_stop,2)/4 - pow(m_top*m_chi0,2))/m_stop;
double e_chi0 = sqrt(p_chi0*p_chi0+m_chi0*m_chi0);
double sqrPol = 0.; if (fabs(topPol)<1) sqrPol = sqrt(1-topPol*topPol);
double tanThetaEff = (p_chi0*sqrPol-m_chi0*topPol)/(topPol*e_chi0+p_chi0);
// This is also a valid solution leading to the same top polarization value
//double tanThetaEff = (-p_chi0*sqrPol-m_chi0*topPol)/(topPol*e_chi0+p_chi0);
return atan(tanThetaEff);
}
// Get the top polarization given an effective theta mixing hypothesis
// The result also depends on the stop, top and chi0 mass hypotheses
// Also valid for an off-shell scenario
double GetTopPolarization(double thetaMixing, double m_stop, double m_top, double m_chi0) {
double p_chi0 = sqrt(pow(m_top*m_top+m_chi0*m_chi0-m_stop*m_stop,2)/4 - pow(m_top*m_chi0,2))/m_stop;
double e_chi0 = sqrt(p_chi0*p_chi0+m_chi0*m_chi0);
double pol = p_chi0*cos(2*thetaMixing)/(e_chi0+m_chi0*sin(2*thetaMixing));
return pol;
}
// The following reweighting makes sense in all cases (OFF-SHELL CASE TOO)
// It assumes isotropy for the reference MC and any SUSY scenario as target
// (via a thetaMixingTarget input)
double Reweight_Stop_to_TopChi0_with_SUSYmodel (std::vector<SUSYGenParticle> genParticles, double thetaMixingTarget, double TOPMASS_REF=172.5) {
double weight = 1.;
unsigned int ngen = genParticles.size();
for (unsigned int ig=0; ig<ngen; ++ig) {
const SUSYGenParticle& gen = genParticles[ig];
if (gen.firstMother<0) continue;
if (abs(gen.pdgId)>20) continue; // expect quarks or leptons from W decay
// Navigate upwards in the stop->top->W->fermion decay chain
const SUSYGenParticle& genW = genParticles[gen.firstMother];
if (genW.firstMother<0) continue;
if (abs(genW.pdgId)!=24) continue;
const SUSYGenParticle& genTop = genParticles[genW.firstMother];
if (abs(genTop.pdgId)!=6) continue;
// We only care about the down-type fermion
if (genTop.pdgId*gen.pdgId>0) continue;
// We also need a stop
if (genTop.firstMother<0) continue;
const SUSYGenParticle& genStop = genParticles[genTop.firstMother];
if (abs(genStop.pdgId)!=1000006) continue;
TLorentzVector top4;
top4.SetPtEtaPhiE(genTop.pt, genTop.eta, genTop.phi, genTop.energy);
TLorentzVector ferm4;
ferm4.SetPtEtaPhiE(gen.pt, gen.eta, gen.phi, gen.energy);
// Get the neutralino
int igstop = genTop.firstMother;
int igchi0 = -1;
TLorentzVector chi04;
for (unsigned int ig=igstop+1; ig<ngen; ++ig) { // assume chi0 comes later
// Move chi0 to the stop rest frame
const SUSYGenParticle& genChi0 = genParticles[ig];
if (genChi0.firstMother!=igstop) continue;
if (abs(genChi0.pdgId)!=1000022) continue;
igchi0 = ig;
chi04.SetPtEtaPhiE(genChi0.pt, genChi0.eta, genChi0.phi, genChi0.energy);
break;
}
if (igchi0<0) continue;
// Determine weight according to model
double cX = cos(thetaMixingTarget);
double sX = sin(thetaMixingTarget);
double coeffTop = 2*sX*sX*(chi04*top4) + 2*sX*cX*chi04.M()*TOPMASS_REF;
double coeffChi = pow(cX*TOPMASS_REF,2) - pow(sX*top4.M(),2);
double coeffNorm = (chi04*top4)*(sX*sX+cX*cX*pow(TOPMASS_REF/top4.M(),2)) + 2*sX*cX*chi04.M()*TOPMASS_REF;
weight *= (coeffTop*(ferm4*top4)+coeffChi*(ferm4*chi04))/(coeffNorm*(ferm4*top4));
}
return weight;
};
// The following reweighting only makes sense for on-shell stop, top and chi0
// In the off-shell case top and anti-top may get very different polarizations
double Reweight_Stop_to_TopChi0_TopOnshell (std::vector<SUSYGenParticle> genParticles, double referenceTopPolarization, double requestedTopPolarization) {
double weight = 1.;
unsigned int ngen = genParticles.size();
for (unsigned int ig=0; ig<ngen; ++ig) {
const SUSYGenParticle& gen = genParticles[ig];
if (gen.firstMother<0) continue;
if (abs(gen.pdgId)>20) continue; // expect quarks or leptons from W decay
// Navigate upwards in the stop->top->W->fermion decay chain
const SUSYGenParticle& genW = genParticles[gen.firstMother];
if (genW.firstMother<0) continue;
if (abs(genW.pdgId)!=24) continue;
const SUSYGenParticle& genTop = genParticles[genW.firstMother];
if (abs(genTop.pdgId)!=6) continue;
// We only care about the down-type fermion
if (genTop.pdgId*gen.pdgId>0) continue;
// We also need a stop
if (genTop.firstMother<0) continue;
const SUSYGenParticle& genStop = genParticles[genTop.firstMother];
if (abs(genStop.pdgId)!=1000006) continue;
// Move top and fermion to the stop center-of-mass frame
TLorentzVector stop4;
stop4.SetPtEtaPhiE(genStop.pt, genStop.eta, genStop.phi, genStop.energy);
TVector3 betaV(-stop4.Px()/stop4.Energy(),-stop4.Py()/stop4.Energy(),-stop4.Pz()/stop4.Energy());
TLorentzVector top4;
top4.SetPtEtaPhiE(genTop.pt, genTop.eta, genTop.phi, genTop.energy);
top4.Boost(betaV);
TLorentzVector ferm4;
ferm4.SetPtEtaPhiE(gen.pt, gen.eta, gen.phi, gen.energy);
ferm4.Boost(betaV);
// Do not reweight if by any reason top/fermion directions are undefined
// This should be pathological if things are fine
if (top4.P()<=0 || ferm4.P()<=0) {
printf("Warning: particles at rest, no weight applied: ptop: %.3e, pf: %.3e\n", top4.P(), ferm4.P());
continue;
}
double costh = (top4.Px()*ferm4.Px()+top4.Py()*ferm4.Py()+top4.Pz()*ferm4.Pz())/top4.P()/ferm4.P();
double weight_L = (top4.Energy()+top4.P())*(1-costh);
double weight_R = (top4.Energy()-top4.P())*(1+costh);
weight *= ((1+requestedTopPolarization)*weight_R+(1-requestedTopPolarization)*weight_L)/((1+referenceTopPolarization)*weight_R+(1-referenceTopPolarization)*weight_L);
}
return weight;
};
///////////////////////////////////////////////////////
//// ADDITIONAL CODE --------------------------------->
///////////////////////////////////////////////////////
// This function estimates the average polarization in the event
// for a given thetaMixingEffective scenario. We note that
// top and (-)antitop polarizations only coincide for narrow stop, top, chi0 masses
// I.e., the function only makes full sense for an on-shell case with narrow widths
double AverageTopPolarization_Stop_to_TopChi0(double thetaMixing, std::vector<SUSYGenParticle> genParticles) {
double pol1 = 0.;
double pol2 = 0.;
unsigned int ngen = genParticles.size();
for (unsigned int ig=0; ig<ngen; ++ig) {
// Find the stop
const SUSYGenParticle& genStop = genParticles[ig];
if (abs(genStop.pdgId)!=1000006) continue; // find the stop
int igstop = ig;
TLorentzVector stop4;
stop4.SetPtEtaPhiE(genStop.pt, genStop.eta, genStop.phi, genStop.energy);
TVector3 betaV(-stop4.Px()/stop4.Energy(),-stop4.Py()/stop4.Energy(),-stop4.Pz()/stop4.Energy());
for (unsigned int ig=igstop+1; ig<ngen; ++ig) { // assume chi0 comes later
// Move chi0 to the stop rest frame
const SUSYGenParticle& genChi0 = genParticles[ig];
if (genChi0.firstMother!=igstop) continue;
if (abs(genChi0.pdgId)!=1000022) continue;
TLorentzVector chi04;
chi04.SetPtEtaPhiE(genChi0.pt, genChi0.eta, genChi0.phi, genChi0.energy);
chi04.Boost(betaV);
if (genParticles[igstop].pdgId>0) {
pol1 = chi04.P()*cos(2*thetaMixing)/(chi04.Energy()+chi04.M()*sin(2*thetaMixing));
} else {
pol2 = chi04.P()*cos(2*thetaMixing)/(chi04.Energy()+chi04.M()*sin(2*thetaMixing));
}
break;
}
}
return (pol1+pol2)/2;
}
// The following reweighting makes sense in all cases, BUT OFF-SHELL TOPs
// It assumes isotropy for the reference MC and any SUSY scenario as target
// (via a thetaMixingTarget input)
double Reweight_Stop_to_TopChi0_TopOnshell_with_SUSYmodel (std::vector<SUSYGenParticle> genParticles, double thetaMixingTarget) {
double weight = 1.;
unsigned int ngen = genParticles.size();
for (unsigned int ig=0; ig<ngen; ++ig) {
const SUSYGenParticle& gen = genParticles[ig];
if (gen.firstMother<0) continue;
if (abs(gen.pdgId)>20) continue; // expect quarks or leptons from W decay
// Navigate upwards in the stop->top->W->fermion decay chain
const SUSYGenParticle& genW = genParticles[gen.firstMother];
if (genW.firstMother<0) continue;
if (abs(genW.pdgId)!=24) continue;
const SUSYGenParticle& genTop = genParticles[genW.firstMother];
if (abs(genTop.pdgId)!=6) continue;
// We only care about the down-type fermion
if (genTop.pdgId*gen.pdgId>0) continue;
// We also need a stop
if (genTop.firstMother<0) continue;
const SUSYGenParticle& genStop = genParticles[genTop.firstMother];
if (abs(genStop.pdgId)!=1000006) continue;
// Move top and fermion to the stop center-of-mass frame
TLorentzVector stop4;
stop4.SetPtEtaPhiE(genStop.pt, genStop.eta, genStop.phi, genStop.energy);
TVector3 betaV(-stop4.Px()/stop4.Energy(),-stop4.Py()/stop4.Energy(),-stop4.Pz()/stop4.Energy());
int igstop = genTop.firstMother;
int igchi0 = -1;
TLorentzVector chi04;
for (unsigned int ig=igstop+1; ig<ngen; ++ig) { // assume chi0 comes later
// Move chi0 to the stop rest frame
const SUSYGenParticle& genChi0 = genParticles[ig];
if (genChi0.firstMother!=igstop) continue;
if (abs(genChi0.pdgId)!=1000022) continue;
igchi0 = ig;
chi04.SetPtEtaPhiE(genChi0.pt, genChi0.eta, genChi0.phi, genChi0.energy);
chi04.Boost(betaV);
break;
}
if (igchi0<0) continue;
// Determine top polarization in this decay according to model
double topPolarization = chi04.P()*cos(2*thetaMixingTarget)/(chi04.Energy()+chi04.M()*sin(2*thetaMixingTarget));
/*
if (genTop.pdgId>0) {
printf("Top polarization: %.3f\n", topPolarization);
} else {
printf("Antitop polarization: %.3f\n", -topPolarization);
}
*/
TLorentzVector top4;
top4.SetPtEtaPhiE(genTop.pt, genTop.eta, genTop.phi, genTop.energy);
top4.Boost(betaV);
TLorentzVector ferm4;
ferm4.SetPtEtaPhiE(gen.pt, gen.eta, gen.phi, gen.energy);
ferm4.Boost(betaV);
// Do not reweight if by any reason top/fermion directions are undefined
// This should be pathological if things are fine
if (top4.P()<=0 || ferm4.P()<=0) {
printf("Warning: particles at rest, no weight applied: ptop: %.3e, pf: %.3e\n", top4.P(), ferm4.P());
continue;
}
double costh = (top4.Px()*ferm4.Px()+top4.Py()*ferm4.Py()+top4.Pz()*ferm4.Pz())/top4.P()/ferm4.P();
double weight_L = (top4.Energy()+top4.P())*(1-costh);
double weight_R = (top4.Energy()-top4.P())*(1+costh);
weight *= ((1+topPolarization)*weight_R+(1-topPolarization)*weight_L)/(weight_R+weight_L);
}
return weight;
};
// The following reweighting only makes sense in the TOP ON-SHELL case
// It goes from a SUSY MC generated with thetaMixingReference to another
// SUSY MC scenario with thetaMixingTarget
double Reweight_Stop_to_TopChi0_TopOnshell_with_SUSYmodel (std::vector<SUSYGenParticle> genParticles, double thetaMixingReference, double thetaMixingTarget) {
double weight = 1.;
unsigned int ngen = genParticles.size();
for (unsigned int ig=0; ig<ngen; ++ig) {
const SUSYGenParticle& gen = genParticles[ig];
if (gen.firstMother<0) continue;
if (abs(gen.pdgId)>20) continue; // expect quarks or leptons from W decay
// Navigate upwards in the stop->top->W->fermion decay chain
const SUSYGenParticle& genW = genParticles[gen.firstMother];
if (genW.firstMother<0) continue;
if (abs(genW.pdgId)!=24) continue;
const SUSYGenParticle& genTop = genParticles[genW.firstMother];
if (abs(genTop.pdgId)!=6) continue;
// We only care about the down-type fermion
if (genTop.pdgId*gen.pdgId>0) continue;
// We also need a stop
if (genTop.firstMother<0) continue;
const SUSYGenParticle& genStop = genParticles[genTop.firstMother];
if (abs(genStop.pdgId)!=1000006) continue;
// Move top and fermion to the stop center-of-mass frame
TLorentzVector stop4;
stop4.SetPtEtaPhiE(genStop.pt, genStop.eta, genStop.phi, genStop.energy);
TVector3 betaV(-stop4.Px()/stop4.Energy(),-stop4.Py()/stop4.Energy(),-stop4.Pz()/stop4.Energy());
int igstop = genTop.firstMother;
int igchi0 = -1;
TLorentzVector chi04;
for (unsigned int ig=igstop+1; ig<ngen; ++ig) { // assume chi0 comes later
// Move chi0 to the stop rest frame
const SUSYGenParticle& genChi0 = genParticles[ig];
if (genChi0.firstMother!=igstop) continue;
if (abs(genChi0.pdgId)!=1000022) continue;
igchi0 = ig;
chi04.SetPtEtaPhiE(genChi0.pt, genChi0.eta, genChi0.phi, genChi0.energy);
chi04.Boost(betaV);
break;
}
if (igchi0<0) continue;
// Determine top polarization in this decay according to models
double topPolarizationReference = chi04.P()*cos(2*thetaMixingReference)/(chi04.Energy()+chi04.M()*sin(2*thetaMixingReference));
double topPolarizationTarget = chi04.P()*cos(2*thetaMixingTarget)/(chi04.Energy()+chi04.M()*sin(2*thetaMixingTarget));
/*
if (genTop.pdgId>0) {
printf("Top polarization: %.3f\n", topPolarization);
} else {
printf("Antitop polarization: %.3f\n", -topPolarization);
}
*/
TLorentzVector top4;
top4.SetPtEtaPhiE(genTop.pt, genTop.eta, genTop.phi, genTop.energy);
top4.Boost(betaV);
TLorentzVector ferm4;
ferm4.SetPtEtaPhiE(gen.pt, gen.eta, gen.phi, gen.energy);
ferm4.Boost(betaV);
// Do not reweight if by any reason top/fermion directions are undefined
// This should be pathological if things are fine
if (top4.P()<=0 || ferm4.P()<=0) {
printf("Warning: particles at rest, no weight applied: ptop: %.3e, pf: %.3e\n", top4.P(), ferm4.P());
continue;
}
double costh = (top4.Px()*ferm4.Px()+top4.Py()*ferm4.Py()+top4.Pz()*ferm4.Pz())/top4.P()/ferm4.P();
double weight_L = (top4.Energy()+top4.P())*(1-costh);
double weight_R = (top4.Energy()-top4.P())*(1+costh);
weight *= ((1+topPolarizationTarget)*weight_R+(1-topPolarizationTarget)*weight_L)/((1+topPolarizationReference)*weight_R+(1-topPolarizationReference)*weight_L);
}
return weight;
};
// The following reweighting makes sense in all cases (OFF-SHELL CASE TOO)
// It assumes isotropy for the reference MC and any SUSY scenario as target
// (via a thetaMixingTarget input)
// WARNING: THIS REWEIGHTING DoeS NOT CONSERVE NORMALIZATION. SO IT REQUIRES
// AN ADDITIONAL FACTOR THAT CAN BE OBTAINED BY CALCULATING THE AVERAGE OF WEIGHTS
// OVER THE WHOLE MC SAMPLE WITHOUT CUTS: contact J.A. if you want/need to
// use it but you do not understand what this warning means...
double Reweight_Stop_to_TopChi0_with_SUSYmodel_ExactBW (std::vector<SUSYGenParticle> genParticles, double thetaMixingTarget, double TOPMASS_REF) {
double weight = 1.;
unsigned int ngen = genParticles.size();
for (unsigned int ig=0; ig<ngen; ++ig) {
const SUSYGenParticle& gen = genParticles[ig];
if (gen.firstMother<0) continue;
if (abs(gen.pdgId)>20) continue; // expect quarks or leptons from W decay
// Navigate upwards in the stop->top->W->fermion decay chain
const SUSYGenParticle& genW = genParticles[gen.firstMother];
if (genW.firstMother<0) continue;
if (abs(genW.pdgId)!=24) continue;
const SUSYGenParticle& genTop = genParticles[genW.firstMother];
if (abs(genTop.pdgId)!=6) continue;
// We only care about the down-type fermion
if (genTop.pdgId*gen.pdgId>0) continue;
// We also need a stop
if (genTop.firstMother<0) continue;
const SUSYGenParticle& genStop = genParticles[genTop.firstMother];
if (abs(genStop.pdgId)!=1000006) continue;
TLorentzVector top4;
top4.SetPtEtaPhiE(genTop.pt, genTop.eta, genTop.phi, genTop.energy);
TLorentzVector ferm4;
ferm4.SetPtEtaPhiE(gen.pt, gen.eta, gen.phi, gen.energy);
// Get the neutralino
int igstop = genTop.firstMother;
int igchi0 = -1;
TLorentzVector chi04;
for (unsigned int ig=igstop+1; ig<ngen; ++ig) { // assume chi0 comes later
// Move chi0 to the stop rest frame
const SUSYGenParticle& genChi0 = genParticles[ig];
if (genChi0.firstMother!=igstop) continue;
if (abs(genChi0.pdgId)!=1000022) continue;
igchi0 = ig;
chi04.SetPtEtaPhiE(genChi0.pt, genChi0.eta, genChi0.phi, genChi0.energy);
break;
}
if (igchi0<0) continue;
// Determine weight according to model
double cX = cos(thetaMixingTarget);
double sX = sin(thetaMixingTarget);
double coeffTop = 2*sX*sX*(chi04*top4) + 2*sX*cX*chi04.M()*TOPMASS_REF;
double coeffChi = pow(cX*TOPMASS_REF,2) - pow(sX*top4.M(),2);
double coeffRef = (chi04*top4) + chi04.M()*top4.M();
weight *= (coeffTop*(ferm4*top4)+coeffChi*(ferm4*chi04))/(coeffRef*(ferm4*top4));
}
return weight;
};