10 from __future__
import print_function
11 from __future__
import division
13 from eFEXNTuple
import *
18 hist, edge = np.histogram(data, binning)
21 for i
in range(len(hist)):
24 newbin.append(edge[i+1])
26 newbin[-1] = binning[-1]
30 hist1, edge = np.histogram(data1, binning)
31 hist2, edge = np.histogram(data2, binning)
35 for i
in range(len(hist1)):
38 if total_1 > 0
and total_2 > 0:
39 newbin.append(edge[i+1])
42 newbin[-1] = binning[-1]
46 bins =
rebin(bins, all_data)
47 hist_all, edges = np.histogram(all_data, bins)
48 hist_selected, edges = np.histogram(selected_data, bins)
49 bin_centre = [(edges[i] + edges[i+1])/2.
for i
in range(len(edges)-1)]
50 hist_height = hist_selected / hist_all
51 hist_error = ((hist_selected**0.5 / hist_all)**2. + (hist_all**0.5 * hist_selected / hist_all**2.)**2.)**0.5
52 return (hist_height, bin_centre, hist_error)
57 selected_l_ET_TLV = []
58 selected_l_eta_TLV = []
59 selected_l_ET_Oregon = []
60 selected_l_eta_Oregon = []
62 for each
in myntuple.entries():
63 each.set_class_type(
"tau")
64 if each.leading_l_id()
is None:
68 if each.is_in_crack(each.leading_l_id()):
70 if abs(each.truth_tauvisible_eta[each.leading_l_id()]) > 2.3:
74 all_l_ET.append(each.truth_tauvisible_ET[each.leading_l_id()])
75 all_l_eta.append(each.truth_tauvisible_eta[each.leading_l_id()])
76 matched_tobs = each.get_eg_matchedtob_id()[each.leading_l_id()]
78 oregon_selected =
False
79 for i
in matched_tobs:
80 if each.eg_tauTLV_Et[i] <= 12:
82 if each.eg_tauTLV_Iso[i] < 0.66
and each.eg_tauTLV_Et[i] <= 15:
86 for i
in matched_tobs:
87 if each.eg_tauOregon_Et[i] <= 12:
89 if each.eg_tauOregon_Iso[i] < 0.66
and each.eg_tauOregon_Et[i] <= 15:
91 oregon_selected =
True
94 selected_l_ET_TLV.append(each.truth_tauvisible_ET[each.leading_l_id()])
97 selected_l_ET_Oregon.append(each.truth_tauvisible_ET[each.leading_l_id()])
99 hist_height, bin_centre, hist_error =
turn_on_curve(all_l_ET, selected_l_ET_TLV,
range(0,100,5))
100 histplot([bin_centre], [hist_height], [hist_error], errorbar_limit=1, filename=
"tautlvtrunon")
101 hist_height, bin_centre, hist_error =
turn_on_curve(all_l_ET, selected_l_ET_Oregon,
range(0,100,5))
102 histplot([bin_centre], [hist_height], [hist_error], errorbar_limit=1, filename=
"tauoregontrunon")
107 if __name__ ==
"__main__":
108 if len(sys.argv) > 2:
109 print(
"Error: too many arguments")
110 print(
"Example: python makeplots.py PATH/TO/INPUT")
112 if len(sys.argv) == 1:
113 print(
"Error: need the path to the input file")
114 print(
"Example: python makeplots.py PATH/TO/INPUT")
115 print(
"Info: Using default input file path")
116 inputfile =
"myfile.root"
118 inputfile = sys.argv[1]