4 # -------------------------------------------------------------------------------------------- 
    6 # Steering script for tuning of (x,y,z) positions of the strings and tripods as well as 
    7 # the (z) positions of the modules. 
    9 # -------------------------------------------------------------------------------------------- 
   11 if [ -z $JPP_DIR ]; 
then 
   12     echo "Variable JPP_DIR undefined." 
   16 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/
null 
   23     usage "$script <detector file> <tripod file> <stage> (input file)+"\
 
   24           "\nInput files correspond to the output of JAcousticsEventBuilder[.sh]."\
 
   25           "\nFirst stage is 1 (or A) and last stage is 3." 
   29     fatal 
"Wrong number of arguments." 
   39 eval `JPrintDetector -
a $DETECTOR -O IDENTIFIER`
 
   43 source JAcoustics.sh    $DETECTOR_ID
 
   45 # copy (part of) configuration 
   55 get_tripods $TRIPOD_FILE TRIPODS
 
   61 typeset -
a CHI2                              # chi2(old,
new)
 
   66 # -------------------------------------------------------------------------------------------- 
   67 # Get center-of-gravity of tripods. 
   70 # -------------------------------------------------------------------------------------------- 
   77     for value 
in "${(@v)TRIPODS}"; 
do 
   81         let X_CENTER=
"$X_CENTER + $X" 
   82         let Y_CENTER=
"$Y_CENTER + $Y" 
   83         let Z_CENTER=
"$Z_CENTER + $Z" 
   86     let X_CENTER=
"$X_CENTER / ${#TRIPODS}" 
   87     let Y_CENTER=
"$Y_CENTER / ${#TRIPODS}" 
   88     let Z_CENTER=
"$Z_CENTER / ${#TRIPODS}" 
   90     printf 
"%12.3f %12.3f %12.3f" $X_CENTER $Y_CENTER $Z_CENTER
 
   94 # -------------------------------------------------------------------------------------------- 
   98 # -------------------------------------------------------------------------------------------- 
  105         -
f "$INPUT_FILES[*]"                      \
 
  110         -@ 
$WORKDIR/acoustics_fit_parameters.txt  \
 
  120 # -------------------------------------------------------------------------------------------- 
  121 # Fit given coordinate of string position. 
  123 # \param  1       string identifier 
  124 # \param  2       coordinate (X|Y|Z) 
  126 # -------------------------------------------------------------------------------------------- 
  127 function fitPositionOfString()
 
  137     if [[ 
"$2" == 
"Z" ]]; 
then 
  138         OPTION=-s                  # optical modules only
 
  140         OPTION=-
S                  # all modules
 
  143     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  149         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  159     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  165         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  175     printf 
"string %04d  %s %6d %7.3f\n" $1 $2 $N $CHI2[1]
 
  179 # -------------------------------------------------------------------------------------------- 
  180 # Fit stretching of string. 
  182 # \param  1       string identifier 
  183 # \param  2       multiplication factor 
  184 # -------------------------------------------------------------------------------------------- 
  185 function fitStretchingOfString()
 
  189     let 
Z=
"$CAN_ZMAX_M * $2" 
  191     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  197         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  207     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  213         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  223     printf 
"string %04d  M %6d %7.3f\n" $1 $N $CHI2[1]
 
  227 # -------------------------------------------------------------------------------------------- 
  228 # Fit given coordinate of tripod position. 
  230 # \param  1       tripod identifier 
  231 # \param  2       coordinate (X|Y|Z) 
  233 # -------------------------------------------------------------------------------------------- 
  234 function fitPositionOfTripod()
 
  238     BUFFER=(
X 0.0 
Y 0.0 Z 0.0)
 
  244     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  246         JEditTripod -
f $TRIPOD_FILE -
T "$1 add $BUFFER[*]" -
d 0 >& /dev/
null 
  250         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  252             JEditTripod -
