3 from __future__
import print_function
5 from ROOT
import gDirectory, gPad, gStyle, kYellow, TCanvas, TFile, TPaveLabel
6 from optparse
import OptionParser
9 if ((gain > 0.5
and gain <1.6)
and (offset > -10
and offset < 10)):
17 if input_file_name
is None:
18 print (
"No input file name, assuming graphs.root")
19 input_file_name =
"graphs.root"
22 gStyle.SetOptStat(111111)
24 gStyle.SetCanvasColor(10)
25 gStyle.SetFrameFillColor(10)
26 gStyle.SetTitleFillColor(0)
27 gStyle.SetTitleBorderSize(1)
28 gStyle.SetStatBorderSize(1)
29 gStyle.SetStatFontSize(0.075)
33 gStyle.SetTitleFontSize(0.075)
35 gStyle.SetPadTopMargin(0.10)
36 gStyle.SetPadBottomMargin(0.12)
37 gStyle.SetPadRightMargin(0.12)
38 gStyle.SetPadLeftMargin(0.12)
39 gStyle.SetHatchesSpacing(4.0)
41 c1 = TCanvas(
'c1',
'Example',200,10,700,500)
44 graphs = TFile(input_file_name)
45 key_list = graphs.GetListOfKeys()
50 c1.Print(
"rampPlots.pdf(")
55 list_of_histos.append(iii.GetName())
59 list_of_histos_dec=[
int(iii,base = 16)
for iii
in list_of_histos]
60 list_of_histos_dec.sort()
61 list_of_histos = [hex(iii)
for iii
in list_of_histos_dec]
66 page_ppm = list_of_histos[0][:-4]
68 for my_name
in list_of_histos:
70 my_graph = gDirectory.Get(my_name)
71 graph_ppm = my_name[:-4]
73 if (nPlot % 64) == 0
or (
not graph_ppm == page_ppm):
74 if (nPage==0)
and (nPlot==0):
75 print (
"start plotting")
78 ppm_number=page_ppm[-1]
79 ppm_crate =page_ppm[2:-2]
80 if len(ppm_crate) == 0:
82 title =
"PP " + ppm_crate +
" PPM " + ppm_number
83 ltit = TPaveLabel(0.35,0.90,0.65,1.0,title)
85 ltit.SetTextSize(0.70)
91 c1.Print(
"rampPlots.pdf")
98 c1.cd(nPlot % 64 +1+8)
99 my_graph.SetMarkerStyle(21)
100 my_graph.SetMarkerSize(0.75)
101 my_graph.SetLineWidth(1)
103 my_graph.GetYaxis().SetRangeUser(0.,my_graph.GetXaxis().GetXmax())
105 my_graph.GetXaxis().SetTitleSize(0.04)
106 my_graph.GetYaxis().SetTitleSize(0.04)
107 my_graph.GetXaxis().SetTitleOffset(1.5)
108 my_graph.GetYaxis().SetTitleOffset(1.5)
111 my_graph.GetXaxis().SetLabelSize(0.04)
112 my_graph.GetYaxis().SetLabelSize(0.04)
114 my_graph.GetXaxis().SetLabelOffset(0.04)
115 my_graph.GetYaxis().SetLabelOffset(0.015)
116 my_graph.GetXaxis().SetTitle(
"L1Calo energies")
117 my_graph.GetYaxis().SetTitle(
"Calo energies")
119 function_list = my_graph.GetListOfFunctions()
120 offset = function_list[0].GetParameter(0)
121 slope = function_list[0].GetParameter(1)
123 gPad.SetFrameFillColor(kYellow)
130 ppm_number=page_ppm[-1]
131 ppm_crate =page_ppm[2:-2]
132 if len(ppm_crate) == 0:
134 title =
"PP " + ppm_crate +
" PPM " + ppm_number
135 ltit = TPaveLabel(0.35,0.90,0.65,1.0,title)
136 ltit.SetTextAlign(22)
137 ltit.SetTextSize(0.70)
139 ltit.SetBorderSize(0)
142 c1.Print(
"rampPlots.pdf")
144 c1.Print(
"rampPlots.pdf)")
147 if __name__ ==
"__main__":
149 print (
"Starting PlotRamps")
151 parser = OptionParser()
152 parser.add_option(
"-f",
"--InputFile",action=
"store",type=
"string",dest=
"input_file_name",help=
"Name of input file")
153 (options, args) = parser.parse_args()