Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-21 23:14:24

0001 #! /bin/bash
0002 
0003 ###########
0004 ## Input ##
0005 ###########
0006 
0007 suite=${1:-"forConf"} # which set of benchmarks to run: full, forPR, forConf, val, valMT1
0008 style=${2:-"--mtv-like-val"} # option --mtv-like-val
0009 inputBin=${3:-"112X_TTbar_PU50_MULTI"}
0010 
0011 ###################
0012 ## Configuration ##
0013 ###################
0014 
0015 source xeon_scripts/common-variables.sh ${suite}
0016 source xeon_scripts/init-env.sh
0017 export MIMI="CE mimi"
0018 declare -a val_builds=(MIMI)
0019 nevents=250
0020 
0021 ## Common file setup
0022 case ${inputBin} in 
0023 "104XPU50CCC_MULTI")
0024         echo "Inputs from 2018 initialStep/default PU 50 with CCC with multiple iterations and hit binary mask"
0025         dir=/data2/slava77/analysis/CMSSW_10_4_0_patch1_mkFit/pass-df52fcc
0026         subdir=/initialStep/default/11024.0_TTbar_13/AVE_50_BX01_25ns/RAW4NT  
0027         file=/memoryFile.fv5.clean.writeAll.CCC1620.recT.allSeeds.masks.201023-64302e5.bin
0028         ;;
0029 "112X_TTbar_PU50_MULTI")
0030         echo "Inputs from 2021 TTbar (PU50) sample with multiple iterations and hit binary mask"
0031         dir=/data2/slava77/samples/
0032         subdir=2021/11834.0_TTbar_14TeV+2021/AVE_50_BX01_25ns/
0033         file=memoryFile.fv6.default.211008-c6b7c67.bin
0034         ;;
0035 "112X_10mu_MULTI")
0036         echo "Inputs from 2021 10mu sample with multiple iterations and hit binary mask"
0037         dir=/data2/slava77/samples
0038         subdir=2021/10muPt0p2to1000HS
0039         file=memoryFile.fv6.default.211008-c6b7c67.bin
0040         nevents=20000
0041         sample=10mu
0042         ;;
0043 *)
0044         echo "INPUT BIN IS UNKNOWN"
0045         exit 12
0046         ;;
0047 esac
0048 
0049 ## Common executable setup
0050 maxth=64
0051 maxvu=16
0052 maxev=32
0053 if [[  "${suite}" == "valMT1" ]]
0054 then
0055     maxth=1
0056     maxev=1
0057 fi
0058 seeds="--cmssw-n2seeds"
0059 exe="./mkFit/mkFit --silent ${seeds} --num-thr ${maxth} --num-thr-ev ${maxev} --input-file ${dir}/${subdir}/${file} --num-events ${nevents} --remove-dup --use-dead-modules"
0060 
0061 ## Common output setup
0062 tmpdir="tmp"
0063 base=${val_arch}_${sample}
0064 
0065 ## flag to save sim info for matched tracks since track states not read in
0066 siminfo="--try-to-save-sim-info"
0067 
0068 ## backward fit flag
0069 bkfit="--backward-fit"
0070 
0071 ## validation options: SIMVAL == sim tracks as reference, CMSSWVAL == cmssw tracks as reference
0072 SIMVAL="SIMVAL --sim-val ${siminfo} ${bkfit} ${style} --num-iters-cmssw 10"
0073 SIMVAL_SEED="SIMVALSEED --sim-val ${siminfo} ${bkfit} --mtv-require-seeds --num-iters-cmssw 10"
0074 
0075 declare -a vals=(SIMVAL SIMVAL_SEED)
0076 
0077 ## plotting options
0078 SIMPLOT="SIMVAL all 0 0 1"
0079 SIMPLOTSEED="SIMVALSEED all 0 0 1"
0080 SIMPLOT4="SIMVAL iter4 0 4 0"
0081 SIMPLOTSEED4="SIMVALSEED iter4 0 4 0" 
0082 SIMPLOT22="SIMVAL iter22 0 22 0"
0083 SIMPLOTSEED22="SIMVALSEED iter22 0 22 0"
0084 SIMPLOT23="SIMVAL iter23 0 23 0"
0085 SIMPLOTSEED23="SIMVALSEED iter23 0 23 0"
0086 SIMPLOT5="SIMVAL iter5 0 5 0"
0087 SIMPLOTSEED5="SIMVALSEED iter5 0 5 0"
0088 SIMPLOT24="SIMVAL iter24 0 24 0"
0089 SIMPLOTSEED24="SIMVALSEED iter24 0 24 0"
0090 SIMPLOT7="SIMVAL iter7 0 7 0"
0091 SIMPLOTSEED7="SIMVALSEED iter7 0 7 0"
0092 SIMPLOT8="SIMVAL iter8 0 8 0"
0093 SIMPLOTSEED8="SIMVALSEED iter8 0 8 0"
0094 SIMPLOT9="SIMVAL iter9 0 9 0"
0095 SIMPLOTSEED9="SIMVALSEED iter9 0 9 0"
0096 SIMPLOT10="SIMVAL iter10 0 10 0"
0097 SIMPLOTSEED10="SIMVALSEED iter10 0 10 0"
0098 SIMPLOT6="SIMVAL iter6 0 6 0"
0099 SIMPLOTSEED6="SIMVALSEED iter6 0 6 0"
0100 
0101 declare -a plots=(SIMPLOT4 SIMPLOTSEED4 SIMPLOT22 SIMPLOTSEED22 SIMPLOT23 SIMPLOTSEED23 SIMPLOT5 SIMPLOTSEED5 SIMPLOT24 SIMPLOTSEED24 SIMPLOT7 SIMPLOTSEED7 SIMPLOT8 SIMPLOTSEED8 SIMPLOT9 SIMPLOTSEED9 SIMPLOT10 SIMPLOTSEED10 SIMPLOT6 SIMPLOTSEED6)
0102 
0103 ## special cmssw dummy build
0104 CMSSW="CMSSW cmssw SIMVAL --sim-val-for-cmssw ${siminfo} --read-cmssw-tracks ${style} --num-iters-cmssw 10"
0105 CMSSW2="CMSSW cmssw SIMVALSEED --sim-val-for-cmssw ${siminfo} --read-cmssw-tracks --mtv-require-seeds --num-iters-cmssw 10"
0106 
0107 ###############
0108 ## Functions ##
0109 ###############
0110 
0111 ## validation function
0112 function doVal()
0113 {
0114     local bN=${1}
0115     local bO=${2}
0116     local vN=${3}
0117     local vO=${4}
0118 
0119     local oBase=${val_arch}_${sample}_${bN}
0120     local bExe="${exe} ${vO} --build-${bO}"
0121     
0122     echo "${oBase}: ${vN} [nTH:${maxth}, nVU:${maxvu}int, nEV:${maxev}]"
0123     ${bExe} >& log_${oBase}_NVU${maxvu}int_NTH${maxth}_NEV${maxev}_${vN}.txt || (echo "Crashed on CMD: "${bExe}; exit 2)
0124     
0125     if (( ${maxev} > 1 ))
0126     then
0127         # hadd output files from different threads for this test, then move to temporary directory
0128         hadd -O valtree.root valtree_*.root
0129         rm valtree_*.root
0130     fi
0131     mv valtree.root ${tmpdir}/valtree_${oBase}_${vN}.root
0132 }               
0133 
0134 ## plotting function
0135 function plotVal()
0136 {
0137     local base=${1}
0138     local bN=${2}
0139     local pN=${3}
0140     local pO=${4}
0141     local iter=${5}
0142     local cancel=${6}     
0143     local rmsuff=${7}
0144 
0145     echo "Computing observables for: ${base} ${bN} ${pN} ${p0} ${iter} ${cancel}"
0146     bExe="root -b -q -l plotting/runValidation.C(\"_${base}_${bN}_${pN}\",${pO},${iter},${cancel},${rmsuff})"
0147     echo ${bExe}
0148 
0149     ${bExe} || (echo "Crashed on CMD: "${bExe}; exit 3)
0150 }
0151 
0152 ########################
0153 ## Run the validation ##
0154 ########################
0155 
0156 ## Compile once
0157 make clean
0158 mVal="-j 32 WITH_ROOT:=1 AVX_512:=1"
0159 make ${mVal}
0160 mkdir -p ${tmpdir}
0161 
0162 ## Special simtrack validation vs cmssw tracks
0163 echo ${CMSSW} | while read -r bN bO vN vO
0164 do
0165     doVal "${bN}" "${bO}" "${vN}" "${vO}"
0166 done
0167 ## Special simtrack validation vs cmssw tracks
0168 echo ${CMSSW2} | while read -r bN bO vN vO
0169 do
0170     doVal "${bN}" "${bO}" "${vN}" "${vO}"
0171 done
0172 
0173 ## Run validation for standard build options
0174 for val in "${vals[@]}"
0175 do echo ${!val} | while read -r vN vO
0176     do
0177         for build in "${val_builds[@]}"
0178         do echo ${!build} | while read -r bN bO
0179             do
0180                 doVal "${bN}" "${bO}" "${vN}" "${vO}"
0181             done
0182         done
0183     done
0184 done
0185 
0186 ## clean up
0187 make clean ${mVal}
0188 mv tmp/valtree_*.root .
0189 rm -rf ${tmpdir}
0190 
0191 
0192 
0193 ## Compute observables and make images
0194 for plot in "${plots[@]}"
0195 do echo ${!plot} | while read -r pN suff pO iter cancel
0196     do
0197         rmsuff=0 # use iterX suffix for output directory
0198         ## Compute observables for special dummy CMSSW
0199         if [[ "${pN}" == "SIMVAL" || "${pN}" == "SIMVAL_"* ]]
0200         then
0201             echo ${CMSSW} | while read -r bN bO val_extras
0202             do
0203                 plotVal "${base}" "${bN}" "${pN}" "${pO}" "${iter}" "${cancel}" "${rmsuff}"
0204             done
0205         fi
0206         if [[ "${pN}" == "SIMVALSEED"* ]]
0207         then
0208             echo ${CMSSW2} | while read -r bN bO val_extras
0209             do
0210                 plotVal "${base}" "${bN}" "${pN}" "${pO}" "${iter}" "${cancel}" "${rmsuff}"
0211             done
0212         fi
0213 
0214         ## Compute observables for builds chosen 
0215         for build in "${val_builds[@]}"
0216         do echo ${!build} | while read -r bN bO
0217             do
0218                 plotVal "${base}" "${bN}" "${pN}" "${pO}" "${iter}" "${cancel}" "${rmsuff}"
0219             done
0220         done
0221         
0222         ## overlay histograms
0223         echo "Overlaying histograms for: ${base} ${vN}"
0224         if [[  "${suff}" == "all" ]]
0225         then
0226             root -b -q -l plotting/makeValidation.C\(\"${base}\",\"_${pN}\",${pO},\"${suite}\"\)
0227         else
0228             root -b -q -l plotting/makeValidation.C\(\"${base}\",\"_${pN}_${suff}\",${pO},\"${suite}\"\)
0229         fi
0230     done
0231 done
0232 
0233 ## Final cleanup
0234 make distclean ${mVal}
0235 
0236 ## Final message
0237 echo "Finished physics validation!"