-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeSkimDriver.py
executable file
·73 lines (50 loc) · 2.12 KB
/
makeSkimDriver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /usr/bin/env python
r'''
The Wrapper for makeSkim.py, the general config for cmsRun.
'''
import optparse
import os
def _green(string):
return '%s%s%s' %('\033[1;32m',string,'\033[1;0m')
# To parse commandline args
usage='%prog -i inrootfile -o outrootfile -n number_of_events --outputcommands name_of_block'
parser=optparse.OptionParser(usage)
parser.add_option("-n", "--number",
help="The number of evts. The default is 50.",
default="50",
dest="nevts")
parser.add_option("-i",
help="The infile name",
default="",
dest="infilename")
parser.add_option("-o",
help="The outfile name",
default="",
dest="outfilename")
parser.add_option("--outputcommands",
help='The outputcommands (i.e. RECOSIMEventContent, '+\
'AODSIMEventContent, FEVTSIMEventContent, '+\
'AODEventContent and all blocks in EventContent.cff)',
default="",
dest="outputCommands")
options,args=parser.parse_args()
if '' in (options.infilename,
options.outfilename,
options.outputCommands):
raise ('Incomplete list of arguments!')
# Construct and dump the metaconfiguration on disk as a python file
metaconfig_content='nevts=%s\n' %options.nevts+\
'outputCommands="%s"\n' %options.outputCommands+\
'infile="%s"\n' %options.infilename+\
'outfile="%s"\n' %options.outfilename
metaconfig_file=open('metaconfig.py','w')
metaconfig_file.write(metaconfig_content)
metaconfig_file.close()
# print it to screen!
print _green('\nThe Metaconfiguration:\n')
print metaconfig_content
# and now execute!
command='cmsRun ./makeSkim.py'
print _green('\nAnd now run %s ...\n' %command)
os.environ['PYTHONPATH']+=':./' # to find the metaconfig..
os.system(command)