Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-25 02:14:14

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 "Mu_phase2")
0057         dir=/ceph/cms/store/user/legianni/generate-phase2/10mu
0058         subdir=
0059         file=ntuple_pt0p1to1_eta0p0to0p4.bin
0060         nevents=100
0061         extraargs="--geom CMS-phase2"
0062         numiters=1
0063         # Pass MIMI flag to ROOT plotting functions -- some will insert STD
0064         # that does not work with MIMI at this point.
0065         export MKFIT_MIMI=1
0066         ;;
0067 # "Mu_phase2_XYZ" samples - see https://gist.github.com/osschar/7cd037f6fcdd05ccf11586fdaadab377
0068 *)
0069         echo "INPUT BIN IS UNKNOWN"
0070         exit 12
0071         ;;
0072 esac
0073 
0074 ## Common executable setup
0075 if [[ `lsb_release -si` == "Fedora" ]]
0076 then
0077     maxth=16 # 64
0078     maxvu=8  # 16
0079     maxev=16 # 32
0080     avxmakearg="AVX2:=1"
0081 else
0082     maxth=64
0083     maxvu=16
0084     maxev=32
0085     avxmakearg="AVX_512:=1"
0086 fi
0087 
0088 if [[  "${suite}" == "valMT1" ]]
0089 then
0090     maxth=1
0091     maxev=1
0092 fi
0093 
0094 silent="--silent"
0095 seeds="--cmssw-n2seeds"
0096 input_data="--input-file ${dir}/${subdir}/${file} --num-events ${nevents}"
0097 threads="--num-thr ${maxth} --num-thr-ev ${maxev}"
0098 
0099 exe="./mkFit ${silent} ${seeds} ${input_data} ${threads} --remove-dup ${extraargs}"
0100 
0101 ## Common output setup
0102 tmpdir="tmp"
0103 base=${val_arch}_${sample}
0104 
0105 ## flag to save sim info for matched tracks since track states not read in
0106 siminfo="--try-to-save-sim-info"
0107 
0108 ## backward fit flag
0109 bkfit="--backward-fit"
0110 
0111 ## validation options: SIMVAL == sim tracks as reference, CMSSWVAL == cmssw tracks as reference
0112 SIMVAL="SIMVAL --sim-val ${siminfo} ${bkfit} ${style} --num-iters-cmssw ${numiters}"
0113 SIMVAL_SEED="SIMVALSEED --sim-val ${siminfo} ${bkfit} --mtv-require-seeds --num-iters-cmssw ${numiters}"
0114 
0115 declare -a vals=(SIMVAL SIMVAL_SEED)
0116 
0117 ## plotting options
0118 SIMPLOT="SIMVAL all 0 0 1"
0119 SIMPLOTSEED="SIMVALSEED all 0 0 1"
0120 SIMPLOT4="SIMVAL iter4 0 4 0"
0121 SIMPLOTSEED4="SIMVALSEED iter4 0 4 0" 
0122 SIMPLOT22="SIMVAL iter22 0 22 0"
0123 SIMPLOTSEED22="SIMVALSEED iter22 0 22 0"
0124 SIMPLOT23="SIMVAL iter23 0 23 0"
0125 SIMPLOTSEED23="SIMVALSEED iter23 0 23 0"
0126 SIMPLOT5="SIMVAL iter5 0 5 0"
0127 SIMPLOTSEED5="SIMVALSEED iter5 0 5 0"
0128 SIMPLOT24="SIMVAL iter24 0 24 0"
0129 SIMPLOTSEED24="SIMVALSEED iter24 0 24 0"
0130 SIMPLOT7="SIMVAL iter7 0 7 0"
0131 SIMPLOTSEED7="SIMVALSEED iter7 0 7 0"
0132 SIMPLOT8="SIMVAL iter8 0 8 0"
0133 SIMPLOTSEED8="SIMVALSEED iter8 0 8 0"
0134 SIMPLOT9="SIMVAL iter9 0 9 0"
0135 SIMPLOTSEED9="SIMVALSEED iter9 0 9 0"
0136 SIMPLOT10="SIMVAL iter10 0 10 0"
0137 SIMPLOTSEED10="SIMVALSEED iter10 0 10 0"
0138 SIMPLOT6="SIMVAL iter6 0 6 0"
0139 SIMPLOTSEED6="SIMVALSEED iter6 0 6 0"
0140 
0141 if [[ ${numiters} -eq 1 ]]
0142 then
0143     declare -a plots=(SIMPLOT4 SIMPLOTSEED4)
0144 else
0145     declare -a plots=(SIMPLOT4 SIMPLOTSEED4 SIMPLOT22 SIMPLOTSEED22 SIMPLOT23 SIMPLOTSEED23 SIMPLOT5 SIMPLOTSEED5 SIMPLOT24 SIMPLOTSEED24 SIMPLOT7 SIMPLOTSEED7 SIMPLOT8 SIMPLOTSEED8 SIMPLOT9 SIMPLOTSEED9 SIMPLOT10 SIMPLOTSEED10 SIMPLOT6 SIMPLOTSEED6)
0146 fi
0147 
0148 ## special cmssw dummy build
0149 CMSSW="CMSSW cmssw SIMVAL --sim-val-for-cmssw ${siminfo} --read-cmssw-tracks ${style} --num-iters-cmssw ${numiters}"
0150 CMSSW2="CMSSW cmssw SIMVALSEED --sim-val-for-cmssw ${siminfo} --read-cmssw-tracks --mtv-require-seeds --num-iters-cmssw ${numiters}"
0151 
0152 ###############
0153 ## Functions ##
0154 ###############
0155 
0156 ## validation function
0157 function doVal()
0158 {
0159     local bN=${1}
0160     local bO=${2}
0161     local vN=${3}
0162     local vO=${4}
0163 
0164     local oBase=${val_arch}_${sample}_${bN}
0165     local bExe="${exe} ${vO} --build-${bO}"
0166 
0167     echo "${oBase}: ${vN} [nTH:${maxth}, nVU:${maxvu}int, nEV:${maxev}]"
0168     logfile=log_${oBase}_NVU${maxvu}int_NTH${maxth}_NEV${maxev}_${vN}.txt
0169     echo logfile ${logfile}
0170     ${bExe} > ${logfile} || (echo "Crashed on CMD: "${bExe}; exit 2)
0171 
0172     if (( ${maxev} > 1 ))
0173     then
0174         # hadd output files from different threads for this test, then move to temporary directory
0175         hadd -O valtree.root valtree_*.root
0176         rm valtree_*.root
0177     fi
0178     mv valtree.root ${tmpdir}/valtree_${oBase}_${vN}.root
0179 }               
0180 
0181 ## plotting function
0182 function plotVal()
0183 {
0184     local base=${1}
0185     local bN=${2}
0186     local pN=${3}
0187     local pO=${4}
0188     local iter=${5}
0189     local cancel=${6}     
0190     local rmsuff=${7}
0191 
0192     echo "Computing observables for: ${base} ${bN} ${pN} ${p0} ${iter} ${cancel}"
0193     bExe="root -b -q -l plotting/runValidation.C(\"_${base}_${bN}_${pN}\",${pO},${iter},${cancel},${rmsuff})"
0194     echo ${bExe}
0195 
0196     ${bExe} || (echo "Crashed on CMD: "${bExe}; exit 3)
0197 }
0198 
0199 ########################
0200 ## Run the validation ##
0201 ########################
0202 
0203 ## Compile once
0204 make distclean
0205 mVal="-j 32 WITH_ROOT:=1 ${avxmakearg}"
0206 make ${mVal}
0207 mkdir -p ${tmpdir}
0208 
0209 ## Special simtrack validation vs cmssw tracks
0210 echo ${CMSSW} | while read -r bN bO vN vO
0211 do
0212     doVal "${bN}" "${bO}" "${vN}" "${vO}"
0213 done
0214 ## Special simtrack validation vs cmssw tracks
0215 echo ${CMSSW2} | while read -r bN bO vN vO
0216 do
0217     doVal "${bN}" "${bO}" "${vN}" "${vO}"
0218 done
0219 
0220 ## Run validation for standard build options
0221 for val in "${vals[@]}"
0222 do echo ${!val} | while read -r vN vO
0223     do
0224         for build in "${val_builds[@]}"
0225         do echo ${!build} | while read -r bN bO
0226             do
0227                 doVal "${bN}" "${bO}" "${vN}" "${vO}"
0228             done
0229         done
0230     done
0231 done
0232 
0233 ## clean up
0234 mv tmp/valtree_*.root .
0235 rm -rf ${tmpdir}
0236 
0237 
0238 ## Compute observables and make images
0239 for plot in "${plots[@]}"
0240 do echo ${!plot} | while read -r pN suff pO iter cancel
0241     do
0242         rmsuff=0 # use iterX suffix for output directory
0243         ## Compute observables for special dummy CMSSW
0244         if [[ "${pN}" == "SIMVAL" || "${pN}" == "SIMVAL_"* ]]
0245         then
0246         echo In SIMVAL plot loop
0247         echo CMSSW=${CMSSW}
0248             echo ${CMSSW} | while read -r bN bO val_extras
0249             do
0250                 plotVal "${base}" "${bN}" "${pN}" "${pO}" "${iter}" "${cancel}" "${rmsuff}"
0251             done
0252         fi
0253         if [[ "${pN}" == "SIMVALSEED"* ]]
0254         then
0255         echo In SIMVALSEED plot loop
0256         echo CMSSW2=${CMSSW2}
0257             echo ${CMSSW2} | while read -r bN bO val_extras
0258             do
0259                 plotVal "${base}" "${bN}" "${pN}" "${pO}" "${iter}" "${cancel}" "${rmsuff}"
0260             done
0261         fi
0262 
0263         ## Compute observables for builds chosen 
0264         for build in "${val_builds[@]}"
0265         do echo ${!build} | while read -r bN bO
0266             do
0267                 plotVal "${base}" "${bN}" "${pN}" "${pO}" "${iter}" "${cancel}" "${rmsuff}"
0268             done
0269         done
0270         
0271         ## overlay histograms
0272         echo "Overlaying histograms for: ${base} ${vN}"
0273         if [[  "${suff}" == "all" ]]
0274         then
0275             root -b -q -l plotting/makeValidation.C\(\"${base}\",\"_${pN}\",${pO},\"${suite}\"\)
0276         else
0277             root -b -q -l plotting/makeValidation.C\(\"${base}\",\"_${pN}_${suff}\",${pO},\"${suite}\"\)
0278         fi
0279     done
0280 done
0281 
0282 ## Final message
0283 echo "Finished physics validation!"