-
Notifications
You must be signed in to change notification settings - Fork 11
/
Computation_Functions.py
762 lines (574 loc) · 33.6 KB
/
Computation_Functions.py
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
import sys
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import scipy
import time
import readMapNew as rmN
import tqdm
import mplhep as hep
import lhe_parser as lhe
import hepmc_parser as hepmc
import uproot
import random
import os
random.seed(123)
hep.style.use("ATLAS")
# set cst
c = 3e8# Light velocity in m/s
#All plots are made with 10 000 events, if you want to try with other numbers of events, you will have to change the number of events in lines 285-314-551-580 for the calculation of the efficiency.
#########################################################################################
#Parsing the hepmc file from the hadronization of the MG outputs to recover the data from the process.
#########################################################################################
def parsing_hepmc(events):
px_TOT = []
py_TOT = []
pz_TOT = []
E_TOT = []
mass_TOT = []
pdg_TOT = []
for ie , event in enumerate(events):
count=0
for id, vertex in event.vertex.items():
if [p.pdg for p in vertex.incoming] == [25] and [p.pdg for p in vertex.outcoming] == [35, 35]: # PDGID 25 = Higgs, PDGID 35 Dark Higgs
px_TOT.append(list(p.px for p in vertex.outcoming)) # recover the x momenta in GeV
py_TOT.append(list(p.py for p in vertex.outcoming)) # recover the y momenta in GeV
pz_TOT.append(list(p.pz for p in vertex.outcoming)) # recover the z momenta in GeV
E_TOT.append(list(p.E for p in vertex.outcoming)) # recover the Energy in GeV
mass_TOT.append(list(p.mass for p in vertex.outcoming)) # recover the mass in GeV
if [p.pdg for p in vertex.incoming] == [35]: # PDGID 35 Dark Higgs
pdg_TOT.append((list(p.pdg for p in vertex.outcoming))) # recover the PDG ID of the particle produced
count = count+1
if count==2: ##
break
pass
return px_TOT, py_TOT, pz_TOT, E_TOT, mass_TOT, pdg_TOT
#########################################################################################
#The data recovered are list of list, we need to convert them into one list to be able to separate the contribution of each LLP.
#########################################################################################
def conversion_one_list(px_TOT, py_TOT, pz_TOT, E_TOT, mass_TOT, pdg_TOT):
px_tot = []
for i in range(len(px_TOT)):
for y in range(len(px_TOT[i])):
px_tot.append(px_TOT[i][y])
py_tot = []
for i in range(len(py_TOT)):
for y in range(len(py_TOT[i])):
py_tot.append(py_TOT[i][y])
pz_tot = []
for i in range(len(pz_TOT)):
for y in range(len(pz_TOT[i])):
pz_tot.append(pz_TOT[i][y])
E_tot = []
for i in range(len(E_TOT)):
for y in range(len(E_TOT[i])):
E_tot.append(E_TOT[i][y])
mass_tot = []
for i in range(len(mass_TOT)):
for y in range(len(mass_TOT[i])):
mass_tot.append(mass_TOT[i][y])
pdg_tot = []
for i in range(len(pdg_TOT)):
for y in range(len(pdg_TOT[i])):
pdg_tot.append(pdg_TOT[i][y])
return px_tot, py_tot, pz_tot, E_tot, mass_tot, pdg_tot
#########################################################################################
# Recovering the data from each LLP (px,py,pz,E,mass,PDG ID).
#########################################################################################
def recover(px_tot, py_tot, pz_tot, E_tot, mass_tot,pdg_tot):
px_DH1 = []
px_DH2 = []
py_DH1 = []
py_DH2 = []
pz_DH1 = []
pz_DH2 = []
E_DH1 = []
E_DH2 = []
mass_DH1 = []
mass_DH2 = []
pdg_tot_DH1 = []
pdg_tot_DH2 = []
for i in range(0, len(px_tot),2): # in the list, each even value is for DH1
px_DH1.append(px_tot[i])
py_DH1.append(py_tot[i])
pz_DH1.append(pz_tot[i])
E_DH1.append(E_tot[i])
mass_DH1.append(mass_tot[i])
for i in range(1, len(px_tot),2): # in the list, each odd value is for DH2
px_DH2.append(px_tot[i])
py_DH2.append(py_tot[i])
pz_DH2.append(pz_tot[i])
E_DH2.append(E_tot[i])
mass_DH2.append(mass_tot[i])
for i in range(0, len(pdg_tot),4): # recover the PDG ID of the particle produced by decay of DH1
pdg_tot_DH1.append(pdg_tot[i])
for i in range(2, len(pdg_tot),4): # recover the PDG ID of the particle produced by decay of DH2
pdg_tot_DH2.append(pdg_tot[i])
# Convert all lists into arrays
px_DH1 = np.array(px_DH1)/c # GeV/c
py_DH1 = np.array(py_DH1)/c
pz_DH1 = np.array(pz_DH1)/c
E_DH1 = np.array(E_DH1)
mass_DH1 = np.array(mass_DH1)
pdg_tot_DH1 = np.array(pdg_tot_DH1)
px_DH2 = np.array(px_DH2)/c
py_DH2 = np.array(py_DH2)/c
pz_DH2 = np.array(pz_DH2)/c
E_DH2 = np.array(E_DH2)
mass_DH2 = np.array(mass_DH2)
pdg_tot_DH2 = np.array(pdg_tot_DH2)
return px_DH1, px_DH2, py_DH1, py_DH2, pz_DH1, pz_DH2, pdg_tot_DH1, pdg_tot_DH2, E_DH1, E_DH2, mass_DH1, mass_DH2
#########################################################################################
# Computation of the kinematics variable for LLP1 (velocities, beta, gamma, pT the transverse momenta, eta the pseudo-rapidity).
#########################################################################################
def kinematics_DH1(px_DH1, py_DH1, pz_DH1, E_DH1):
vx_DH1 = (px_DH1*c**2)/E_DH1 #compute the velocities in each direction
vy_DH1 = (py_DH1*c**2)/E_DH1
vz_DH1 = (pz_DH1*c**2)/E_DH1
beta_DH1 = np.sqrt(vx_DH1**2 + vy_DH1**2 + vz_DH1**2)/c # compute beta
gamma_DH1 = 1/(np.sqrt(1-beta_DH1**2)) # compute gamma
pT_DH1 = np.sqrt(px_DH1**2 + py_DH1**2)*c # compute the transverse momenta
eta_DH1 = np.arctanh(pz_DH1/(np.sqrt(px_DH1**2 + py_DH1**2 + pz_DH1**2))) # compute the pseudorapidity
return beta_DH1, gamma_DH1, pT_DH1, eta_DH1
#########################################################################################
# Computation of the kinematics variable for LLP2 (velocities, beta, gamma, pT the transverse momenta, eta the pseudo-rapidity).
#########################################################################################
def kinematics_DH2(px_DH2, py_DH2, pz_DH2, E_DH2):
vx_DH2 = (px_DH2*c**2)/E_DH2 #compute the velocities in each direction
vy_DH2 = (py_DH2*c**2)/E_DH2
vz_DH2 = (pz_DH2*c**2)/E_DH2
beta_DH2 = np.sqrt(vx_DH2**2 + vy_DH2**2 + vz_DH2**2)/c # compute beta
gamma_DH2 = 1/(np.sqrt(1-beta_DH2**2)) # compute gamma
pT_DH2 = np.sqrt(px_DH2**2 + py_DH2**2)*c # compute the transverse momenta
eta_DH2 = np.arctanh(pz_DH2/(np.sqrt(px_DH2**2 + py_DH2**2 + pz_DH2**2))) # compute the pseudorapidity
return beta_DH2, gamma_DH2, pT_DH2, eta_DH2
#########################################################################################
# lifetime function.
#########################################################################################
def lifetime(avgtau = 4.3):
import math
avgtau = avgtau / c
t = random.random()
return -1.0 * avgtau * math.log(t)
#########################################################################################
# Decay lenght computation for LLP1.
#########################################################################################
def decaylenghtDH1(px_DH1, py_DH1, pz_DH1, E_DH1, gamma_DH1, tauN):
Lx_tot_DH1 = []
Ly_tot_DH1 = []
Lz_tot_DH1 = []
Lxy_tot_DH1 = []
for ctau in range(len(tauN)):
Lx_DH1 = []
Ly_DH1 = []
Lz_DH1 = []
Lxy_DH1 = []
for i in range(len(gamma_DH1)):
lt = lifetime(tauN[ctau]) # set mean lifetime
Lx_DH1.append((px_DH1[i]/E_DH1[i])*c**2 * lt * gamma_DH1[i]) # compute the decay lenght in x,y,z
Ly_DH1.append((py_DH1[i]/E_DH1[i])*c**2 * lt * gamma_DH1[i])
Lz_DH1.append((abs(pz_DH1[i])/E_DH1[i])*c**2 * lt * gamma_DH1[i] )
Lxy_DH1.append(np.sqrt((Lx_DH1[i])**2 + (Ly_DH1[i])**2)) # compte the transverse decay lenght
Lx_tot_DH1.append(Lx_DH1)
Ly_tot_DH1.append(Ly_DH1)
Lz_tot_DH1.append(Lz_DH1)
Lxy_tot_DH1.append(Lxy_DH1)
return Lxy_tot_DH1, Lz_tot_DH1
#########################################################################################
# Decay lenght computation for LLP2.
#########################################################################################
def decaylenghtDH2(px_DH2, py_DH2, pz_DH2, E_DH2, gamma_DH2, tauN):
Lx_tot_DH2 = []
Ly_tot_DH2 = []
Lz_tot_DH2 = []
Lxy_tot_DH2 = []
for ctau in range(len(tauN)):
Lx_DH2 = []
Ly_DH2 = []
Lz_DH2 = []
Lxy_DH2 = []
for i in range(len(gamma_DH2)):
lt = lifetime(tauN[ctau]) # set mean lifetime
Lx_DH2.append((px_DH2[i]/E_DH2[i])*c**2 * lt * gamma_DH2[i]) # compute the decay lenght in x,y,z
Ly_DH2.append((py_DH2[i]/E_DH2[i])*c**2 * lt * gamma_DH2[i])
Lz_DH2.append((abs(pz_DH2[i])/E_DH2[i])*c**2 * lt* gamma_DH2[i])
Lxy_DH2.append(np.sqrt((Lx_DH2[i])**2 + (Ly_DH2[i])**2)) # compte the transverse decay lenght
Lx_tot_DH2.append(Lx_DH2)
Ly_tot_DH2.append(Ly_DH2)
Lz_tot_DH2.append(Lz_DH2)
Lxy_tot_DH2.append(Lxy_DH2)
return Lxy_tot_DH2, Lz_tot_DH2
#########################################################################################
# Computation of the efficiency with the map from the data obtained with MG+Pythia8 for the high-ET samples (mH >= 400GeV).
#########################################################################################
def eff_map_High(pT_DH1, eta_DH1, Lxy_tot_DH1, Lz_tot_DH1, pdg_tot_DH1, pT_DH2, eta_DH2, Lxy_tot_DH2, Lz_tot_DH2, pdg_tot_DH2, tauN, nevent, mass_phi, mass_s):
eff_highETX = []
for index in tqdm.tqdm(range(len(tauN))):
queryMapResult = []
for iEvent in range(len(pT_DH1)):
queryMapResult.append(rmN.queryMapFromKinematics(pT_DH1[iEvent],
eta_DH1[iEvent],
Lxy_tot_DH1[index][iEvent],
Lz_tot_DH1[index][iEvent],
abs(pdg_tot_DH1[iEvent]),
pT_DH2[iEvent],
eta_DH2[iEvent],
Lxy_tot_DH2[index][iEvent],
Lz_tot_DH2[index][iEvent],
abs(pdg_tot_DH2[iEvent]),
selection = "high-ET"))
eff_highETX.append(sum(queryMapResult))
queryMapResult = np.array(queryMapResult) #convertion into array
eff_highETX = np.array(eff_highETX) #convertion into array
eff_highETX = eff_highETX/nevent #efficiency/(nbr of event)
Data_Eff_High = np.column_stack(eff_highETX)
np.savetxt(f'./Plots_High/Efficiencies_Text_{mass_phi}_{mass_s}.txt', Data_Eff_High)
return eff_highETX
#########################################################################################
# Computation of the efficiency with the map from the data obtained with MG+Pythia8 for the low-ET samples (mH <= 400GeV).
#########################################################################################
def eff_map_Low(pT_DH1, eta_DH1, Lxy_tot_DH1, Lz_tot_DH1, pdg_tot_DH1, pT_DH2, eta_DH2, Lxy_tot_DH2, Lz_tot_DH2, pdg_tot_DH2, tauN,nevent, mass_phi, mass_s):
eff_lowETX = []
for index in tqdm.tqdm(range(len(tauN))):
queryMapResult = []
for iEvent in range(len(pT_DH1)):
queryMapResult.append(rmN.queryMapFromKinematics(pT_DH1[iEvent],
eta_DH1[iEvent],
Lxy_tot_DH1[index][iEvent],
Lz_tot_DH1[index][iEvent],
abs(pdg_tot_DH1[iEvent]),
pT_DH2[iEvent],
eta_DH2[iEvent],
Lxy_tot_DH2[index][iEvent],
Lz_tot_DH2[index][iEvent],
abs(pdg_tot_DH2[iEvent]),
selection = "low-ET"))
eff_lowETX.append(sum(queryMapResult))
queryMapResult = np.array(queryMapResult) #convertion into array
eff_lowETX = np.array(eff_lowETX) #convertion into array
eff_lowETX = eff_lowETX/nevent #efficiency/(nbr of event)
Data_Eff_Low = np.column_stack(eff_lowETX)
np.savetxt(f'./Plots_Low/Efficiencies_Text_{mass_phi}_{mass_s}.txt', Data_Eff_Low)
return eff_lowETX
#########################################################################################
#########################################################################################
#########################################################################################
#########################################################################################
#########################################################################################
#########################################################################################
#########################################################################################
#Parsing the lhe file from the MG output to recover the data from the process.
#########################################################################################
def parsing_LHE(MG_events):
px = []
py = []
pz = []
pdg = []
E = []
MASS = []
for event in MG_events:
for particle in event:
pdg.append(particle.pdg)
if particle.pdg == 35: # PDGID 35 Dark Higgs
px.append(particle.px)
py.append(particle.py)
pz.append(particle.pz)
E.append(particle.E)
MASS.append(particle.mass)
px = np.array(px)/c # GeV/c
py = np.array(py)/c
pz = np.array(pz)/c
return px, py, pz, pdg, E, MASS
#########################################################################################
# Recovering the data from MG (LHE) (PDG ID, px,py,pz,E,mass).
#########################################################################################
def recover_MG_DH1(px, py, pz, E, MASS, pdg):
MG_pdg_DH1_1 = []
for i in range(5,len(pdg),9):
MG_pdg_DH1_1.append(pdg[i]) #List with the PDG ID of the particle produced by the decay of the LLP1
MG_E_DH1 = []
for i in range(0,len(px),2):
MG_E_DH1.append(E[i]) #List with the energy of the LLP1
MG_px_DH1 = []
for i in range(0,len(px),2):
MG_px_DH1.append(px[i]) #List with x momenta from LLP1
MG_py_DH1 = []
for i in range(0,len(px),2):
MG_py_DH1.append(py[i]) #List with y momenta from LLP1
MG_pz_DH1 = []
for i in range(0,len(px),2):
MG_pz_DH1.append(pz[i]) #List with z momenta from LLP1
MG_mass_DH1 = []
for i in range(0,len(px),2):
MG_mass_DH1.append(MASS[i]) #List with the mass from LLP1
MG_px_DH1 = np.array(MG_px_DH1) # convertion into arrays
MG_py_DH1 = np.array(MG_py_DH1)
MG_pz_DH1 = np.array(MG_pz_DH1)
MG_E_DH1 = np.array(MG_E_DH1)
MG_mass_DH1 = np.array(MG_mass_DH1)
return MG_px_DH1, MG_py_DH1,MG_pz_DH1,MG_E_DH1,MG_mass_DH1,MG_pdg_DH1_1
#########################################################################################
# Computation of the kinematics variable for LLP1 (velocities, beta, gamma, pT the transverse momenta, eta the pseudo-rapidity).
#########################################################################################
def kinematics_MG_DH1(MG_px_DH1,MG_py_DH1,MG_pz_DH1,MG_E_DH1 ):
MG_vx_DH1 = (MG_px_DH1*c**2)/MG_E_DH1 #compute the velocities in each direction
MG_vy_DH1 = (MG_py_DH1*c**2)/MG_E_DH1
MG_vz_DH1 = (MG_pz_DH1*c**2)/MG_E_DH1
MG_beta_DH1 = np.sqrt(MG_vx_DH1**2 + MG_vy_DH1**2 + MG_vz_DH1**2)/c # compute beta
MG_gamma_DH1 = 1/(np.sqrt(1-MG_beta_DH1**2)) # compute gamma
MG_pT_DH1 = np.sqrt(MG_px_DH1**2 + MG_py_DH1**2)*c # compute the transverse momenta
MG_eta_DH1 = np.arctanh(MG_pz_DH1/(np.sqrt(MG_px_DH1**2 + MG_py_DH1**2 + MG_pz_DH1**2))) # compute the pseudorapidity
return MG_pT_DH1,MG_eta_DH1, MG_gamma_DH1
#########################################################################################
# Recovering the data from LLP2 (PDG ID, px,py,pz,E,mass).
#########################################################################################
def recover_MG_DH2(px, py, pz, E, MASS, pdg):
MG_pdg_DH2_1 = []
for i in range(7,len(pdg),9):
MG_pdg_DH2_1.append(pdg[i]) #List with the PDG ID of the particle produced by the decay of the LLP2
MG_E_DH2 = []
for i in range(1,len(px),2):
MG_E_DH2.append(E[i]) #List with the energy of the LLP2
MG_px_DH2 = []
for i in range(1,len(px),2):
MG_px_DH2.append(px[i]) #List with x momenta from LLP2
MG_py_DH2 = []
for i in range(1,len(px),2):
MG_py_DH2.append(py[i]) #List with y momenta from LLP2
MG_pz_DH2 = []
for i in range(1,len(px),2):
MG_pz_DH2.append(pz[i]) #List with z momenta from LLP2
MG_mass_DH2 = []
for i in range(1,len(px),2):
MG_mass_DH2.append(MASS[i]) #List with the mass from LLP2
MG_px_DH2 = np.array(MG_px_DH2) # convertion into arrays
MG_py_DH2 = np.array(MG_py_DH2)
MG_pz_DH2 = np.array(MG_pz_DH2)
MG_E_DH2 = np.array(MG_E_DH2)
MG_mass_DH2 = np.array(MG_mass_DH2)
return MG_px_DH2, MG_py_DH2,MG_pz_DH2,MG_E_DH2,MG_mass_DH2,MG_pdg_DH2_1
#########################################################################################
# Computation of the kinematics variable for LLP2 (velocities, beta, gamma, pT the transverse momenta, eta the pseudo-rapidity).
#########################################################################################
def kinemamtics_MG_DH2(MG_px_DH2,MG_py_DH2,MG_pz_DH2,MG_E_DH2):
MG_vx_DH2 = (MG_px_DH2*c**2)/MG_E_DH2 #compute the velocities in each direction
MG_vy_DH2 = (MG_py_DH2*c**2)/MG_E_DH2
MG_vz_DH2 = (MG_pz_DH2*c**2)/MG_E_DH2
MG_beta_DH2 = np.sqrt(MG_vx_DH2**2 + MG_vy_DH2**2 + MG_vz_DH2**2)/c # compute beta
MG_gamma_DH2 = 1/(np.sqrt(1-MG_beta_DH2**2)) # compute gamma
MG_pT_DH2 = np.sqrt(MG_px_DH2**2 + MG_py_DH2**2)*c # compute the transverse momenta
MG_eta_DH2 = np.arctanh(MG_pz_DH2/(np.sqrt(MG_px_DH2**2 + MG_py_DH2**2 + MG_pz_DH2**2))) # compute the pseudorapidity
return MG_pT_DH2,MG_eta_DH2, MG_gamma_DH2
#########################################################################################
# Decay lenght computation for LLP1.
#########################################################################################
def decaylenght_MG_DH1(MG_px_DH1, MG_py_DH1, MG_pz_DH1, E_DH1, MG_gamma_DH1, tauN):
MG_Lx_tot_DH1 = []
MG_Ly_tot_DH1 = []
MG_Lz_tot_DH1 = []
MG_Lxy_tot_DH1 = []
for ctau in range(len(tauN)):
MG_Lx_DH1 = []
MG_Ly_DH1 = []
MG_Lz_DH1 = []
MG_Lxy_DH1 = []
for i in range(len(MG_gamma_DH1)):
MG_lt = lifetime(tauN[ctau]) # set the mean lifetime
MG_Lx_DH1.append((MG_px_DH1[i]/E_DH1[i])*c**2 * MG_lt * MG_gamma_DH1[i]) # compute the decay lenght in x,y,z
MG_Ly_DH1.append((MG_py_DH1[i]/E_DH1[i])*c**2 * MG_lt * MG_gamma_DH1[i])
MG_Lz_DH1.append((abs(MG_pz_DH1[i])/E_DH1[i])*c**2 * MG_lt * MG_gamma_DH1[i] )
MG_Lxy_DH1.append(np.sqrt((MG_Lx_DH1[i])**2 + (MG_Ly_DH1[i])**2)) # compute the transverse decay lenght
MG_Lx_tot_DH1.append(MG_Lx_DH1) # convertion into arrays
MG_Ly_tot_DH1.append(MG_Ly_DH1)
MG_Lz_tot_DH1.append(MG_Lz_DH1)
MG_Lxy_tot_DH1.append(MG_Lxy_DH1)
return MG_Lxy_tot_DH1, MG_Lz_tot_DH1
#########################################################################################
# Decay lenght computation for LLP2.
#########################################################################################
def decaylenght_MG_DH2(MG_px_DH2, MG_py_DH2, MG_pz_DH2, E_DH2, MG_gamma_DH2, tauN):
MG_Lx_tot_DH2 = []
MG_Ly_tot_DH2 = []
MG_Lz_tot_DH2 = []
MG_Lxy_tot_DH2 = []
for ctau in range(len(tauN)):
MG_Lx_DH2 = []
MG_Ly_DH2 = []
MG_Lz_DH2 = []
MG_Lxy_DH2 = []
for i in range(len(MG_gamma_DH2)):
MG_lt = lifetime(tauN[ctau]) # set the mean lifetime
MG_Lx_DH2.append((MG_px_DH2[i]/E_DH2[i])*c**2 * MG_lt * MG_gamma_DH2[i]) # compute the decay lenght in x,y,z
MG_Ly_DH2.append((MG_py_DH2[i]/E_DH2[i])*c**2 * MG_lt * MG_gamma_DH2[i])
MG_Lz_DH2.append((abs(MG_pz_DH2[i])/E_DH2[i])*c**2 * MG_lt * MG_gamma_DH2[i] )
MG_Lxy_DH2.append(np.sqrt((MG_Lx_DH2[i])**2 + (MG_Ly_DH2[i])**2)) # compute the transverse decay lenght
MG_Lx_tot_DH2.append(MG_Lx_DH2)
MG_Ly_tot_DH2.append(MG_Ly_DH2)
MG_Lz_tot_DH2.append(MG_Lz_DH2)
MG_Lxy_tot_DH2.append(MG_Lxy_DH2)
return MG_Lxy_tot_DH2, MG_Lz_tot_DH2
#########################################################################################
# Computation of the efficiency with the map from the data obtained with MG for the high-ET samples (mH <= 400GeV).
#########################################################################################
def eff_map_MG_high(MG_pT_DH1, MG_eta_DH1,MG_Lxy_tot_DH1, MG_Lz_tot_DH1, MG_pdg_DH1_1, MG_pT_DH2, MG_eta_DH2, MG_Lxy_tot_DH2, MG_Lz_tot_DH2, MG_pdg_DH2_1, tauN, nevent, mass_phi, mass_s):
MG_eff_highETX = []
for index in tqdm.tqdm(range(len(tauN))):
MG_queryMapResult = []
for iEvent in range(len(MG_pT_DH1)):
MG_queryMapResult.append(rmN.queryMapFromKinematics(MG_pT_DH1[iEvent],
MG_eta_DH1[iEvent],
MG_Lxy_tot_DH1[index][iEvent],
MG_Lz_tot_DH1[index][iEvent],
abs(MG_pdg_DH1_1[iEvent]),
MG_pT_DH2[iEvent],
MG_eta_DH2[iEvent],
MG_Lxy_tot_DH2[index][iEvent],
MG_Lz_tot_DH2[index][iEvent],
abs(MG_pdg_DH2_1[iEvent]),
selection = "high-ET"))
MG_eff_highETX.append(sum(MG_queryMapResult))
MG_queryMapResult = np.array(MG_queryMapResult) # convertion into arrays
MG_eff_highETX = np.array(MG_eff_highETX) # convertion into arrays
MG_eff_highETX = MG_eff_highETX/nevent #eff/nbrevent
MG_Data_Eff_High = np.column_stack(MG_eff_highETX)
np.savetxt(f'./Plots_High/Efficiencies_Text_{mass_phi}_{mass_s}.txt', MG_Data_Eff_High)
return MG_eff_highETX
#########################################################################################
# Computation of the efficiency with the map from the data obtained with MG for the low-ET samples (mH <= 400GeV).
#########################################################################################
def eff_map_MG_low(MG_pT_DH1, MG_eta_DH1,MG_Lxy_tot_DH1, MG_Lz_tot_DH1, MG_pdg_DH1_1, MG_pT_DH2, MG_eta_DH2, MG_Lxy_tot_DH2, MG_Lz_tot_DH2, MG_pdg_DH2_1, tauN, nevent, mass_phi, mass_s):
MG_eff_lowETX = []
for index in tqdm.tqdm(range(len(tauN))):
MG_queryMapResult = []
for iEvent in range(len(MG_pT_DH1)):
MG_queryMapResult.append(rmN.queryMapFromKinematics(MG_pT_DH1[iEvent],
MG_eta_DH1[iEvent],
MG_Lxy_tot_DH1[index][iEvent],
MG_Lz_tot_DH1[index][iEvent],
abs(MG_pdg_DH1_1[iEvent]),
MG_pT_DH2[iEvent],
MG_eta_DH2[iEvent],
MG_Lxy_tot_DH2[index][iEvent],
MG_Lz_tot_DH2[index][iEvent],
abs(MG_pdg_DH2_1[iEvent]),
selection = "low-ET"))
MG_eff_lowETX.append(sum(MG_queryMapResult))
MG_queryMapResult = np.array(MG_queryMapResult) # convertion into arrays
MG_eff_lowETX = np.array(MG_eff_lowETX) # convertion into arrays
MG_eff_lowETX = MG_eff_lowETX/nevent #eff/nbrevent
MG_Data_Eff_Low = np.column_stack(MG_eff_lowETX)
np.savetxt(f'./Plots_Low/Efficiencies_Text_{mass_phi}_{mass_s}.txt', MG_Data_Eff_Low)
return MG_eff_lowETX
#################################################################################################################
#################################################################################################################
#################################################################################################################
#################################################################################################################
#################################################################################################################
#################################################################################################################
#########################################################################################
# Computing HEP data
#########################################################################################
def elem_list(HEP, Branch_HEP, File_HEP_limit, Branch_HEP_limit):
file_HEP = uproot.open(HEP) # open the file from HEP data for the efficiency
data_HEP = file_HEP[Branch_HEP] # open the branch
file_HEP_limit = uproot.open(File_HEP_limit) # open the file from HEP data for the limits
branch_HEP_limit = file_HEP_limit[Branch_HEP_limit] # open the branch
return data_HEP, branch_HEP_limit
#########################################################################################
# Plots to compare the results of efficiency obtained with MG, MG+Pythia8 (High-ET).
#########################################################################################
def plt_eff_high(MG_eff_highETX, eff_highETX,tauN, data_HEP, mass_phi , mass_s):
################## PLOT EFFICIENCY ##################
fig, ax = plt.subplots()
################## Plot efficiency from MG ##################
plt.plot(tauN,MG_eff_highETX, 'k--', linewidth=2, label = 'MG')
################## Plot efficiency from MG+Pythia8 ##################
plt.plot(tauN,eff_highETX, 'r', linewidth=2, label = 'MG + Pythia')
################## Plot efficiency from HEP data ##################
plt.plot(data_HEP.values(axis='both')[0],data_HEP.values(axis='both')[1], 'b')
################ Uncertainties from HEP ##################
plt.fill_between(data_HEP.values(axis='both')[0], data_HEP.values(axis='both')[1] + data_HEP.errors('high')[1] , data_HEP.values(axis='both')[1] - data_HEP.errors('high')[1] , color = 'blue', label = r'ATLAS, with $\pm$ 1 $\sigma$ error bands',alpha=.7)
################## Uncertainties from Map ##################
plt.fill_between(tauN, np.array(eff_highETX) + 0.25* np.array(eff_highETX), np.array(eff_highETX) - 0.25 * np.array(eff_highETX), label='MG+Pythia8, with error bands ', alpha=.7)
################## Limits of validity ##################
ax.hlines(y=(0.25*(max(eff_highETX))), xmin=0, xmax=1e2, linewidth=2, color='g', label = 'Limits of validity' )
# place a text box in upper left in axes coords
props = dict(boxstyle='round', facecolor='white', alpha=0.5)
ax.text(0.05, 0.95, f" $ m_Φ $ = {mass_phi} GeV, $m_S$ = {mass_s} GeV" , transform=ax.transAxes, fontsize=14, verticalalignment='top', bbox=props)
x = np.linspace(0,100)
ax.fill_between(x, 0.25*(max(eff_highETX)), color='black', alpha=.2, hatch="/", edgecolor="black", linewidth=1.0) # adding hatch
plt.ylim(0) # start at 0
plt.xscale('log')
plt.xlabel(r'c$\tau$ [m]', fontsize=20)
plt.ylabel('Efficiency', fontsize=20 )
plt.legend(fontsize = 11, loc=1) # set the legend in the upper right corner
plt.savefig(f"./Plots_High/Efficiency_comparison_mH{mass_phi}_mS{mass_s}.png")
plt.close()
#########################################################################################
# Plots to compared the reasults of efficiency obtained with MG, MG+Pythia8 (Low-ET).
#########################################################################################
def plt_eff_low(MG_eff_lowETX, eff_lowETX,tauN, data_HEP, mass_phi , mass_s):
################## PLOT EFFICIENCY ##################
fig, ax = plt.subplots()
################## Plot efficiency from MG ##################
plt.plot(tauN,MG_eff_lowETX, 'k--',linewidth=2, label = 'MG')
################## Plot efficiency from MG+Pythia8 ##################
plt.plot(tauN,eff_lowETX, 'r', linewidth=2 ,label = 'MG + Pythia')
################## Plot efficiency from HEP data ##################
plt.plot(data_HEP.values(axis='both')[0],data_HEP.values(axis='both')[1], 'b')
################ Uncertainties from HEP ##################
plt.fill_between(data_HEP.values(axis='both')[0], data_HEP.values(axis='both')[1] + data_HEP.errors('high')[1] , data_HEP.values(axis='both')[1] - data_HEP.errors('high')[1] , color = 'blue', label = r'ATLAS, with $\pm$ 1 $\sigma$ error bands',alpha=.7)
################## Uncertainties from Map ##################
plt.fill_between(tauN, np.array(eff_lowETX) + 0.25* np.array(eff_lowETX), np.array(eff_lowETX) - 0.25*np.array(eff_lowETX), label='MG+Pythia8, with error bands ',alpha=.7)
################## Limits of validity ##################
ax.hlines(y=(0.33*(max(eff_lowETX))), xmin=0, xmax=1e2, linewidth=2, color='g', label = 'Limits of validity' )
# place a text box in upper left in axes coords
props = dict(boxstyle='round', facecolor='white', alpha=0.5)
ax.text(0.05, 0.95, f" $ m_Φ $ = {mass_phi} GeV, $m_S$ = {mass_s} GeV" , transform=ax.transAxes, fontsize=14, verticalalignment='top', bbox=props)
x = np.linspace(0,100)
ax.fill_between(x, 0.33*(max(eff_lowETX)), color='black', alpha=.2, hatch="/", edgecolor="black", linewidth=1.0) # adding hatch
plt.ylim(0) # start at 0
plt.xscale('log')
plt.xlabel(r'c$\tau$ [m]', fontsize=20)
plt.ylabel('Efficiency', fontsize=20 )
plt.legend( fontsize = 10, loc=1) # set the legend in the upper right corner
plt.savefig(f"./Plots_Low/Efficiency_comparison_mH{mass_phi}_mS{mass_s}.png")
plt.close()
#########################################################################################
# Plot limits obtained with the map, to compare with those obtain by ATLAS (High-ET).
#########################################################################################
def plt_cross_High(eff_highETX, tauN, mass_phi, mass_s, branch_HEP_limit, factor):
fig, ax = plt.subplots()
Nsobs = 0.5630 * 26 * factor # nbr of observed events = 26 ( factor )
Crr_Sec_obs = (Nsobs)/((np.array(eff_highETX)) * 139e3 ) # Luminosity = 139e3 fb**(-1)
plt.plot(tauN, Crr_Sec_obs, 'r', label ='Map results', linewidth = 2)
plt.plot(tauN, np.array(branch_HEP_limit.values(axis='both')[1]), 'b', label ='Observed', linewidth = 2)
plt.xscale('log')
plt.yscale('log')
plt.xlabel(r'c$\tau$ [m]')
plt.ylabel(r'95% CL limit on $\sigma \times B$ [pb]')
# place a text box in upper left in axes coords
props = dict(boxstyle='round', facecolor='white', alpha=0.5)
ax.text(0.05, 0.95, f" $ m_Φ $ = {mass_phi} GeV, $m_S$ = {mass_s} GeV" , transform=ax.transAxes, fontsize=14, verticalalignment='top', bbox=props)
plt.legend( fontsize = 10, loc=3)
plt.savefig(f"./Plots_High/Cross_section_mH{mass_phi}_mS{mass_s}.png") #create a new fodlder ' Plots ' and save the fig in it
plt.close()
#########################################################################################
# Plot limits obtained with the map, to those obtain by ATLAS (Low-ET).
#########################################################################################
def plt_cross_Low(eff_lowETX , tauN, mass_phi, mass_s, branch_HEP_limit, factor):
fig, ax = plt.subplots()
Nsobs = 0.6592 * 26 * factor # nbr of observed events = 26
Crr_Sec_obs = (Nsobs)/((np.array(eff_lowETX)) * 139e3 )
plt.plot(tauN, Crr_Sec_obs, 'r', label ='Map results', linewidth = 2)
plt.plot(tauN, np.array(branch_HEP_limit.values(axis='both')[1]), 'b', label ='Observed', linewidth = 2)
plt.xscale('log')
plt.yscale('log')
plt.xlabel(r'c$\tau$ [m]')
plt.ylabel(r'95% CL limit on $\sigma \times B$ [pb]')
# place a text box in upper left in axes coords
props = dict(boxstyle='round', facecolor='white', alpha=0.5)
ax.text(0.05, 0.95, f" $ m_Φ $ = {mass_phi} GeV, $m_S$ = {mass_s} GeV" , transform=ax.transAxes, fontsize=14, verticalalignment='top', bbox=props)
plt.legend( fontsize = 10, loc=3)
plt.savefig(f"./Plots_Low/Cross_section_mH{mass_phi}_mS{mass_s}.png") #create a new fodlder ' Plots ' and save the fig in it
plt.close()