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