-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.py
83 lines (74 loc) · 2.39 KB
/
helper.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
def get_pdflabel(s):
pdf_labels = {}
if s in pdf_labels:
return pdf_labels[s]
elif 'HERAMCDR_DISCMSJETSCMSWASYM' in s:
return 'HERA DIS + CMS WASYM/Jets'
elif 'HERAMCDR_DISCMSJETS' in s:
return 'HERA DIS + CMS Jets'
elif 'HERAMCDR_DISCMSWASYM' in s:
return 'HERA DIS + CMS W ASYM'
elif 'HERAMCDR_DIS' in s:
return 'HERA DIS'
elif 'HERADISCMSJETS' in s:
return 'HERA DIS + CMS Jets'
elif 'HERADISATLASJETS' in s:
return 'HERA DIS + Atlas Jets'
elif 'HERADISCMSATLASJETS' in s:
return 'HERA DIS + Atlas + CMS Jets'
elif 'HERADIS' in s:
return 'HERA DIS'
else:
return s.replace('_','\_')
def get_partonlabel(s, short=False):
parton_labels = {0: "gluon",
1: "d quark",
2: "u quark",
3: "s quark",
4: "c quark",
-1: 'd antiquark',
-2: 'u antiquark',
7: '$d_{\mathrm{val}}$ quark',
8: '$u_{\mathrm{val}}$ quark',
9: 'sea quarks'}
parton_labels_short = {0: r"g",
1: r"D",
2: r"U",
3: r"s",
4: r"c",
-1: r"\bar D",
-2: r"\bar U",
7: r"d_{{\mathrm{{v}}}}",
8: r"u_{{\mathrm{{v}}}}",
9: r"\Sigma"}
if short:
if s in parton_labels:
return parton_labels_short[s]
else:
return s
else:
if s in parton_labels:
return parton_labels[s]
else:
return s
def get_q2label(q2):
q2_str = r'{:.2G}'.format(q2)
if "E" in q2_str:
base, exponent = q2_str.split('E')
print base, exponent
if base == '1':
return r"10^{{{0}}}".format(int(exponent))
else:
return r"{0}\times 10^{{{1}}}".format(base, int(exponent))
else:
return q2_str
def get_plot_scalefactor(flavor, q2=1.9):
scalefactors = {
0 : { 1.9 : 0.2},
1 : { 1.9 : 1.0},
2 : { 1.9 : 1.0},
7 : { 1.9 : 1.0},
8 : { 1.9 : 1.0},
9 : { 1.9 : 0.2},
}
return scalefactors[flavor].get(q2, 1.0)