Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-22 00:47:33

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