f $TRIPOD_FILE -
T "$1 sub $BUFFER[*]" -
d 0 >& /dev/
null 
  260     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  262         JEditTripod -
f $TRIPOD_FILE -
T "$1 sub $BUFFER[*]" -
d 0 >& /dev/
null 
  266         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  268             JEditTripod -
f $TRIPOD_FILE -
T "$1 add $BUFFER[*]" -
d 0 >& /dev/
null 
  276     printf 
"tripod   %2d  %s %6d %7.3f\n" $1 $2 $N $CHI2[1]
 
  280 # -------------------------------------------------------------------------------------------- 
  281 # Fit module z-position. 
  283 # \param  1       string identifier 
  286 # -------------------------------------------------------------------------------------------- 
  287 function fitPositionOfModule()
 
  291     BUFFER=(
X 0.0 
Y 0.0 Z $3)
 
  298     for (( i=0 ; 
$i != $NUMBER_OF_STEPS && $N != $NUMBER_OF_ITERATIONS; ++i, ++
N )); 
do 
  304         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  314     for (( i=0 ; 
$i != $NUMBER_OF_STEPS && $N != $NUMBER_OF_ITERATIONS; ++i, ++
N )); 
do 
  320         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  330     printf 
"module %04d.%02d %6d %7.3f\n" $1 $2 $N $CHI2[1]
 
  338 echo "Processing stage $STAGE" 
  348     A)  # ------------------------------------------------------------------------------------
 
  353         cat>acoustics_fit_parameters.txt<<EOF    # fix tilt angles of 
strings 
  362         for DX_M 
in 0.5 0.2; 
do                  # fit (
x,y,z) positions of 
strings and tripods
 
  364             for (( 
N=0; $N < $NUMBER_OF_ITERATIONS; ++N )); 
do 
  371                     fitPositionOfString 
$STRING Z $DX_M
 
  374                 for TRIPOD 
in ${(
k)TRIPODS}; 
do 
  377                     fitPositionOfTripod 
$TRIPOD Z $DX_M
 
  380                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  387             let 
X=
"$X - $X_CENTER" 
  388             let 
Y=
"$Y - $Y_CENTER" 
  389             let Z=
"$Z - $Z_CENTER" 
  391             JEditTripod   -
f $TRIPOD_FILE -
T "-1 sub $X $Y $Z"              -
d 0 >& /dev/
null 
  396             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  397                 printf 
"warning: reached maximum number of iterations %d - converenge %7.3f\n" $N $(($CHI2[3] - $CHI2[1]))
 
  404         for DX_M in 0.1; 
do                      # fit (z) positions of modules 
  406             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  410                 for STRING in $STRINGS[*]; 
do 
  411                     for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); 
do 
  412                         fitPositionOfModule 
$STRING $FLOOR $DX_M
 
  416                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  423             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  424                 printf 
"warning: reached maximum number of iterations %d - converenge %7.3f\n" $N $(($CHI2[3] - $CHI2[1]))
 
  429     1)  
# ------------------------------------------------------------------------------------ 
  434         cat>acoustics_fit_parameters.txt<<EOF
 
  443         for STRING in $STRINGS[*]; 
do            # fit stretching and (z) position of given 
string           
  450             for MUL in 0.005 0.001; 
do 
  454                 for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++N )); 
do 
  458                     fitPositionOfString   
$STRING Z  $DX_M
 
  459                     fitStretchingOfString 
$STRING $MUL
 
  461                     if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  466                 if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  467                     printf "
warning: reached maximum number of iterations %
d - 
converenge %7.3
f\
n" $N $(($CHI2[3] - $CHI2[1]))
 
  480     2)  
# ------------------------------------------------------------------------------------ 
  485         cat>acoustics_fit_parameters.txt<<EOF
 
  494         for DX_M in 0.2; 
do                      # fit (
x,y,z) positions of 
strings and tripods
 
  496             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++N )); 
