AliPhysics  6cf2591 (6cf2591)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MakeSlides.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 
3 #include <Riostream.h>
4 
5 // ROOT includes
6 #include "TString.h"
7 #include "TSystem.h"
8 #include "TROOT.h"
9 #include "TFile.h"
10 #include "TEnv.h"
11 #include "TObjArray.h"
12 #include "TObjString.h"
13 #include "TArrayI.h"
14 #include "TPRegexp.h"
15 #include "TRegexp.h"
16 #endif
17 
18 //_________________________________
19 TString PdfToTxt ( TString filename, Bool_t clear = kFALSE )
20 {
21  TString convertedFilename = filename;
22  convertedFilename.ReplaceAll(".pdf",".txt");
23 
24  if ( clear ) {
25  if ( gSystem->AccessPathName(convertedFilename.Data()) == 0 ) {
26  gSystem->Exec(Form("rm %s",convertedFilename.Data()));
27  }
28  return "";
29  }
30 
31  if ( gSystem->AccessPathName(convertedFilename.Data()) != 0 ) {
32  gSystem->Exec(Form("gs -dBATCH -dNOPAUSE -sDEVICE=txtwrite -sOutputFile=- %s | xargs -I %% > %s",filename.Data(),convertedFilename.Data()));
33  }
34 
35  return convertedFilename;
36 }
37 
38 //_________________________________
40 {
41  TObjArray* arr = trigName.Tokenize("-");
42  TString shortName = arr->At(0)->GetName();
43  if ( arr->GetEntries() > 2 ) {
44  shortName.Append(Form("-%s",arr->At(1)->GetName()));
45  }
46  delete arr;
47  return shortName;
48 }
49 
50 //_________________________________
52 {
53  TString specials = "+ ( )";
54  TObjArray* specialList = specials.Tokenize(" ");
55  for ( Int_t ichar=0; ichar<specialList->GetEntries(); ichar++ ) {
56  TString currChar = static_cast<TObjString*>(specialList->At(ichar))->GetString();
57  if ( str.Contains(currChar.Data()) ) str.ReplaceAll(currChar.Data(),Form("\\%s",currChar.Data()));
58  }
59  delete specialList;
60 }
61 
62 
63 //_________________________________
64 Int_t GetPage ( TString pattern, TString filename, TString trigger = "", Bool_t warnIfMissing = kTRUE )
65 {
66  TString convertedFilename = PdfToTxt(filename);
67 
68  ifstream inFile(convertedFilename.Data());
69  if ( ! inFile.is_open() ) return -1;
70 
72 
73  TObjArray* patternArr = pattern.Tokenize("&");
74  if ( ! trigger.IsNull() ) {
75  trigger.Prepend("(^|[ ]|/)");
76  trigger.Append("([ ]|$)");
77  patternArr->Add(new TObjString(trigger));
78  }
79 
80  TString currLine = "", currToken = "";
81  Int_t currPage = -1, foundPage = -1;
82  while ( ! inFile.eof() ) {
83  currToken.ReadToken(inFile);
84  if ( currToken == "Page" || inFile.eof() ) {
85  Bool_t isOk = kTRUE;
86  for ( Int_t ipat=0; ipat<patternArr->GetEntries(); ipat++ ) {
87  TString currPattern(static_cast<TObjString*>(patternArr->At(ipat))->GetString());
88  TPRegexp re(currPattern.Data());
89  if ( ! currLine.Contains(re) ) {
90  isOk = kFALSE;
91  break;
92  }
93  }
94  if ( isOk ) {
95  foundPage = currPage;
96  break;
97  }
98  if ( ! inFile.eof() ) {
99  currToken.ReadToken(inFile);
100  currPage = currToken.Atoi();
101  currLine = "";
102  }
103  }
104  else currLine += currToken + " ";
105  }
106  inFile.close();
107  delete patternArr;
108  if ( foundPage < 0 && warnIfMissing ) printf("Warning: cannot find %s\n",pattern.Data());
109 
110  return foundPage;
111 }
112 
113 //_________________________________
115 {
116  TString convertedFilename = PdfToTxt(filename);
117 
118  ifstream inFile(convertedFilename.Data());
119  if ( ! inFile.is_open() ) return -1;
120 
121  TString runList = "", currToken = "";
122  TString keyword = "RUN:";
123  while ( ! inFile.eof() ) {
124  currToken.ReadToken(inFile);
125  if ( currToken.Contains(keyword.Data()) ) {
126  currToken.ReplaceAll(keyword.Data(),"");
127  if ( currToken.Contains(",") || currToken.IsDigit() ) {
128  runList = currToken;
129  break;
130  }
131  }
132  }
133  inFile.close();
134  return runList;
135 }
136 
137 //_________________________________
139 {
140  str.ReplaceAll("\\","");
141  TString specials = "_";
142  TObjArray* specialList = specials.Tokenize(" ");
143  for ( Int_t ichar=0; ichar<specialList->GetEntries(); ichar++ ) {
144  TString currChar = static_cast<TObjString*>(specialList->At(ichar))->GetString();
145  if ( str.Contains(currChar.Data()) ) str.ReplaceAll(currChar.Data(),Form("\\\%s",currChar.Data()));
146  }
147  delete specialList;
148 }
149 
150 //_________________________________
151 void BeginFrame ( TString title, ofstream& outFile, TString label = "" )
152 {
153  outFile << endl;
154  outFile << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
155  outFile << "\\begin{frame}";
156  if ( ! label.IsNull() ) outFile << "\\label{" << label.Data() << "}";
157  outFile << endl;
158  outFile << " \\frametitle{" << title.Data() << "}" << endl;
159 }
160 
161 //_________________________________
162 void EndFrame ( ofstream& outFile )
163 {
164  outFile << "\\end{frame}" << endl;
165 }
166 
167 //_________________________________
168 void MakeDefaultItem ( ofstream& outFile, TString defaultItem = "" )
169 {
170  outFile << "\\begin{itemize}" << endl;
171  outFile << " \\item " << defaultItem.Data() << endl;
172  outFile << "\\end{itemize}" << endl;
173 }
174 
175 //_________________________________
176 Bool_t MakeSingleFigureSlide ( TString pattern, TString filename, TString title, ofstream &outFile, TString trigger = "", TString label = "", Bool_t warnIfMissing = kTRUE )
177 {
178  Int_t pageNum = GetPage(pattern,filename,trigger,warnIfMissing);
179  if ( pageNum<0 ) {
180  return kFALSE;
181  }
182 
183  BeginFrame(title,outFile,label);
184  outFile << " \\begin{columns}[onlytextwidth]" << endl;
185  outFile << " \\column{\\textwidth}" << endl;
186  outFile << " \\centering" << endl;
187  outFile << " \\includegraphics[width=0.98\\textwidth,height=0.92\\textheight,page=" << pageNum << "]{" << gSystem->BaseName(filename.Data()) << "}" <<endl;
188  outFile << " \\end{columns}" << endl;
189  EndFrame(outFile);
190  return kTRUE;
191 }
192 
193 //_________________________________
194 Bool_t MakeTriggerSlide ( TString filename, ofstream &outFile )
195 {
196  BeginFrame("Trigger chamber efficiencies", outFile);
197  outFile << " \\begin{columns}[onlytextwidth]" << endl;
198  outFile << " \\column{0.66\\textwidth}" << endl;
199  outFile << " \\centering" << endl;
200  for ( Int_t ich=0; ich<4; ich++ ) {
201  if ( ich%2 == 0 ) outFile << endl;
202  Int_t ipage = GetPage(Form("Trigger chamber efficiency vs run for chamber %i",11+ich),filename);
203  outFile << " \\includegraphics[width=0.48\\textwidth,page=" << ipage << "]{" << filename.Data() << "}" << endl;
204  }
205  outFile << " \\column{0.34\\textwidth}" << endl;
206  outFile << " \\centering" << endl;
207  Int_t ipage = GetPage("Multinomial probability",filename);
208  outFile << " \\includegraphics[width=0.98\\textwidth,page=" << ipage << "]{" << filename.Data() << "}" << endl;
209  outFile << " \\end{columns}" << endl;
210  EndFrame(outFile);
211  return kTRUE;
212 }
213 
214 //_________________________________
215 Bool_t MakeTriggerRPCslide ( TString filename, ofstream &outFile, Bool_t outliers = kFALSE )
216 {
217  TString baseName = outliers ? "eff.-<eff.> for outliers" : "efficiency";
218  BeginFrame(Form("Trigger chamber %s per RPC",baseName.Data()),outFile,outliers?"":"rpcEff");
219  outFile << " \\begin{columns}[onlytextwidth]" << endl;
220  outFile << " \\column{\\textwidth}" << endl;
221  outFile << " \\centering" << endl;
222  for ( Int_t ich=0; ich<4; ich++ ) {
223  if ( ich%2 == 0 ) outFile << endl;
224  Int_t ipage = GetPage(Form("Trigger chamber %s vs run for chamber %i&RPC",baseName.Data(),11+ich),filename);
225  outFile << " \\includegraphics[width=0.37\\textwidth,page=" << ipage << "]{" << filename.Data() << "}" << endl;
226  }
227  outFile << " \\end{columns}" << endl;
228  EndFrame(outFile);
229  return kTRUE;
230 }
231 
232 //_________________________________
233 void MakeSummary ( TString period, ofstream &outFile )
234 {
235  BeginFrame("Summary I",outFile);
236  outFile << "General informations" << endl;
237  outFile << "\\begin{itemize}" << endl;
238  outFile << " \\item Runs selected for MUON on ALICE logbook:" << endl;
239  outFile << " \\begin{itemize}" << endl;
240  outFile << " \\item Run Type: PHYSICS" << endl;
241  outFile << " \\item Duration: at least 10 min" << endl;
242  outFile << " \\item GDC mStream Recording: Yes" << endl;
243  outFile << " \\item Period: " << period.Data() << endl;
244  outFile << " \\item Detectors: At least [ MUON\\_TRG \\& MUON\\_TRK ] as Readout" << endl;
245  outFile << " \\item Quality: globally GOOD and NOT BAD for readout Detectors" << endl;
246  outFile << " \\item Beam Mode: STABLE" << endl;
247  outFile << " \\end{itemize}" << endl;
248  outFile << "\\end{itemize}" << endl;
249  outFile << endl;
250  outFile << " \\vspace{5mm}" << endl;
251  outFile << endl;
252  outFile << "\\begin{columns}[onlytextwidth]" << endl;
253  outFile << " \\column{\\textwidth}" << endl;
254  outFile << " \\centering" << endl;
255  outFile << " \\begin{tabular}{|l|lll|}" << endl;
256  outFile << " \\hline" << endl;
257  outFile << " & Total runs & CMUL & CMSL \\\\" << endl;
258  outFile << " \\hline" << endl;
259  outFile << " ALICE logbook & xx & xx & xx\\\\" << endl;
260  outFile << " Good from QA & xx & xx & xx\\\\" << endl;
261  outFile << " \\hline" << endl;
262  outFile << " \\end{tabular}" << endl;
263  outFile << "\\end{columns}" << endl;
264  EndFrame(outFile);
265 
266  BeginFrame("Summary II",outFile);
267  outFile << endl;
268  outFile << "General:" << endl;
269  MakeDefaultItem(outFile);
270  outFile << endl;
271  outFile << "MTR efficiency:" << endl;
272  MakeDefaultItem(outFile,"More than xx\\% efficiency in trigger chambers, stable");
273  outFile << endl;
274  outFile << "MCH and MUON data quality:" << endl;
275  MakeDefaultItem(outFile);
276  EndFrame(outFile);
277 }
278 
279 //_________________________________
280 void MakeRunSummary ( ofstream &outFile, TString trackerQA, ifstream* inFile = 0x0 )
281 {
282  TString runList = GetRunList(trackerQA);
283  TObjArray* runListArr = runList.Tokenize(",");
284  runListArr->Sort();
285 
286  Bool_t readSummary = ( inFile ) ? kTRUE : kFALSE;
287 
288  TString romanNum[10] = {"I","II","III","IV","V","VI","VII","VIII","IX","X"};
289 
290  Int_t nRuns = runListArr->GetEntries();
291  Int_t nRunsPerPage = 40;
292  Int_t nRunsPerColumn = nRunsPerPage/2;
293 
294  Int_t nPages = nRuns/nRunsPerPage;
295  if ( nRuns%nRunsPerPage > 0 ) nPages++;
296 
297  Int_t irun = 0;
298  Int_t readRun = -2, currRun = -1;
299 
300  for ( Int_t ipage=0; ipage<nPages; ipage++ ) {
301  TString title = "Run summary";
302  if ( nPages > 1 ) title += Form(" (%s)",romanNum[ipage].Data());
303  BeginFrame(title,outFile);
304  outFile << " \\begin{columns}[onlytextwidth,T]" << endl;
305  outFile << " \\footnotesize" << endl;
306  for ( Int_t icol=0; icol<2; icol++ ) {
307  Bool_t needsHline = ( icol == 0 || irun < nRuns );
308  outFile << " \\column{0.5\\textwidth}" << endl;
309  outFile << " \\centering" << endl;
310  outFile << " \\begin{tabular}{|cp{0.63\\textwidth}|}" << endl;
311  if ( needsHline ) outFile << " \\hline" << endl;
312  if ( nRuns == 0 ) {
313  outFile << " \\runTab[\\errorColor]{xxx}{xxx}" << endl;
314  }
315  else {
316  while ( irun<nRuns ) {
317  currRun = static_cast<TObjString*>(runListArr->UncheckedAt(irun++))->GetString().Atoi();
318  Bool_t isNew = kTRUE;
319  TString readLines = "", currLine = "";
320  while ( readSummary ) {
321  currLine.ReadLine(*inFile,kFALSE);
322  if ( currLine.Contains("runTab") ) {
323  TString sRun = currLine(TRegexp("{[0-9][0-9][0-9][0-9][0-9][0-9]}"));
324  sRun.Remove(TString::kLeading,'{');
325  sRun.Remove(TString::kTrailing,'}');
326  readRun = sRun.Atoi();
327  if ( readRun <= currRun ) readLines += currLine + "\n";
328  if ( readRun == currRun ) {
329  isNew = kFALSE;
330  break;
331  }
332  }
333  else if ( currLine.Contains("colorLegend") ) readSummary = kFALSE;
334  }
335  if ( isNew ) outFile << " \\runTab{" << currRun << "}{}" << endl;
336  else outFile << readLines.Data();
337  if ( irun%nRunsPerColumn == 0 ) break;
338  }
339  }
340 
341  if ( needsHline ) outFile << " \\hline" << endl;
342  if ( icol == 1 && ipage == nPages -1 ) {
343  outFile << " \\hline" << endl;
344  outFile << " \\colorLegend" << endl;
345  outFile << " \\hline" << endl;
346  }
347  outFile << " \\end{tabular}" << endl;
348  if ( icol == 0 ) outFile << endl;
349  else {
350  outFile << " \\end{columns}" << endl;
351  EndFrame(outFile);
352  }
353  } // loop on columns
354  } // loop on pages
355 
356  delete runListArr;
357 }
358 
359 //_________________________________
360 void MakePreamble ( ofstream &outFile )
361 {
362  outFile << "\\documentclass[9pt,table]{beamer}" << endl;
363  outFile << "\\mode<presentation>" << endl;
364  outFile << "\\usepackage[T1]{fontenc}" << endl;
365  outFile << "\\usepackage{lmodern}" << endl;
366  outFile << "\\usepackage{textcomp}" << endl;
367  outFile << "\\usepackage{amsmath}" << endl;
368  outFile << "\\usepackage{color,graphicx}" << endl;
369  outFile << "\\usepackage{colortbl}" << endl;
370  outFile << "\\usepackage{multirow}" << endl;
371  outFile << "\\usepackage{pifont}" << endl;
372  outFile << "\\usepackage{wasysym}" << endl;
373  outFile << "\\usepackage{appendixnumberbeamer}" << endl;
374  outFile << "\\usepackage[absolute,overlay]{textpos}" << endl;
375  outFile << "\\usetheme{Madrid}" << endl;
376  outFile << "\\useoutertheme{shadow}" << endl;
377  outFile << endl;
378  outFile << "\\setbeamersize{text margin left=0.5cm, text margin right=0.5cm}" << endl;
379  outFile << endl;
380  outFile << "\\hypersetup{colorlinks,linkcolor=red,urlcolor=blue}" << endl;
381  outFile << endl;
382  outFile << "% Slightly change the template" << endl;
383  outFile << "\\setbeamertemplate{navigation symbols}{} %suppress navigation symbols (bottom-right of frame)" << endl;
384 
385  outFile << "\\setbeamercolor*{author in head/foot}{parent=palette tertiary}" << endl;
386  outFile << "\\setbeamercolor*{title in head/foot}{parent=palette secondary}" << endl;
387  outFile << "\\setbeamercolor*{date in head/foot}{parent=palette primary}" << endl;
388  outFile << "\\setbeamercolor*{section in head/foot}{parent=palette tertiary}" << endl;
389  outFile << "\\setbeamercolor*{subsection in head/foot}{parent=palette primary}" << endl;
390  outFile << "\\newcommand{\\changeFootline}[1]{" << endl;
391  outFile << " \\setbeamertemplate{footline}{" << endl;
392  outFile << " \\hbox{%" << endl;
393  outFile << " \\begin{beamercolorbox}[wd=.2\\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%" << endl;
394  outFile << " \\insertshortauthor%~~(\\insertshortinstitute)" << endl;
395  outFile << " \\end{beamercolorbox}%" << endl;
396  outFile << " \\begin{beamercolorbox}[wd=.6\\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%" << endl;
397  outFile << " \\hypersetup{hidelinks}%" << endl;
398  outFile << " \\insertshorttitle" << endl;
399  outFile << " \\hspace*{2em}\\insertshortdate{}" << endl;
400  outFile << " \\end{beamercolorbox}%" << endl;
401  outFile << " \\begin{beamercolorbox}[wd=.2\\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%" << endl;
402  outFile << " #1\\hspace*{2ex}" << endl;
403  outFile << " \\end{beamercolorbox}}%" << endl;
404  outFile << " }}" << endl;
405  outFile << "\\changeFootline{\\insertframenumber / \\inserttotalframenumber}" << endl;
406  outFile << "\\setbeamertemplate{headline}{}" << endl;
407  outFile << endl;
408  outFile << endl;
409  outFile << "\\newcommand{\\badForPassColor}{magenta!50!white}" << endl;
410  outFile << "\\newcommand{\\errorColor}{red!50!white}" << endl;
411 // outFile << "\\newcommand{\\newColor}{blue!20!white}" << endl;
412  outFile << "\\newcommand{\\notInLogColor}{black!20!white}" << endl;
413  outFile << "\\newcommand{\\pendingColor}{yellow!50!white}" << endl;
414  outFile << "\\newcommand{\\warningColor}{orange!50!white}" << endl;
415  outFile << "\\newcommand{\\colorLegend}{" << endl;
416 // outFile << " \\multicolumn{2}{|l|}{\\colorbox{\\newColor}{~~} = newly analyzed}\\\\" << endl;
417  outFile << " \\multicolumn{2}{|l|}{\\colorbox{\\notInLogColor}{~~} = non-selected from e-logbook}\\\\" << endl;
418  outFile << " \\multicolumn{2}{|l|}{\\colorbox{\\pendingColor}{~~} = pending statement}\\\\" << endl;
419  outFile << " \\multicolumn{2}{|l|}{\\colorbox{\\warningColor}{~~} = possible problem}\\\\" << endl;
420  outFile << " \\multicolumn{2}{|l|}{\\colorbox{\\errorColor}{~~} = problem spotted}\\\\" << endl;
421  outFile << " \\multicolumn{2}{|l|}{\\colorbox{\\badForPassColor}{~~} = bad for this pass}\\\\}" << endl;
422  outFile << "\\newcommand{\\runTab}[3][white]{\\cellcolor{#1} #2 & \\cellcolor{#1} #3\\\\}" << endl;
423  outFile << endl;
424  outFile << "\\newcommand{\\pik}{\\ensuremath{\\pi\\mathrm{/K}}}" << endl;
425  outFile << "\\newcommand{\\mum}{\\mbox{$\\mu {\\rm m}$}}" << endl;
426  outFile << "\\newcommand{\\mom}{\\mbox{GeV$\\kern-0.15em /\\kern-0.12em c$}}" << endl;
427  outFile << "\\newcommand{\\pt}{\\ensuremath{p_{\\mathrm{T}}}}" << endl;
428  outFile << "\\newcommand{\\dd}{\\text{d}}" << endl;
429  outFile << "\\newcommand{\\raa}{\\ensuremath{R_{AA}}}" << endl;
430  outFile << "\\newcommand{\\un}[1]{\\protect\\detokenize{#1}}" << endl;
431  outFile << endl;
432 }
433 
434 //_________________________________
435 void BeginSlides ( TString period, TString pass, TString authors, ofstream &outFile )
436 {
437  TString authorsShort = "";
438  Bool_t previousIsLetter = kFALSE;
439  for ( Int_t ichar=0; ichar<authors.Length(); ichar++ ) {
440  TString currChar = authors[ichar];
441  currChar.ToUpper();
442  Int_t currentIsLetter = currChar.IsAlpha();
443  if ( currentIsLetter && ! previousIsLetter ) authorsShort += currChar + ".";
444  if ( currChar == "," ) authorsShort += ",";
445  previousIsLetter = currentIsLetter;
446  }
447 
448  outFile << "\\title{Muon QA: " << period.Data() << " " << pass.Data() << "}" << endl;
449  outFile << "\\author[" << authorsShort.Data() << "]{" << authors.Data() << "}" << endl;
450  outFile << "\\date{\\today}" << endl;
451 
452  outFile << "\\begin{document}" << endl;
453  outFile << "\\setlength{\\TPHorizModule}{1bp}" << endl;
454  outFile << "\\setlength{\\TPVertModule}{1bp}" << endl;
455  outFile << "\\textblockorigin{0bp}{0bp}" << endl;
456  outFile << endl;
457  outFile << "\\graphicspath{{images/}}" << endl;
458 
459  outFile << endl;
460  outFile << "\\begin{frame}" << endl;
461  outFile << " \\titlepage" << endl;
462  outFile << "\\end{frame}" << endl;
463 }
464 
465 //_________________________________
466 void EndSlides ( ofstream &outFile )
467 {
468  outFile << "\\end{document}" << endl;
469  outFile.close();
470 }
471 
472 //_________________________________
473 void StartAppendix ( ofstream &outFile )
474 {
475  outFile << endl;
476  outFile << endl;
477  outFile << "\\AtBeginSection[] % Do nothing for \\section*" << endl;
478  outFile << "{" << endl;
479  outFile << " \\begin{frame}<beamer>" << endl;
480  outFile << " \\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}" << endl;
481  outFile << " \\usebeamerfont{title}\\insertsectionhead" << endl;
482  outFile << " \\end{beamercolorbox}" << endl;
483  outFile << " \\end{frame}" << endl;
484  outFile << "}" << endl;
485  outFile << endl;
486  outFile << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
487  outFile << "\\appendix" << endl;
488  outFile << "\\renewcommand{\\theframenumber}{A.\\arabic{framenumber}}" << endl;
489  outFile << "\\changeFootline{\\theframenumber}" << endl;
490  outFile << "\\hypersetup{hidelinks}" << endl;
491  outFile << "\\section{\\huge Backup slides}" << endl;
492 }
493 
494 //_________________________________
495 void WriteRunList ( TString trackerQA, TString outFilename = "runListQA.txt" )
496 {
497  TString runList = GetRunList(trackerQA);
498  TObjArray* runListArr = runList.Tokenize(",");
499 
500  ofstream outFile(outFilename);
501  for ( Int_t irun=0; irun<runListArr->GetEntries(); irun++ ) {
502  outFile << static_cast<TObjString*>(runListArr->At(irun))->GetString().Atoi() << endl;
503  }
504  outFile.close();
505  delete runListArr;
506 
507  PdfToTxt(trackerQA,kTRUE);
508 }
509 
510 
511 //_________________________________
512 void UpdateExisting ( TString texFilename, TString trackerQA )
513 {
514  TString backupFile = texFilename;
515  backupFile.Append(".backup");
516  printf("Copying existing file into %s\n",backupFile.Data());
517  TFile::Cp(texFilename.Data(),backupFile);
518  ofstream outFile(texFilename.Data(),std::ofstream::out | std::ofstream::trunc);
519  ifstream inFile(backupFile.Data());
520  TString currLine = "", frameTitle = "";
521  Int_t nBlanks = 0;
522  while ( ! inFile.eof() ) {
523  currLine.ReadLine(inFile,kFALSE);
524  // Avoid too many blank lines
525  if ( currLine.IsNull() ) {
526  nBlanks++;
527  if ( nBlanks > 2 ) continue;
528  }
529  else nBlanks = 0;
530  if ( currLine == "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" ) {
531  frameTitle.ReadLine(inFile,kFALSE);
532  currLine += Form("\n%s",frameTitle.Data());
533  frameTitle.ReadLine(inFile,kFALSE);
534  currLine += Form("\n%s",frameTitle.Data());
535  if ( frameTitle.Contains("frametitle") && frameTitle.Contains("Run summary") ) {
536  MakeRunSummary(outFile, trackerQA, &inFile);
537  while ( currLine != "\\end{frame}" ) {
538  currLine.ReadLine(inFile);
539  }
540  continue;
541  }
542  }
543  outFile << currLine.Data() << endl;
544  }
545  inFile.close();
546 }
547 
548 //_________________________________
549 void MakeSlides ( TString period, TString pass, TString triggerList, TString authors, TString trackerQA = "QA_muon_tracker.pdf", TString triggerQA = "QA_muon_trigger.pdf", TString texFilename = "muonQA.tex", TString outRunList = "" )
550 {
551 
552  TString hasGs = gSystem->GetFromPipe("which gs");
553  if ( hasGs.IsNull() ) {
554  printf("The macro selects the pdf page with gs, but the program was not found on this machine. Sorry, but slides cannot be automatically generated on this machine.\n");
555  return;
556  }
557 
558  if ( gSystem->AccessPathName(texFilename.Data()) == 0 ) {
559  printf("Output file %s already exists: updating it\n", texFilename.Data());
560  UpdateExisting(texFilename, trackerQA);
561  }
562  else {
563  EscapeSpecialChars(period);
564  EscapeSpecialChars(pass);
565 
566  TObjArray* trigList = triggerList.Tokenize(",");
567 
568  ofstream outFile(texFilename);
569  outFile << "%TriggerList=" << triggerList.Data() << endl;
570  MakePreamble(outFile);
571  BeginSlides(period,pass,authors,outFile);
572 
573  MakeSummary(period,outFile);
574  MakeRunSummary(outFile, trackerQA);
575 
576  MakeSingleFigureSlide("Selections: RUN",trackerQA,"Number of events per trigger",outFile);
577  MakeSingleFigureSlide("L2A from QA",triggerQA,"Reconstruction: reconstructed triggers in QA wrt L2A from OCDB scalers",outFile);
578  MakeTriggerSlide(triggerQA,outFile);
579 
580  for ( Int_t itrig=0; itrig<trigList->GetEntries(); itrig++ ) {
581  TString currTrig = trigList->At(itrig)->GetName();
582  TString shortTrig = GetTriggerShort(currTrig);
583  MakeSingleFigureSlide("Number of Tracks",trackerQA,Form("Muon tracks / event in %s events",shortTrig.Data()),outFile,currTrig);
584  MakeSingleFigureSlide("Number of Tracks&for high mult.",trackerQA,Form("Muon tracks / event in %s events (central collisions)",shortTrig.Data()),outFile,currTrig,"",kFALSE);
585  MakeSingleFigureSlide("Sum of trigger tracks (matched + trigger-only) / # events in",trackerQA,Form("Muon tracker-trigger tracks / event in %s events",shortTrig.Data()),outFile,currTrig);
586  MakeSingleFigureSlide("Matched tracks charge asymmetry for&with acc. cuts",trackerQA,Form("Charge asymmetry in %s events",shortTrig.Data()),outFile,currTrig);
587  MakeSingleFigureSlide("Identified beam-gas tracks (pxDCA cuts) in matched tracks for",trackerQA,Form("Rel. num. of beam-gas tracks (id. by p$\\times$DCA cuts) in %s events",shortTrig.Data()),outFile,currTrig);
588  }
589  MakeSingleFigureSlide("averaged number of associated clusters or of the number of chamber hit per track",trackerQA,"Average number of clusters per track and dispersion",outFile);
590  MakeSingleFigureSlide("averaged number of clusters in chamber i per track",trackerQA,"Average number of clusters per chamber",outFile,"","clustersPerChamber");
591 
592  StartAppendix(outFile);
593  MakeSingleFigureSlide("Physics Selection Cut on selected triggers:",trackerQA,"Physics selection effects",outFile);
594  MakeSingleFigureSlide("<X> of clusters - associated to a track - in chamber i",trackerQA,"Average cluster position per chamber",outFile,"","clustersPosition");
595  MakeSingleFigureSlide("averaged normalized",trackerQA,"Tracking quality",outFile);
596 
597  MakeTriggerRPCslide(triggerQA,outFile);
598  MakeTriggerRPCslide(triggerQA,outFile,kTRUE);
599  MakeSingleFigureSlide("Trigger Lpt cut per run",trackerQA,"Trigger \\pt\\ cut",outFile);
600 
601  BeginFrame("Hardware issues",outFile);
602  outFile << "MUON Trigger" << endl;
603  MakeDefaultItem(outFile);
604  outFile << endl;
605  outFile << "MUON tracker" << endl;
606  MakeDefaultItem(outFile);
607  EndFrame(outFile);
608 
609  EndSlides(outFile);
610 
611  delete trigList;
612  }
613 
614  if ( ! outRunList.IsNull() ) WriteRunList(trackerQA, outRunList);
615 
616  // Clean converted txt files
617  TString filenames[2] = {trackerQA, triggerQA};
618  for ( Int_t ifile=0; ifile<2; ifile++ ) {
619  PdfToTxt(filenames[ifile],kTRUE);
620  }
621 }
void BeginSlides(TString period, TString pass, TString authors, ofstream &outFile)
Definition: MakeSlides.C:435
const char * filename
Definition: TestFCM.C:1
return jsonbuilder str().c_str()
Bool_t MakeTriggerSlide(TString filename, ofstream &outFile)
Definition: MakeSlides.C:194
const char * title
Definition: MakeQAPdf.C:26
void MakeDefaultItem(ofstream &outFile, TString defaultItem="")
Definition: MakeSlides.C:168
void MakeSlides(TString period, TString pass, TString triggerList, TString authors, TString trackerQA="QA_muon_tracker.pdf", TString triggerQA="QA_muon_trigger.pdf", TString texFilename="muonQA.tex", TString outRunList="")
Definition: MakeSlides.C:549
TSystem * gSystem
void WriteRunList(TString trackerQA, TString outFilename="runListQA.txt")
Definition: MakeSlides.C:495
TString GetRunList(TString filename)
Definition: MakeSlides.C:114
Bool_t MakeTriggerRPCslide(TString filename, ofstream &outFile, Bool_t outliers=kFALSE)
Definition: MakeSlides.C:215
void UpdateExisting(TString texFilename, TString trackerQA)
Definition: MakeSlides.C:512
int Int_t
Definition: External.C:63
void MakePreamble(ofstream &outFile)
Definition: MakeSlides.C:360
void MakeRunSummary(ofstream &outFile, TString trackerQA, ifstream *inFile=0x0)
Definition: MakeSlides.C:280
Bool_t MakeSingleFigureSlide(TString pattern, TString filename, TString title, ofstream &outFile, TString trigger="", TString label="", Bool_t warnIfMissing=kTRUE)
Definition: MakeSlides.C:176
void EscapeSpecialChars(TString &str)
Definition: MakeSlides.C:138
void EndSlides(ofstream &outFile)
Definition: MakeSlides.C:466
void BeginFrame(TString title, ofstream &outFile, TString label="")
Definition: MakeSlides.C:151
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
void EndFrame(ofstream &outFile)
Definition: MakeSlides.C:162
Int_t GetPage(TString pattern, TString filename, TString trigger="", Bool_t warnIfMissing=kTRUE)
Definition: MakeSlides.C:64
void MakeSummary(TString period, ofstream &outFile)
Definition: MakeSlides.C:233
void StartAppendix(ofstream &outFile)
Definition: MakeSlides.C:473
TString PdfToTxt(TString filename, Bool_t clear=kFALSE)
Definition: MakeSlides.C:19
void EscapeSpecialCharsForRegex(TString &str)
Definition: MakeSlides.C:51
bool Bool_t
Definition: External.C:53
TString GetTriggerShort(TString trigName)
Definition: MakeSlides.C:39