4 from ROOT
import gROOT, gDirectory, gPad, gStyle, kYellow, kGray, TCanvas, TFile, TPaveLabel, TH1F
5 from optparse
import OptionParser
9 if ((gain > 0.5
and gain <1.6)
and (offset > -10
and offset < 10)):
15 return (coolId & 0xf000000) >> 24
18 return (coolId & 0x00f0000) >> 16
21 return (coolId & 0x0000f00) >> 8
24 return (coolId & 0x000000f) >> 0
30 id = 0 | (crt<<24) | (1<<20) | (mod<<16) | (mcm<<8) | (chn<<0)
40 if input_file_name
is None:
41 print (
"No input file name, assuming graphs.root")
42 input_file_name =
"graphs.root"
44 gROOT.SetBatch(
True )
46 gStyle.SetOptStat(111111)
48 gStyle.SetCanvasColor(10)
49 gStyle.SetFrameFillColor(10)
50 gStyle.SetTitleFillColor(0)
51 gStyle.SetTitleBorderSize(1)
52 gStyle.SetStatBorderSize(1)
53 gStyle.SetStatFontSize(0.075)
57 gStyle.SetTitleFontSize(0.075)
58 gStyle.SetPaperSize(gStyle.kA4)
60 gStyle.SetPadTopMargin(0.10)
61 gStyle.SetPadBottomMargin(0.12)
62 gStyle.SetPadRightMargin(0.12)
63 gStyle.SetPadLeftMargin(0.12)
64 gStyle.SetHatchesSpacing(4.0)
66 canvas = TCanvas(
'canvas',
'Ramps',200,10,1000,750)
67 canvas.SetBatch(
True )
69 graphs = TFile(input_file_name)
70 key_list = graphs.GetListOfKeys()
72 pdfFileName =
'rampPlots.pdf'
73 canvas.Print( pdfFileName +
'[' )
76 histo =
TH1F(
"foo",
"foo",300,0.,300.)
78 histo.SetMaximum(300.)
79 histo.GetXaxis().SetTitle(
"L1Calo energy")
80 histo.GetYaxis().SetTitle(
"Calo energy")
81 histo.GetXaxis().SetTitleSize(0.04)
82 histo.GetYaxis().SetTitleSize(0.04)
85 modPresent = [ [
False for module
in range(16) ]
for crate
in range(8) ]
90 keyStr = key.GetName()
91 keyInt =
int(keyStr, base = 16)
92 list_of_histos.append( keyInt )
97 for ppCrt
in range(8):
98 for ppMod
in range(16):
100 if not modPresent[ppCrt][ppMod]:
continue
103 for logChn
in range(64):
105 my_graph = gDirectory.Get(hex(coolId))
107 if ( logChn % 64 ) == 0:
110 gStyle.SetOptTitle(0)
112 gPad.SetRightMargin(0.1)
113 gPad.SetLeftMargin(0.1)
114 gPad.SetTopMargin(0.0)
115 gPad.SetBottomMargin(0.1)
117 canvas.Divide(8,9,-1,-1)
119 title =
"Crate %d PPM %d: L1Calo (x) vs Calo (y) Energies" % ( ppCrt, ppMod )
120 ltit = TPaveLabel(0.35,0.90,0.65,1.0,title)
121 ltit.SetTextAlign(22)
122 ltit.SetTextSize(0.40)
124 ltit.SetBorderSize(0)
127 canvas.cd( logChn + 9 )
134 function_list = my_graph.GetListOfFunctions()
135 my_fit = function_list[0]
136 offset = my_fit.GetParameter(0)
137 slope = my_fit.GetParameter(1)
139 gPad.SetFrameFillColor(kYellow-9)
141 my_graph.SetMarkerStyle(34)
142 my_graph.SetMarkerSize(0.8)
143 my_fit.SetLineWidth(1)
144 my_fit.SetLineStyle(1)
147 gPad.SetFrameFillColor(kGray)
151 canvas.Print( pdfFileName )
154 canvas.Print( pdfFileName +
']' )
157 if __name__ ==
"__main__":
159 print (
"Starting PlotRamps")
161 parser = OptionParser()
162 parser.add_option(
"-f",
"--InputFile",action=
"store",type=
"string",
163 dest=
"input_file_name",help=
"Name of input file")
164 (options, args) = parser.parse_args()