Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:19

0001 #!/bin/bash
0002 
0003 # This file is part of the ACTS project.
0004 #
0005 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0006 #
0007 # This Source Code Form is subject to the terms of the Mozilla Public
0008 # License, v. 2.0. If a copy of the MPL was not distributed with this
0009 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0010 
0011 # Absolute path of detray git root directory
0012 root_dir="$(git rev-parse --show-toplevel)"
0013 
0014 # Number of threads
0015 n_threads=1
0016 
0017 # Number of tracks per thread
0018 n_tracks_per_thread=1000
0019 
0020 # Min and Max log10 rk tolerance to iterate
0021 log10_min_rk_tol=-6
0022 log10_max_rk_tol=2
0023 
0024 # log10 rk tolerance for displaced track
0025 log10_rk_tol_dis=-6
0026 
0027 # log10 rk tolerance for jacobian comparison
0028 log10_rk_tol_jac=${log10_min_rk_tol}
0029 
0030 # log10 rk tolerance for covariance transport
0031 log10_rk_tol_cov=-4
0032 
0033 # Helix intersector tolerance [log10 in mm]
0034 log10_helix_tol=-3
0035 # Surface tolerance [log10 in mm]
0036 log10_on_surface_tol=-3
0037 
0038 # Monte-Carlo seed
0039 mc_seed=0
0040 
0041 # Skip the first phase
0042 skip_first_phase=false
0043 
0044 # Skip the second phase
0045 skip_second_phase=false
0046 
0047 # Verbose level
0048 verbose_level=1
0049 
0050 while getopts "hd:n:t:m:c:p:q:i:s:f:r:v:" arg; do
0051     case $arg in
0052         h)
0053             echo ""
0054             echo "Mandatory arguments"
0055             echo "-d <Directory of detray_integration_test_jacobian_validation>"
0056             echo ""
0057             echo "Optional arguments"
0058             echo "-n <Number of threads>"
0059             echo "-t <Number of tracks per thread>"
0060             echo "-m <log10(rk_error_tolerance_in_mm_for_displaced_tracks)>"
0061             echo "-c <log10(rk_error_tolerance_in_mm_for_covariance_transport)>"
0062             echo "-p <log10(min_rk_error_tolerance_in_mm)>"
0063             echo "-q <log10(max_rk_error_tolerance_in_mm)>"
0064             echo "-i <log10(intersection_tolerance_in_mm)>"
0065             echo "-s <Monte-Carlo seed>"
0066             echo "-f <Skip the first phase>"
0067             echo "-r <Skip the second phase>"
0068             echo "-v <Verbose level>"
0069             echo ""
0070             exit 0
0071         ;;
0072         d)
0073             dir=$OPTARG
0074         ;;
0075         n)
0076             n_threads=$OPTARG
0077         ;;
0078         t)
0079             n_tracks_per_thread=$OPTARG
0080         ;;
0081         m)
0082             log10_rk_tol_dis=$OPTARG
0083             echo "log10(rk_error_tolerance_in_mm_for_displaced_tracks): ${log10_rk_tol_dis}"
0084         ;;
0085         c)
0086             log10_rk_tol_cov=$OPTARG
0087         ;;
0088         p)
0089             log10_min_rk_tol=$OPTARG
0090             log10_rk_tol_jac=${log10_min_rk_tol}
0091         ;;
0092         q)
0093             log10_max_rk_tol=$OPTARG
0094         ;;
0095         i)
0096             log10_helix_tol=$OPTARG
0097             log10_on_surface_tol=$OPTARG
0098         ;;
0099         s)
0100             mc_seed=$OPTARG
0101         ;;
0102         f)
0103             skip_first_phase=$OPTARG
0104         ;;
0105         r)
0106             skip_second_phase=$OPTARG
0107         ;;
0108         v)
0109             verbose_level=$OPTARG
0110         ;;
0111         *)
0112             echo "Unknown option"
0113         ;;
0114     esac
0115 done
0116 
0117 echo "Directory of detray_integration_test_jacobian_validation: ${dir}"
0118 echo "Number of threads: ${n_threads}"
0119 echo "Number of tracks per thread: ${n_tracks_per_thread}"
0120 echo "log10(rk_error_tolerance_in_mm_for_covariance_transport): ${log10_rk_tol_cov}"
0121 echo "log10(min_rk_error_tolerance_in_mm): ${log10_min_rk_tol}"
0122 echo "log10(max_rk_error_tolerance_in_mm): ${log10_max_rk_tol}"
0123 echo "log10(intersection_tolerance_in_mm): ${log10_helix_tol}"
0124 echo "Monte-Carlo seed: ${mc_seed}"
0125 echo "Skip the first phase: ${skip_first_phase}"
0126 echo "Skip the second phase: ${skip_second_phase}"
0127 echo "Set the verbose level: ${verbose_level}"
0128 
0129 echo ""
0130 
0131 if [[ -z "${dir}" ]]; then
0132     echo "Option -d is missing"
0133     exit 1
0134 fi
0135 
0136 ##########################
0137 # RK tolerance iteration #
0138 ##########################
0139 
0140 if [[ "$skip_first_phase" = false ]] ; then
0141 
0142     echo "Starting rk toleracne iteration..."
0143 
0144     # Remove the old directories
0145     for (( i=0; i < ${n_threads}; ++i ))
0146     do
0147         rm -rf ${PWD}/thread_${i}
0148     done
0149     rm -rf ${PWD}/merged
0150 
0151     for (( i=0; i < ${n_threads}; ++i ))
0152     do
0153         n_skips=`expr ${i} \* ${n_tracks_per_thread}`
0154 
0155         command_rk_tolerance="${dir}/detray_integration_test_jacobian_validation \
0156         --output-directory=thread_${i} \
0157         --rk-tolerance-iterate-mode=true \
0158         --n-tracks=${n_tracks_per_thread} \
0159         --n-skips=${n_skips} \
0160         --log10-rk-tolerance-dis-mm=${log10_rk_tol_dis} \
0161         --log10-min-rk-tolerance-mm=${log10_min_rk_tol} \
0162         --log10-max-rk-tolerance-mm=${log10_max_rk_tol} \
0163         --log10-helix-tolerance-mm=${log10_helix_tol} \
0164         --log10-on-surface-tolerance-mm=${log10_on_surface_tol} \
0165         --mc-seed=${mc_seed} \
0166         --verbose-level=${verbose_level}"
0167         ${command_rk_tolerance} &
0168     done
0169     wait
0170 
0171     echo "Finished rk toleracne iteration"
0172 
0173 fi
0174 
0175 #####################################
0176 # Jacobi validation & Cov transport #
0177 #####################################
0178 
0179 if [[ "$skip_second_phase" = false ]] ; then
0180 
0181     echo "Starting Jacobi validation & Cov transport..."
0182 
0183     for (( i=0; i < ${n_threads}; ++i ))
0184     do
0185         n_skips=`expr ${i} \* ${n_tracks_per_thread}`
0186 
0187         command_jacobi_validation="${dir}/detray_integration_test_jacobian_validation \
0188         --output-directory=thread_${i} \
0189         --rk-tolerance-iterate-mode=false \
0190         --n-tracks=${n_tracks_per_thread} \
0191         --n-skips=${n_skips} \
0192         --log10-rk-tolerance-dis-mm=${log10_rk_tol_dis} \
0193         --log10-rk-tolerance-jac-mm=${log10_rk_tol_jac} \
0194         --log10-rk-tolerance-cov-mm=${log10_rk_tol_cov} \
0195         --log10-helix-tolerance-mm=${log10_helix_tol} \
0196         --log10-on-surface-tolerance-mm=${log10_on_surface_tol} \
0197         --mc-seed=${mc_seed} \
0198         --verbose-level=${verbose_level}"
0199         ${command_jacobi_validation} &
0200     done
0201     wait
0202 
0203     echo "Finished Jacobi validation & Cov transport"
0204 fi
0205 
0206 ###################
0207 # Merge Csv files #
0208 ###################
0209 
0210 echo "Starting merging Csv files..."
0211 
0212 file_names=()
0213 
0214 # Get the unique file names
0215 echo ""
0216 echo "/// Merged Csv file list ///"
0217 for full_name in ./thread_0/*; do
0218     # Only take csv format files
0219     if [[ "$full_name" == *".csv" ]];then
0220         name=$(basename -- "$full_name")
0221         file_names+=(${name})
0222         echo $name
0223     fi
0224 done
0225 echo ""
0226 
0227 output_dir=merged
0228 mkdir -p ${output_dir}
0229 # Merge the files
0230 for name in "${file_names[@]}"
0231 do
0232     arr=()
0233     for (( i=0; i < ${n_threads}; ++i ))
0234     do
0235         arr+=(thread_${i}/${name})
0236     done
0237     awk 'FNR==1 && NR!=1{next;}{print}' ${arr[@]} > ./${output_dir}/${name}
0238 done
0239 
0240 echo "Finished merging Csv files"
0241 
0242 ####################
0243 # Run ROOT Scripts #
0244 ####################
0245 
0246 cd ${output_dir}
0247 
0248 if [[ "$skip_first_phase" = false ]] && [[ "$skip_second_phase" = false ]]; then
0249 
0250     # Run rk_tolerance_comparision.C
0251     root -q "$root_dir"'/tests/tools/root/rk_tolerance_comparison.C+O('${log10_min_rk_tol}','${log10_max_rk_tol}')'
0252 
0253     # Run jacobian_histogram.C
0254     root -q -l "$root_dir"'/tests/tools/root/jacobian_histogram.C+O('${log10_min_rk_tol}')'
0255 
0256     # Run jacobian_comparison.C
0257     root -q -l "$root_dir"/tests/tools/root/jacobian_comparison.C+O
0258 
0259     # Run covariance_validation.C
0260     root -q -l "$root_dir"/tests/tools/root/covariance_validation.C+O
0261 
0262     elif [[ "$skip_first_phase" = true ]] && [[ "$skip_second_phase" = false
0263     ]]; then
0264 
0265     # Run covariance_validation.C
0266     root "$root_dir"/tests/tools/root/covariance_validation.C+O
0267 
0268     elif [[ "$skip_first_phase" = false ]] && [[ "$skip_second_phase" = true ]]; then
0269 
0270     # Run rk_tolerance_comparision.C
0271     root "$root_dir"'/tests/tools/root/rk_tolerance_comparison.C+O('${log10_min_rk_tol}','${log10_max_rk_tol}')'
0272 
0273     # Run jacobian_histogram.C
0274     root "$root_dir"'/tests/tools/root/jacobian_histogram.C+O('${log10_min_rk_tol}')'
0275 
0276 fi