#!/bin/bash #SBATCH --time=1-00:00:00 #SBATCH --mem-per-cpu=3072 #SBATCH --cpus-per-task=1 #SBATCH --partition=long #SBATCH --array=0 #SBATCH --job-name="tof_digi" #SBATCH --comment="CBM TOF" #SBATCH --workdir=/lustre/nyx/cbm/users/csimon/simulation/production #SBATCH --open-mode=truncate if [ ! -z "$SLURM_SUBMIT_DIR" ]; then wdir=`pwd` else wdir=/lustre/nyx/cbm/users/csimon/simulation/production origdir=`pwd` fi if [ ! -z "$SLURM_SUBMIT_DIR" ]; then source /lustre/nyx/cbm/users/csimon/cbmroot/development/csimon/bld/v1805_may18_new/config.sh fi if [ -z "$VMCWORKDIR" ]; then echo 'no ROOT environment available' exit 1 fi if [ -z "$cSetup" ]; then if [ -z "$1" ]; then echo 'no setup specified' exit 1 else cSetup=$1 fi fi if [ -z "$iNSerialSpills" ]; then if [ -z "$2" ]; then echo 'number of serial spills not specified' exit 1 else iNSerialSpills=$2 fi fi if [ -z "$dSpillLength" ]; then if [ -z "$3" ]; then echo 'no spill length specified' exit 1 else dSpillLength=$3 fi fi if [ -z "$dSpillBreakLength" ]; then if [ -z "$4" ]; then echo 'no spill break length specified' exit 1 else dSpillBreakLength=$4 fi fi if [ -z "$dParticleFlux" ]; then if [ -z "$5" ]; then echo 'no particle flux specified' exit 1 else dParticleFlux=$5 fi fi if [ -z "$iModuleType" ]; then if [ -z "$6" ]; then echo 'no module type specified' exit 1 else iModuleType=$6 fi fi if [ -z "$iModuleIndex" ]; then if [ -z "$7" ]; then echo 'no module index specified' exit 1 else iModuleIndex=$7 fi fi if [ -z "$iCounterIndex" ]; then if [ -z "$8" ]; then echo 'no counter index specified' exit 1 else iCounterIndex=$8 fi fi if [ -z "$dGlassDimX" ]; then if [ -z "$9" ]; then echo 'no glass X dimension specified' exit 1 else dGlassDimX=$9 fi fi if [ -z "$dGlassDimY" ]; then if [ -z "${10}" ]; then echo 'no glass Y dimension specified' exit 1 else dGlassDimY=${10} fi fi if [ -z "$bSpotResponse" ]; then if [ -z "${11}" ]; then echo 'no response type specified' exit 1 else bSpotResponse=${11} fi fi if [ -z "$bAverageSerialSpills" ]; then if [ -z "${12}" ]; then echo 'no averaging method specified' exit 1 else bAverageSerialSpills=${12} fi fi if [ -z "$dDistanceScale" ]; then if [ -z "${13}" ]; then echo 'no hit distance scale specified' exit 1 else dDistanceScale=${13} fi fi if [ -z "$dRelaxationTime" ]; then if [ -z "${14}" ]; then echo 'no relaxation time constant specified' exit 1 else dRelaxationTime=${14} fi fi if [ -z "$bSingleTimeSlice" ]; then if [ -z "${15}" ]; then echo 'no time slice type specified' exit 1 else bSingleTimeSlice=${15} fi fi if [ -z "$bSingleCounter" ]; then if [ -z "${16}" ]; then echo 'no single counter mode specified' exit 1 else bSingleCounter=${16} fi fi if [ -z "$bPlaneVertex" ]; then if [ -z "${17}" ]; then echo 'no vertex type specified' exit 1 else bPlaneVertex=${17} fi fi if [ -z "$bHitCompatibility" ]; then if [ -z "${18}" ]; then echo 'no hit compatibility specified' exit 1 else bHitCompatibility=${18} fi fi if [ -z "$bEquidistantEvents" ]; then if [ -z "${19}" ]; then echo 'no event interval type specified' exit 1 else bEquidistantEvents=${19} fi fi if [ -z "$bRunWithMemory" ]; then if [ -z "${20}" ]; then echo 'no memory flag specified' exit 1 else bRunWithMemory=${20} fi fi if [ -z "$bRunQA" ]; then if [ -z "${21}" ]; then echo 'no QA flag specified' exit 1 else bRunQA=${21} fi fi if [ -z "$cGeometry" ]; then if [ -z "${22}" ]; then echo 'no geometry tag specified' exit 1 else cGeometry=${22} fi fi if [ -z "$bAlternativeBranchNames" ]; then if [ -z "${23}" ]; then echo 'no branch name flag specified' exit 1 else bAlternativeBranchNames=${23} fi fi if [ -z "$bBuildCbmEvents" ]; then if [ -z "${24}" ]; then echo 'no CbmEvent flag specified' exit 1 else bBuildCbmEvents=${24} fi fi if [ -z "$bBuildHits" ]; then if [ -z "${25}" ]; then echo 'no hit building flag specified' exit 1 else bBuildHits=${25} fi fi if [ -z "$bRunReco" ]; then if [ -z "${26}" ]; then echo 'no run reco flag specified' exit 1 else bRunReco=${26} fi fi if [ -z "$bNoTransportPhysics" ]; then if [ -z "${27}" ]; then echo 'no transport physics flag specified' exit 1 else bNoTransportPhysics=${27} fi fi if [ -z "$bTwoSidedReadout" ]; then if [ -z "${28}" ]; then echo 'no two-sided readout specified' exit 1 else bTwoSidedReadout=${28} fi fi if [ -z "$bCalibrateDigis" ]; then if [ -z "${29}" ]; then echo 'no digi calibration specified' exit 1 else bCalibrateDigis=${29} fi fi if [ -z "$bStorePointsInTS" ]; then if [ -z "${30}" ]; then echo 'no point storage flag specified' exit 1 else bStorePointsInTS=${30} fi fi if [ -z "$dWorkingCoefficient" ]; then if [ -z "${31}" ]; then echo 'no working coefficient specified' exit 1 else dWorkingCoefficient=${31} fi fi dParticleRate=$dParticleFlux if [ "${bSpotResponse}" == "0" ]; then dParticleRate=`echo "$dParticleRate * $dGlassDimX * $dGlassDimY" | bc -l` # [Hz] fi dParticleDistance=`echo "10^9 / $dParticleRate" | bc -l` # [ns] iNumberParticles=`echo "($dParticleRate*$dSpillLength + 0.5)/1" | bc` iNumberParticles=`echo "$iNumberParticles * $iNSerialSpills" | bc` # make sure enough events are simulated to cross the final spill break iNumberParticles=`echo "1/2*(2*${iNumberParticles} +5*sqrt(4*${iNumberParticles}+25) +25) +0.5" | bc -l` iNumberParticles=`echo "${iNumberParticles}/1" | bc` # FIXME: uncomment for debugging purposes only!!! #iNumberParticles=100000 iNChildThreads=`echo "${SLURM_CPUS_PER_TASK}*2 - 1" | bc` iCounterAddress=`echo "1000000*${iModuleType} + 1000*${iModuleIndex} + ${iCounterIndex}" | bc` outdir=${wdir}/`printf "%03d" ${SLURM_ARRAY_TASK_ID}` mkdir ${outdir} mkdir ${outdir}/data if [ ! -d "${outdir}" ]; then echo 'output directory does not exist and cannot be created' exit 1 else cd ${outdir} cp -v ${VMCWORKDIR}/macro/tof/digitizer/.rootrc ${outdir}/.rootrc cp -v ${VMCWORKDIR}/macro/tof/digitizer/rootlogon.C ${outdir}/rootlogon.C # document the steering scripts/macros and the geometry file used in this simulation run if [ "${SLURM_ARRAY_TASK_ID}" == "1" ]; then cp -v ${VMCWORKDIR}/macro/tof/digitizer/production.sh ${wdir}/ cp -v ${VMCWORKDIR}/macro/tof/digitizer/run_flood.sh ${wdir}/ cp -v ${VMCWORKDIR}/macro/tof/digitizer/run_mc_flood.C ${wdir}/ cp -v ${VMCWORKDIR}/macro/tof/digitizer/run_digi_tb_flood.C ${wdir}/ cp -v ${VMCWORKDIR}/macro/tof/digitizer/run_reco_tb_digi_flood.C ${wdir}/ cp -v ${VMCWORKDIR}/macro/tof/setup/counters_${cSetup}.C ${wdir}/ cp -v ${VMCWORKDIR}/geometry/tof/tof_${cGeometry}.geo.root ${wdir}/ cp -v ${VMCWORKDIR}/parameters/tof/tof_${cGeometry}.digitb.par ${wdir}/ cp -v ${VMCWORKDIR}/parameters/tof/tof_${cGeometry}.digitb.root ${wdir}/ fi cp -v ${VMCWORKDIR}/parameters/tof/tof_${cGeometry}.digitb.par ${outdir}/ if [ "${bSingleCounter}" == "1" ]; then gawk -i inplace '$1 ~ /'${iCounterAddress}',$/ {$2 = "'${dDistanceScale}',"}1' ${outdir}/tof_${cGeometry}.digitb.par gawk -i inplace '$1 ~ /'${iCounterAddress}',$/ {$3 = "'${dRelaxationTime}',"}1' ${outdir}/tof_${cGeometry}.digitb.par gawk -i inplace '$1 ~ /'${iCounterAddress}',$/ {$4 = "'${dWorkingCoefficient}',"}1' ${outdir}/tof_${cGeometry}.digitb.par fi # Occasionally, an incorrect memory layout of the 32-bit Geant3 on a 64-bit machine # may occur and terminate the 'root' process when instantiating 'TGeant3TGeo' right # at the beginning. while : ; do root -b -q ''${VMCWORKDIR}'/macro/tof/digitizer/run_mc_flood.C('${iNumberParticles}',"'${cSetup}'",'${SLURM_ARRAY_TASK_ID}','${iModuleType}','${iModuleIndex}','${iCounterIndex}',\ '${bSpotResponse}','${bSingleCounter}','${bPlaneVertex}','${bNoTransportPhysics}')' sleep 30 if [ "`grep 'MC Real time' ${wdir}/slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out | wc -l`" == "0" ]; then rm -rfv ${outdir}/data/* else break fi done root -b -q ''${VMCWORKDIR}'/macro/tof/digitizer/run_digi_tb_flood.C('${iNumberParticles}',"'${cSetup}'",'${SLURM_ARRAY_TASK_ID}','${dParticleDistance}','${iNChildThreads}',\ '${dSpillLength}','${dSpillBreakLength}','${bAverageSerialSpills}','${iNSerialSpills}','${bSingleTimeSlice}',\ '${bRunWithMemory}','${bEquidistantEvents}','${bAlternativeBranchNames}','${bTwoSidedReadout}',\ '${bCalibrateDigis}','${bStorePointsInTS}','${bSingleCounter}')' if [ "${bRunReco}" == "1" ]; then rm -rf ${outdir}/data/${cSetup}_hist.reco.root root -b -q ''${VMCWORKDIR}'/macro/tof/digitizer/run_reco_tb_digi_flood.C('${iNumberParticles}',"'${cSetup}'",'${SLURM_ARRAY_TASK_ID}','${dSpillLength}','${dSpillBreakLength}',\ '${bAverageSerialSpills}','${iNSerialSpills}','${bSingleCounter}','${bRunQA}','${bHitCompatibility}',\ '${bAlternativeBranchNames}','${bBuildCbmEvents}','${bBuildHits}')' # TODO: If 'CbmTofRecoMCQa::fbFillLocalHistos' is set to true, starting the reconstruction run twice will result in even more extreme computation times root -b -q ''${VMCWORKDIR}'/macro/tof/digitizer/run_reco_tb_digi_flood.C('${iNumberParticles}',"'${cSetup}'",'${SLURM_ARRAY_TASK_ID}','${dSpillLength}','${dSpillBreakLength}',\ '${bAverageSerialSpills}','${iNSerialSpills}','${bSingleCounter}','${bRunQA}','${bHitCompatibility}',\ '${bAlternativeBranchNames}','${bBuildCbmEvents}','${bBuildHits}')' fi echo "" echo "Array job ran on ${SLURM_JOB_CPUS_PER_NODE} CPUs of node ${SLURM_JOB_NODELIST} in partition ${SLURM_JOB_PARTITION}." echo "" if [ ! -z "$SLURM_SUBMIT_DIR" ]; then mv -v ${wdir}/slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/ else cd ${origdir} fi fi