do 
  501                     fitPositionOfString 
$STRING X $DX_M
 
  502                     fitPositionOfString 
$STRING Y $DX_M
 
  503                     fitPositionOfString 
$STRING Z $DX_M
 
  506                 for TRIPOD in ${(
k)TRIPODS}; 
do 
  507                     fitPositionOfTripod 
$TRIPOD X $DX_M
 
  508                     fitPositionOfTripod 
$TRIPOD Y $DX_M
 
  509                     fitPositionOfTripod 
$TRIPOD Z $DX_M
 
  512                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  517             getCenter | 
read X Y Z
 
  519             let X=
"$X - $X_CENTER" 
  520             let Y=
"$Y - $Y_CENTER" 
  521             let Z=
"$Z - $Z_CENTER" 
  523             JEditTripod   -
f $TRIPOD_FILE -
T "-1 sub $X $Y $Z"              -
d 0 >& /dev/
null 
  528             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  529                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  536         for DX_M in 0.10; 
do                     # fit (z) positions of modules and (
x,y) positions of 
strings 
  538             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  542                 for STRING in $STRINGS[*]; 
do    
  544                     for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); 
do 
  545                         fitPositionOfModule 
$STRING $FLOOR $DX_M
 
  548                     fitPositionOfString 
$STRING X $DX_M
 
  549                     fitPositionOfString 
$STRING Y $DX_M
 
  552                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  559             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  560                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  565     3)  # ------------------------------------------------------------------------------------
 
  570         cat>acoustics_fit_parameters.txt<<EOF
 
  579         for DX_M in 0.10 0.05; 
do                # fit (
x,y,z) positions of 
strings and tripods
 
  581             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  585                 for STRING in $STRINGS[*]; 
do    
  586                     fitPositionOfString 
$STRING X $DX_M
 
  587                     fitPositionOfString 
$STRING Y $DX_M
 
  588                     fitPositionOfString 
$STRING Z $DX_M
 
  591                 for TRIPOD in ${(
k)TRIPODS}; 
do 
  592                     fitPositionOfTripod 
$TRIPOD X $DX_M
 
  593                     fitPositionOfTripod 
$TRIPOD Y $DX_M
 
  594                     fitPositionOfTripod 
$TRIPOD Z $DX_M
 
  597                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  602             getCenter | 
read X Y Z
 
  604             let X=
"$X - $X_CENTER" 
  605             let Y=
"$Y - $Y_CENTER" 
  606             let Z=
"$Z - $Z_CENTER" 
  608             JEditTripod   -
f $TRIPOD_FILE -
T "-1 sub $X $Y $Z"              -
d 0 >& /dev/
null 
  613             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  614                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  621         for DX_M in 0.05; 
do                     # fit (z) positions of modules and (
x,y) positions of 
strings 
  623             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  627                 for STRING in $STRINGS[*]; 
do    
  629                     for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); 
do 
  630                         fitPositionOfModule 
$STRING $FLOOR $DX_M
 
  633                     fitPositionOfString 
$STRING X $DX_M
 
  634                     fitPositionOfString 
$STRING Y $DX_M
 
  637                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  644             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  645                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  650     *)  # ------------------------------------------------------------------------------------
 
  652         fatal 
"invalid stage $STAGE (possible stages: 1, 2, 3)" 
  664 rm -
f acoustics_fit_parameters.txt
 
  666 source JAcoustics.sh    $DETECTOR_ID
 
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison fi case set_variable RANGE $argv[3]
 
then usage $script< detector >< run >< outputfile > fi case set_variable OPTION
 
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
 
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary. 
 
clean eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY set_variable STRING
 
then usage $script< detector file >< inputfile > nUtility script to create PDF and CDF of transition time distribution fi case set_variable WORKDIR
 
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 E $EMITTER d $DEBUG!done kill_child_processes_at_exit attach getModule a $DETECTOR typeset Z STRING typeset Z FLOOR set_variable FIRST_FLOOR for STRING in $STRINGS[*]
 
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
 
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
 
