-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplot_xsecs_from_json.py
193 lines (171 loc) · 6.87 KB
/
plot_xsecs_from_json.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Example script to create 1-D plots of cross sections as function of mass from data in JSON format.
#
# External requirements (Python modules):
#
# pandas (https://pandas.pydata.org/)
# matplotlib (https://matplotlib.org/)
#
# Run with:
#
# python plot_xsecs_from_json.py
#
# (85)
#
# $Id: plot_xsecs_from_json.py 3190 2019-05-28 17:21:31Z eis $
### imports
import os, sys
import json
import pandas as pd
import matplotlib.pyplot as plt
### helpers
def PlotXsec(df, label):
plt.yscale("log")
baseline = plt.plot(df.mass_GeV, df.xsec_pb, label = label)
# check which uncertainty type we have
if "unc_up_pb" in df.columns:
# asymmetric
band = plt.fill_between(df.mass_GeV, df.xsec_pb + df.unc_down_pb, df.xsec_pb + df.unc_up_pb, alpha = 0.2, facecolor = baseline[0].get_color(), linewidth=0)
else:
# assume symmetric always present
band = plt.fill_between(df.mass_GeV, df.xsec_pb - df.unc_pb , df.xsec_pb + df.unc_pb , alpha = 0.2, facecolor = baseline[0].get_color(), linewidth=0)
### main
# define datasets (NOTE: files that are commented out do exist and can be used)
filenames_13600 = [
## 13.6 TeV
"pp13600_gluino_NNLO+NNLL.json",
"pp13600_gluinosquark_NNLO+NNLL.json",
"pp13600_squark_NNLO+NNLL.json",
"pp13600_stopsbottom_NNLO+NNLL.json",
#"pp13600_SGmodel_GGxsec_NNLOa+NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_SGmodel_SBxsec_NNLOa+NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_SGmodel_SGxsec_NNLOa+NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_SGmodel_SSxsec_NNLOa+NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
"pp13600_hino_deg_1000022_-1000024_NNLL.json",
"pp13600_hino_deg_1000022_1000023_NNLL.json",
"pp13600_hino_deg_1000022_1000024_NNLL.json",
"pp13600_hino_deg_1000024_-1000024_NNLL.json",
#"pp13600_hino_nondeg_1000022_1000023_NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_hino_nondeg_1000023_-1000024_NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_hino_nondeg_1000023_1000024_NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_hino_nondeg_1000024_-1000024_NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
"pp13600_sleptons_1000011_-1000011_NNLL.json",
"pp13600_sleptons_1000015_-1000015_NNLL.json",
"pp13600_sleptons_2000011_-2000011_NNLL.json",
"pp13600_wino_1000023_-1000024_NNLL.json",
"pp13600_wino_1000023_1000024_NNLL.json",
"pp13600_wino_1000024_-1000024_NNLL.json",
#"pp13600_wino_sq_dep_1000023_-1000024_NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_wino_sq_dep_1000023_1000024_NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
#"pp13600_wino_sq_dep_1000024_-1000024_NNLL.json", # JSON files with 2 mass parameters cannot be plotted yet
]
filenames_13600_strong = [
## 13.6 TeV
"pp13600_gluino_NNLO+NNLL.json",
"pp13600_gluinosquark_NNLO+NNLL.json",
"pp13600_squark_NNLO+NNLL.json",
"pp13600_stopsbottom_NNLO+NNLL.json",
]
filenames_13600_ewk = [
"pp13600_hino_deg_1000022_-1000024_NNLL.json",
"pp13600_hino_deg_1000022_1000023_NNLL.json",
"pp13600_hino_deg_1000022_1000024_NNLL.json",
"pp13600_hino_deg_1000024_-1000024_NNLL.json",
"pp13600_sleptons_1000011_-1000011_NNLL.json",
"pp13600_sleptons_1000015_-1000015_NNLL.json",
"pp13600_sleptons_2000011_-2000011_NNLL.json",
"pp13600_wino_1000023_-1000024_NNLL.json",
"pp13600_wino_1000023_1000024_NNLL.json",
"pp13600_wino_1000024_-1000024_NNLL.json",
]
filenames_13000 = [
# 13 TeV
"pp13_gluino_NNLO+NNLL.json",
"pp13_gluinosquark_NNLO+NNLL.json",
"pp13_squark_NNLO+NNLL.json",
"pp13_stopsbottom_NNLO+NNLL.json",
##
"pp13_hino_NLO+NLL.json",
"pp13_wino_C1C1_NLO+NLL.json",
#"pp13_winom_C1N2_NLO+NLL.json",
#"pp13_winop_C1N2_NLO+NLL.json",
"pp13_winopm_C1N2_NLO+NLL.json",
##
"pp13_slep_L_NLO+NLL_PDF4LHC.json",
"pp13_slep_R_NLO+NLL_PDF4LHC.json",
"pp13_snu-snu_NLO+NLL_PDF4LHC.json",
"pp13_snuM-slep_NLO+NLL_PDF4LHC.json",
"pp13_snuP-slep_NLO+NLL_PDF4LHC.json",
#"pp13_stau_L_NLO+NLL_PDF4LHC.json",
#"pp13_stau_R_NLO+NLL_PDF4LHC.json",
"pp13_stau_LR_NLO+NLL_PDF4LHC.json",
## JSON files with 2 mass parameters cannot be plotted yet
#"pp13_hinosplit_C1C1_NLO+NLL.json",
]
# load data and plot
def getLoadAndPlot(name):
ofname = ""
filenames = []
if name == "13000":
ofname = "SUSY_xsecs_13000GeV.pdf"
label = "13"
filenames = filenames_13000
title = "$pp$, $\sqrt{s} = "+label+"$ TeV, NLO+NLL - NNLO$_\mathregular{approx}$+NNLL"
elif name == "13600":
ofname = "SUSY_xsecs_13600GeV.pdf"
label = "13.6"
filenames = filenames_13600
title = "$pp$, $\sqrt{s} = "+label+"$ TeV, NNLO$_\mathregular{approx}$+NNLL"
elif name == "13600_strong":
ofname = "SUSY_xsecs_13600GeV_strong.pdf"
label = "13.6"
filenames = filenames_13600_strong
title = "$pp$, $\sqrt{s} = "+label+"$ TeV, NNLO$_\mathregular{approx}$+NNLL"
elif name == "13600_ewk":
ofname = "SUSY_xsecs_13600GeV_ewk.pdf"
label = "13.6"
filenames = filenames_13600_ewk
title = "$pp$, $\sqrt{s} = "+label+"$ TeV, NNLO$_\mathregular{approx}$+NNLL"
# init plotting
plt.ion()
use_latex = False
if use_latex:
plt.rc('text', usetex=True)
plt.rc('font', size=18)
plt.rc('legend', fontsize=14)
plt.rc('text.latex', preamble=r'\usepackage{cmbright}')
else:
plt.rcParams.update({'font.size': 10})
for idx, filename in enumerate(filenames):
print(filename)
data = json.load(open(os.path.join("json", filename)))
df = pd.DataFrame.from_dict(data["data"], orient = "index")
# restore mass as column and sort
df["mass_GeV"] = df.index.astype(int)
df = df.sort_values("mass_GeV")
df.reset_index(inplace = True, drop = True)
# plot
PlotXsec(df, data["process_latex"])
#
#dfs[filename] = df
# draw legend and style plot
plt.xlabel("particle mass [GeV]")
plt.ylabel("cross section [pb]")
plt.grid()
plt.xlim(100, 2000)
plt.ylim(1e-6, 1e4)
plt.legend(ncol = 2, framealpha = 1)
plt.locator_params(axis = "y", base = 100) # for log-scaled axis, it's LogLocator, not MaxNLocator
plt.title(title, fontsize = 9, loc = "right")
plt.savefig(ofname)
plt.savefig(ofname[:-3]+"png")
plt.close()
def main():
getLoadAndPlot("13000")
getLoadAndPlot("13600")
getLoadAndPlot("13600_strong")
getLoadAndPlot("13600_ewk")
if __name__ == "__main__":
main()