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)+" 
   27     fatal 
"Wrong number of arguments." 
   37 eval `JPrintDetector -
a $DETECTOR -O IDENTIFIER`
 
   40 source JAcoustics.sh    $DETECTOR_ID
 
   44 get_tripods $TRIPOD_FILE TRIPODS
 
   46 #unset "TRIPODS[1]"                           # exclude tripod 1 
   47 #unset "TRIPODS[${(A)${(k)TRIPODS}[1]}]"      # exclude 1st tripod 
   49 typeset -
a CHI2                              # chi2(old,
new)
 
   58 # -------------------------------------------------------------------------------------------- 
   59 # Get center-of-gravity of tripods. 
   62 # -------------------------------------------------------------------------------------------- 
   69     for value 
in "${(@v)TRIPODS}"; 
do 
   73         let X_CENTER=
"$X_CENTER + $X" 
   74         let Y_CENTER=
"$Y_CENTER + $Y" 
   75         let Z_CENTER=
"$Z_CENTER + $Z" 
   78     let X_CENTER=
"$X_CENTER / ${#TRIPODS}" 
   79     let Y_CENTER=
"$Y_CENTER / ${#TRIPODS}" 
   80     let Z_CENTER=
"$Z_CENTER / ${#TRIPODS}" 
   82     printf 
"%12.3f %12.3f %12.3f" $X_CENTER $Y_CENTER $Z_CENTER
 
   86 # -------------------------------------------------------------------------------------------- 
   90 # -------------------------------------------------------------------------------------------- 
   97         -
f "$INPUT_FILES[*]"                      \
 
  102         -@ 
$WORKDIR/acoustics_fit_parameters.txt  \
 
  111 # -------------------------------------------------------------------------------------------- 
  112 # Fit given coordinate of string position. 
  114 # \param  1       string identifier 
  115 # \param  2       coordinate (X|Y|Z) 
  117 # -------------------------------------------------------------------------------------------- 
  118 function fitPositionOfString()
 
  128     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  134         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  144     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  150         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  160     printf 
"string %04d  %s %6d %7.3f\n" $1 $2 $N $CHI2[1]
 
  164 # -------------------------------------------------------------------------------------------- 
  165 # Fit given coordinate of tripod position. 
  167 # \param  1       tripod identifier 
  168 # \param  2       coordinate (X|Y|Z) 
  170 # -------------------------------------------------------------------------------------------- 
  171 function fitPositionOfTripod()
 
  175     BUFFER=(
X 0.0 
Y 0.0 Z 0.0)
 
  181     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  183         JEditTripod -
f $TRIPOD_FILE -
T "$1 add $BUFFER[*]" -
d 0 >& /dev/
null 
  187         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  189             JEditTripod -
