CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 import os
21 import stat
22 import sys
23 import time
24 
27 
28 # Script execution.
29 def main():
30  print 'Producing a .tex file from plots...'
31 
32  # Get plots from given paths
33  if len(sys.argv) < 2:
34  print 'Error: Need path of plots as an argument!'
35  sys.exit(1)
36 
37  validations = []
38  for plotpath in sys.argv[1:]:
39  validations.append(ValidationPlots(plotpath))
40 
41  classes = validationclasses(validations)
42 
43  # Compose .tex frames
44  frames = ''
45  for cls in classes:
46  for subsection in cls.presentationsubsections():
47  frames += subsection.write([_ for _ in validations if _.validationclass == cls])
48  # Summary
49  frames += SummarySection().write(validations)
50  # Additional plots
51  #frames += writePageReg('YourRegExp', 'PageTitle', validations)
52 
53  # Write final .tex file
54  file = open('presentation.tex', 'w')
55  file.write(texTemplate.replace('[frames]', frames).\
56  replace('[time]', time.ctime()))
57  file.close()
58 
59  # A script to get from .tex to .pdf
60  pdfScript = open('toPdf.sh', 'w')
61  pdfScript.write(toPdf)
62  pdfScript.close()
63  os.chmod("toPdf.sh", stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
64 
65 
66 
67 if __name__ == '__main__':
68  main()
def replace(string, replacements)
def validationclasses(validations)
Definition: presentation.py:35
Definition: main.py:1
def write(self, setup)