160
161 parser = argparse.ArgumentParser( description = 'Create Muon Validation Slides in LaTeX Beamer' )
162 parser.add_argument( '-r', '--reference', help = 'reference sample ROOT file' )
163 parser.add_argument( '-t', '--test', required=True, help = 'test sample ROOT file' )
164 parser.add_argument( '-d', '--directory', default = 'beamer', help = 'directory to put new files' )
165 parser.add_argument( '-n', '--notitlepage', action = 'store_true', help = 'set to remove title page' )
166 parser.add_argument( '-c', '--compile', action= 'store_true', help = 'compile beamer file' )
167 args = parser.parse_args()
168 args.directory = os.path.dirname( args.directory + '/' )
169 outdir = args.directory + '/plots'
170 if not os.path.isdir( outdir ):
171 os.makedirs( outdir )
172
173
174 testfile = ROOT.TFile.Open( args.test, 'read' )
175 reffile = ROOT.TFile.Open( args.reference, 'read' )
176
177
178
179 specialTypes = [ 'RecoFrac', 'PtRes', 'Res_pT_vs', 'PtScale', 'Eff' ]
180 for PlotList in PlotPages.values():
181 for PlotPath in PlotList:
182 HistDir, HistName = os.path.split( PlotPath )
183 if testfile.GetDirectory( HistDir ):
184 testhist = testfile.GetDirectory( HistDir ).
Get( HistName )
185 else:
186 testhist = False
187 if reffile.GetDirectory( HistDir ):
188 refhist = reffile.GetDirectory( HistDir ).
Get( HistName )
189 else:
190 refhist = False
191
192 doNorm = not sum([ HistName.__contains__(i) for i in specialTypes ])
193
194 MakeComparisonPlot( refhist, testhist, HistName, outdir, doNorm = doNorm, doRatio = True )
195
196 testfile.Close()
197 reffile.Close()
198
199
200 endl = '\n'
201 output = r'\documentclass{beamer}' + endl
202 output += r'\definecolor{links}{HTML}{0000FF}' + endl
203 output += r'\hypersetup{colorlinks=true,urlcolor=links}' + endl
204 output += r'\usepackage[latin1]{inputenc}' + endl
205 output += r'\usetheme{Warsaw}' + endl*2
206 output += r'\definecolor{LightBlue}{cmyk}{0.248,0.0609,0,0.098}' + endl
207 output += r'\setbeamercolor{author in head/foot}{fg=white, bg=blue}'+endl
208 output += r'\setbeamercolor{title in head/foot}{fg=white, bg=LightBlue}'+endl
209 output += r'\makeatother' + endl
210 output += r'\setbeamertemplate{footline}{' + endl
211 output += r'\leavevmode' + endl
212 output += r'\hbox{%' + endl
213
214 ht = 2.4
215 dp = 1.1
216 output += r'\begin{beamercolorbox}[wd=0.4\paperwidth,ht=%0.3fex,dp=%0.3fex,center]{author in head/foot}'%( ht, dp ) + r'%' + endl
217 output += r' \usebeamerfont{author in head/foot}\insertshortauthor' + endl
218
219 output += r'\end{beamercolorbox}%' + endl
220 output += r'\begin{beamercolorbox}[wd=0.5\paperwidth,ht=%0.3fex,dp=%0.3fex,center]{title in head/foot}'%( ht, dp ) + r'%' + endl
221 output += r' \usebeamerfont{author in head/foot}\insertshorttitle' + endl
222 output += r'\end{beamercolorbox}%' + endl
223 output += r'\begin{beamercolorbox}[wd=0.1\paperwidth,ht=%0.3fex,dp=%0.3fex,center]{author in head/foot}'%( ht, dp ) + r'%' + endl
224 output += r' \insertframenumber{}/\inserttotalframenumber' + endl
225 output += r'\end{beamercolorbox}}%' + endl
226 output += r'\vskip0pt}' + endl*2
227
228 output += r'\makeatletter' + endl
229 output += r'\setbeamertemplate{navigation symbols}{}' + endl*2
230 output += r'\setbeamerfont{footline}{size=\fontsize{10}{11}\selectfont}' + endl
231
232 output += r'\setbeamersize{text margin left=0.5cm}' + endl
233 output += r'\setbeamersize{text margin right=0.5cm}' + endl
234
235 output += r'\title[%s]{%s}'%(ShortTitle, Title) + endl
236 output += r'\subtitle{%s}'%(Subtitle) + endl
237 output += r'\author[%s]{%s}'%(ShortAuthor, Author) + endl
238 output += r'\institute[%s]{%s}'%(ShortInstitute, Institute) + endl
239 output += r'\date{%s}'%(Date) + endl
240 output += r'\begin{document}' + endl*2
241 output += r'%%%%%%%%%%%%%%%%%%%% BEGIN DOCUMENT %%%%%%%%%%%%%%%%%%%%' + endl*2
242 if not args.notitlepage:
243 output += r'{\setbeamertemplate{footline}{}' + endl
244 output += r'\begin{frame} \titlepage \end{frame} }' + endl
245 output += r'\addtocounter{framenumber}{-1}' + endl*2
246
247
248 output += r'\begin{frame}' + endl
249 output += r'\frametitle{Introduction}' + endl
250 output += 'Reference:' + endl*2
251 output += '{0}: {1}'.format(RefVersion, RefDescription) + endl*2
252 output += RefDataset + endl*2
253 output += r'\vspace{12pt}' + endl
254 output += 'Test:' + endl*2
255 output += '{0}: {1}'.format(TestVersion, TestDescription) + endl*2
256 output += TestDataset + endl*2
257 output += r'\vspace{12pt}' + Intro + endl
258 output += r'\end{frame}' + endl*2
259
260 for page in PlotPages:
261 plotlist = PlotPages[page]
262 output += r'\begin{frame}' + endl
263 output += r'\frametitle{%s}'%(page) + endl
264 output += r'\hspace*{-4pt}\makebox[\linewidth][c]{' + endl
265 output += r'\begin{tabular}{c%s}'%(r'@{\hspace{1pt}}c'*(len(plotlist)-1)) + endl
266 for n, plotpath in enumerate(plotlist):
267 output += r'\includegraphics[width=%0.2f\textwidth]{%s/%s.png}'%( 0.35, outdir.replace( args.directory+'/', '' ), os.path.split(plotpath)[1] )
268 if n+1 < len(plotlist):
269 output += ' &'
270 output += endl
271 output += r'\end{tabular} }' + endl
272 if page in PlotComments:
273 output += PlotComments[page] + endl
274 output += r'\end{frame}' + endl*2
275
276
277 if len(Summary) > 0:
278 output += r'\begin{frame}' + endl
279 output += 'Summary' + endl
280 output += r'\begin{itemize}' + endl
281
282 for item in Summary:
283 output += r'\item %s'%(item) + endl
284
285 output += r'\end{itemize}' + endl
286 output += r'\end{frame}' + endl
287 output += r'\end{document}'
288
289 with open( args.directory + '/' + texfile, 'w' ) as f:
290 f.write( output )
291
292 badEnvVars = [ 'TEXMFCNF', 'TEXINPUTS', 'TEXMFHOME' ]
293 for i in badEnvVars:
294 os.unsetenv(i)
295 if args.compile:
296 stat, out = getstatusoutput( 'cd %s; pdflatex -halt-on-error %s; pdflatex -halt-on-error %s'%( args.directory, texfile, texfile ) )
297 if stat != 0:
298 print out
299
300
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...