4source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
6set_variable: DEBUG RECONSTRUCTION_DEBUG 2
7set_variable: WORKDIR RECONSTRUCTION_WORKDIR ${TMPDIR:-/tmp}/
8set_variable: FORMAT GRAPHICS_FORMAT gif
9set_variable+ BATCH GRAPHICS_BATCH -B
12 usage "$script <option> [<detector> (input file)+]"\
13 "\nPossible options: run, plot, update and clean."\
14 "\nThe option run should be followed by a detector file and one or more input files (output of JTriggerEfficiency)."\
15 "\nThe option plot could be followed by the name of the fit (prefit, simplex or gandalf) and the quantity (50%, 90%, 99% or efficiency)."
19 set_variable OPTION ${argv[1]}
20elif (( $# >= 3 )) && [[ $1 == "run" ]]; then
21 set_variable OPTION ${argv[1]}
22 set_variable DETECTOR ${argv[2]:a}
23 set_array INPUT_FILES ${argv[3,-1]:a}
24elif (( $# >= 1 )) && [[ $1 == "plot" ]]; then
25 set_variable OPTION ${argv[1]}
26 set_array APPS ${argv[2]}
27 set_variable QUANTITY ${argv[3]}
29 fatal "Wrong number of arguments."
32if [[ $OPTION != "run" && $OPTION != "plot" && $OPTION != "update" && $OPTION != "clean" ]]; then
33 fatal "Invalid option $OPTION."
36if (( ${#APPS} == 0 )); then
37 APPS=(prefit simplex gandalf)
40typeset -A NUMBER_OF_FIT
42NUMBER_OF_FIT=(prefit 0
58PARAMETERS[prefit.gridAngle_deg]="4.0 5.0 6.0"
59PARAMETERS[prefit.roadWidth_m]="35.0 40.0 45.0 50.0 55.0 60.0"
60PARAMETERS[prefit.TMaxLocal_ns]="10.0 12.5 15.0 17.5 20.0"
61PARAMETERS[prefit.sigma_ns]="4.0 5.0 6.0 7.0"
62PARAMETERS[prefit.ctMin]="-0.1 0.0 0.1 0.2 0.3"
63PARAMETERS[prefit.numberOfPrefits]="10 25 50 75 100"
64PARAMETERS[prefit.numberOfPostfits]="0 10 20 50"
65PARAMETERS[prefit.Qwatershed]="0 0.5 1.0 1.5 2.0 2.5"
66#PARAMETERS[prefit.numberOfOutliers]="0 1 2 3 4 5"
67#PARAMETERS[prefit.factoryLimit]="7 8 9 10"
68PARAMETERS[prefit.useL0]="0 1"
70PARAMETERS[simplex.sigma_ns]="2.0 2.5 3.0 3.5 4.0"
71PARAMETERS[simplex.TMaxLocal_ns]="10.0 12.5 15.0 17.5 20.0"
72PARAMETERS[simplex.ctMin]="-0.1 0.0 0.1 0.2 0.3"
73PARAMETERS[simplex.roadWidth_m]="35.0 40.0 45.0 50.0 55.0 60.0"
75PARAMETERS[start.roadWidth_m]="35.0 40.0 45.0 50.0 55.0 60.0"
76PARAMETERS[start.TMin_ns]="-30.0 -25.0 -20.0 -15.0"
77PARAMETERS[start.TMax_ns]="+15.0 +20.0 +25.0 +30.0"
78PARAMETERS[start.Pmin1]="0.5e-3 1.0e-3 1.5e-3"
79PARAMETERS[start.Pmin2]="0.5e-2 1.0e-2 1.5e-2"
81PARAMETERS[gandalf.TTS_ns]="0.0 0.5 1.0 1.5 2.0 2.5"
82PARAMETERS[gandalf.E_GeV]="5.0 10.0 15.0 20.0"
83PARAMETERS[gandalf.TMin_ns]="-60.0 -50.0 -40.0 -30.0 -20.0"
84PARAMETERS[gandalf.TMax_ns]="+350.0 +400.0 +450.0 +500.0 +550.0"
85PARAMETERS[gandalf.ZMin_m]="-1.0 -2.0 -3.0 -4.0 -5.0"
86PARAMETERS[gandalf.ZMax_m]="+7.0 +8.0 +9.0 +10.0 +11.0"
87PARAMETERS[gandalf.roadWidth_m]="35.0 40.0 45.0 50.0 55.0 60.0"
89if [[ $OPTION == "run" ]]; then
91 set_variable DIR `pwd`
92 set_variable WORKDIR `mktemp -d $WORKDIR/XXXXXX`
96 set_variable RECONSTRUCTION_NUMBER_OF_THREADS 10
98 for PARAMETER VALUES in ${(kv)PARAMETERS}; do
100 VALUES=($(echo $VALUES))
102 if [[ ! -f $DIR/$PARAMETER.$APPS[1].txt ]]; then
104 for VALUE in $VALUES[*]; do
106 set_variable RECONSTRUCTION_OPTION -@ $PARAMETER=$VALUE
108 { rm -f jmuon.*.root } >& /dev/null
110 for (( i = 1; $i <= ${#INPUT_FILES}; i += 1 )); do
111 JORCAMuonReconstruction.sh $DETECTOR $INPUT_FILES[$i] jmuon.$i.root $JPP_DATA/PMT_parameters.txt >& /dev/null
114 for APP in $APPS[*]; do
116 JMuonPostfit -fjmuon.{1..${#INPUT_FILES}}.root -A $ENUMERATION[$APP] -N $NUMBER_OF_FIT[$APP] -o /dev/null >& $PARAMETER.$APP.log
118 set_variable N0 $(JPrintChain -fjmuon.{1..${#INPUT_FILES}}.root | awk '/^EVT/ {print $2}')
119 set_variable N1 $(awk '/Number of events with fit/ {print $NF}' $PARAMETER.$APP.log)
120 set_array N2 $(awk '/Space angle/ {print $NF}' $PARAMETER.$APP.log)
122 printf "%-1s %7.3f %7.3f %7.3f %6.4f\n" ${VALUE} ${N2[1]:-0} ${N2[2]:-0} ${N2[3]:-0} $(((1.0 * ${N1:-0}) / (1.0 * ${N0:-1}))) >> $DIR/$PARAMETER.$APP.txt
130 rm -rf $WORKDIR >& /dev/null
132elif [[ $OPTION == "plot" ]]; then
134 if [[ "$QUANTITY" == "" ]]; then
135 set_variable QUANTITY 50%
139 50%) let "COLUMN = 2"; set_variable Y_LABEL "$QUANTITY angle [deg]";;
140 90%) let "COLUMN = 3"; set_variable Y_LABEL "$QUANTITY angle [deg]";;
141 99%) let "COLUMN = 4"; set_variable Y_LABEL "$QUANTITY angle [deg]";;
142 efficiency) let "COLUMN = 5"; set_variable Y_LABEL "$QUANTITY";;
143 *) fatal "Invalid quantity $QUANTITY."
149 for PARAMETER in ${(k)PARAMETERS}; do
151 Y=$(sort -gr -k 2 $PARAMETER.${^APPS}.txt | awk -v COLUMN=$COLUMN '{if (NR == 1) {print $COLUMN}}')
153 if (( $Y > $YMAX )); then
158 YMAX=$(printf "%1.1f" $(($YMAX * 1.1)))
160 for PARAMETER VALUES in ${(kv)PARAMETERS}; do
162 echo "Generating graphics for $PARAMETER."
164 VALUES=($(echo $VALUES | sed 's/[[:space:]][[:space:]]*/\n/g' | sort -g))
166 set_variable RECONSTRUCTION_OPTION -h!
168 typeset -T PARAMETER ARRAY .
170 set_variable X $(eval JORCAMuonReconstruction.sh - - - - \| sed -n \'/\^$ARRAY[1]\\\./,/\^\$/s/\.\*$ARRAY[2] \*= \*//p\')
173 -p "$X $YMIN $X $YMAX" \
176 for APP in $APPS[*]; do
178 -f $PARAMETER.$APP.txt \
179 -o $PARAMETER\[$APP\].root \
184 let "NX = ${#VALUES}"
185 let "XMIN = $VALUES[+1]"
186 let "XMAX = $VALUES[-1]"
187 let "DX = ($XMAX - $XMIN) / ($NX - 1)"
190 -f$PARAMETER\[${^APPS}\].root:"${PARAMETER}\[$(($COLUMN - 2))\]" \
192 -x "$(($XMIN - 0.5*$DX)) $(($XMAX + 0.5*$DX))" \
199 -o $PARAMETER.$FORMAT $BATCH
201 { rm -f $PARAMETER\[${^APPS}\].root line.root } >& /dev/null
204elif [[ $OPTION == "update" ]]; then
210 for PARAMETER in ${(k)PARAMETERS}; do
212 if [[ -f $PARAMETER.$APP.txt ]]; then
214 VALUES=($(sort -g -k 2 $PARAMETER.$APP.txt | awk '{print $2}'))
216 if (( $VALUES[+1] < $VALUES[-1] - $EPS )); then
218 VALUE=$(sort -g -k 2 $PARAMETER.$APP.txt | awk '{if (NR == 1) {print $1}}')
220 eval sed -i \'s/\\\(${PARAMETER} \*\\\)\[\^\)\]\*/\\\1${VALUE}/\' $JPP_DIR/software/JReconstruction/JORCAMuonReconstruction.sh
225elif [[ $OPTION == "clean" ]]; then
227 for PARAMETER in ${(k)PARAMETERS}; do
228 for APP in $APPS[*]; do
229 rm -f $PARAMETER.$APP.txt >& /dev/null