File indexing completed on 2025-12-16 09:28:28
0001
0002 set -e
0003
0004
0005
0006 : ${DETECTOR_CONFIG:="epic_craterlake_material_map"}
0007
0008 if [[ -z ${DETECTOR_PATH} ]] ; then
0009 echo "You must set \$DETECTOR_PATH before running this script."
0010 exit -1
0011 fi
0012
0013
0014 ACTS_VERSION="v39.2.0"
0015 ACTS_URL="https://github.com/acts-project/acts/raw/"
0016 ACTS_FILES=(
0017 "Examples/Scripts/Python/geometry.py"
0018 "Examples/Scripts/Python/material_mapping.py"
0019 "Examples/Scripts/Python/material_recording.py"
0020 "Examples/Scripts/Python/material_validation.py"
0021 "Examples/Scripts/MaterialMapping/writeMapConfig.py"
0022 "Examples/Scripts/MaterialMapping/configureMap.py"
0023 "Examples/Scripts/MaterialMapping/GeometryVisualisationAndMaterialHandling.py"
0024 "Examples/Scripts/MaterialMapping/Mat_map.C"
0025 "Examples/Scripts/MaterialMapping/Mat_map_surface_plot.C"
0026 "Examples/Scripts/MaterialMapping/Mat_map_surface_plot_ratio.C"
0027 "Examples/Scripts/MaterialMapping/Mat_map_surface_plot_dist.C"
0028 "Examples/Scripts/MaterialMapping/Mat_map_surface_plot_1D.C"
0029 "Examples/Scripts/MaterialMapping/materialPlotHelper.cpp"
0030 "Examples/Scripts/MaterialMapping/materialPlotHelper.hpp"
0031 )
0032 for file in ${ACTS_FILES[@]} ; do
0033 if [ ! -f ${file} ] ; then
0034 curl --silent --location --create-dirs --output ${file} ${ACTS_URL}/${ACTS_VERSION}/${file}
0035 if [ "${file}" = "Examples/Scripts/MaterialMapping/Mat_map.C" ] ; then
0036
0037 patch -p1 <<EOF
0038 diff -aru a/Examples/Scripts/MaterialMapping/Mat_map.C b/Examples/Scripts/MaterialMapping/Mat_map.C
0039 --- a/Examples/Scripts/MaterialMapping/Mat_map.C
0040 +++ b/Examples/Scripts/MaterialMapping/Mat_map.C
0041 @@ -145,7 +145,8 @@
0042
0043 // 2D map for Validation input
0044 TCanvas *VM = new TCanvas("VM","Validation Map") ;
0045 - Val_file->Draw("mat_y:mat_z","std::abs(mat_x)<1");
0046 + Val_file->Draw("sqrt(mat_x**2+mat_y**2):mat_z>>mat_map1","(mat_z>-5000)&(mat_z<8000)");
0047 + VM->SetGrid();
0048
0049 eta_0->Draw("Same");
0050 eta_1p->Draw("Same");
0051 EOF
0052 fi
0053 fi
0054 done
0055 export PYTHONPATH=$PWD/Examples/Scripts/Python:$PYTHONPATH
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 export ACTS_SEQUENCER_DISABLE_FPEMON=1
0070
0071
0072
0073
0074
0075
0076
0077 nevents=100
0078 nparticles=500
0079
0080 function print_the_help {
0081 echo "USAGE: [--nevents <int>] [--nparticles <int>]"
0082 echo "OPTIONAL ARGUMENTS:"
0083 echo " --nevents Number of events (default: $nevents)"
0084 echo " --nparticles Number of particles per event (default: $nparticles)"
0085 echo " -h,--help Print this message"
0086 echo ""
0087 echo " Run material map validation."
0088 exit
0089 }
0090
0091 while [[ $
0092 do
0093 key="$1"
0094 case $key in
0095 --nevents)
0096 nevents=$2
0097 shift
0098 shift
0099 ;;
0100 --nparticles)
0101 nparticles=$2
0102 shift
0103 shift
0104 ;;
0105 *)
0106
0107 echo "unknown option $1"
0108 print_the_help
0109 shift
0110 ;;
0111 esac
0112 done
0113 set -- "${POSITIONAL[@]}"
0114
0115 recordingFile=geant4_material_tracks.root
0116 geoFile=geometry-map.json
0117 matFile=material-map.cbor
0118 trackFile=material-map_tracks.root
0119 propFile=propagation_material
0120
0121 echo "::group::----GEANTINO SCAN------"
0122
0123
0124 python material_recording_epic.py -i ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml -n ${nevents} -t ${nparticles} -o ${recordingFile}
0125 echo "::endgroup::"
0126
0127 echo "::group::-----MAPPING Configuration-----"
0128
0129 python geometry_epic.py -i ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml
0130
0131
0132 python Examples/Scripts/MaterialMapping/writeMapConfig.py ${geoFile} config-map.json
0133
0134
0135
0136 python materialmap_config.py -i config-map.json -o config-map_regenerated.json
0137
0138
0139 python Examples/Scripts/MaterialMapping/configureMap.py ${geoFile} config-map_regenerated.json
0140
0141
0142 rm -rf plots
0143 mkdir -p plots
0144 python Examples/Scripts/MaterialMapping/GeometryVisualisationAndMaterialHandling.py --geometry ${geoFile}
0145 echo "::endgroup::"
0146
0147 echo "::group::----MAPPING Debugging-----"
0148 echo "Volumes by name:"
0149 jq -r '.Volumes.entries[] | "vol=\(.volume): \(.value.NAME)"' geometry-map.json
0150 echo "Volume surfaces:"
0151 jq -r '.Surfaces.entries[] | select(.boundary != null) | "vol=\(.volume)|bnd=\(.boundary): \(.value.type) \(.value.bounds.type) \(.value.bounds.values) rot=\(.value.transform.rotation) pos=\(.value.transform.translation)"' geometry-map.json
0152 echo "Layer surfaces:"
0153 jq -r '.Surfaces.entries[] | select(.volume < 40 and .layer != null) | "vol=\(.volume)|lay=\(.layer): \(.value.type) \(.value.bounds.type) \(.value.bounds.values) rot=\(.value.transform.rotation) pos=\(.value.transform.translation)"' geometry-map.json
0154 echo "::endgroup::"
0155
0156 echo "::group::----MAPPING------------"
0157
0158
0159
0160 sed -i 's/acts\.logging\.INFO/acts.logging.VERBOSE/g' Examples/Scripts/Python/material_mapping.py
0161 sed -i 's/navigator = Navigator($/&level=acts.logging.VERBOSE,/' Examples/Scripts/Python/material_mapping.py
0162 sed -i 's/propagator = Propagator(stepper, navigator)$/propagator = Propagator(stepper, navigator, loglevel=acts.logging.VERBOSE)/' Examples/Scripts/Python/material_mapping.py
0163 set -o pipefail
0164 python material_mapping_epic.py --xmlFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml --geoFile ${geoFile} --matFile ${matFile} | tail -n 5000
0165 echo "::endgroup::"
0166
0167 echo "::group::----Prepare validation rootfile--------"
0168
0169 python material_validation_epic.py --xmlFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml --outputName ${propFile}_regenerated --matFile ${matFile} -n ${nevents} -t ${nparticles}
0170 python material_validation_epic.py --xmlFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml --outputName ${propFile}_current --matFile "calibrations/materials-map.cbor" -n ${nevents} -t ${nparticles}
0171 echo "::endgroup::"
0172
0173 echo "::group::-------Comparison plots---------"
0174 rm -rf Validation/regenerated
0175 mkdir -p Validation/regenerated
0176 root -l -b -q Examples/Scripts/MaterialMapping/Mat_map.C'("'${propFile}_regenerated'.root","'${trackFile}'","Validation/regenerated")'
0177 rm -rf Validation/current
0178 mkdir -p Validation/current
0179 root -l -b -q Examples/Scripts/MaterialMapping/Mat_map.C'("'${propFile}_current'.root","'${trackFile}'","Validation/current")'
0180
0181 rm -rf Surfaces
0182 mkdir -p Surfaces/regenerated/ratio_plot
0183 mkdir -p Surfaces/regenerated/prop_plot
0184 mkdir -p Surfaces/regenerated/map_plot
0185 mkdir -p Surfaces/current/ratio_plot
0186 mkdir -p Surfaces/current/prop_plot
0187 mkdir -p Surfaces/current/map_plot
0188 mkdir -p Surfaces/dist_plot
0189 mkdir -p Surfaces/1D_plot
0190
0191 root -l -b -q Examples/Scripts/MaterialMapping/Mat_map_surface_plot_ratio.C'("'${propFile}_regenerated'.root","'${trackFile}'",-1,"Surfaces/regenerated/ratio_plot","Surfaces/regenerated/prop_plot","Surfaces/regenerated/map_plot")'
0192 root -l -b -q Examples/Scripts/MaterialMapping/Mat_map_surface_plot_ratio.C'("'${propFile}_current'.root","'${trackFile}'",-1,"Surfaces/current/ratio_plot","Surfaces/current/prop_plot","Surfaces/current/map_plot")'
0193 root -l -b -q Examples/Scripts/MaterialMapping/Mat_map_surface_plot_dist.C'("'${trackFile}'",-1,"Surfaces/dist_plot")'
0194 root -l -b -q Examples/Scripts/MaterialMapping/Mat_map_surface_plot_1D.C'("'${trackFile}'",-1,"Surfaces/1D_plot")'
0195 echo "::endgroup::"