diff --git a/macro/geometry/README.md b/macro/geometry/README.md index eda01b2fc7d53746fb357076a897887518bdd13d..8d06bfa668e4b6776fc20d579a90984394df9487 100644 --- a/macro/geometry/README.md +++ b/macro/geometry/README.md @@ -158,3 +158,27 @@ include * APR21 - (current 2021 default geometries. This is the official release geometries. * TEST - (Geometries shift such that the center of the magnet is the origin of the CBM exp.) + +## check_radlen.sh + +Checks for a common issue whereby the radiaiton length is miscalculated by root. + +The script calculates the radiation length from the stated atomic number, mass and density of the material +and compares this to the stated radlen in the material. If the difference is more than a tolerance (currently +5%) then failure is declared. It is up to the use to assess information. Dummy and vacuum materials may be safely +ignored. + +Sugggested command + +sh check_radlen.sh much_v20b_mcbm.geo.root + +This will check the materials rad length within a certain tolerance (5%). Recommended checking +the transported geometry file in simulations to check whether target definition and all geometries +are correct. + +sh check_radlen.sh test.geo.root + + +--- + + diff --git a/macro/geometry/check_radlen.sh b/macro/geometry/check_radlen.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c7fbd195419396afe5fc57f9a61aca3b268ace5 --- /dev/null +++ b/macro/geometry/check_radlen.sh @@ -0,0 +1,60 @@ +#/bin/bash +# check_radlen.sh - checks radiation length of materials in user supplied geometry +# Author: Eoin Clerkin (FAIR) 2022-01-31 + +echo "Scanning the geometry" $1 + +root -l -q '$VMCWORKDIR/macro/geometry/scan_geometry.C("'$1'")' 1>tmp + +grep '^M\(at\|ix\)' tmp | \ +sort | \ +uniq -c | \ +sort -g -k 1 1>MATERIALS + +COUNT=0; +FAIL=0; +SKIP=0; +OKAY=0; + + +while IFS= read -r line; +do + +variables=`echo "$line" | sed -e 's/eff//g' | sed -e 's/index/jndex/g' | sed -e 's/.*A=/ A=/g' | sed -e 's/ / -v /g'` + + awk \ + -v TOL=0.1 \ + $variables \ + 'BEGIN{\ + if(Z==0){ + printf "SKIP"; \ + exit 3; + }; + cal_rad_len=(716.4*A/(Z*(Z+1)*log(287/sqrt(Z)))/rho);\ + #print cal_rad_len; + if(((cal_rad_len - radlen)/radlen)**2 <= TOL**2 ){\ + printf "OKAY"; exit 1; + }else{\ + printf "FAIL"; exit 2; + }}' + + STATUS=$?; + + if [ $STATUS -eq 1 ]; then OKAY=$((OKAY+1)); fi; + if [ $STATUS -eq 2 ]; then FAIL=$((FAIL+1)); fi; + if [ $STATUS -eq 3 ]; then SKIP=$((SKIP+1)); fi; + + COUNT=$((COUNT+1)); + + echo " \t $line" + +done < MATERIALS + +rm tmp MATERIALS + + +echo ${FAIL}" failures in " $COUNT " materials" + +echo "ENDED successfully" + +exit ${FAIL};