forked from LArbys/ssnet_example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_ssnet.py
59 lines (50 loc) · 1.41 KB
/
run_ssnet.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
import os, sys
flist=[]
if len(sys.argv) < 3:
print 'Usage:',sys.argv[0],'OUTPUT_FILE','INPUT_FILE0, INPUTFILE1, ...'
sys.exit(1)
outfile = sys.argv[1]
if os.path.isfile(outfile):
print 'output file already present:',outfile
sys.exit(1)
for argv in sys.argv:
if argv == outfile: continue
if not argv.endswith('.root'): continue
flist.append(argv)
outlist=[]
ERROR=False
for plane in ['plane0','plane1','plane2']:
try:
print 'Processing',plane
cmd = 'python pyana.py pyana.prototxt %s ' % plane
for f in flist:
cmd += '%s ' % f
print cmd
return_code = int(os.system(cmd))
fname = 'larcv_fcn_plane%s.root' % plane
if return_code:
sys.stderr.write('Failed with return code %d\n' % return_code)
raise Exception
if not os.path.isfile(fname):
sys.stderr.write('Expected output not found: %s\n' % fname)
raise Exception
outlist.append(fname)
except Exception:
print 'Error occurred! cleaning...'
for f in outlist:
os.remove(f)
ERROR=True
break
if ERROR:
if os.path.isfile('ssnet_input.root'):
os.remove('ssnet_input.root')
sys.exit(1)
outlist.append('ssnet_input.root')
cmd='hadd %s ' % outfile
print cmd
for f in outlist:
cmd += ' %s' % f
os.system(cmd)
for f in outlist:
os.remove(f)
sys.exit(0)