Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:18:28

0001 #!/bin/bash
0002 set -Eu # no pipefail to allow head to cut pipe
0003 trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
0004 IFS=$'\n\t'
0005 
0006 out=${1?Specify output}
0007 file=${2?Specify filename}
0008 ext=${3?Specify extension}
0009 nevents=${4?Specify nevents}
0010 n_lines_per_event=${5?Specify n_lines_per_event}
0011 n_events_test=${NEVENTS_PER_TEST:-100}
0012 
0013 n=$n_events_test
0014 if [[ $ext != "hepmc3.tree.root" && $ext != "steer" ]]; then
0015   echo "Error: Input extension is not recognized. Only 'hepmc3.tree.root' or 'steer' format is accepted. Please see the input pre-processing policy https://eic.github.io/epic-prod/documentation/input_preprocessing.html"
0016   exit -1
0017 fi
0018 
0019 if [ -n "${dt0:-}" -a -n "${dt1:-}" ] ; then
0020   # reuse if already determined
0021   echo "$file,$ext,$nevents,$dt0,$dt1" | tee -a "${out}"
0022   exit
0023 fi
0024 
0025 # number of hepmc lines to read (includes buffer)
0026 nlines=$((2*n_events_test*n_lines_per_event))
0027 
0028 # ensure CI is added to local file
0029 dir=$(dirname EVGEN/${file}.${ext})
0030 mkdir -p ${dir}
0031 
0032 logfile=results/logs/${file}.out
0033 mkdir -p $(dirname ${logfile})
0034 
0035 # time for 1 event (first)
0036 t1=$(date +%s.%N)
0037 /opt/campaigns/hepmc3/scripts/run.sh EVGEN/${file} ${ext} 1 2>&1 | tee ${logfile}.1
0038 t2=$(date +%s.%N)
0039 dt01=$(echo "scale=5; ($t2-$t1)" | bc -l)
0040 duf01=$(du -sc $TMPDIR/*/FULL | tail -n 1 | awk '{print($1)}')
0041 dur01=$(du -sc $TMPDIR/*/RECO | tail -n 1 | awk '{print($1)}')
0042 
0043 # time for n events (last, so will overwrite 1 event)
0044 t1=$(date +%s.%N)
0045 /opt/campaigns/hepmc3/scripts/run.sh EVGEN/${file} ${ext} ${n} 2>&1 | tee ${logfile}.n
0046 t2=$(date +%s.%N)
0047 dt0n=$(echo "scale=5; ($t2-$t1)" | bc -l)
0048 duf0n=$(du -sc $TMPDIR/*/FULL | tail -n 1 | awk '{print($1)}')
0049 dur0n=$(du -sc $TMPDIR/*/RECO | tail -n 1 | awk '{print($1)}')
0050 
0051 # initialization correction (require at least a minimum positive difference)
0052 dt1=$(echo "scale=5; if($dt0n-$dt01>0.1*$dt01) print(($dt0n-$dt01)/($n-1)) else print(0.1*$dt01/$n)" | bc -l)
0053 dt0=$(echo "scale=5; if($dt01>$dt1) print(($dt01-$dt1)) else print(100)" | bc -l)
0054 
0055 # initialization correction (require at least a minimum positive difference)
0056 # full data usage
0057 duf1=$(echo "scale=5; if($duf0n-$duf01>0.1*$duf01) print(($duf0n-$duf01)/($n-1)) else print(0.1*$duf01/$n)" | bc -l)
0058 duf0=$(echo "scale=5; if($duf01>$duf1) print(($duf01-$duf1)) else print(100)" | bc -l)
0059 # reco data usage
0060 dur1=$(echo "scale=5; if($dur0n-$dur01>0.1*$dur01) print(($dur0n-$dur01)/($n-1)) else print(0.1*$dur01/$n)" | bc -l)
0061 dur0=$(echo "scale=5; if($dur01>$dur1) print(($dur01-$dur1)) else print(100)" | bc -l)
0062 
0063 # output
0064 echo "$file,$ext,$nevents,$dt0,$dt1,$duf0,$duf1,$dur0,$dur1" | tee -a "${out}"