Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:06

0001 #!/usr/bin/env python3
0002 # This script creates a .tex-file for displaying the results
0003 # of an offline alignment validation of the CMS tracker.
0004 #
0005 # HOW TO USE:
0006 # -Pass the paths of the directories containing the plots as arguments
0007 #  (these would be the ExtendedValidationImages-directories of the
0008 #  relevant validations). E.g.
0009 #    produceOfflineValidationTex.py plotdir1 plotdir2
0010 # -To change the general properties of the presentation to be produced,
0011 #  modify the templates found in presentationTemplates.py.
0012 # -To produce different plots, use the writePageReg-function to select
0013 #  the types of files you want on a page.
0014 #
0015 #
0016 # Originally by Eemeli Tomberg, 2014
0017 
0018 
0019 
0020 import os
0021 import stat
0022 import sys
0023 import time
0024 
0025 from Alignment.OfflineValidation.TkAlAllInOneTool.presentation import *
0026 from Alignment.OfflineValidation.TkAlAllInOneTool.presentationTemplates import *
0027 
0028 # Script execution.
0029 def main():
0030     print('Producing a .tex file from plots...')
0031 
0032     # Get plots from given paths
0033     if len(sys.argv) < 2:
0034         print('Error: Need path of plots as an argument!')
0035         sys.exit(1)
0036 
0037     validations = []
0038     for plotpath in sys.argv[1:]:
0039         validations.append(ValidationPlots(plotpath))
0040 
0041     classes = validationclasses(validations)
0042 
0043     # Compose .tex frames
0044     frames = ''
0045     for cls in classes:
0046         for subsection in cls.presentationsubsections():
0047             frames += subsection.write([_ for _ in validations if _.validationclass == cls])
0048     # Summary
0049     frames += SummarySection().write(validations)
0050     # Additional plots
0051     #frames += writePageReg('YourRegExp', 'PageTitle', validations)
0052 
0053     # Write final .tex file
0054     file = open('presentation.tex', 'w')
0055     file.write(texTemplate.replace('[frames]', frames).\
0056                replace('[time]', time.ctime()))
0057     file.close()
0058 
0059     # A script to get from .tex to .pdf
0060     pdfScript = open('toPdf.sh', 'w')
0061     pdfScript.write(toPdf)
0062     pdfScript.close()
0063     os.chmod("toPdf.sh", stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
0064 
0065 
0066 
0067 if __name__ == '__main__':
0068     main()