4# --------------------------------------------------------------------------------------------
6# Steering script for the global-fit-of-global-fits procedure of the D0ORCA042 (???) detector.
8# --------------------------------------------------------------------------------------------
10if [ -z $JPP_DIR ]; then
11 echo "Variable JPP_DIR undefined."
15source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
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
29 "\nRequires variable CALIBRATION_ARCHIVE to be set for the user."
32source JAcousticsToolkit.sh
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
47# -------------------------------------------------------------------------------------------------------------
49# 1. Clone the git calibration archive to workdir to retrieve the required detector, tripod and transmitter inputs
51# -------------------------------------------------------------------------------------------------------------
55 --branch $ARCHIVE_INPUT_BRANCH \
56 git@git.km3net.de:auxiliary_data/calibration \
57 $WORKDIR/auxiliary_data/calibration
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"
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"
70# -------------------------------------------------------------------------------------------------------------
72# 2. Retrieve online ORCA42 inputs to merge with ORCA38 calibration outputs
74# -------------------------------------------------------------------------------------------------------------
76# Get a initial detector for D0ORCA042 from the JDetectorDB, to be optimised in the global-fit-of-global-fits procedure.
79 -@ "tcal=A07004647; pcal=A07004636; rcal=A07004637; acal=A07004638; ccal=A07004639; scal=A07004640" \
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
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
101# From input_tables of D0ORCA042
102cat>$HYDROPHONE_INITIAL<<EOF
103# Data from D0ORCA042 input_tables
136 64 -1 -0.07 1.04 0.55
140 48 0 -1.03 -0.16 0.55
141 37 0 -1.01 -0.25 0.55
148eval `JPrintDetector -a $DETECTOR_INITIAL -O SUMMARY`; FINAL_STRINGS=($STRINGS[*])
149eval `JPrintDetector -a D0ORCA038.datx -O SUMMARY`; FIXED_STRINGS=($STRINGS[*])
155 -a $DETECTOR_INITIAL \
158eval `JPrintDetector -a detector.datx -O SUMMARY`
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 --!
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
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
179cp -p $TRANSMITTER_INITIAL transmitter.txt
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
186# temporary use hydrophone_ititial.txt for hydrophone.txt, as the hydrophone_D0ORCA038.txt is not calibrated
187cp -p $WORKDIR/$HYDROPHONE_INITIAL hydrophone.txt
189# -------------------------------------------------------------------------------------------------------------
191# 3. Acoustic event building
193# -------------------------------------------------------------------------------------------------------------
196# Data from D2ORCA024_waveforms.csv
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
223# Updated disable file for D0ORCA042
225# b39669d0-1781-4395-8490-b27e826c4bdb$
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
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
267set_variable: QUALITY_FACTOR ACOUSTICS_QUALITYFACTOR 2.0e3
269BUFFER=(`JRuns -D $DETECTOR_ID -F RUN`)
270let "NUMBER_OF_ERRORS = 0"
271for RUN in ${RUNS:*BUFFER}; do
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
276 if [[ ! -f $INPUT_FILE ]]; then
279 -@ "detid = `getDetector -D $DETECTOR_ID`" \
282 -@ "QUALITYFACTOR >= $QUALITY_FACTOR" \
286 if (( $? != 0 )); then
287 let "NUMBER_OF_ERRORS = $NUMBER_OF_ERRORS + 1"
291 if [[ -f $INPUT_FILE ]] && [[ ! -f $OUTPUT_FILE ]]; then
295 JAcousticsEventBuilder \
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 \
307 if (( $? != 0 )); then
308 let "NUMBER_OF_ERRORS = $NUMBER_OF_ERRORS + 1"
317if (( $NUMBER_OF_ERRORS != 0 )); then
318 error "Number of errors $NUMBER_OF_ERRORS"
321# -------------------------------------------------------------------------------------------------------------
323# 4. Run the global-fit-of-global-fits procedure to optimise the detector and tripod and transmitter positions
325# -------------------------------------------------------------------------------------------------------------
327INPUT_FILES=(`ls KM3NeT_${(l:8::0::0:)DETECTOR_ID}_0*${^RUNS}_event.root`)
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
342fix string $FIXED_STRINGS[*]
343fix tripod $FIXED_TRIPODS[*]
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
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
360 -f "$INPUT_FILES[*]" \
363 -V sound_velocity.txt \
365 -@ acoustics_fit_parameters.txt \
371if [ ! $HOMEDIR -ef $WORKDIR ]; then
375# Require Katoomba for Creep correction
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 \
392# copy detector to apply creep correction and z-adjustment
393cp -p $WORKDIR/$DETECTOR $WORKDIR/detector_creep.datx
396 -a $WORKDIR/detector_creep.datx \
397 -f $WORKDIR/katoomba.root \
401 -a $WORKDIR/detector_creep.datx \
402 -f $WORKDIR/KM3NeT_00000300_*event.root \
403 -o $WORKDIR/detector_z_adjusted.datx \
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
410#Align with ROV measurements (xyz only)
412 -a $WORKDIR/aligned_detector.datx \
413 -b $WORKDIR/$DETECTOR_INITIAL \
416 -T $WORKDIR/aligned_tripod.txt \