-function addWithoutPartialResult {
- IN1=$2
- RESULT=$4
-
- test -f ${IN1} || usage
-
- TMP="$(mktemp)"
-
- nblines=`cat ${IN1} | wc -l`
-
- #Copy the 1st line in output
- line1=`sed -n "1p" < ${IN1}`
- echo "${line1}" >> ${TMP}
- # for all lines (except the 1st), split according tab
- # sum the some elements (dose, edep) ...
- for i in $(seq 2 $nblines); do
- #Get the lines
- file1=`sed -n "${i}p" < ${IN1}`
-
- # copy id
- id1=$(echo ${file1} | cut -f1 -d' ')
- id1=${id1/#./0.}
- file3=$(echo $id1)
-
- # copy volume
- vol1=$(echo ${file1} | cut -f2 -d' ')
- vol1=${vol1/#./0.}
- file3=$(echo "$file3 $vol1")
-
- # copy edep
- edep1=$(echo ${file1} | cut -f3 -d' ')
- edep1=${edep1/#./0.}
- file3=$(echo "$file3 $edep1")
-
- # sqrt sum square std_edep*edep
- stdEdep1=$(echo ${file1} | cut -f4 -d' ')
- stdEdep3=$(python <<EOP
-import math;
-temp=$edep1*$stdEdep1;
-print(math.sqrt(temp*temp))
-EOP
- )
- stdEdep3=${stdEdep3/#./0.}
- file3=$(echo "$file3 $stdEdep3")
-
- # copy square_edep
- sqEdep1=$(echo ${file1} | cut -f5 -d' ')
- sqEdep1=${sqEdep1/#./0.}
- file3=$(echo "$file3 $sqEdep1")
-
- # copy dose
- dose1=$(echo ${file1} | cut -f6 -d' ')
- dose1=${dose1/#./0.}
- file3=$(echo "$file3 $dose1")
-
- # sqrt sum square std_dose*dose
- stdDose1=$(echo ${file1} | cut -f7 -d' ')
- stdDose3=$(python <<EOP
-import math;
-temp=$dose1*$stdDose1;
-print(math.sqrt(temp*temp))
-EOP
- )
- stdDose3=${stdDose3/#./0.}
- file3=$(echo "$file3 $stdDose3")
-
- # copy square_dose
- sqDose1=$(echo ${file1} | cut -f8 -d' ')
- sqDose1=${sqDose1/#./0.}
- file3=$(echo "$file3 $sqDose1")
-
- # copy n_hits
- hit1=$(echo ${file1} | cut -f9 -d' ')
- hit1=${hit1/#./0.}
- file3=$(echo "$file3 $hit1")
-
- # copy n_event_hits
- event1=$(echo ${file1} | cut -f10 -d' ')
- event1=${event1/#./0.}
- file3=$(echo "$file3 $event1")
-
- #Write the output
- echo "${file3}" >> ${TMP}
- done
- mv -f ${TMP} ${RESULT}
-}
-
-