forked from pcbend/GRUTinizer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
unpacker
executable file
·86 lines (66 loc) · 1.95 KB
/
unpacker
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
#!/bin/bash
#PBS -q AM
# usage : qsub -l select=1:ncpus=8:mem=8gb -v RUN_NUMBER=<run number> unpack
# e.g. : qsub -l select=1:ncpus=8:mem=8gb -v RUN_NUMBER=2071 unpack
# rootfiles are placed in output directory below
RUN_NUMBER="-1"
anadir=.
hists="e441"
CAL_FILE=e441.cal
VAL_FILE=c12.val
DO_HISTS=0
while getopts ":r:v:c:h" opt; do
case $opt in
r)
RUN_NUMBER=$OPTARG
;;
c)
CAL_FILE=$OPTARG
;;
v)
VAL_FILE=$OPTARG
;;
h) DO_HISTS=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [ $RUN_NUMBER -eq -1 ] || [ $# == 0 ]; then
echo "Usage: ./unpack -r RUN_NUMBER -c CALIBRATION_FILE -v VALUE_FILE"
exit
fi
histlib=$anadir/lib/lib$hists.so
histsrc=$anadir/histos/$hists.cxx
calibrations=$anadir/config/$CAL_FILE
histdef=$anadir/hist.def
constants=$anadir/config/$VAL_FILE
grutinizer=$anadir/bin/grutinizer
# data directories
grdata=$anadir/data/gr/
outputdir=$anadir/data/analysis/
run_number=$(echo "$RUN_NUMBER" | sed -r 's/.*_([0-9]*)\..*/\1/g')
outputdir+="Run$run_number/"
mkdir -p $outputdir
x=$(ls $anadir/data/cagra/run_${run_number}.gtd* 2> /dev/null)
if [ "$x" == "" ]; then
cagradata=""
else
cagradata="$anadir/data/cagra/run_${run_number}.gtd*"
fi
if [ $DO_HISTS == 1 ]; then
cp $calibrations $constants $histdef $histsrc $outputdir
cmd="$grutinizer -Hmq $histlib $calibrations $constants ${cagradata} ${grdata}run${run_number}.bld -o ${outputdir}run${run_number}.root --hist-output ./hist${run_number}.root"
else
cp $calibrations $constants $histdef $outputdir
cmd="$grutinizer -mq $calibrations $constants ${cagradata} ${grdata}run${run_number}.bld -o ${outputdir}run${run_number}.root"
fi
echo $cmd
echo $cmd > $outputdir"grut.cmd"
$cmd