then timer_start(JRandomTimesliceWriter-a ${DETECTOR}-o ${PIPE}-n ${NUMBER_OF_SLICES}-P ${PMT_FILE}-d ${DEBUG}-S ${SEED}-B"$BACKGROUND_HZ"-N"$RECYCLING"--!&&for((i=0;$i!=10;++i));do;echo 'EOF' > $PIPE;usleep 100000;done &&rm-f $PIPE)&JTimesliceReprocessor-a $
 
do for((RUN=${RANGE%%-*};$RUN<=${RANGE##*-};RUN+=1))
 
then fatal Invalid string $STRING
 
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
then usage $script< detector specific acoustics-fit script >< option > nAuxiliary script to make scan of pre stretching of detector strings(see JEditDetector)." "\nPossible options
 
then break fi done getCenter read X Y Z let X
 
do set_variable SIGMA_NS set_variable OUTLIERS set_variable OUTPUT_FILE matrix[${ALPHA_DEG}\deg\] root $JPP JMatrixNZ a $DETECTOR f $INPUT_FILE o $OUTPUT_FILE S
 
&set_variable OUTPUT_FILE
 
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
 
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
 
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
 
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DEBUG set_variable WORKDIR $JPP_DATA set_variable MAKE_PDF set_variable MERGE_PDF set_variable MAKE_CDF set_variable CLEAN set_variable BACKGROUND set_variable WGET set_variable RMAX_M set_variable absorptionLengthFactor set_variable scatteringLengthFactor BUFFER
 
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
 
double getChi2(const double P)
Get chi2 corresponding to given probability. 
 
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
 
then eval awk Processing stage $STAGE
 
set_variable NUMBER_OF_ITERATIONS set_variable EPSILON cat acoustics_fit_parameters txt<< EOF $CONFIGURATION[*]Nmin=3;sigma_s=100.0e-6;stdev=10.0;mestimator=0;fixStrings=0;EOF for STRING in $STRINGS[*];do#fit stretching and(z) position of given string set_variable DETECTOR_TMP/tmp/detector_A.datx JEditDetector-a $DETECTOR-o $DETECTOR_TMP-r $STRING JEditDetector-a $DETECTOR-o $DETECTOR-k $STRING for MUL in 0.005 0.001;do DX_M=0.2 for((N=0;$N< $NUMBER_OF_ITERATIONS;++N));do CHI2[3]=$CHI2[1] fitPositionOfString $STRING Z $DX_M fitStretchingOfString $STRING $MUL if(($CHI2[3]-$CHI2[1]< $EPSILON));then break fi done if(($N >=$NUMBER_OF_ITERATIONS));then printf"warning: reached maximum number of iterations %d - converenge %7.3f\n"$N $(($CHI2[3]-$CHI2[1])) fi done JMergeDetector-a $DETECTOR-a $DETECTOR_TMP-o $DETECTOR rm-f $DETECTOR_TMP JConvertDetectorFormat-a $DETECTOR-o $DETECTOR-r-d 0 > &dev null done
 
*fatal Wrong option $OPTION
 
then warning reached maximum number of iterations $N converenge(($CHI2[3]-$CHI2[1]))" fi done set_variable NUMBER_OF_ITERATIONS 1000 set_variable EPSILON 5.0E-4 for DX_M in 0.10
 
then fatal Invalid tripod $TRIPOD
 
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
 
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 
 
do if[[!-f $ACOUSTICS_WORKDIR/${KEY}.txt]]
 
then usage $script< detector file >< tripodfile >< stage > input file nInput files correspond to the output of JAcousticsEventBuilder[.sh] nFirst stage eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY eval JPrintDetector a $DETECTOR O CAN source JAcoustics sh $DETECTOR_ID typeset A CONFIGURATION for key in Tmax_s