Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:32:54

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 from __future__ import print_function
0021 import os
0022 import stat
0023 import sys
0024 import time
0025 
0026 from Alignment.OfflineValidation.TkAlAllInOneTool.presentation import *
0027 from Alignment.OfflineValidation.TkAlAllInOneTool.presentationTemplates import *
0028 
0029 # Script execution.
0030 def main():
0031     print('Producing a .tex file from plots...')
0032 
0033     # Get plots from given paths
0034     if len(sys.argv) < 2:
0035         print('Error: Need path of plots as an argument!')
0036         sys.exit(1)
0037 
0038     validations = []
0039     for plotpath in sys.argv[1:]:
0040         validations.append(ValidationPlots(plotpath))
0041 
0042     classes = validationclasses(validations)
0043 
0044     # Compose .tex frames
0045     frames = ''
0046     for cls in classes:
0047         for subsection in cls.presentationsubsections():
0048             frames += subsection.write([_ for _ in validations if _.validationclass == cls])
0049     # Summary
0050     frames += SummarySection().write(validations)
0051     # Additional plots
0052     #frames += writePageReg('YourRegExp', 'PageTitle', validations)
0053 
0054     # Write final .tex file
0055     file = open('presentation.tex', 'w')
0056     file.write(texTemplate.replace('[frames]', frames).\
0057                replace('[time]', time.ctime()))
0058     file.close()
0059 
0060     # A script to get from .tex to .pdf
0061     pdfScript = open('toPdf.sh', 'w')
0062     pdfScript.write(toPdf)
0063     pdfScript.close()
0064     os.chmod("toPdf.sh", stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
0065 
0066 
0067 
0068 if __name__ == '__main__':
0069     main()