12
12
import ROOT
13
13
14
14
15
- def plotEfficiency (graph ):
15
+ def plotEfficiency (graph , col = ROOT . kBlack , opts = "AP" ):
16
16
"""Plot one efficiency histogram"""
17
17
18
18
# Set the properties of the histogram.
@@ -23,12 +23,14 @@ def plotEfficiency(graph):
23
23
graph .GetYaxis ().SetRangeUser (0.0 , 1.1 )
24
24
graph .GetXaxis ().SetTitleSize (0.07 )
25
25
graph .GetXaxis ().SetTitleOffset (0.6 )
26
+ graph .SetLineColor (col )
27
+ graph .SetMarkerColor (col )
26
28
27
29
# Draw the histogram.
28
- graph .Draw ("AP" )
30
+ graph .Draw (opts )
29
31
30
32
# Return gracefully.
31
- return
33
+ return graph
32
34
33
35
34
36
def main ():
@@ -42,7 +44,8 @@ def main():
42
44
parser .add_argument (
43
45
"-i" ,
44
46
"--input" ,
45
- help = "Input ROOT file" ,
47
+ nargs = 2 ,
48
+ help = "Input ROOT files" ,
46
49
default = "track_finding_efficiency.root" ,
47
50
)
48
51
parser .add_argument (
@@ -53,28 +56,51 @@ def main():
53
56
)
54
57
args = parser .parse_args ()
55
58
56
- # Open the input file.
57
- input_file = ROOT .TFile .Open (args .input , "READ" )
58
- if not input_file :
59
- print (f"Failed to open input file '{ args .input } '" )
60
- return 1
61
-
62
59
# Create a canvas to draw on.
63
60
canvas = ROOT .TCanvas ("canvas" , "canvas" , 1000 , 1000 )
64
61
canvas .Divide (1 , 2 )
65
62
66
- # Get the efficiency histograms from the input file.
67
- eta_plot = input_file .Get ("track_finding_eff_eta" )
68
- phi_plot = input_file .Get ("track_finding_eff_phi" )
69
- if not eta_plot or not phi_plot :
70
- print ("Failed to retrieve efficiency histograms" )
63
+ # Open the seeding efficiency file.
64
+ seeding_efficiency_file = ROOT .TFile .Open (args .input [0 ], "READ" )
65
+ if not seeding_efficiency_file :
66
+ print (f"Failed to open input file '{ args .input [0 ]} '" )
67
+ return 1
68
+
69
+ # Get the seeding efficiency histograms.
70
+ seeding_efficiency_eta = seeding_efficiency_file .Get ("seed_finding_eff_eta" )
71
+ seeding_efficiency_phi = seeding_efficiency_file .Get ("seed_finding_eff_phi" )
72
+ if not seeding_efficiency_eta or not seeding_efficiency_phi :
73
+ print ("Failed to retrieve efficiency histograms in %s" % args .input [0 ])
74
+ return 1
75
+
76
+ # Open the tracking efficiency file.
77
+ tracking_efficiency_file = ROOT .TFile .Open (args .input [1 ], "READ" )
78
+ if not tracking_efficiency_file :
79
+ print (f"Failed to open input file '{ args .input [1 ]} '" )
80
+ return 1
81
+
82
+ # Get the tracking efficiency histograms.
83
+ tracking_efficiency_eta = tracking_efficiency_file .Get ("track_finding_eff_eta" )
84
+ tracking_efficiency_phi = tracking_efficiency_file .Get ("track_finding_eff_phi" )
85
+ if not tracking_efficiency_eta or not tracking_efficiency_phi :
86
+ print ("Failed to retrieve efficiency histograms in %s" % args .input [1 ])
71
87
return 1
72
88
73
89
# Draw the histograms.
74
90
canvas .cd (1 )
75
- plotEfficiency (eta_plot .CreateGraph ())
91
+ seeding_legend = plotEfficiency (seeding_efficiency_eta .CreateGraph (), ROOT .kBlue )
92
+ tracking_legend = plotEfficiency (
93
+ tracking_efficiency_eta .CreateGraph (), ROOT .kRed , "P"
94
+ )
76
95
canvas .cd (2 )
77
- plotEfficiency (phi_plot .CreateGraph ())
96
+ plotEfficiency (seeding_efficiency_phi .CreateGraph (), ROOT .kBlue )
97
+ plotEfficiency (tracking_efficiency_phi .CreateGraph (), ROOT .kRed , "P" )
98
+
99
+ # Create a legend.
100
+ legend = ROOT .TLegend (0.6 , 0.2 , 0.9 , 0.4 )
101
+ legend .AddEntry (seeding_legend , "Seed finding efficiency" , "lpe" )
102
+ legend .AddEntry (tracking_legend , "Track finding efficiency" , "lpe" )
103
+ legend .Draw ()
78
104
79
105
# Save the canvas to a file.
80
106
canvas .SaveAs (args .output )
0 commit comments