8 from aux_functions
import *
13 print 'Checking', part, mod
15 filename =
'%stiletb_%d_CIS.%s%02d.0.aan.root' % (datadir, runnumber, part, mod)
17 partnames = [
'LBA',
'LBC',
'EBA',
'EBC']
18 partmap = {
'LBA':
'A',
'LBC':
'C',
'EBA':
'D',
'EBC':
'E'}
20 histoshg = [ROOT.TH1F(
'%s MOD %02d PMT %02d HG' % (part, mod,
int(pmt + 1)),
'%02d' % (
int(pmt + 1)), 7, 1, 8)
for pmt
in range(48)]
21 histoslg = [ROOT.TH1F(
'%s MOD %02d PMT %02d LG' % (part, mod,
int(pmt + 1)),
'%02d' % (
int(pmt + 1)), 7, 1, 8)
for pmt
in range(48)]
23 entrieshg = [0
for pmt
in range(48)]
24 entrieslg = [0
for pmt
in range(48)]
26 for list
in [histoshg, histoslg]:
28 hist.GetXaxis().CenterLabels(ROOT.kTRUE)
32 if os.path.exists(filename):
33 print 'Using', filename
34 file = ROOT.TFile.Open(filename)
35 if file
and not file.IsZombie():
36 tree = file.Get(
'h1000')
37 nevents = tree.GetEntries()
40 for ev
in range(1, nevents):
44 pha = tree.m_cispar[5]
45 dac = tree.m_cispar[6]
46 cap = tree.m_cispar[7]
47 if pha!=0
or cap!=100:
51 sampleshg = getattr(tree,
'sample%s%02dhi' % (partmap[part], mod))
53 histoshg[pmt].Fill(samp+1, sampleshg[pmt*9+samp])
54 entrieshg[pmt] = entrieshg[pmt] + 1
57 sampleslg = getattr(tree,
'sample%s%02dlo' % (partmap[part], mod))
59 histoslg[pmt].Fill(samp+1, sampleslg[pmt*9+samp])
60 entrieslg[pmt] = entrieslg[pmt] + 1
66 factor = 1./
float(entrieshg[pmt])
67 histoshg[pmt].
Scale(factor)
72 factor = 1./
float(entrieslg[pmt])
73 histoslg[pmt].
Scale(factor)
76 for histo
in histoshg:
79 for histo
in histoslg:
83 saveHistos(histoshg, part, mod,
'hg', runnumber, outdir)
84 saveHistos(histoslg, part, mod,
'lg', runnumber, outdir)
95 for bin
in range(1, histo.GetXaxis().GetNbins()):
96 val = histo.GetBinContent(bin)
102 histo.SetFillColor(ROOT.kGreen)
104 elif maxvalsamp==3
or maxvalsamp==5:
105 histo.SetFillColor(ROOT.kYellow)
107 elif maxvalsamp==1
or maxvalsamp==2
or maxvalsamp==6
or maxvalsamp==7:
108 histo.SetFillColor(ROOT.kRed)
118 partnames = [
'LBA',
'LBC',
'EBA',
'EBC']
128 toptitle = ROOT.TLatex(0.42, 0.9,
'%s %02d %s' % (part, mod, gn))
129 toptitle.SetTextSize(0.05)
131 toptitle.SetTextAlign(12)
140 can.cd(histos.index(hist)+8+1)
141 pmt =
int(hist.GetTitle())
159 pickfile =
open(
'%s%s%02d%s.dat' % (outdir, part, mod, gain),
'w')
160 pickle.dump(can, pickfile)
166 pave = ROOT.TPaveText(0.7, 0.6, 0.9, 0.95)
170 pave.SetBorderSize(1)
171 pave.SetTextSize(0.15)
172 pave.SetTextAlign(12)
178 hist.GetXaxis().CenterTitle()
179 hist.GetXaxis().SetTitleOffset(1.4)
180 hist.GetXaxis().SetLabelOffset(0.021)
181 hist.GetXaxis().SetLabelSize(0.06)
182 hist.GetYaxis().CenterTitle()
183 hist.GetYaxis().SetTitleOffset(1.3)
184 hist.GetYaxis().SetLabelOffset(0.015)
185 hist.GetYaxis().SetLabelSize(0.06)
186 hist.SetFillColor(ROOT.kGray)
193 ROOT.gROOT.SetStyle(
"Plain")
194 ROOT.gStyle.SetCanvasBorderMode(0)
195 ROOT.gStyle.SetPadBorderMode(0)
196 ROOT.gStyle.SetTitleX(0.75)
197 ROOT.gStyle.SetTitleY(1.0)
198 ROOT.gStyle.SetTitleW(0.25)
199 ROOT.gStyle.SetTitleH(0.25)
202 ROOT.gStyle.SetLabelFont(42,
"XYZ")
203 ROOT.gStyle.SetTextFont(42)
205 ROOT.gStyle.SetOptStat(0)
206 ROOT.gStyle.SetPalette(1)
207 ROOT.gStyle.SetTitleFont(42,
"XYZ")
208 ROOT.gStyle.SetTitleBorderSize(1)
209 ROOT.gStyle.SetPadColor(0)
210 ROOT.gStyle.SetCanvasColor(0)
211 ROOT.gStyle.SetOptFit(0)
214 c1.SetFrameBorderMode(0)
229 print "Please pass a run number."
232 runnumber =
int(sys.argv[1])
234 datadir =
'/location/of/ntuples'
235 outdir =
'/where/output/will/be/sent/'
237 datadir = datadir +
str(runnumber) +
'/'
238 outdir = outdir +
str(runnumber) +
'/'
240 if not os.path.exists(outdir):
243 print 'Using data from', datadir
244 print 'Ouput will be sent to', outdir
246 parts = [
'LBA',
'LBC',
'EBA',
'EBC']
249 for mod
in range(1,65):
250 readModule(part, mod, runnumber, datadir, outdir)
252 namehg =
'samples_HG_%d.ps' % runnumber
253 namelg =
'samples_LG_%d.ps' % runnumber
254 packnamehg = outdir + namehg
255 packnamelg = outdir + namelg
258 can.Print(
'%s[' % packnamehg)
261 for mod
in range(1,65):
262 pickfile =
'%s%s%02dhg.dat' % (outdir, part, mod)
263 if os.path.exists(pickfile):
264 pickfile =
open(pickfile,
'r')
265 page = pickle.load(pickfile)
266 page.Print(packnamehg)
269 can.Print(
'%s]' % packnamehg)
272 can.Print(
'%s[' % packnamelg)
275 for mod
in range(1,65):
276 pickfile =
'%s%s%02dlg.dat' % (outdir, part, mod)
277 if os.path.exists(pickfile):
278 pickfile =
open(pickfile,
'r')
279 page = pickle.load(pickfile)
280 page.Print(packnamelg)
283 can.Print(
'%s]' % packnamelg)
286 if __name__ ==
'__main__':