-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkOpenHLTmenu.py
71 lines (51 loc) · 1.42 KB
/
mkOpenHLTmenu.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
#!/usr/bin/python
#
import sys,string,math,os
def usage():
""" Usage: mkOpenHLTmenu.py
Reads in list of HLT paths and output list of paths suitable for RateEff macros
outfile is optional
"""
pass
def OpenFile(file_in,iodir):
""" file_in -- Input file name
iodir -- 'r' readonly 'r+' read+write """
try:
ifile=open(file_in, iodir)
# print "Opened file: ",file_in," iodir ",iodir
except:
print "Could not open file: ",file_in
sys.exit(1)
return ifile
def CloseFile(ifile):
ifile.close()
def ReadFile(file):
infile=OpenFile(file,'r')
iline=0
x = infile.readline()
pathlist=[]
while x != "":
iline+=1
xx=string.strip(x)
pathlist.append(xx)
x = infile.readline()
CloseFile(infile)
return pathlist
if __name__ == '__main__':
narg=len(sys.argv)
if narg < 2 :
print usage.__doc__
sys.exit(1)
InputFile=sys.argv[1]
pathlist=ReadFile(InputFile)
OUTPUTFILE="hltnames.dat"
ifile=OpenFile(OUTPUTFILE,"w")
ifile.write(" triggers = (" + "\n")
for path in pathlist:
print path
out_string=" (\"" + path
out_string=out_string + "\",\t\"OpenL1_ZeroBias" + "\",\t"
out_string=out_string + "1, 0.15),"
ifile.write(out_string + "\n")
ifile.write(" );" + "\n")
CloseFile(ifile)