From 08f7de414957e92b25ca5b299007e941b610d3a8 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Tue, 27 Nov 2018 15:56:54 +0100 Subject: [PATCH] Change N formula N is the number of primaries and is determine using the value of std, edep and squared edep. If it is null, we look for the next line, etc... --- cluster_tools/gate_power_merge.sh | 2 + cluster_tools/mergeDoseByRegions.sh | 148 ++++++++++++++++++++++++++-- 2 files changed, 144 insertions(+), 6 deletions(-) diff --git a/cluster_tools/gate_power_merge.sh b/cluster_tools/gate_power_merge.sh index b2ced88..43d90d0 100755 --- a/cluster_tools/gate_power_merge.sh +++ b/cluster_tools/gate_power_merge.sh @@ -218,12 +218,14 @@ function merge_doseByRegions { then update_bar ${count} "copying first partial result ${partial}" cp "${partial}" "${merged}" + copyFirstPartialResult -i "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${doseMerger}" continue fi update_bar ${count} "adding ${partial}" addToPartialResult -i "${merged}" -j "${partial}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${doseMerger}" done + divideUncertaintyResult -i "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${doseMerger}" end_bar echo " ${indent}merged ${count} files" } diff --git a/cluster_tools/mergeDoseByRegions.sh b/cluster_tools/mergeDoseByRegions.sh index ad0b5bc..b9303aa 100755 --- a/cluster_tools/mergeDoseByRegions.sh +++ b/cluster_tools/mergeDoseByRegions.sh @@ -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} @@ -51,6 +89,16 @@ function addToPartialResult { sqEdep3=${sqEdep3/#./0.} file3=$(echo $file3 |awk -v r=${sqEdep3} '{$5=r}1') + # Get the number of primaries from edep and square_edep to determine the std. + # Sum the number of primaries with the latter ones + nbPrimaryEdep1=$(echo ${file1} | cut -f4 -d' ') + nbPrimaryEdep3=$(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}` + + 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} + done + mv -f ${TMP} ${RESULT} +} + function divideUncertaintyResult { IN1=$2 - value=$4 - RESULT=$6 + RESULT=$4 TMP="$(mktemp)" @@ -111,11 +239,15 @@ function divideUncertaintyResult { # Divide uncertainty and replace it in the file3 edep1=$(echo ${file1} | cut -f3 -d' ') + nbPrimaryEdep1=$(echo ${file1} | cut -f4 -d' ') sqEdep1=$(echo ${file1} | cut -f5 -d' ') stdEdep3=$(python <