Jpp 20.0.0-rc.7
the software that should make you happy
Loading...
Searching...
No Matches
JDetectorSupportkit.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2script=${0##*/}
3
4# ------------------------------------------------------------------------------------------
5#
6# Auxiliary script to test consistency of geometry of optical modules from database.
7#
8# ------------------------------------------------------------------------------------------
9
10if [ -z $JPP_DIR ]; then
11 echo "Variable JPP_DIR undefined."
12 exit
13fi
14
15source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
16
17set_variable DEBUG 3
18set_variable: WORKDIR TEST_WORKDIR ${TMPDIR:-/tmp}
19set_array FILTER P0ARCW016
20
21if ( do_usage $* ); then
22 usage "$script (detector identifier)*"
23fi
24
25
26typeset -A DETECTORS
27
28if (( $# != 0 )); then
29
30 for D in $argv[*]; do
31
32 if [[ "$D[1]" == "D" ]]; then
33 DETECTORS[$D]=$(getDetector -D $D -O int)
34 else
35 DETECTORS[$(getDetector -D $D -O string)]=$D
36 fi
37 done
38else
39
40 # list of detectors deployed in the sea
41
42 CSV=";"
43
44 DETECTORS=($(JPrintDB \
45 -q detectors \
46 -c "$CSV" \
47 -W 1 | awk -F "$CSV" '{ if ($4 ~ ".*Deployment.*") { print $1, $2 }}'))
48fi
49
50# dependencies of pre-calibration of detectors
51
52typeset -A DEPENDENCIES
53
54DEPENDENCIES[D0ARCA009]=D0ARCA006
55DEPENDENCIES[D0ARCA021]=D0ARCA009
56DEPENDENCIES[D0ARCA020]=D0ARCA021
57#DEPENDENCIES[D0ARCA028]=D0ARCA021 # optical module anomalies already implemented in database for this detector
58
59DEPENDENCIES[D0ORCA018]=D1ORCA015
60DEPENDENCIES[D1ORCA015]=D0ORCA015
61DEPENDENCIES[D0ORCA015]=D1ORCA011
62DEPENDENCIES[D1ORCA011]=D0ORCA010
63DEPENDENCIES[D0ORCA010]=D_ORCA006
64DEPENDENCIES[D0ORCA023]=D0ORCA018
65
66# future modificatons per detector
67
68D0ARCA051=()
69D0ARCA051+=("-M \"805631219 swap 23 25\"")
70D0ARCA051+=("-M \"805631219 swap 24 30\"")
71D0ARCA051+=("-M \"805536812 lower \$((+60.0 * \$PI / 180.0))\"")
72D0ARCA051+=("-M \"810310870 swap 12 15\"")
73#D0ARCA051+=("-R \"805536976 D1\"") # anomalies of this optical module already implemented in database
74
75D0ARCW021=($D0ARCA051) # copy modifications
76
77ERRORS=()
78
79for DETID DETOID in ${(kv)DETECTORS}; do
80
81 if (( $FILTER[(I)$DETID] != 0)); then
82 continue
83 fi
84
85 printf "Checking detector %s/%4d\n" $DETID $DETOID
86
87 RUNS=($(JRuns -D $DETID -F RUN))
88
89 if (( ${#RUNS} != 0 )); then
90
91 JDetectorDB -D $DETID -@ "tcal = ?" -@ "pcal = ?" -@ "rcal = ?" -@ "acal = ?" -@ "ccal = ?" -@ "scal = ?" -o $WORKDIR/detector.datx
92
93 # future modifications
94
95 MODIFICATIONS=(${(P)DETID})
96
97 # recursively collect previous modifications
98
99 D=$DETID
100
101 while [[ "$D" != "" ]]; do
102
103 ACOUSTICS_SCRIPT=$(which pre-calibration_$D.sh)
104
105 if (( $? == 0 )); then
106 MODIFICATIONS+=("$(grep -- swap $ACOUSTICS_SCRIPT | tr '\\' ' ')")
107 MODIFICATIONS+=("$(grep -- lower $ACOUSTICS_SCRIPT | tr '\\' ' ')")
108 MODIFICATIONS+=("$(grep -- -R $ACOUSTICS_SCRIPT | tr '\\' ' ')")
109 fi
110
111 if [[ "$DEPENDENCIES[$D]" != "" ]]; then
112 echo "$D -> $DEPENDENCIES[$D]"
113 fi
114
115 D=$DEPENDENCIES[$D]
116 done
117
118 # reduce
119
120 for (( i = 1; $i <= ${#MODIFICATIONS}; )); do
121 if [[ "$MODIFICATIONS[$i]" == "" ]]; then
122 MODIFICATIONS[$i]=()
123 else
124 let "i += 1"
125 fi
126 done
127
128 # apply mofifications
129
130 if (( ${#MODIFICATIONS} != 0 )); then
131
132 echo "Applying modifications:"
133
134 for M in $MODIFICATIONS[*]; do
135 echo " $M"
136 done
137
138 eval JEditDetector \
139 -a $WORKDIR/detector.datx \
140 -o $WORKDIR/detector.datx \
141 " ${^MODIFICATIONS}"
142 fi
143
144 # test
145
146 $JPP_DIR/software/JDetector/JDestructDetector -a $WORKDIR/detector.datx -o $WORKDIR/test_%.txt
147
148 if (( $? != 0 )); then
149
150 ERRORS+=($DETID)
151
152 echo "${RED}Detector $DETID is incompatible with database.${RESET}"
153 else
154 echo "${GREEN}Detector $DETID is compatible with database after ${#MODIFICATIONS} modifications.${RESET}"
155 fi
156 fi
157done
158
159rm -f $WORKDIR/detector.datx
160rm -f $WORKDIR/test_*.txt
161
162if (( ${#ERRORS} != 0 )); then
163 fatal "Failing detectors $ERRORS[*]."
164fi