8 from aux_functions
import *
13 print 'Checking', part, mod
15 filename =
'%stiletb_%d_MonoCis.%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 histos = [ROOT.TH1F(
'%s MOD %02d PMT %02d' % (part, mod,
int(pmt + 1)),
'%02d' % (
int(pmt + 1)), 7, 1, 8)
for pmt
in range(48)]
21 entries = [0
for pmt
in range(48)]
23 hist.GetXaxis().CenterLabels(ROOT.kTRUE)
27 if os.path.exists(filename):
28 print 'Using', filename
29 file = ROOT.TFile.Open(filename)
30 if file
and not file.IsZombie():
31 tree = file.Get(
'h1000')
32 nevents = tree.GetEntries()
35 for ev
in range(1, nevents):
39 pha = tree.m_cispar[5]
40 dac = tree.m_cispar[6]
41 cap = tree.m_cispar[7]
42 if pha!=0
or dac!=120
or cap!=100:
45 samples = getattr(tree,
'sample%s%02d' % (partmap[part], mod))
47 histos[pmt].Fill(samp+1, samples[pmt*9+samp])
48 entries[pmt] = entries[pmt] + 1
54 factor = 1./
float(entries[pmt])
55 histos[pmt].
Scale(factor)
60 saveHistos(histos, part, mod, runnumber, outdir)
71 for bin
in range(1, histo.GetXaxis().GetNbins()):
72 val = histo.GetBinContent(bin)
78 histo.SetFillColor(ROOT.kGreen)
80 elif maxvalsamp==3
or maxvalsamp==5:
81 histo.SetFillColor(ROOT.kYellow)
83 elif maxvalsamp==1
or maxvalsamp==2
or maxvalsamp==6
or maxvalsamp==7:
84 histo.SetFillColor(ROOT.kRed)
92 name =
'%s%02d.ps' % (part, mod)
94 packname = outdir+name
95 partnames = [
'LBA',
'LBC',
'EBA',
'EBC']
100 toptitle = ROOT.TLatex(0.45, 0.9,
'%s %02d' % (part, mod))
101 toptitle.SetTextSize(0.05)
103 toptitle.SetTextAlign(12)
108 can.cd(histos.index(hist)+8+1)
109 pmt =
int(hist.GetTitle())
127 pickfile =
open(
'%s%s%02d.dat' % (outdir, part, mod),
'w')
128 pickle.dump(can, pickfile)
134 pave = ROOT.TPaveText(0.7, 0.6, 0.9, 0.95)
138 pave.SetBorderSize(1)
139 pave.SetTextSize(0.15)
140 pave.SetTextAlign(12)
146 hist.GetXaxis().CenterTitle()
147 hist.GetXaxis().SetTitleOffset(1.4)
148 hist.GetXaxis().SetLabelOffset(0.021)
149 hist.GetXaxis().SetLabelSize(0.06)
150 hist.GetYaxis().CenterTitle()
151 hist.GetYaxis().SetTitleOffset(1.3)
152 hist.GetYaxis().SetLabelOffset(0.015)
153 hist.GetYaxis().SetLabelSize(0.06)
154 hist.SetFillColor(ROOT.kGray)
161 ROOT.gROOT.SetStyle(
"Plain")
162 ROOT.gStyle.SetCanvasBorderMode(0)
163 ROOT.gStyle.SetPadBorderMode(0)
164 ROOT.gStyle.SetTitleX(0.75)
165 ROOT.gStyle.SetTitleY(1.0)
166 ROOT.gStyle.SetTitleW(0.25)
167 ROOT.gStyle.SetTitleH(0.25)
170 ROOT.gStyle.SetLabelFont(42,
"XYZ")
171 ROOT.gStyle.SetTextFont(42)
173 ROOT.gStyle.SetOptStat(0)
174 ROOT.gStyle.SetPalette(1)
175 ROOT.gStyle.SetTitleFont(42,
"XYZ")
176 ROOT.gStyle.SetTitleBorderSize(1)
177 ROOT.gStyle.SetPadColor(0)
178 ROOT.gStyle.SetCanvasColor(0)
179 ROOT.gStyle.SetOptFit(0)
182 c1.SetFrameBorderMode(0)
197 print "Please pass a run number."
200 runnumber =
int(sys.argv[1])
202 datadir =
'/location/of/ntuples'
203 outdir =
'/where/output/will/be/sent/'
205 datadir = datadir +
str(runnumber) +
'/'
206 outdir = outdir +
str(runnumber) +
'/'
208 if not os.path.exists(outdir):
211 print 'Using data from', datadir
212 print 'Ouput will be sent to', outdir
214 parts = [
'LBA',
'LBC',
'EBA',
'EBC']
217 for mod
in range(1,65):
218 readModule(part, mod, runnumber, datadir, outdir)
220 name =
'samples_%d.ps' % runnumber
221 packname = outdir + name
224 can.Print(
'%s[' % packname)
227 for mod
in range(1,65):
228 pickfile =
'%s%s%02d.dat' % (outdir, part, mod)
229 if os.path.exists(pickfile):
230 pickfile =
open(pickfile,
'r')
231 page = pickle.load(pickfile)
235 can.Print(
'%s]' % packname)
237 if __name__ ==
'__main__':