-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_all.sh
executable file
·103 lines (82 loc) · 1.91 KB
/
run_all.sh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
DATADIR=midas
FRAGDIR=frag
ANALDIR=newanal
CALFILE=CalibrationFile.cal
GRSIFolder=./bin/GRSISort
#RUNINFO=run_info.info
FINISHEDSIZE=970000
#source $GRSIFolder/thisgrsi.sh
FILES=$DATADIR"/run*.mid"
#Not needed as GRSISort can cope
#THIS ROUGHLY ESTABLISHES A FILE THAT IS STILL BEING WRITTEN
#LAST=""
#for LAST in $FILES; do true; done
#echo $LAST file
#LASTFILESIZE=$(du "$LAST" | awk '{print $1}')
#if [ $LASTFILESIZE -gt $FINISHEDSIZE ]; then LAST=""; fi
ILEN=$#
for bar in $@
do
if [ "$bar" = "ONLY" ]
then
echo "Only making fragment trees"
ONLYFRAG=1
ILEN=$(($ILEN-1))
fi
done
#IF THERE IS USER INPUT USE THAT RATHER THAN DOING ALL
if [ $ILEN -gt 0 ];
then
FILES=""
for var in $@
do
if [ ! "$var" = "ONLY" ]
then
FILES=$FILES" "$DATADIR"/run"$var"*.mid"
fi
done
fi
#GO THROUGH THE FILE LIST
DLEN=${#DATADIR}
for f in $FILES
do
#SKIP THE OPEN FILE
#if [ "$f" == "$LAST" ]; then
# continue
#fi
g=${f:DLEN+4}
h=${g:0:${#g}-4}
FFILE=$FRAGDIR/fragment$h.root
AFILE=$ANALDIR/analysis$h.root
#echo "Processing $g $h"
# do something on $f
if [ ! -f $FFILE ] || [ "$FFILE" -ot "$f" ];
then
if [ -f $FFILE ];
then echo "File $FFILE exists but is older than $f."
else echo "File $FFILE does not exist."
fi
if [ $ONLYFRAG ];
then grsisort -lq --suppress-errors $CALFILE $f
else grsisort -laq --suppress-errors $CALFILE $f
fi
else
echo "File $FFILE exists."
fi
if [ -f analysis$h.root ];then mv analysis$h.root $ANALDIR;fi
if [ -f fragment$h.root ];then mv fragment$h.root $FRAGDIR;fi
if [ ! $ONLYFRAG ];
then
if [ ! -f $AFILE ] || [ "$AFILE" -ot "$$FFILE" ];then
if [ -f $AFILE ];
then echo "File $AFILE exists but is older than $f."
else echo "File $AFILE does not exist."
fi
grsisort -laq --suppress-errors $CALFILE $FFILE
else
echo "File $AFILE exists."
fi
if [ -f analysis$h.root ];then mv analysis$h.root $ANALDIR;fi
fi
done