-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakeGlobalAsimovPlots.py
59 lines (43 loc) · 2.34 KB
/
MakeGlobalAsimovPlots.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
import os, argparse, pickle
from argparse import ArgumentParser
import matplotlib.pyplot as plt
from plotting.PerformancePlotter import PerformancePlotter
def load_plotdata(model_dirs, lambda_veto = lambda cur: False):
hypodicts = []
sensdicts = []
model_performance = {}
for model_dir in model_dirs:
try:
with open(os.path.join(model_dir, "hypodict.pkl"), "rb") as fit_infile, open(os.path.join(model_dir, "anadict.pkl"), "rb") as sens_infile:
hypodict = pickle.load(fit_infile)
sensdict = pickle.load(sens_infile)
if lambda_veto(float(sensdict["lambda"])):
continue
hypodicts.append(hypodict)
sensdicts.append(sensdict)
cur_dir = os.path.split(os.path.normpath(model_dir))[-1]
model_performance[cur_dir] = hypodict["asimov_sig_ncat_background_floating"]
except:
print("either sensdict.pkl or perfdict.pkl not found for model '{}'".format(model_dir))
# sort and print the list of Asimov significances achieved by each model
sorted_model_performance = sorted(model_performance.items(), key = lambda cur: cur[1])
for (name, sig) in sorted_model_performance:
print("{}: {} sigma".format(name, sig))
print("CBA original: {} sigma".format(hypodict["original_asimov_sig_high_low_MET_background_floating"]))
print("CBA optimized: {} sigma".format(hypodict["optimized_asimov_sig_high_low_MET_background_floating"]))
return hypodicts, sensdicts
def MakeGlobalAsimovPlots(model_dirs, plot_dir):
hypodicts, sensdicts = load_plotdata(model_dirs)
# now have all the data, just need to plot it
dark_blue = plt.cm.Blues(1000)
PerformancePlotter.plot_asimov_significance_comparison([hypodicts], [sensdicts], colors = [dark_blue], labels = ["pivotal classifier"], outdir = plot_dir, plotlabel = ["MadGraph + Pythia8", r'$\sqrt{s}=13$ TeV, 140 fb$^{-1}$'])
def main():
parser = ArgumentParser(description = "create global summary plots for Asimov sensitivities")
parser.add_argument("--plotdir")
parser.add_argument("model_dirs", nargs = '+', action = "store")
args = vars(parser.parse_args())
plot_dir = args["plotdir"]
model_dirs = args["model_dirs"]
MakeGlobalAsimovPlots(model_dirs, plot_dir)
if __name__ == "__main__":
main()