Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
pre-calibration_D0ORCA042.sh
Go to the documentation of this file.
1#!/bin/zsh
2script=${0##*/}
3
4# --------------------------------------------------------------------------------------------
5#
6# Steering script for the global-fit-of-global-fits procedure of the D0ORCA042 (???) detector.
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 DETECTOR_ID 300
18set_array RUNS 30086-30094
19set_variable ARCHIVE_INPUT_BRANCH D0ORCA033_fixed
20set_variable INPUT_DETECTOR_ID 291
21set_variable: THREADS ACOUSTICS_THREADS 32
22set_variable SINGULARITY -
23set_variable: WORKDIR ACOUSTICS_WORKDIR ./
24set_variable HOMEDIR $WORKDIR
25
26
27if do_usage $*; then
28 usage "$script"\
29 "\nRequires variable CALIBRATION_ARCHIVE to be set for the user."
30fi
31
32source JAcousticsToolkit.sh
33
34set_variable DETECTOR $WORKDIR/detector.datx
35set_variable TRIPOD $WORKDIR/tripod.txt
36set_variable DETECTOR_INITIAL detector_initial.datx
37set_variable TRIPOD_INITIAL tripod_initial.txt
38set_variable TRANSMITTER_INITIAL transmitter_initial.txt
39set_variable HYDROPHONE_INITIAL hydrophone_initial.txt
40expand_array RUNS
41
42
43# Run in HOMEDIR
44mkdir -p $HOMEDIR
45cd $HOMEDIR
46
47# -------------------------------------------------------------------------------------------------------------
48#
49# 1. Clone the git calibration archive to workdir to retrieve the required detector, tripod and transmitter inputs
50#
51# -------------------------------------------------------------------------------------------------------------
52
53git clone \
54 --recursive \
55 --branch $ARCHIVE_INPUT_BRANCH \
56 git@git.km3net.de:auxiliary_data/calibration \
57 $WORKDIR/auxiliary_data/calibration
58
59# Retrieve D0ORCA038 detector, tripod, transmitter and hydrophone from the calibration archive
60getFile.sh "$WORKDIR/auxiliary_data/calibration" $INPUT_DETECTOR_ID 1 detector G_1.3.1 "$WORKDIR/D0ORCA038"
61getFile.sh "$WORKDIR/auxiliary_data/calibration" $INPUT_DETECTOR_ID 1 tripod A_1.3.0 "$WORKDIR/tripod_D0ORCA038"
62getFile.sh "$WORKDIR/auxiliary_data/calibration" $INPUT_DETECTOR_ID 1 transmitter A_1.3.0 "$WORKDIR/transmitter_D0ORCA038"
63getFile.sh "$WORKDIR/auxiliary_data/calibration" $INPUT_DETECTOR_ID 1 hydrophone A_1.3.0 "$WORKDIR/hydrophone_D0ORCA038"
64
65# retrieve D0ORCA038 mechanics, fit parameters, sound velocity from JPP inputs
66getFile.sh "$JPP_DIR/inputs/" $INPUT_DETECTOR_ID 1 mechanics "$WORKDIR/mechanics"
67getFile.sh "$JPP_DIR/inputs/" $INPUT_DETECTOR_ID 1 acoustics_fit_parameters "$WORKDIR/acoustics_fit_parameters"
68getFile.sh "$JPP_DIR/inputs/" $INPUT_DETECTOR_ID 1 sound_velocity "$WORKDIR/sound_velocity"
69
70# -------------------------------------------------------------------------------------------------------------
71#
72# 2. Retrieve online ORCA42 inputs to merge with ORCA38 calibration outputs
73#
74# -------------------------------------------------------------------------------------------------------------
75
76# Get a initial detector for D0ORCA042 from the JDetectorDB, to be optimised in the global-fit-of-global-fits procedure.
77JDetectorDB \
78 -D $DETECTOR_ID \
79 -@ "tcal=A07004647; pcal=A07004636; rcal=A07004637; acal=A07004638; ccal=A07004639; scal=A07004640" \
80 -WW \
81 -o $DETECTOR_INITIAL
82
83# From input_tables of D0ORCA042
84cat>$TRIPOD_INITIAL<<EOF
85# Data from D0ORCA038 input_tables
8611 257208.80 4743611.20 -2440.19
8712 257000.30 4743616.80 -2441.30
8815 257222.80 4743333.20 -2438.49
89EOF
90
91# From input_tables of D0ORCA042
92cat>$TRANSMITTER_INITIAL<<EOF
93# Data from D0ORCA042 input_tables
94 9 27 0 -0.74 -0.64 0.71
9510 41 0 -0.40 -0.89 0.71
9614 50 0 -0.27 -0.94 0.71
9717 75 0 0.50 -0.84 0.71
9818 82 0 0.15 -0.96 0.71
99EOF
100
101# From input_tables of D0ORCA042
102cat>$HYDROPHONE_INITIAL<<EOF
103# Data from D0ORCA042 input_tables
104 2 0 0.02 1.04 0.55
105 3 0 0.46 0.93 0.55
106 9 0 -0.75 -0.72 0.55
107 10 -1 0.11 1.04 0.55
108 12 0 0.46 0.93 0.55
109 4 0 0.20 1.02 0.55
110 18 0 0.61 0.84 0.55
111 28 0 0.69 0.78 0.55
112 11 0 -0.07 1.04 0.55
113 19 0 0.46 0.93 0.55
114 20 0 0.61 0.84 0.55
115 29 0 0.46 0.93 0.55
116 30 0 0.46 0.93 0.55
117 21 0 0.11 1.04 0.55
118 17 0 0.46 0.93 0.55
119 27 0 1.04 0.07 0.55
120 31 0 0.75 0.72 0.55
121 39 0 0.46 0.93 0.55
122 40 0 0.46 0.93 0.55
123 41 0 0.91 0.50 0.55
124 42 0 0.29 1.00 0.55
125 38 0 0.89 -0.54 0.55
126 1 0 -0.25 1.01 0.55
127 49 0 0.32 -0.99 0.55
128 50 0 0.83 0.62 0.55
129 51 0 0.54 0.89 0.55
130 52 0 0.82 0.64 0.55
131 53 0 0.43 0.95 0.55
132 60 0 -0.16 1.03 0.55
133 61 0 -0.42 0.95 0.55
134 62 0 1.01 0.25 0.55
135 63 0 0.20 1.02 0.55
136 64 -1 -0.07 1.04 0.55
137 72 0 -0.25 1.01 0.55
138 73 0 0.46 0.93 0.55
139 74 0 0.38 0.97 0.55
140 48 0 -1.03 -0.16 0.55
141 37 0 -1.01 -0.25 0.55
142 26 0 -0.84 0.61 0.55
143 75 0 0.11 1.04 0.55
144 82 0 0.49 0.92 0.55
145 83 0 0.17 1.03 0.55
146EOF
147
148eval `JPrintDetector -a $DETECTOR_INITIAL -O SUMMARY`; FINAL_STRINGS=($STRINGS[*])
149eval `JPrintDetector -a D0ORCA038.datx -O SUMMARY`; FIXED_STRINGS=($STRINGS[*])
150
151# Apply merging.
152
153# Detector
154JEditDetector \
155 -a $DETECTOR_INITIAL \
156 -o detector.datx --!
157
158eval `JPrintDetector -a detector.datx -O SUMMARY`
159
160JEditDetector -a detector.datx -r "$FIXED_STRINGS[*]" -o detector.datx --!
161JMergeDetector -a detector.datx -a D0ORCA038.datx -o detector.datx --!
162JEditDetector -a detector.datx -k "$FINAL_STRINGS[*]" -o detector.datx --!
163
164# Tripod
165typeset -A TRIPODS
166
167get_tripods $TRIPOD_INITIAL TRIPODS; FINAL_TRIPODS=(${(k)TRIPODS[*]})
168echo "Final tripods: ${FINAL_TRIPODS[*]}"
169get_tripods $WORKDIR/tripod_D0ORCA038.txt TRIPODS; FIXED_TRIPODS=(${(k)TRIPODS[*]})
170echo "Fixed tripods: ${FIXED_TRIPODS[*]}"
171cp -p $TRIPOD_INITIAL tripod.txt
172
173JEditTripod -f tripod.txt -r "${FIXED_TRIPODS}" -o tripod.txt
174JMergeTripod -f tripod.txt -f $WORKDIR/tripod_D0ORCA038.txt -o tripod.txt
175JEditTripod -f tripod.txt -k "${FINAL_TRIPODS}" -o tripod.txt
176JEditTripod -f tripod.txt -r "16" -o tripod.txt # remove tripod 16, which was recovered during D0ORCA042 sea campaign
177
178# Transmitter
179cp -p $TRANSMITTER_INITIAL transmitter.txt
180
181JEditTransmitter -f transmitter.txt -r "${FIXED_STRINGS[*]}" -o transmitter.txt
182JMergeTransmitter -f transmitter.txt -f $WORKDIR/transmitter_D0ORCA038.txt -o transmitter.txt
183JEditTransmitter -f transmitter.txt -k "${FINAL_STRINGS[*]}" -o transmitter.txt
184
185# Hydrophone
186# temporary use hydrophone_ititial.txt for hydrophone.txt, as the hydrophone_D0ORCA038.txt is not calibrated
187cp -p $WORKDIR/$HYDROPHONE_INITIAL hydrophone.txt
188
189# -------------------------------------------------------------------------------------------------------------
190#
191# 3. Acoustic event building
192#
193# -------------------------------------------------------------------------------------------------------------
194
195cat>waveform.txt<<EOF
196# Data from D2ORCA024_waveforms.csv
197 35 9
198-36 9
199 34 10
200-35 10
201 28 11
202-29 11
203 48 12
204-49 12
205 49 14
206-50 14
207 16 15
208-17 15
209 51 17
210-52 17
211 52 18
212-53 18
213EOF
214
215# Changed to 550 based on investigation average number of hits per event in D0ORCA042
216cat>acoustics_trigger_parameters.txt<<EOF
217# Trigger parameters D0ORCA042
218Q = 0.0;
219TMax_s = 0.020;
220numberOfHits = 550;
221EOF
222
223# Updated disable file for D0ORCA042
224cat>disable.txt<<EOF
225# b39669d0-1781-4395-8490-b27e826c4bdb$
226# GIT 20.0.0
227# ROOT 6.32.02
228# application JEditDisable
229# command /pbs/throng/km3net/software/RHEL9/jpp/v20.0.0/out/Linux/bin/JEditDisable -f ../disable.txt -o new_disable.txt -a ../detector.datx -q
230# namespace KM3NET
231# system Linux cca018 5.14.0-687.29.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 21 03:19:43 EDT 2026 x86_64
2329 813524210
23310 808972598
23410 813524210
23511 808489117
23611 809161495
23711 809175478
23811 809187005
23911 813524210
24011 816928387
24111 817317552
24211 817331139
24311 817338029
24411 819737869
24511 819740066
24612 808972598
24712 809161495
24812 809521500
24912 813524210
25012 813709200
25112 817320256
25212 817355794
25314 808961480
25414 813524210
25515 808981510
25615 809076040
25715 809161495
25815 813524210
25915 817295057
26015 817301191
26117 813524210
26218 813524210
263EOF
264
265expand_array RUNS
266
267set_variable: QUALITY_FACTOR ACOUSTICS_QUALITYFACTOR 2.0e3
268
269BUFFER=(`JRuns -D $DETECTOR_ID -F RUN`)
270let "NUMBER_OF_ERRORS = 0"
271for RUN in ${RUNS:*BUFFER}; do
272
273 set_variable INPUT_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_toa.root
274 set_variable OUTPUT_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_event.root
275
276 if [[ ! -f $INPUT_FILE ]]; then
277
278 JToA \
279 -@ "detid = `getDetector -D $DETECTOR_ID`" \
280 -@ "minrun = $RUN" \
281 -@ "maxrun = $RUN" \
282 -@ "QUALITYFACTOR >= $QUALITY_FACTOR" \
283 -o $INPUT_FILE \
284 -d $DEBUG --!
285
286 if (( $? != 0 )); then
287 let "NUMBER_OF_ERRORS = $NUMBER_OF_ERRORS + 1"
288 fi
289 fi
290
291 if [[ -f $INPUT_FILE ]] && [[ ! -f $OUTPUT_FILE ]]; then
292
293 timer_start
294
295 JAcousticsEventBuilder \
296 -a $DETECTOR \
297 -f $INPUT_FILE \
298 -T $WORKDIR/tripod.txt \
299 -Y $WORKDIR/transmitter.txt \
300 -V $WORKDIR/sound_velocity.txt \
301 -W $WORKDIR/waveform.txt \
302 -@ $WORKDIR/acoustics_trigger_parameters.txt \
303 -H $WORKDIR/hydrophone.txt \
304 -o $OUTPUT_FILE \
305 -d $DEBUG --!
306
307 if (( $? != 0 )); then
308 let "NUMBER_OF_ERRORS = $NUMBER_OF_ERRORS + 1"
309 fi
310
311 timer_stop
312 timer_print
313 fi
314done
315
316
317if (( $NUMBER_OF_ERRORS != 0 )); then
318 error "Number of errors $NUMBER_OF_ERRORS"
319fi
320
321# -------------------------------------------------------------------------------------------------------------
322#
323# 4. Run the global-fit-of-global-fits procedure to optimise the detector and tripod and transmitter positions
324#
325# -------------------------------------------------------------------------------------------------------------
326
327INPUT_FILES=(`ls KM3NeT_${(l:8::0::0:)DETECTOR_ID}_0*${^RUNS}_event.root`)
328
329# Run in WORKDIR
330
331cd $WORKDIR
332
333if [ ! $HOMEDIR -ef $WORKDIR ]; then
334 cp -p $HOMEDIR/$ACOUSTICS_DETECTOR $WORKDIR
335 cp -p $HOMEDIR/${^ACOUSTICS_KEYS}.txt $WORKDIR
336 cp -p $HOMEDIR/${^ACOUSTICS_AUXS}.txt $WORKDIR
337 cp -p $HOMEDIR/${^INPUT_FILES} $WORKDIR
338fi
339
340cat>script.txt<<EOF
341
342fix string $FIXED_STRINGS[*]
343fix tripod $FIXED_TRIPODS[*]
344
345stage 0 ${SINGULARITY}1 0 100.0e-6 10.0 10 0.5
346stage 1B ${SINGULARITY}1 0 100.0e-6 10.0 0 0.001 0.1
347stage 2A ${SINGULARITY}1 0 100.0e-6 10.0 20 0.2 0.5
348stage 2C ${SINGULARITY}1 0 100.0e-6 10.0 20 0.2
349stage 3A ${SINGULARITY}1 0 50.0e-6 10.0 20 0.2 0.5
350stage 3C ${SINGULARITY}1 0 50.0e-6 10.0 20 0.2
351
352initialise
353
354stage 3a ${SINGULARITY}1 0 50.0e-6 10.0 20 0.2 0.5
355stage 3c ${SINGULARITY}1 0 50.0e-6 10.0 20 0.2
356EOF
357
358JSydney \
359 -a $DETECTOR \
360 -f "$INPUT_FILES[*]" \
361 -T tripod.txt \
362 -Y transmitter.txt \
363 -V sound_velocity.txt \
364 -M mechanics.txt \
365 -@ acoustics_fit_parameters.txt \
366 -! disable.txt \
367 -N $THREADS \
368 -s script.txt \
369 -d $DEBUG --!
370
371if [ ! $HOMEDIR -ef $WORKDIR ]; then
372 cp -vru * $HOMEDIR
373fi
374
375# Require Katoomba for Creep correction
376JKatoomba \
377 -a $DETECTOR \
378 -f "$INPUT_FILES[*]" \
379 -o $WORKDIR/katoomba.root \
380 -T $WORKDIR/tripod.txt \
381 -Y $WORKDIR/transmitter.txt \
382 -V $WORKDIR/sound_velocity.txt \
383 -M $WORKDIR/mechanics.txt \
384 -@ $WORKDIR/acoustics_fit_parameters.txt \
385 -! $WORKDIR/disable.txt \
386 ${HYDROPHONE} \
387 $STRIP \
388 $SQUASH \
389 -d $DEBUG --!
390
391
392# copy detector to apply creep correction and z-adjustment
393cp -p $WORKDIR/$DETECTOR $WORKDIR/detector_creep.datx
394
395JCreep \
396 -a $WORKDIR/detector_creep.datx \
397 -f $WORKDIR/katoomba.root \
398 -A
399
400JAdjustZpos \
401 -a $WORKDIR/detector_creep.datx \
402 -f $WORKDIR/KM3NeT_00000300_*event.root \
403 -o $WORKDIR/detector_z_adjusted.datx \
404 -m 1
405
406#copy detector and tripod to align with ROV measurements
407cp -p $WORKDIR/detector_z_adjusted.datx $WORKDIR/aligned_detector.datx
408cp -p $TRIPOD $WORKDIR/aligned_tripod.txt
409
410#Align with ROV measurements (xyz only)
411JAlignDetector \
412 -a $WORKDIR/aligned_detector.datx \
413 -b $WORKDIR/$DETECTOR_INITIAL \
414 -P "x y z" \
415 -O \
416 -T $WORKDIR/aligned_tripod.txt \
417 -A \