Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JAcousticsMonitorPeriod.sh
Go to the documentation of this file.
1#!/bin/zsh
2script=${0##*/}
3
4if [ -z $JPP_DIR ]; then
5 echo "Variable JPP_DIR undefined."
6 exit
7fi
8
9source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
10
11set_variable: WORKDIR ACOUSTICS_WORKDIR ./
12set_variable: FORMAT GRAPHICS_FORMAT gif
13
14if do_usage $*; then
15 usage "$script <detector file> minrun maxrun"
16fi
17
18if (( $# == 3 )); then
19 set_variable DETECTOR $argv[1]
20 set_variable MINRUN $argv[2]
21 set_variable MAXRUN $argv[3]
22else
23 fatal "Wrong number of arguments."
24fi
25
26JCookie.sh
27
28eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
29eval `JPrintDetector -a $DETECTOR -O SUMMARY`
30
31JAcoustics.sh $DETECTOR_ID
32
33source JAcousticsToolkit.sh
34
35CHECK_EXIT_CODE
36
37set_variable MONITOR_FILE_WEEK $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${MINRUN}_${MAXRUN}_monitor.root
38set_variable TEST_FILE_WEEK $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${MINRUN}_${MAXRUN}_test.root
39set_variable PLOT_ACOUS_RATE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${MINRUN}_${MAXRUN}_acous_rate
40set_variable PLOT_ACOUS_RATE_TEST $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${MINRUN}_${MAXRUN}_acous_rate-test
41set_variable NUM_RUNS $(($MAXRUN - $MINRUN + 1))
42set_array MONITOR_FILES
43set_array TEST_FILES
44
45for ((RUN=$MINRUN; RUN<=$MAXRUN; RUN++)); do
46
47 set_variable MONITOR_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_monitor.root
48 set_variable TEST_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_test.root
49
50 MONITOR_FILES+=($MONITOR_FILE)
51 TEST_FILES+=($TEST_FILE)
52
53 if [[ ! -f $MONITOR_FILE || ! -f $TEST_FILE ]]; then
54 $JPP_DIR/examples/JAcoustics/JAcousticsMonitor_short.sh $DETECTOR $RUN $RUN 0
55 fi
56
57done
58
59hadd -f $MONITOR_FILE_WEEK $MONITOR_FILES
60hadd -f $TEST_FILE_WEEK $TEST_FILES
61
62typeset -A EMITTERS
63
64get_tripods+ $WORKDIR/tripod.txt EMITTERS
65get_transmitters+ $WORKDIR/transmitter.txt EMITTERS
66
67for EMITTER in ${(@k)EMITTERS}; do
68
69 JScale1D \
70 -f "${MONITOR_FILE_WEEK}:H\[${EMITTER}\].event" \
71 -F "1.0/$NUM_RUNS" \
72 -o "scale.root" >& /dev/null
73
74 JPlot2D \
75 -f "scale.root:H\[${EMITTER}\].event" \
76 -> "string" \
77 -< "floor" \
78 -\^ "rate [Hz]" \
79 -O COLZ \
80 -p "57" \
81 -T "Emitter ${EMITTER}" \
82 -o ${PLOT_ACOUS_RATE}_\[${EMITTER}\].$FORMAT -B
83
84 JScale1D \
85 -f "${TEST_FILE_WEEK}:H\[${EMITTER}\].rate-test" \
86 -F "1.0/$NUM_RUNS" \
87 -o "scale_test.root" >& /dev/null
88
89 JPlot2D \
90 -f "scale_test.root:H\[${EMITTER}\].rate-test" \
91 -> "string" \
92 -< "floor" \
93 -\^ "fraction of runs outside the rate range" \
94 -z "0 1" \
95 -O COLZ \
96 -T "Emitter ${EMITTER}" \
97 -o ${PLOT_ACOUS_RATE_TEST}_\[${EMITTER}\].$FORMAT -B
98
99 #remove temporary files
100 rm -f "scale.root"
101 rm -f "scale_test.root"
102done
103
104if [[ -f ${PLOT_ACOUS_RATE}.$FORMAT ]]; then
105 rm -f ${PLOT_ACOUS_RATE}.$FORMAT
106fi
107
108if [[ -f ${PLOT_ACOUS_RATE_TEST}.$FORMAT ]]; then
109 rm -f ${PLOT_ACOUS_RATE_TEST}.$FORMAT
110fi
111
112set_array start_time $(JRuns -D "$DETECTOR_ID" -@ "run = ${MINRUN}" -F UNIXJOBSTART -F UNIXJOBEND --)
113set_array end_time $(JRuns -D "$DETECTOR_ID" -@ "run = ${MAXRUN}" -F UNIXJOBSTART -F UNIXJOBEND --)
114
115set_variable start_time_h $(date '+%d-%m-%Y %H:%M' -d @$(($start_time[1]/1000)))
116set_variable end_time_h $(date '+%d-%m-%Y %H:%M' -d @$(($end_time[2]/1000)))
117
118montage \
119 -tile 3x10 \
120 -geometry +0+10 \
121 -title "Average acoustic rate \n Runs: ${MINRUN}-${MAXRUN}, Time: ${start_time_h} - ${end_time_h}" \
122 ${PLOT_ACOUS_RATE}_*.$FORMAT \
123 ${PLOT_ACOUS_RATE}.$FORMAT >& /dev/null
124
125montage \
126 -tile 3x10 \
127 -geometry +0+10 \
128 -title "Fraction of runs outside accepted rate range: 10% < rate < 102% of the expected rate \n Runs: ${MINRUN}-${MAXRUN}, Time: ${start_time_h} - ${end_time_h}" \
129 ${PLOT_ACOUS_RATE_TEST}_*.$FORMAT \
130 ${PLOT_ACOUS_RATE_TEST}.$FORMAT >& /dev/null
131
132#clean
133rm -f ${PLOT_ACOUS_RATE}_*.$FORMAT
134rm -f ${PLOT_ACOUS_RATE_TEST}_*.$FORMAT