Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
acoustics-fit-toolkit.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 # -----------------------------------------------------------------------------------------------------
5 #
6 # Toolkit for the determination of the fixed parameters in the system, a.k.a. "pre-calibration".
7 # The list of parameters includes (x,y,z) positions of strings and tripods, stretching of strings,
8 # z-positions of the optical modules, orientations of the strings and possibly z-positions of anchors.
9 #
10 # The value of a given parameter is optimised by minimising the average chi2/NDF
11 # of a series of global fits applied to a predefined set of acoustic events.
12 # For each parameter, there exists a designated function.
13 #
14 # There are also steering functions to consistently determine the optimal values for a set of parameters.
15 # In these, the current accuracy of the parameter values is taken into account.
16 # These are therefore referred to as "stages".
17 # The pre-calibration thus consists of a sequence of stages.
18 # For each detector, a complete pre-calibration procedure is implemented in a designated script.
19 #
20 # Mandatory input variables:
21 #
22 # DETECTOR # detector file
23 # INPUT_FILES # list of input files (output of JAcousticsEventBuilder[.sh])
24 #
25 # Optional input variables:
26 #
27 # HYDROPHONE # if defined, use hydrophones in global fit; else do not use hydrophones
28 #
29 # In the following:
30 #
31 # STRINGS corresponds to list of strings to be fitted; this can be changed with function fixStrings.
32 # TRIPODS corresponds to list of tripods to be fitted; this can be changed with function fixTripods.
33 #
34 # TRANSMITTERS corresponds to list of strings which have an emitter on the anchor (maybe empty).
35 # For these strings, the orientations and the z-positions of the anchors will separately be fitted.
36 # This list will also be changed with function fixStrings.
37 # -----------------------------------------------------------------------------------------------------
38 
39 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
40 source $JPP_BIN/gradient.sh
41 
42 if [[ ! $ZSH_EVAL_CONTEXT =~ :file$ ]]; then
43  echo "Auxiliary script for the pre-calibrations."
44  echo "This script should be sourced by the steering script for a specific detector."
45  echo "Consult the script '$0' for more details."
46  exit
47 fi
48 
49 source JAcousticsToolkit.sh
50 
51 set_variable TMPDIR `pwd`/.$$ # temporary directory
52 set_variable: DEBUG ACOUSTICS_DEBUG 3 # debug level
53 set_variable: JOBS ACOUSTICS_JOBS 0 # number of parallel threads
54 set_variable: SLEEP_US ACOUSTICS_SLEEP_US 100 # sleep time [us] of main thread when data queue exceeds limit
55 
56 typeset -A TRIPODS # tripods
57 typeset -a CHI2 # chi2 values; index [1] corresponds to best value
58 
59 let "NUMBER_OF_ITERATIONS = 100" # maximal number of iterations
60 let "EPSILON = 5.0E-4" # maximal distance to minimum of chi2
61 let "RADIUS_M = 1.0" # maximal horizontal distance between T-bar and emitter/hydrophone
62 let "PRECISION = 10" # number of decimals of chi2 evaluation
63 
64 
65 # -----------------------------------------------------------------------------------------------------
66 # Initialise.
67 #
68 # Install input files in working directory and create temporary directory TMPDIR.
69 #
70 # -----------------------------------------------------------------------------------------------------
71 function initialise()
72 {
73  eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
74  eval `JPrintDetector -a $DETECTOR -O SUMMARY`
75  eval `JPrintDetector -a $DETECTOR -O CAN`
76 
77  JAcoustics.sh $DETECTOR_ID
78 
79  get_tripods tripod.txt TRIPODS
80 
81  TRANSMITTERS=(`get_strings_with_transmitter transmitter.txt`)
82 
83  if [[ "${HYDROPHONE+YES}" == "YES" ]]; then
84  HYDROPHONES=(`get_strings_with_hydrophone hydrophone.txt`)
85  else
86  HYDROPHONES=()
87  fi
88 
89  mkdir -p $TMPDIR
90 
91  JConvertDetectorFormat -a $DETECTOR -o $TMPDIR/pmt.datx
92  JDetachPMTs -a $DETECTOR -o $DETECTOR
93 }
94 
95 
96 # -----------------------------------------------------------------------------------------------------
97 # Backup files in given directory.
98 #
99 # \param 1 directory
100 # -----------------------------------------------------------------------------------------------------
101 function backup()
102 {
103  mkdir -p $1
104 
105  cp -p {tripod.txt,transmitter.txt,hydrophone.txt} $1
106 
107  JAttachPMTs -a $DETECTOR -f $TMPDIR/pmt.datx -o $1/detector.datx
108 }
109 
110 
111 # -----------------------------------------------------------------------------------------------------
112 # Remove temporary directory and restore input files in working directory.
113 #
114 # -----------------------------------------------------------------------------------------------------
115 function clean()
116 {
117  JAttachPMTs -a $DETECTOR -f $TMPDIR/pmt.datx -o $DETECTOR
118 
119  rm -rf $TMPDIR >& /dev/null
120 
121  rm -f {acoustics_fit_parameters,acoustics_trigger_parameters}.txt
122 
123  JAcoustics.sh $DETECTOR_ID
124 }
125 
126 
127 # -----------------------------------------------------------------------------------------------------
128 # Fix strings.
129 #
130 # \param 1-N identifiers
131 # -----------------------------------------------------------------------------------------------------
132 function fixStrings()
133 {
134  typeset -a BUFFER
135 
136  BUFFER=(`echo $*`)
137 
138  if (( ${#BUFFER} > 0 )); then
139  STRINGS=(${STRINGS:|BUFFER})
140  TRANSMITTERS=(${TRANSMITTERS:|BUFFER})
141  HYDROPHONES=(${HYDROPHONES:|BUFFER})
142  fi
143 }
144 
145 
146 # -----------------------------------------------------------------------------------------------------
147 # Fix tripods.
148 #
149 # \param 1-N identifiers
150 # -----------------------------------------------------------------------------------------------------
151 function fixTripods()
152 {
153  typeset -a BUFFER
154 
155  BUFFER=(`echo $*`)
156 
157  if (( ${#BUFFER} > 0 )); then
158  for ID in $BUFFER[*]; do
159  unset "TRIPODS[${ID}]"
160  done
161  fi
162 }
163 
164 
165 # -----------------------------------------------------------------------------------------------------
166 # Evaluate current chi2.
167 #
168 # \param 1 variable containing chi2 value on return
169 # -----------------------------------------------------------------------------------------------------
170 function getChi2()
171 {
172  rm -f $TMPDIR/katoomba.root >& /dev/null
173 
174  if (( $JOBS == 0 )); then
175 
176  JKatoomba \
177  -a $DETECTOR \
178  -f "$INPUT_FILES[*]" \
179  -o $TMPDIR/katoomba.root \
180  -T tripod.txt \
181  -Y transmitter.txt \
182  -V sound_velocity.txt \
183  -M mechanics.txt \
184  -@ $TMPDIR/acoustics_fit_parameters.txt \
185  -! disable.txt \
186  ${HYDROPHONE+-H hydrophone.txt} \
187  -u \
188  -d 0 --! >& $TMPDIR/job.log
189 
190  else
191 
192  JFremantle \
193  -a $DETECTOR \
194  -f "$INPUT_FILES[*]" \
195  -o $TMPDIR/katoomba.root \
196  -T tripod.txt \
197  -Y transmitter.txt \
198  -V sound_velocity.txt \
199  -M mechanics.txt \
200  -@ $TMPDIR/acoustics_fit_parameters.txt \
201  -! disable.txt \
202  ${HYDROPHONE+-H hydrophone.txt} \
203  -u \
204  -N $JOBS \
205  -s $SLEEP_US \
206  -d 0 --! >& $TMPDIR/job.log
207  fi
208 
209  if (( $? != 0 )); then
210  fatal "non-zero exit code, see $TMPDIR/job.log"
211  fi
212 
213  let "UV = $($JPP_DIR/examples/JAcoustics/JPrintChi2 -f $TMPDIR/katoomba.root -p $PRECISION)"
214 
215  if (( $? != 0 )); then
216  fatal "non-zero exit code let."
217  fi
218 
219  eval $1=$UV
220 }
221 
222 
223 # -----------------------------------------------------------------------------------------------------
224 # Stage 0.
225 # This stage can be used to determine the (x,y,z) positions of tripods when a number of strings is fixed.
226 #
227 # \param 1 step size
228 # \param 2 maximum number of extra steps
229 # -----------------------------------------------------------------------------------------------------
230 function stage_0()
231 {
232  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
233 `egrep Tmax_s acoustics_fit_parameters.txt`
234 Nmin = 3;
235 sigma_s = 100.0e-6;
236 stdev = 10.0;
237 mestimator = 0;
238 option = 1;
239 EOF
240 
241  if (( ${#STRINGS} > 0 )); then
242  JEditDetector -a $DETECTOR -o $TMPDIR/detector_0.datx -k "$STRINGS[*]" -q -d 0 >& /dev/null
243  JEditDetector -a $DETECTOR -o $DETECTOR -r "$STRINGS[*]" -q -d 0 >& /dev/null
244  fi
245 
246  PARAMETERS=()
247 
248  for ID in ${(k)TRIPODS}; do
249  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addx %" -o tripod.txt -q -d 0 >& /dev/null']=$1
250  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addy %" -o tripod.txt -q -d 0 >& /dev/null']=$1
251  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addz %" -o tripod.txt -q -d 0 >& /dev/null']=$1
252  done
253 
254  gradient $2 Y
255 
256  printf "detector %6d %8.4f\n" $N $Y
257 
258  if (( ${#STRINGS} > 0 )); then
259  JMergeDetector -a $DETECTOR -a $TMPDIR/detector_0.datx -o $DETECTOR >& /dev/null
260  fi
261 }
262 
263 
264 # -----------------------------------------------------------------------------------------------------
265 # Stage 1a.
266 # This stage can be used to roughly determine the positions of the strings and tripods.
267 # During this procedure, the strings are kept vertical in the global fits.
268 #
269 # \param 1 step size strings
270 # \param 2 step size tripods
271 # \param 3 maximum number of extra steps
272 # -----------------------------------------------------------------------------------------------------
273 function stage_1a()
274 {
275  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
276 `egrep Tmax_s acoustics_fit_parameters.txt`
277 Nmin = 3;
278 sigma_s = 250.0e-6;
279 stdev = 10.0;
280 mestimator = 2;
281 option = 0;
282 EOF
283 
284  PARAMETERS=()
285 
286  for STRING in $STRINGS[*]; do
287  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addx %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
288  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addy %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
289  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
290  done
291 
292  for ID in ${(k)TRIPODS}; do
293  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addx %" -o tripod.txt -q -d 0 >& /dev/null']=$2
294  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addy %" -o tripod.txt -q -d 0 >& /dev/null']=$2
295  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addz %" -o tripod.txt -q -d 0 >& /dev/null']=$2
296  done
297 
298  for STRING in ${HYDROPHONES:|TRANSMITTERS}; do
299  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
300  done
301 
302  for STRING in $TRANSMITTERS[*]; do
303 
304  set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"`
305 
306  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
307  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
308  done
309 
310  gradient $3 Y
311 
312  printf "detector %6d %8.4f\n" $N $Y
313 }
314 
315 
316 # -----------------------------------------------------------------------------------------------------
317 # Stage 1b.
318 # This stage can be used to roughly determine the stretching and z-positions of individual strings.
319 # During this procedure, the strings are kept vertical in the global fits.
320 #
321 # \param 1 step size stretching
322 # \param 2 step size z-position
323 # \param 3 maximum number of extra steps
324 # -----------------------------------------------------------------------------------------------------
325 function stage_1b()
326 {
327  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
328 `egrep Tmax_s acoustics_fit_parameters.txt`
329 Nmin = 3;
330 sigma_s = 250.0e-6;
331 stdev = 10.0;
332 mestimator = 2;
333 option = 0;
334 EOF
335 
336  for STRING in $STRINGS[*]; do
337 
338  JEditDetector -a $DETECTOR -o $TMPDIR/detector_1.datx -r "$STRING" -q -d 0 >& /dev/null
339  JEditDetector -a $DETECTOR -o $DETECTOR -k "$STRING" -q -d 0 >& /dev/null
340 
341  PARAMETERS=()
342 
343  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING mul %" -o $DETECTOR -q -d 0 >& /dev/null; JEditDetector -a $DETECTOR -s "$STRING subz \$\(\(% * $CAN_ZMAX_M\)\)" -o $DETECTOR -q -d 0 >& /dev/null']=$1
344  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$2
345 
346  gradient $3 Y
347 
348  printf "string %04d %6d %8.4f\n" $STRING $N $Y
349 
350  JMergeDetector -a $DETECTOR -a $TMPDIR/detector_1.datx -o $DETECTOR >& /dev/null
351  done
352 }
353 
354 
355 # -----------------------------------------------------------------------------------------------------
356 # Stage 1c.
357 # This stage can be used to roughly determine the z-positions of the modules.
358 # During this procedure, the strings are kept vertical in the global fits.
359 #
360 # \param 1 step size
361 # \param 2 maximum number of extra steps
362 # -----------------------------------------------------------------------------------------------------
363 function stage_1c()
364 {
365  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
366 `egrep Tmax_s acoustics_fit_parameters.txt`
367 Nmin = 3;
368 sigma_s = 250.0e-6;
369 stdev = 10.0;
370 mestimator = 2;
371 option = 0;
372 EOF
373 
374  PARAMETERS=()
375 
376  for STRING in $STRINGS[*]; do
377 
378  for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); do
379 
380  set_variable MODULE `getModule -a $DETECTOR -L "$STRING $FLOOR"`
381 
382  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
383  done
384  done
385 
386  gradient $2 Y
387 
388  printf "detector %6d %8.4f\n" $N $Y
389 }
390 
391 
392 # -----------------------------------------------------------------------------------------------------
393 # Stage 1B.
394 # This stage can be used to determine the stretching and z-positions of individual strings.
395 #
396 # \param 1 step size stretching
397 # \param 2 step size z-position
398 # \param 3 maximum number of extra steps
399 # -----------------------------------------------------------------------------------------------------
400 function stage_1B()
401 {
402  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
403 `egrep Tmax_s acoustics_fit_parameters.txt`
404 Nmin = 3;
405 sigma_s = 100.0e-6;
406 stdev = 10.0;
407 mestimator = 0;
408 option = 1;
409 EOF
410 
411  for STRING in $STRINGS[*]; do
412 
413  JEditDetector -a $DETECTOR -o $TMPDIR/detector_1.datx -r "$STRING" -q -d 0 >& /dev/null
414  JEditDetector -a $DETECTOR -o $DETECTOR -k "$STRING" -q -d 0 >& /dev/null
415 
416  PARAMETERS=()
417 
418  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING mul %" -o $DETECTOR -q -d 0 >& /dev/null; JEditDetector -a $DETECTOR -s "$STRING subz \$\(\(% * $CAN_ZMAX_M\)\)" -o $DETECTOR -q -d 0 >& /dev/null']=$1
419  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$2
420 
421  gradient $3 Y
422 
423  printf "string %04d %6d %8.4f\n" $STRING $N $Y
424 
425  JMergeDetector -a $DETECTOR -a $TMPDIR/detector_1.datx -o $DETECTOR >& /dev/null
426  done
427 }
428 
429 
430 # -----------------------------------------------------------------------------------------------------
431 # Stage 2a.
432 # This stage can be used to improve the determination the positions of the strings and tripods.
433 #
434 # \param 1 step size strings
435 # \param 2 step size tripods
436 # \param 3 maximum number of extra steps
437 # -----------------------------------------------------------------------------------------------------
438 function stage_2a()
439 {
440  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
441 `egrep Tmax_s acoustics_fit_parameters.txt`
442 Nmin = 3;
443 sigma_s = 100.0e-6;
444 stdev = 10.0;
445 mestimator = 0;
446 option = 1;
447 EOF
448 
449  PARAMETERS=()
450 
451  for STRING in $STRINGS[*]; do
452  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addx %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
453  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addy %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
454  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
455  done
456 
457  for ID in ${(k)TRIPODS}; do
458  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addx %" -o tripod.txt -q -d 0 >& /dev/null']=$2
459  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addy %" -o tripod.txt -q -d 0 >& /dev/null']=$2
460  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addz %" -o tripod.txt -q -d 0 >& /dev/null']=$2
461  done
462 
463  for STRING in ${HYDROPHONES:|TRANSMITTERS}; do
464  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
465  done
466 
467  for STRING in $TRANSMITTERS[*]; do
468 
469  set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"`
470 
471  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
472  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
473  done
474 
475  gradient $3 Y
476 
477  printf "detector %6d %8.4f\n" $N $Y
478 }
479 
480 
481 # -----------------------------------------------------------------------------------------------------
482 # Stage 2b.
483 # This stage can be used to improve the determination the z-positions of the modules.
484 #
485 # \param 1 step size
486 # \param 2 maximum number of extra steps
487 # -----------------------------------------------------------------------------------------------------
488 function stage_2b()
489 {
490  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
491 `egrep Tmax_s acoustics_fit_parameters.txt`
492 Nmin = 3;
493 sigma_s = 100.0e-6;
494 stdev = 10.0;
495 mestimator = 0;
496 option = 1;
497 EOF
498 
499  PARAMETERS=()
500 
501  for STRING in $STRINGS[*]; do
502 
503  for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); do
504 
505  set_variable MODULE `getModule -a $DETECTOR -L "$STRING $FLOOR"`
506 
507  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
508  done
509 
510  #PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addx %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
511  #PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addy %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
512  done
513 
514  gradient $2 Y
515 
516  printf "detector %6d %8.4f\n" $N $Y
517 }
518 
519 
520 # -----------------------------------------------------------------------------------------------------
521 # Stage 3a.
522 # This stage can be used to finalise the determination of the positions of the strings and tripods.
523 #
524 # \param 1 step size strings
525 # \param 2 step size tripods
526 # \param 3 maximum number of extra steps
527 # -----------------------------------------------------------------------------------------------------
528 function stage_3a()
529 {
530  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
531 `egrep Tmax_s acoustics_fit_parameters.txt`
532 Nmin = 3;
533 sigma_s = 50.0e-6;
534 stdev = 10.0;
535 mestimator = 0;
536 option = 1;
537 EOF
538 
539  PARAMETERS=()
540 
541  for STRING in $STRINGS[*]; do
542  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addx %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
543  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addy %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
544  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
545  done
546 
547  for ID in ${(k)TRIPODS}; do
548  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addx %" -o tripod.txt -q -d 0 >& /dev/null']=$2
549  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addy %" -o tripod.txt -q -d 0 >& /dev/null']=$2
550  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addz %" -o tripod.txt -q -d 0 >& /dev/null']=$2
551  done
552 
553  for STRING in ${HYDROPHONES:|TRANSMITTERS}; do
554  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
555  done
556 
557  for STRING in $TRANSMITTERS[*]; do
558 
559  set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"`
560 
561  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
562  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
563  done
564 
565  gradient $3 Y
566 
567  printf "detector %6d %8.4f\n" $N $Y
568 }
569 
570 
571 # -----------------------------------------------------------------------------------------------------
572 # Stage 3b.
573 # This stage can be used to finalise the determination of the z-positions of the modules.
574 #
575 # \param 1 step size
576 # \param 2 maximum number of extra steps
577 # -----------------------------------------------------------------------------------------------------
578 function stage_3b()
579 {
580  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
581 `egrep Tmax_s acoustics_fit_parameters.txt`
582 Nmin = 3;
583 sigma_s = 50.0e-6;
584 stdev = 10.0;
585 mestimator = 0;
586 option = 1;
587 EOF
588 
589  PARAMETERS=()
590 
591  for STRING in $STRINGS[*]; do
592 
593  for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); do
594 
595  set_variable MODULE `getModule -a $DETECTOR -L "$STRING $FLOOR"`
596 
597  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
598  done
599 
600  #PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addx %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
601  #PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addy %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
602  done
603 
604  gradient $2 Y
605 
606  printf "detector %6d %8.4f\n" $N $Y
607 }
608 
609 
610 # -----------------------------------------------------------------------------------------------------
611 # Stage D.
612 # This stage can be used to determine the rotations of the strings and z-positions of the anchors
613 # including the response of hydrophones.
614 # It includes a determination of the positions of the strings, tripods and modules.
615 #
616 # \param 1 step size strings
617 # \param 2 step size tripods
618 # \param 3 maximum number of extra steps
619 # -----------------------------------------------------------------------------------------------------
620 function stage_D()
621 {
622  cat>$TMPDIR/acoustics_fit_parameters.txt<<EOF
623 `egrep Tmax_s acoustics_fit_parameters.txt`
624 Nmin = 3;
625 sigma_s = 50.0e-6;
626 stdev = 10.0;
627 mestimator = 0;
628 option = 1;
629 EOF
630 
632 
633  PARAMETERS=()
634 
635  for STRING in $STRINGS[*]; do
636 
637  set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"`
638 
639  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addx %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
640  PARAMETERS['JEditDetector -a $DETECTOR -S "$STRING addy %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
641  PARAMETERS['JEditDetector -a $DETECTOR -s "$STRING addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
642  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
643 
644  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
645  done
646 
647  for ID in ${(k)TRIPODS}; do
648  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addx %" -o tripod.txt -q -d 0 >& /dev/null']=$2
649  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addy %" -o tripod.txt -q -d 0 >& /dev/null']=$2
650  PARAMETERS['JEditTripod -f tripod.txt -T "$ID addz %" -o tripod.txt -q -d 0 >& /dev/null']=$2
651  done
652 
653  for STRING in ${HYDROPHONES:|TRANSMITTERS}; do
654  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
655  done
656 
657  for STRING in $TRANSMITTERS[*]; do
658 
659  set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"`
660 
661  PARAMETERS['JEditDetector -a $DETECTOR -M "$MODULE addz %" -o $DETECTOR -q -d 0 >& /dev/null']=$1
662  PARAMETERS['JEditHydrophone -f hydrophone.txt -S "$STRING rot %" -o hydrophone.txt -q -d 0 >& /dev/null; JEditTransmitter -f transmitter.txt -S "$STRING rot %" -o transmitter.txt -q -d 0 >& /dev/null']=$(($1 / $RADIUS_M))
663  done
664 
665  gradient $3 Y
666 
667  printf "detector %6d %8.4f\n" $N $Y
668 }
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
int main(int argc, char *argv[])
Definition: Main.cc:15
clean eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY set_variable STRING
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
then JLigier sh continue fi cat
Definition: JDAQDriver.sh:51
then echo Submitting reweighting and histogram comparison jobs to nikhef stbc batch queue
o $QUALITY_ROOT d $DEBUG!JPlot1D f
Definition: JDataQuality.sh:66
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
usr share Modules init zsh export TMPDIR
static const double H
Planck constant [eV s].
exit
Definition: JPizza.sh:36
then fatal Number of tripods
Definition: JFootprint.sh:45
data_type r[M+1]
Definition: JPolint.hh:779
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
then fatal Wrong number of arguments fi JConvertDetectorFormat a o
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null if do_usage *then usage source $script nToolkit for acoustics scripts fi function get_tripods()
then echo
do JCanberra a $DETECTOR f $INPUT_FILE o $WORKDIR canberra[${EMITTER}\] root T $WORKDIR tripod txt V $WORKDIR sound_velocity txt M $WORKDIR mechanics txt H $WORKDIR hydrophone txt E $EMITTER $DISABLE d $DEBUG!done kill_child_processes_at_exit attach getModule a $DETECTOR typeset Z STRING typeset Z FLOOR for STRING in $STRINGS[*]
Definition: JCanberra.sh:68
then fatal Invalid string $STRING
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
Definition: JAcoustics.sh:21
case $OPTION in clean clean
do set_variable OUTPUT_DIRECTORY $WORKDIR T
set_array INPUT_FILES argv[2,$((START_INDEX_STRING-1))] set_array STRINGS
then $DIR JKatoomba a $DETECTOR o $WORKDIR katoomba root T $TRIPOD n sigma_s
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
then JCalibrateToT a
Definition: JTuneHV.sh:116
then set_variable MODULE getModule a $DETECTOR L $STRING $FLOOR JEditDetector a $DETECTOR M $MODULE add $X o $DETECTOR else echo No update of detector $DETECTOR
static const JPBS_t HYDROPHONE(4, 5)
PBS of hydrophone
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
esac typeset A BUFFER $JPP_DIR examples JAcoustics JCreep f $INPUT_FILE BUFFER
Definition: JCreep.sh:34
then cp
possible values
then echo Creating output directory
Definition: JTuneHV.sh:83
do set_variable DETECTOR_TXT $WORKDIR detector
double u[N+1]
Definition: JPolint.hh:776
double getChi2(const double P)
Get chi2 corresponding to given probability.
Definition: JFitToolkit.hh:56
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
script
Definition: JAcoustics.sh:2
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number
int debug
debug level
esac done
Definition: JAddHDE.sh:21
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62