Jpp  19.1.0
the software that should make you happy
JAHRS.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 #
4 # \author mdejong
5 #
6 version=1.0
7 script=${0##*/}
8 
9 if [ -z $JPP_DIR ]; then
10  echo "Variable JPP_DIR undefined."
11  exit
12 fi
13 
14 source $JPP_DIR/setenv.sh $JPP_DIR
15 
16 set_variable: DEBUG COMPASS_DEBUG 2
17 set_variable: WORKDIR COMPASS_WORKDIR ./
18 
19 if do_usage $*; then
20  usage "$script <detector identifier> (run[-run])+"\
21  "\nAuxiliary script to download AHRS data from database."
22 fi
23 
24 if (( $# > 1 )); then
25  set_variable DETECTOR_ID $argv[1]
26  set_array RUNS $argv[2,-1]
27 else
28  fatal "Wrong number of arguments."
29 fi
30 
31 JCookie.sh
32 
33 let "NUMBER_OF_ERRORS = 0"
34 
35 expand_array RUNS
36 
37 BUFFER=(`JRuns -D $DETECTOR_ID -F RUN`)
38 
39 for RUN in ${RUNS:*BUFFER}; do
40 
41  set_variable AHRS_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_ahrs.root
42 
43  if [[ ! -f $AHRS_FILE ]]; then
44 
45  echo -n "Writing $AHRS_FILE... "
46 
47  JConvertDB \
48  -q "ahrs" \
49  -@ "detid = $DETECTOR_ID" \
50  -@ "minrun = $RUN" \
51  -@ "maxrun = $RUN" \
52  -o $AHRS_FILE \
53  -d $DEBUG --
54 
55  if (( $? == 0 )); then
56  echo "OK"
57  else
58  echo "no data"
59  let "NUMBER_OF_ERRORS = $NUMBER_OF_ERRORS + 1"
60  fi
61  fi
62 done
63 
64 if (( $NUMBER_OF_ERRORS != 0 )); then
65  error "Number of errors $NUMBER_OF_ERRORS"
66 fi