28 subdetectors = [
"BPIX",
"FPIX",
"TIB",
"TOB",
"TID",
"TEC"]
34 if not os.path.isdir(path):
35 print "Error: Directory "+path+
" not found!"
37 if not path.endswith(
'/'):
39 path = path.replace(
'\\',
'/')
42 self.
plots = [file
for file
in os.listdir(path)
43 if file.endswith(
'.eps')]
48 def __init__(self, pattern=[], width=1, height=1):
61 nplots = sum(len(p)
for p
in plots)
62 length = int(math.ceil(math.sqrt(nplots)))
64 fullRows = int(nplots/length)
65 residual = nplots - length*fullRows
68 rowlengths.append(residual)
70 for _
in xrange(fullRows):
71 rowlengths.append(length)
75 if residual == 0
and len(plots[0])%length != 0
and\
76 len(plots[0])%nrows == 0:
78 self.pattern.extend(range(i, i+nrows*(length-1)+1, nrows)
79 for i
in range(1, nrows+1))
82 self.pattern.append(range(1, 1+residual))
83 self.pattern.extend(range(i, i+length)
for i
in
84 range(residual+1, nplots-length+2, length))
86 self.
width = 1.0/length
98 for subdetector
in subdetectors:
99 script +=
writePageReg(
'(?=.*%s)%s'%(subdetector, identifier),
100 title+
': ' +subdetector, validations)
102 script = subsectionTemplate.replace(
'[title]', title)+script
114 for validation
in validations:
115 valiplots = [validation.path+plot
for plot
in validation.plots
116 if re.search(identifier, plot)]
117 valiplots.sort(key=plotSortKey)
118 plots.append(valiplots)
119 if sum(len(p)
for p
in plots) == 0:
120 print 'Warning: no plots matching ' + identifier
128 return writePage([p
for vali
in plots
for p
in vali], title, layout)
138 for row
in layout.pattern:
140 for i
in xrange(len(row)):
141 plotrow.append(plotTemplate.replace(
'[width]', str(layout.width)).\
142 replace(
'[height]', str(layout.height)).\
143 replace(
'[path]', plots[row[i]-1]))
144 plotrows.append(
'\n'.
join(plotrow))
145 script =
' \\\\\n'.
join(plotrows)
147 return frameTemplate.replace(
'[plots]', script).
replace(
'[title]', title)
154 if plot.find(
'normchi2') != -1:
156 if plot.find(
'chi2Prob') != -1:
167 print 'Producing a .tex file from plots...'
170 if len(sys.argv) < 2:
171 print 'Error: Need path of plots as an argument!'
175 for plotpath
in sys.argv[1:]:
181 frames += subsectionTemplate.replace(
'[title]',
'Chi^2 plots')
182 frames +=
writePageReg(
'chi2',
r'$\chi^2$ plots', validations)
184 frames +=
writeSubsection(
'DmedianY*R.*plain.eps$',
'DMR', validations)
186 frames +=
writeSubsection(
'DmedianY*R.*split.eps$',
'Split DMR',validations)
190 frames +=
writeSubsection(
'SurfaceShape',
'Surface Shape', validations)
195 file = open(
'presentation.tex',
'w')
196 file.write(texTemplate.replace(
'[frames]', frames).\
197 replace(
'[time]', time.ctime()))
201 pdfScript = open(
'toPdf.sh',
'w')
202 pdfScript.write(toPdf)
204 os.chmod(
"toPdf.sh", stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
208 if __name__ ==
'__main__':
static std::string join(char **cmd)