Skip to content

Commit

Permalink
(Optional) decoupling of event gen from transport
Browse files Browse the repository at this point in the history
Development allowing event generation to run in a separate task
from detector simulation. In this mode, event generation will write
kinematics to disc, which is later picked up by o2-sim.

Development done in order to increase CPU efficiency in cases
where event generation was slow and not being able to serve the workers
of o2-sim with enought work. The development fixes such cases, because
multiple event generators (for different timeframes) can now run in parallel.

The new mode is the default, but we can return to the intregrated mode
by using option `--event-gen-mode integrated`.
  • Loading branch information
sawenzel committed Mar 22, 2024
1 parent 8de3655 commit 2ff54f6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
37 changes: 28 additions & 9 deletions MC/bin/o2dpg_sim_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
parser.add_argument('--sor', default=-1, type=int, help=argparse.SUPPRESS) # may pass start of run with this (otherwise it is autodetermined from run number)
parser.add_argument('--run-anchored', action='store_true', help=argparse.SUPPRESS)
parser.add_argument('--alternative-reco-software', default="", help=argparse.SUPPRESS) # power feature to set CVFMS alienv software version for reco steps (different from default)
parser.add_argument('--dpl-child-driver', default="", help="Child driver to use in DPL processes (export mode)")
parser.add_argument('--dpl-child-driver', default="", help="Child driver to use in DPL processes (expert mode)")
parser.add_argument('--event-gen-mode', choices=['separated', 'integrated'], default='separated', help="Whether event generation is done before (separated) or within detector simulation (integrated).")

# QC related arguments
parser.add_argument('--include-qc', '--include-full-qc', action='store_true', help='includes QC in the workflow, both per-tf processing and finalization')
Expand Down Expand Up @@ -685,7 +686,6 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
if (args.pregenCollContext == True):
signalneeds.append(PreCollContextTask['name'])


# add embedIntoFile only if embeddPattern does contain a '@'
embeddinto= "--embedIntoFile ../bkg_MCHeader.root" if (doembedding & ("@" in args.embeddPattern)) else ""
#embeddinto= "--embedIntoFile ../bkg_MCHeader.root" if doembedding else ""
Expand All @@ -694,18 +694,37 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
signalneeds = signalneeds + [ BKGtask['name'] ]
else:
signalneeds = signalneeds + [ BKG_HEADER_task['name'] ]

# (separate) event generation task
sep_event_mode = args.event_gen_mode == 'separated'
SGNGENtask=createTask(name='sgngen_'+str(tf), needs=signalneeds, tf=tf, cwd='tf'+str(tf), lab=["GEN"],
cpu=1, mem=1000)
SGNGENtask['cmd']='${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode kCCDB' \
+ ' --run ' + str(args.run) + ' ' + str(CONFKEY) + str(TRIGGER) \
+ ' -g ' + str(GENERATOR) + ' ' + str(INIFILE) + ' -o genevents ' + embeddinto \
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] \
+ ' --seed ' + str(TFSEED) + ' -n ' + str(NSIGEVENTS)
if args.pregenCollContext == True:
SGNGENtask['cmd'] += ' --fromCollContext collisioncontext.root:' + signalprefix
if sep_event_mode == True:
workflow['stages'].append(SGNGENtask)
signalneeds = signalneeds + [SGNGENtask['name']]

sgnmem = 6000 if COLTYPE == 'PbPb' else 4000
SGNtask=createTask(name='sgnsim_'+str(tf), needs=signalneeds, tf=tf, cwd='tf'+str(tf), lab=["GEANT"], relative_cpu=7/8, n_workers=NWORKERS, mem=str(sgnmem))
SGNtask['cmd']='${O2_ROOT}/bin/o2-sim -e ' + str(SIMENGINE) + ' ' + str(MODULES) + ' -n ' + str(NSIGEVENTS) + ' --seed ' + str(TFSEED) \
+ ' --field ccdb -j ' + str(NWORKERS) + ' -g ' + str(GENERATOR) \
+ ' ' + str(TRIGGER) + ' ' + str(CONFKEY) + ' ' + str(INIFILE) \
+ ' -o ' + signalprefix + ' ' + embeddinto \
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run) \
+ ' --vertexMode kCCDB'
SGNtask=createTask(name='sgnsim_'+str(tf), needs=signalneeds, tf=tf, cwd='tf'+str(tf), lab=["GEANT"],
relative_cpu=7/8, n_workers=NWORKERS, mem=str(sgnmem))
sgncmdbase = '${O2_ROOT}/bin/o2-sim -e ' + str(SIMENGINE) + ' ' + str(MODULES) + ' -n ' + str(NSIGEVENTS) + ' --seed ' + str(TFSEED) \
+ ' --field ccdb -j ' + str(NWORKERS) + ' ' + str(CONFKEY) + ' ' + str(INIFILE) + ' -o ' + signalprefix + ' ' + embeddinto \
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run)
if sep_event_mode:
SGNtask['cmd'] = sgncmdbase + ' -g extkinO2 --extKinFile genevents_Kine.root ' + ' --vertexMode kNoVertex'
else:
SGNtask['cmd'] = sgncmdbase + ' -g ' + str(GENERATOR) + ' ' + str(TRIGGER) + ' --vertexMode kCCDB '
if not isActive('all'):
SGNtask['cmd'] += ' --readoutDetectors ' + " ".join(activeDetectors)
if args.pregenCollContext == True:
SGNtask['cmd'] += ' --fromCollContext collisioncontext.root'

workflow['stages'].append(SGNtask)

# some tasks further below still want geometry + grp in fixed names, so we provide it here
Expand Down
2 changes: 1 addition & 1 deletion MC/run/ANCHOR/anchorMC.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ echo "Ready to start main workflow"

${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt ${ALIEN_JDL_O2DPGWORKFLOWTARGET:-aod} --cpu-limit ${ALIEN_JDL_CPULIMIT:-8}
MCRC=$? # <--- we'll report back this code

exit 0
if [[ "${ALIEN_JDL_ADDTIMESERIESINMC}" != "0" ]]; then
# Default value is 1 so this is run by default.
echo "Running TPC time series"
Expand Down
2 changes: 1 addition & 1 deletion MC/run/ANCHOR/tests/test_anchor_2023_apass2_pp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export ALIEN_JDL_LPMANCHORRUN=535069
export ALIEN_JDL_LPMANCHORPRODUCTION=LHC23f
export ALIEN_JDL_LPMANCHORYEAR=2023

export NTIMEFRAMES=2
export NTIMEFRAMES=1
export NSIGEVENTS=50
export SPLITID=100
export PRODSPLIT=153
Expand Down

0 comments on commit 2ff54f6

Please sign in to comment.