X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=cluster_tools%2FmergeDoseByRegions.sh;h=b9303aac008b3b3a55a77bf4808531ad1c9e56b6;hb=83eb68efc39ad8fcb5e4e684afafcfc86b829c96;hp=0548db6372d87354637939d608e867513e3842cf;hpb=88759fd450cc61a1b6818f80548c8632b2a3ffea;p=clitk.git diff --git a/cluster_tools/mergeDoseByRegions.sh b/cluster_tools/mergeDoseByRegions.sh index 0548db6..b9303aa 100755 --- a/cluster_tools/mergeDoseByRegions.sh +++ b/cluster_tools/mergeDoseByRegions.sh @@ -7,9 +7,9 @@ function usage { } function addToPartialResult { - IN1=$2 - IN2=$4 - RESULT=$6 + IN1=$2 #merged file for previous jobs + IN2=$4 # current job + RESULT=$6 #output merged file test -f ${IN1} && test -f ${IN2} || usage @@ -25,6 +25,44 @@ function addToPartialResult { exit 1 fi + # Find the number of primaries for this job (the same for all line and different of 0) + # Get the number of primaries from edep and square_edep to determine the std. + nbPrimary=0 + for i in $(seq 2 $nblines); do + #Get the line + file2=`sed -n "${i}p" < ${IN2}` + + edep2=$(echo ${file2} | cut -f3 -d' ') + stdEdep2=$(echo ${file2} | cut -f4 -d' ') + sqEdep2=$(echo ${file2} | cut -f5 -d' ') + nbPrimary=$(python <> ${TMP} @@ -44,18 +82,6 @@ function addToPartialResult { edep3=${edep3/#./0.} file3=$(echo $file3 |awk -v r=${edep3} '{$3=r}1') - # sqrt sum square std_edep*edep: get the 2 values, sum the square, take the sqrt and replace it in the file3 - stdEdep1=$(echo ${file1} | cut -f4 -d' ') - stdEdep2=$(echo ${file2} | cut -f4 -d' ') - stdEdep3=$(python <> ${TMP} - # for all lines (except the 1st), split according tab - # sum the some elements (dose, edep) ... + if [ $nblines -ne $nb3 ]; then + echo "Files does not have the same size" + exit 1 + fi + # Find the number of primaries for this job (the same for all line and different of 0) + # Get the number of primaries from edep and square_edep to determine the std. + nbPrimary=0 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") + #Get the line + file2=`sed -n "${i}p" < ${IN1}` - # sqrt sum square std_edep*edep - stdEdep1=$(echo ${file1} | cut -f4 -d' ') - stdEdep3=$(python <> ${TMP} + # for all lines (except the 1st), split according tab + # write the number of primaries + for i in $(seq 2 $nblines); do + #Get the lines + file3=`sed -n "${i}p" < ${RESULT}` - # copy n_event_hits - event1=$(echo ${file1} | cut -f10 -d' ') - event1=${event1/#./0.} - file3=$(echo "$file3 $event1") + file3=$(echo $file3 |awk -v r=${nbPrimary} '{$4=r}1') + file3=$(echo $file3 |awk -v r=${nbPrimary} '{$7=r}1') #Write the output echo "${file3}" >> ${TMP} @@ -194,15 +212,13 @@ EOP mv -f ${TMP} ${RESULT} } - function divideUncertaintyResult { IN1=$2 - value=$4 - RESULT=$6 + RESULT=$4 TMP="$(mktemp)" - # check if all 3 text files have the same number of lines + # check if all 2 text files have the same number of lines nblines=`cat ${IN1} | wc -l` nb3=`cat ${RESULT} | wc -l` @@ -223,14 +239,15 @@ function divideUncertaintyResult { # Divide uncertainty and replace it in the file3 edep1=$(echo ${file1} | cut -f3 -d' ') - stdEdep1=$(echo ${file1} | cut -f4 -d' ') + nbPrimaryEdep1=$(echo ${file1} | cut -f4 -d' ') + sqEdep1=$(echo ${file1} | cut -f5 -d' ') stdEdep3=$(python <