3 from __future__
import print_function
5 from ROOT
import gROOT, gDirectory, gPad, gStyle, kYellow, kGray, TCanvas, TFile, TPaveLabel, TH1F
6 from optparse
import OptionParser
10 if ((gain > 0.5
and gain <1.6)
and (offset > -10
and offset < 10)):
16 return (coolId & 0xf000000) >> 24
19 return (coolId & 0x00f0000) >> 16
22 return (coolId & 0x0000f00) >> 8
25 return (coolId & 0x000000f) >> 0
31 id = 0 | (crt<<24) | (1<<20) | (mod<<16) | (mcm<<8) | (chn<<0)
41 if input_file_name
is None:
42 print (
"No input file name, assuming graphs.root")
43 input_file_name =
"graphs.root"
45 gROOT.SetBatch(
True )
47 gStyle.SetOptStat(111111)
49 gStyle.SetCanvasColor(10)
50 gStyle.SetFrameFillColor(10)
51 gStyle.SetTitleFillColor(0)
52 gStyle.SetTitleBorderSize(1)
53 gStyle.SetStatBorderSize(1)
54 gStyle.SetStatFontSize(0.075)
58 gStyle.SetTitleFontSize(0.075)
59 gStyle.SetPaperSize(gStyle.kA4)
61 gStyle.SetPadTopMargin(0.10)
62 gStyle.SetPadBottomMargin(0.12)
63 gStyle.SetPadRightMargin(0.12)
64 gStyle.SetPadLeftMargin(0.12)
65 gStyle.SetHatchesSpacing(4.0)
67 canvas = TCanvas(
'canvas',
'Ramps',200,10,1000,750)
68 canvas.SetBatch(
True )
70 graphs = TFile(input_file_name)
71 key_list = graphs.GetListOfKeys()
73 pdfFileName =
'rampPlots.pdf'
74 canvas.Print( pdfFileName +
'[' )
77 histo =
TH1F(
"foo",
"foo",300,0.,300.)
79 histo.SetMaximum(300.)
80 histo.GetXaxis().SetTitle(
"L1Calo energy")
81 histo.GetYaxis().SetTitle(
"Calo energy")
82 histo.GetXaxis().SetTitleSize(0.04)
83 histo.GetYaxis().SetTitleSize(0.04)
86 modPresent = [ [
False for module
in range(16) ]
for crate
in range(8) ]
91 keyStr = key.GetName()
92 keyInt =
int(keyStr, base = 16)
93 list_of_histos.append( keyInt )
98 for ppCrt
in range(8):
99 for ppMod
in range(16):
101 if not modPresent[ppCrt][ppMod]:
continue
104 for logChn
in range(64):
106 my_graph = gDirectory.Get(hex(coolId))
108 if ( logChn % 64 ) == 0:
111 gStyle.SetOptTitle(0)
113 gPad.SetRightMargin(0.1)
114 gPad.SetLeftMargin(0.1)
115 gPad.SetTopMargin(0.0)
116 gPad.SetBottomMargin(0.1)
118 canvas.Divide(8,9,-1,-1)
120 title =
"Crate %d PPM %d: L1Calo (x) vs Calo (y) Energies" % ( ppCrt, ppMod )
121 ltit = TPaveLabel(0.35,0.90,0.65,1.0,title)
122 ltit.SetTextAlign(22)
123 ltit.SetTextSize(0.40)
125 ltit.SetBorderSize(0)
128 canvas.cd( logChn + 9 )
135 function_list = my_graph.GetListOfFunctions()
136 my_fit = function_list[0]
137 offset = my_fit.GetParameter(0)
138 slope = my_fit.GetParameter(1)
140 gPad.SetFrameFillColor(kYellow-9)
142 my_graph.SetMarkerStyle(34)
143 my_graph.SetMarkerSize(0.8)
144 my_fit.SetLineWidth(1)
145 my_fit.SetLineStyle(1)
148 gPad.SetFrameFillColor(kGray)
152 canvas.Print( pdfFileName )
155 canvas.Print( pdfFileName +
']' )
158 if __name__ ==
"__main__":
160 print (
"Starting PlotRamps")
162 parser = OptionParser()
163 parser.add_option(
"-f",
"--InputFile",action=
"store",type=
"string",
164 dest=
"input_file_name",help=
"Name of input file")
165 (options, args) = parser.parse_args()