Skip to content

Commit

Permalink
Convert PWGHF embedding_bechmark to pipeline system
Browse files Browse the repository at this point in the history
First step of code reduction and transition.
  • Loading branch information
sawenzel committed Mar 2, 2021
1 parent f2a65e1 commit 2e31c7c
Showing 1 changed file with 7 additions and 118 deletions.
125 changes: 7 additions & 118 deletions MC/run/PWGHF/embedding_benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,124 +22,13 @@ NBKGEVENTS=${NBKGEVENTS:-20}
MODULES="--skipModules ZDC"
SIMENGINE=${SIMENGINE:-TGeant4}

# We will collect output files of the workflow in a dedicated output dir
# (these are typically the files that should be left-over from a GRID job)
[ ! -d output ] && mkdir output
# create workflow
${O2DPG_ROOT}/MC/run/PWGHF/create_embedding_workflow.py -tf ${NTIMEFRAMES} -nb ${NBKGEVENTS} \
-ns ${NSIGEVENTS} -e ${SIMENGINE} \
-j ${NWORKERS} --embedding True

copypersistentsimfiles() {
simprefix=$1
outputdir=$2
cp ${simprefix}_Kine.root ${simprefix}_grp.root ${simprefix}*.ini ${outputdir}
}
# run workflow (linearized)
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -jmax 1

# background task -------
taskwrapper bkgsim.log o2-sim -e ${SIMENGINE} -j ${NWORKERS} -n ${NBKGEVENTS} -g pythia8hi ${MODULES} -o bkg \
--configFile ${O2DPG_ROOT}/MC/config/common/ini/basic.ini
echo "Return status of background sim: $?"
# register some background output --> make this declarative
copypersistentsimfiles bkg output

# loop over timeframes
for tf in `seq 1 ${NTIMEFRAMES}`; do

RNDSEED=0
PTHATMIN=0. # [default = 0]
PTHATMAX=-1. # [default = -1]

# produce the signal configuration
taskwrapper gensgnconf_${tf}.log ${O2DPG_ROOT}/MC/config/common/pythia8/utils/mkpy8cfg.py \
--output=pythia8.cfg \
--seed=${RNDSEED} \
--idA=2212 \
--idB=2212 \
--eCM=13000. \
--process=ccbar \
--ptHatMin=${PTHATMIN} \
--ptHatMax=${PTHATMAX}

# simulate the signals for this timeframe
taskwrapper sgnsim_${tf}.log o2-sim -e ${SIMENGINE} ${MODULES} -n ${NSIGEVENTS} -j ${NWORKERS} -g extgen \
--configFile ${O2DPG_ROOT}/MC/config/PWGHF/ini/GeneratorHF.ini \
--configKeyValues "GeneratorPythia8.config=pythia8.cfg" \
--embedIntoFile bkg_Kine.root \
-o sgn${tf}

# register some signal output --> make this declarative
# copypersistentsimfiles sgn${tf} output
# we need to copy the current geometry file for its-reco
cp sgn${tf}_geometry.root o2sim_geometry.root

CONTEXTFILE=collisioncontext_${tf}.root

# now run digitization phase
echo "Running digitization for $intRate kHz interaction rate"

gloOpt="-b --run --shm-segment-size ${SHMSIZE:-50000000000}" # TODO: decide shared mem based on event number - default should be ok for 100PbPb timeframes

taskwrapper tpcdigi_${tf}.log o2-sim-digitizer-workflow $gloOpt -n ${NSIGEVENTS} --sims bkg,sgn${tf} --onlyDet TPC --interactionRate 50000 --tpc-lanes ${NWORKERS} --outcontext ${CONTEXTFILE}
echo "Return status of TPC digitization: $?"

[ ! -f tpcdigits_${tf}.root ] && mv tpcdigits.root tpcdigits_${tf}.root
# --> a) random seeding
# --> b) propagation of collisioncontext and application in other digitization steps

taskwrapper trddigi_${tf}.log o2-sim-digitizer-workflow $gloOpt -n ${NSIGEVENTS} --sims bkg,sgn${tf} --onlyDet TRD --interactionRate 50000 --configKeyValues "TRDSimParams.digithreads=10" --incontext ${CONTEXTFILE}
echo "Return status of TRD digitization: $?"

taskwrapper restdigi_${tf}.log o2-sim-digitizer-workflow $gloOpt -n ${NSIGEVENTS} --sims bkg,sgn${tf} --skipDet TRD,TPC --interactionRate 50000 --incontext ${CONTEXTFILE}
echo "Return status of OTHER digitization: $?"

cp bkg_grp.root o2sim_grp.root
cp collisioncontext_${tf}.root collisioncontext.root
# -----------
# reco
# -----------

# TODO: check value for MaxTimeBin; A large value had to be set tmp in order to avoid crashes bases on "exceeding timeframe limit"
taskwrapper tpcreco_${tf}.log o2-tpc-reco-workflow $gloOpt --tpc-digit-reader \"--infile tpcdigits_${tf}.root\" --input-type digits --output-type clusters,tracks,send-clusters-per-sector --configKeyValues "\"GPU_global.continuousMaxTimeBin=100000;GPU_proc.ompThreads=${NWORKERS}\""
echo "Return status of tpcreco: $?"

echo "Running ITS reco flow"
taskwrapper itsreco_${tf}.log o2-its-reco-workflow --trackerCA --tracking-mode async $gloOpt
echo "Return status of itsreco: $?"

echo "Running FT0 reco flow"
#needs FT0 digitized data
taskwrapper ft0reco_${tf}.log o2-ft0-reco-workflow $gloOpt
echo "Return status of ft0reco: $?"

echo "Running ITS-TPC macthing flow"
#needs results of o2-tpc-reco-workflow, o2-its-reco-workflow and o2-fit-reco-workflow
taskwrapper itstpcMatch_${tf}.log o2-tpcits-match-workflow $gloOpt --tpc-track-reader \"tpctracks.root\" --tpc-native-cluster-reader \"--infile tpc-native-clusters.root\"
echo "Return status of itstpcMatch: $?"

echo "Running ITSTPC-TOF macthing flow"
#needs results of TOF digitized data and results of o2-tpcits-match-workflow
taskwrapper tofMatch_${tf}.log o2-tof-reco-workflow $gloOpt
echo "Return status of its-tpc-tof match: $?"

echo "Running TPC-TOF macthing flow"
#needs results of TOF clusters data from o2-tof-reco-workflow and results of o2-tpc-reco-workflow
taskwrapper tofMatchTPC.log o2-tof-matcher-tpc $gloOpt
echo "Return status of o2-tof-matcher-tpc: $?"

echo "Running primary vertex finding flow"
#needs results of TPC-ITS matching and FIT workflows
taskwrapper pvfinder_${tf}.log o2-primary-vertexing-workflow $gloOpt
echo "Return status of primary vertexing: $?"

# -----------
# produce AOD
# -----------

# enable later. It still has memory access problems
# taskwrapper aod_${tf}.log o2-aod-producer-workflow --aod-writer-keep dangling --aod-writer-resfile "AO2D" --aod-writer-resmode UPDATE --aod-timeframe-id ${tf} $gloOpt

cp ${CONTEXTFILE} output

# cleanup step for this timeframe (we cleanup disc space early so as to make possible checkpoint dumps smaller)
taskwrapper cleanup_${tf}.log "[ -f aod${tf}.log_done ] && rm sgn${tf}* && rm *digits*.root; exit 0"
done

# We need to exit for the ALIEN JOB HANDLER!
exit 0

0 comments on commit 2e31c7c

Please sign in to comment.