Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:33

0001 #! /usr/bin/env python
0002 
0003 r'''
0004 The Wrapper for makeSkim.py, the general config for cmsRun.
0005 '''
0006 from __future__ import print_function
0007 
0008 import optparse
0009 import os
0010 
0011 def _green(string):
0012     return '%s%s%s' %('\033[1;32m',string,'\033[1;0m') 
0013 
0014 # To parse commandline args
0015 
0016 usage='%prog -i inrootfile -o outrootfile -n number_of_events --outputcommands name_of_block'
0017 
0018 parser=optparse.OptionParser(usage)
0019 
0020 
0021 parser.add_option("-n", "--number",
0022                    help="The number of evts. The default is 50.",
0023                    default="50",
0024                    dest="nevts")
0025 
0026 parser.add_option("-i",
0027                    help="The infile name",
0028                    default="",
0029                    dest="infilename")                  
0030                    
0031 parser.add_option("-o",
0032                    help="The outfile name",
0033                    default="",
0034                    dest="outfilename")       
0035                    
0036 parser.add_option("--outputcommands",
0037                    help='The outputcommands (i.e. RECOSIMEventContent, '+\
0038                    'AODSIMEventContent, FEVTSIMEventContent, '+\
0039                    'AODEventContent and all blocks in EventContent.cff)',
0040                    default="",
0041                    dest="outputCommands")
0042 
0043 options,args=parser.parse_args() 
0044 
0045 if '' in (options.infilename,
0046           options.outfilename,
0047           options.outputCommands):
0048     raise ('Incomplete list of arguments!')
0049                                       
0050 # Construct and dump the metaconfiguration on disk as a python file
0051 metaconfig_content='nevts=%s\n' %options.nevts+\
0052                    'outputCommands="%s"\n' %options.outputCommands+\
0053                    'infile="%s"\n' %options.infilename+\
0054                    'outfile="%s"\n' %options.outfilename
0055 
0056 metaconfig_file=open('metaconfig.py','w')
0057 metaconfig_file.write(metaconfig_content) 
0058 metaconfig_file.close()
0059 
0060 # print it to screen!
0061 print(_green('\nThe Metaconfiguration:\n'))
0062 print(metaconfig_content)
0063 
0064 
0065 # and now execute!
0066 command='cmsRun ./makeSkim.py'
0067 print(_green('\nAnd now run %s ...\n' %command))
0068 os.environ['PYTHONPATH']+=':./' # to find the metaconfig..
0069 os.system(command)
0070 
0071 
0072 
0073                       
0074