Skip to content
Snippets Groups Projects
Commit 68f684f3 authored by Eoin Clerkin's avatar Eoin Clerkin
Browse files

Radiation length checker

Script which checks the radiation lenght of materials in a
user specified geometry, i.e. test.geo.root

Counts failures. Reports errror code.
parent 1e70cb3f
No related branches found
No related tags found
1 merge request!678Radiation length checker
Pipeline #15644 passed
......@@ -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
---
#/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};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment