Jpp  master_rocky
the software that should make you happy
test-Tuna.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 # ------------------------------------------------------------------------------------------
5 #
6 # Auxiliary script to test slow control data from database.
7 #
8 # ------------------------------------------------------------------------------------------
9 
10 if [ -z $JPP_DIR ]; then
11  echo "Variable JPP_DIR undefined."
12  exit
13 fi
14 
15 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
16 
17 set_variable: DEBUG DATABASE_DEBUG 2
18 set_variable: WORKDIR DATABASE_WORKDIR ${TMPDIR:-/tmp}/
19 set_variable: CANVAS DATABASE_CANVAS 1200x600
20 set_variable: TIMEAXIS DATABASE_TIMESAXIS %d:%m:%y%F1970-01-01 00:00:00
21 set_variable: GRAPHICS DATABASE_GRAPHICS gif
22 
23 if do_usage $*; then
24  usage "$script <input file> <parameters file> [working directory]"
25 fi
26 
27 case $# in
28  3) set_variable WORKDIR $3;&
29  2) set_variable PARAMETERS_FILE $2;
30  set_variable INPUT_FILE $1;;
31  *) fatal "Wrong number of arguments."
32 esac
33 
34 if [[ ! -f $INPUT_FILE ]]; then
35  fatal "File $INPUT_FILE not found."
36 fi
37 
38 if [[ ! -f $PARAMETERS_FILE ]]; then
39  echo $PARAMETERS_FILE > $WORKDIR/.parameters.txt # temporary file
40  set_variable PARAMETERS_FILE $WORKDIR/.parameters.txt
41 fi
42 
43 mkdir -p $WORKDIR
44 
45 set_variable OUTPUT_FILE $WORKDIR/test.root
46 
47 JTestTuna \
48  -f $INPUT_FILE:\.\* \
49  -P $PARAMETERS_FILE \
50  -o $OUTPUT_FILE \
51  -d $DEBUG
52 
53 for QUANTITY in `JPrintResult -f ${OUTPUT_FILE}:\.\* -O "%s"`; do
54 
55  notice "Creating graphics ${WORKDIR}/${QUANTITY}.${GRAPHICS}."
56 
57  set_variable quantity `echo $QUANTITY | sed 's/\[/\\\[/g;s/\]/\\\]/g'`
58 
59  JPlot1D \
60  -w "$CANVAS" \
61  -f "${OUTPUT_FILE}:${quantity}$" \
62  -T "?" \
63  -t "$TIMEAXIS" \
64  -o ${WORKDIR}/${QUANTITY}.${GRAPHICS} \
65  -d $DEBUG -B
66 done
67 
68 rm -f $OUTPUT_FILE
69 rm -f $WORKDIR/.parameters.txt