CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
produceOfflineValidationTex.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # This script creates a .tex-file for displaying the results
3 # of an offline alignment validation of the CMS tracker.
4 #
5 # HOW TO USE:
6 # -Pass the paths of the directories containing the plots as arguments
7 # (these would be the ExtendedValidationImages-directories of the
8 # relevant validations). E.g.
9 # produceOfflineValidationTex.py plotdir1 plotdir2
10 # -To change the general properties of the presentation to be produced,
11 # modify the templates found in presentationTemplates.py.
12 # -To produce different plots, use the writePageReg-function to select
13 # the types of files you want on a page.
14 #
15 #
16 # Originally by Eemeli Tomberg, 2014
17 
18 
19 
20 from __future__ import print_function
21 import os
22 import stat
23 import sys
24 import time
25 
28 
29 # Script execution.
30 def main():
31  print('Producing a .tex file from plots...')
32 
33  # Get plots from given paths
34  if len(sys.argv) < 2:
35  print('Error: Need path of plots as an argument!')
36  sys.exit(1)
37 
38  validations = []
39  for plotpath in sys.argv[1:]:
40  validations.append(ValidationPlots(plotpath))
41 
42  classes = validationclasses(validations)
43 
44  # Compose .tex frames
45  frames = ''
46  for cls in classes:
47  for subsection in cls.presentationsubsections():
48  frames += subsection.write([_ for _ in validations if _.validationclass == cls])
49  # Summary
50  frames += SummarySection().write(validations)
51  # Additional plots
52  #frames += writePageReg('YourRegExp', 'PageTitle', validations)
53 
54  # Write final .tex file
55  file = open('presentation.tex', 'w')
56  file.write(texTemplate.replace('[frames]', frames).\
57  replace('[time]', time.ctime()))
58  file.close()
59 
60  # A script to get from .tex to .pdf
61  pdfScript = open('toPdf.sh', 'w')
62  pdfScript.write(toPdf)
63  pdfScript.close()
64  os.chmod("toPdf.sh", stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
65 
66 
67 
68 if __name__ == '__main__':
69  main()
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
Definition: main.py:1
def validationclasses
Definition: presentation.py:38