-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathplot_max_hem_E.py
66 lines (51 loc) · 2.04 KB
/
plot_max_hem_E.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
import sys, os, argparse
import json
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import joblib
from collections import OrderedDict
import uproot
import pickle
from decay_mode_xs import modes as bkg_modes
from scipy import interpolate
#Local code
from userConfig import loc, mode, train_vars, train_vars_vtx
import plotting
import utils as ut
from matplotlib import rc
rc('font',**{'family':'serif','serif':['Roman']})
rc('text', usetex=True)
path = loc.ANALYSIS
modes = OrderedDict()
file_prefix = "p8_ee_Zbb_ecm91_EvtGen"
#Signal and B+ modes
modes["Bc2TauNu"] = f"{file_prefix}_Bc2TauNuTAUHADNU"
modes["Zbb"] = "p8_ee_Zbb_ecm91"
tree = {}
events = {}
df = {}
for m in modes:
print(m)
tree[m] = uproot.open(f"{path}/{modes[m]}_sel2.root")["events"]
df[m] = tree[m].arrays(library="pd", how="zip", filter_name=["EVT_*"])
#Ratio of charged to neutral energy
df[m]["EVT_ThrustEmax_R_Echarged_Enuetral"] = df[m]["EVT_ThrustEmax_Echarged"] / df[m]["EVT_ThrustEmax_Eneutral"]
print(f"Number of events {len(df[m])}")
vars = {"EVT_ThrustEmax_Echarged": {"name": "Maximum hemisphere charged E", "range": [0.,50.], "unit": "[GeV/$c^2$]"},
"EVT_ThrustEmax_Eneutral": {"name": "Maximum hemisphere neutral E", "range": [0.,50.], "unit": "[GeV/$c^2$]"},
"EVT_ThrustEmax_E": {"name": "Maximum hemisphere E", "range": [0.,50.], "unit": "[GeV/$c^2$]"},
}
bins = 30
xvar = "EVT_ThrustEmax_Echarged"
yvar = "EVT_ThrustEmax_Eneutral"
for m in modes:
fig, ax = plt.subplots(figsize=(8,8))
plt.hist2d(df[m][xvar], df[m][yvar], bins=bins, range = [vars[xvar]["range"], vars[yvar]["range"]], density=True)
ax.tick_params(axis='both', which='major', labelsize=25)
plt.xlim(vars[xvar]["range"][0], vars[xvar]["range"][1])
plt.ylim(vars[yvar]["range"][0], vars[yvar]["range"][1])
plt.xlabel(vars[xvar]["name"]+" "+vars[xvar]["unit"],fontsize=30)
plt.ylabel(vars[yvar]["name"]+" "+vars[yvar]["unit"],fontsize=30)
plt.tight_layout()
fig.savefig(f"{loc.PLOTS}/{m}_{xvar}_vs_{yvar}.pdf")