f $TRIPOD_FILE -
T "$1 sub $BUFFER[*]" -
d 0 >& /dev/
null 
  197     for (( ; $N != $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  199         JEditTripod -
f $TRIPOD_FILE -
T "$1 sub $BUFFER[*]" -
d 0 >& /dev/
null 
  203         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  205             JEditTripod -
f $TRIPOD_FILE -
T "$1 add $BUFFER[*]" -
d 0 >& /dev/
null 
  213     printf 
"tripod   %2d  %s %6d %7.3f\n" $1 $2 $N $CHI2[1]
 
  217 # -------------------------------------------------------------------------------------------- 
  218 # Fit module z-position. 
  220 # \param  1       string identifier 
  223 # -------------------------------------------------------------------------------------------- 
  224 function fitPositionOfModule()
 
  228     BUFFER=(
X 0.0 
Y 0.0 Z $3)
 
  235     for (( i=0 ; 
$i != $NUMBER_OF_STEPS && $N != $NUMBER_OF_ITERATIONS; ++i, ++
N )); 
do 
  241         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  251     for (( i=0 ; 
$i != $NUMBER_OF_STEPS && $N != $NUMBER_OF_ITERATIONS; ++i, ++
N )); 
do 
  257         if (( $CHI2[2] >= $CHI2[1] )); 
then 
  267     printf 
"module %04d.%02d %6d %7.3f\n" $1 $2 $N $CHI2[1]
 
  280     1)  # ------------------------------------------------------------------------------------
 
  285         cat>acoustics_fit_parameters.txt<<EOF    # fix tilt angles
 
  294         for DX_M 
in 0.5 0.2; 
do                  # fit (x,y,z) positions of strings and tripods
 
  296             for (( 
N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  303                     fitPositionOfString 
$STRING Z $DX_M
 
  306                 for TRIPOD 
in ${(
k)TRIPODS}; 
do 
  309                     fitPositionOfTripod 
$TRIPOD Z $DX_M
 
  312                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  319             let 
X=
"$X - $X_CENTER" 
  320             let 
Y=
"$Y - $Y_CENTER" 
  321             let Z=
"$Z - $Z_CENTER" 
  323             JEditTripod   -
f $TRIPOD_FILE -
T "-1 sub $X $Y $Z"              -
d 0 >& /dev/
null 
  328             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  329                 printf 
"warning: reached maximum number of iterations %d - converenge %7.3f\n" $N $(($CHI2[3] - $CHI2[1]))
 
  336         for DX_M 
in 0.1; 
do                      # fit (z) positions of modules 
  338             for (( 
N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  342                 for STRING in $STRINGS[*]; 
do 
  343                     for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); 
do 
  344                         fitPositionOfModule 
$STRING $FLOOR $DX_M
 
  348                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  355             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  356                 printf 
"warning: reached maximum number of iterations %d - converenge %7.3f\n" $N $(($CHI2[3] - $CHI2[1]))
 
  361     2)  
# ------------------------------------------------------------------------------------ 
  366         cat>acoustics_fit_parameters.txt<<EOF
 
  375         for DX_M in 0.2; 
do                      # fit (x,y,z) positions of strings and tripods
 
  377             for (( 
N=0; $N < $NUMBER_OF_ITERATIONS; ++N )); 
do 
  382                     fitPositionOfString 
$STRING X $DX_M
 
  383                     fitPositionOfString 
$STRING Y $DX_M
 
  384                     fitPositionOfString 
$STRING Z $DX_M
 
  387                 for TRIPOD in ${(
k)TRIPODS}; 
do 
  388                     fitPositionOfTripod 
$TRIPOD X $DX_M
 
  389                     fitPositionOfTripod 
$TRIPOD Y $DX_M
 
  390                     fitPositionOfTripod 
$TRIPOD Z $DX_M
 
  393                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  398             getCenter | 
read X Y Z
 
  400             let X=
"$X - $X_CENTER" 
  401             let Y=
"$Y - $Y_CENTER" 
  402             let Z=
"$Z - $Z_CENTER" 
  404             JEditTripod   -
f $TRIPOD_FILE -
T "-1 sub $X $Y $Z"              -
d 0 >& /dev/
null 
  409             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  410                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  417         for DX_M in 0.10; 
do                     # fit (z) positions of modules and (x,y) positions of strings
 
  419             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  423                 for STRING in $STRINGS[*]; 
do    
  425                     for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); 
do 
  426                         fitPositionOfModule 
$STRING $FLOOR $DX_M
 
  429                     fitPositionOfString 
$STRING X $DX_M
 
  430                     fitPositionOfString 
$STRING Y $DX_M
 
  433                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  440             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  441                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  446     3)  # ------------------------------------------------------------------------------------
 
  451         cat>acoustics_fit_parameters.txt<<EOF
 
  460         for DX_M in 0.10 0.05; 
do                # fit (x,y,z) positions of strings and tripods
 
  462             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  466                 for STRING in $STRINGS[*]; 
do    
  467                     fitPositionOfString 
$STRING X $DX_M
 
  468                     fitPositionOfString 
$STRING Y $DX_M
 
  469                     fitPositionOfString 
$STRING Z $DX_M
 
  472                 for TRIPOD in ${(
k)TRIPODS}; 
do 
  473                     fitPositionOfTripod 
$TRIPOD X $DX_M
 
  474                     fitPositionOfTripod 
$TRIPOD Y $DX_M
 
  475                     fitPositionOfTripod 
$TRIPOD Z $DX_M
 
  478                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  483             getCenter | 
read X Y Z
 
  485             let X=
"$X - $X_CENTER" 
  486             let Y=
"$Y - $Y_CENTER" 
  487             let Z=
"$Z - $Z_CENTER" 
  489             JEditTripod   -
f $TRIPOD_FILE -
T "-1 sub $X $Y $Z"              -
d 0 >& /dev/
null 
  494             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  495                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  502         for DX_M in 0.05; 
do                     # fit (z) positions of modules and (x,y) positions of strings
 
  504             for (( N=0; $N < $NUMBER_OF_ITERATIONS; ++
N )); 
do 
  508                 for STRING in $STRINGS[*]; 
do    
  510                     for (( FLOOR = 1; $FLOOR <= 18; FLOOR += 1 )); 
do 
  511                         fitPositionOfModule 
$STRING $FLOOR $DX_M
 
  514                     fitPositionOfString 
$STRING X $DX_M
 
  515                     fitPositionOfString 
$STRING Y $DX_M
 
  518                 if (( $CHI2[3] - $CHI2[1] < $EPSILON )); 
then 
  525             if (( $N >= $NUMBER_OF_ITERATIONS )); 
then 
  526                 warning "reached maximum number of iterations $N - converenge $(($CHI2[3] - $CHI2[1]))" 
  531     *)  # ------------------------------------------------------------------------------------
 
  533         fatal 
"invalid stage $STAGE (possible stages: 1, 2, 3)" 
  545 rm -
f acoustics_fit_parameters.txt
 
  547 source JAcoustics.sh    $DETECTOR_ID
 
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
clean eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY set_variable STRING
bool read(Vec &v, std::istream &is)
Read a Vec(tor) from a stream. 
then JPlot1D f $WORKDIR postfit[prefit\] root
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 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 break fi done getCenter read X Y Z let X
*set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2,-2] set_variable OUTPUT_FILE $argv[-1]
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
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DEBUG set_variable WORKDIR tmp set_variable JDAQ_TIMESLICE JDAQTimeslice if do_usage *then usage $script< detector file >< inputfile > fi case set_variable WORKDIR
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable TRIPOD_FILE $argv[2] set_variable STAGE $argv[3] set_array INPUT_FILES $argv[4,-1] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $TRIPOD_FILE TRIPODS typeset a CHI2 CHI2
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 usage $script[input file[working directory[option]]] nWhere option can be N
*fatal invalid stage $STAGE(possible stages:1, 2, 3)" 
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 
then usage $script[input file[working directory[option]]] nWhere option can be E