Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
examples/JCompass/JAHRSMonitor.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3#
4# \author mdejong
5#
6version=1.0
7script=${0##*/}
8
9if [ -z $JPP_DIR ]; then
10 echo "Variable JPP_DIR undefined."
11 exit
12fi
13
14source $JPP_DIR/setenv.sh $JPP_DIR
15
16zmodload zsh/mathfunc
17
18set_variable: DEBUG COMPASS_DEBUG 2
19set_variable: WORKDIR COMPASS_WORKDIR ./
20set_variable: ZMIN COMPASS_ZMIN 1000
21set_variable: ZMAX COMPASS_ZMAX 0
22set_variable DIR $JPP_DIR/examples/JCompass/
23set_variable: FORMAT GRAPHICS_FORMAT gif
24set_variable+ BATCH GRAPHICS_BATCH -B
25
26if do_usage $*; then
27 usage "$script <detector file> (run[-run])+"\
28 "\nAuxiliary script to download acoustic data from database and to process them through the event builder."
29fi
30
31if (( $# > 1 )); then
32 set_variable DETECTOR $argv[1]
33 set_array RUNS $argv[2,-1]
34else
35 fatal "Wrong number of arguments."
36fi
37
38set_variable AHRS_CALIBRATION_FILE $WORKDIR/ahrs_calibration.txt
39
40eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
41
42
43if [[ ! -f $AHRS_CALIBRATION_FILE ]]; then
44
45 JAHRSCalibration \
46 -D $DETECTOR_ID \
47 -o $AHRS_CALIBRATION_FILE \
48 -d $DEBUG
49fi
50
51expand_array RUNS
52
53for RUN in $RUNS[*]; do
54
55 set_variable INPUT_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_ahrs.root
56
57 if [[ ! -f $INPUT_FILE ]]; then
58
59 echo -n "Writing $INPUT_FILE... "
60
61 JConvertDB \
62 -q "ahrs" \
63 -@ "detid = $DETECTOR_ID" \
64 -@ "minrun = $RUN" \
65 -@ "maxrun = $RUN" \
66 -o $INPUT_FILE \
67 -d $DEBUG --!
68
69 if (( $? == 0 )); then
70 echo "OK"
71 else
72 echo "no data"
73 fi
74 fi
75
76 $DIR/JAHRSMonitor \
77 -a $DETECTOR \
78 -c $AHRS_CALIBRATION_FILE \
79 -f $INPUT_FILE \
80 -o $WORKDIR/monitor.root \
81 -d $DEBUG --!
82
83 JPlot2D \
84 -f $WORKDIR/monitor.root:detector \
85 -> "string" \
86 -< "floor" \
87 -z "$ZMIN $ZMAX" \
88 -O COLZ \
89 -T "$RUN" \
90 -o ${TMPDIR:-/tmp}/AHRS_$RUN.$FORMAT $BATCH
91done
92
93INPUT_FILES=(${TMPDIR:-/tmp}/AHRS_${^RUNS}.$FORMAT)
94
95typeset -i NX
96typeset -i NY
97
98let "NY = sqrt(${#INPUT_FILES}) * 0.75 + 0.25"
99let "NX = (${#INPUT_FILES} + $NY - 1)/ $NY"
100
101montage \
102 -tile ${NX}x${NY} \
103 -geometry +0+0 \
104 $INPUT_FILES \
105 $WORKDIR/AHRS.$FORMAT >& /dev/null
106