Skip to content

Commit 3b4451e

Browse files
committed
(Optional) decoupling of event gen from transport
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`.
1 parent 53a5674 commit 3b4451e

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

MC/bin/o2dpg_sim_workflow.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
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)
122122
parser.add_argument('--run-anchored', action='store_true', help=argparse.SUPPRESS)
123123
parser.add_argument('--alternative-reco-software', default="", help=argparse.SUPPRESS) # power feature to set CVFMS alienv software version for reco steps (different from default)
124-
parser.add_argument('--dpl-child-driver', default="", help="Child driver to use in DPL processes (export mode)")
124+
parser.add_argument('--dpl-child-driver', default="", help="Child driver to use in DPL processes (expert mode)")
125+
parser.add_argument('--event-gen-mode', choices=['separated', 'integrated'], default='separated', help="Whether event generation is done before (separated) or within detector simulation (integrated).")
125126

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

694-
695695
# add embedIntoFile only if embeddPattern does contain a '@'
696696
embeddinto= "--embedIntoFile ../bkg_MCHeader.root" if (doembedding & ("@" in args.embeddPattern)) else ""
697697
#embeddinto= "--embedIntoFile ../bkg_MCHeader.root" if doembedding else ""
@@ -700,18 +700,37 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
700700
signalneeds = signalneeds + [ BKGtask['name'] ]
701701
else:
702702
signalneeds = signalneeds + [ BKG_HEADER_task['name'] ]
703+
704+
# (separate) event generation task
705+
sep_event_mode = args.event_gen_mode == 'separated'
706+
SGNGENtask=createTask(name='sgngen_'+str(tf), needs=signalneeds, tf=tf, cwd='tf'+str(tf), lab=["GEN"],
707+
cpu=1, mem=1000)
708+
SGNGENtask['cmd']='${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode kCCDB' \
709+
+ ' --run ' + str(args.run) + ' ' + str(CONFKEY) + str(TRIGGER) \
710+
+ ' -g ' + str(GENERATOR) + ' ' + str(INIFILE) + ' -o genevents ' + embeddinto \
711+
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] \
712+
+ ' --seed ' + str(TFSEED) + ' -n ' + str(NSIGEVENTS)
713+
if args.pregenCollContext == True:
714+
SGNGENtask['cmd'] += ' --fromCollContext collisioncontext.root:' + signalprefix
715+
if sep_event_mode == True:
716+
workflow['stages'].append(SGNGENtask)
717+
signalneeds = signalneeds + [SGNGENtask['name']]
718+
703719
sgnmem = 6000 if COLTYPE == 'PbPb' else 4000
704-
SGNtask=createTask(name='sgnsim_'+str(tf), needs=signalneeds, tf=tf, cwd='tf'+str(tf), lab=["GEANT"], relative_cpu=7/8, n_workers=NWORKERS_TF, mem=str(sgnmem))
705-
SGNtask['cmd']='${O2_ROOT}/bin/o2-sim -e ' + str(SIMENGINE) + ' ' + str(MODULES) + ' -n ' + str(NSIGEVENTS) + ' --seed ' + str(TFSEED) \
706-
+ ' --field ccdb -j ' + str(NWORKERS_TF) + ' -g ' + str(GENERATOR) \
707-
+ ' ' + str(TRIGGER) + ' ' + str(CONFKEY) + ' ' + str(INIFILE) \
708-
+ ' -o ' + signalprefix + ' ' + embeddinto \
709-
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run) \
710-
+ ' --vertexMode kCCDB'
720+
SGNtask=createTask(name='sgnsim_'+str(tf), needs=signalneeds, tf=tf, cwd='tf'+str(tf), lab=["GEANT"],
721+
relative_cpu=7/8, n_workers=NWORKERS_TF, mem=str(sgnmem))
722+
sgncmdbase = '${O2_ROOT}/bin/o2-sim -e ' + str(SIMENGINE) + ' ' + str(MODULES) + ' -n ' + str(NSIGEVENTS) + ' --seed ' + str(TFSEED) \
723+
+ ' --field ccdb -j ' + str(NWORKERS_TF) + ' ' + str(CONFKEY) + ' ' + str(INIFILE) + ' -o ' + signalprefix + ' ' + embeddinto \
724+
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run)
725+
if sep_event_mode:
726+
SGNtask['cmd'] = sgncmdbase + ' -g extkinO2 --extKinFile genevents_Kine.root ' + ' --vertexMode kNoVertex'
727+
else:
728+
SGNtask['cmd'] = sgncmdbase + ' -g ' + str(GENERATOR) + ' ' + str(TRIGGER) + ' --vertexMode kCCDB '
711729
if not isActive('all'):
712730
SGNtask['cmd'] += ' --readoutDetectors ' + " ".join(activeDetectors)
713731
if args.pregenCollContext == True:
714732
SGNtask['cmd'] += ' --fromCollContext collisioncontext.root'
733+
715734
workflow['stages'].append(SGNtask)
716735

717736
# some tasks further below still want geometry + grp in fixed names, so we provide it here

MC/run/ANCHOR/anchorMC.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ echo "Ready to start main workflow"
239239

240240
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt ${ALIEN_JDL_O2DPGWORKFLOWTARGET:-aod} --cpu-limit ${ALIEN_JDL_CPULIMIT:-8}
241241
MCRC=$? # <--- we'll report back this code
242-
242+
exit 0
243243
if [[ "${ALIEN_JDL_ADDTIMESERIESINMC}" != "0" ]]; then
244244
# Default value is 1 so this is run by default.
245245
echo "Running TPC time series"

MC/run/ANCHOR/tests/test_anchor_2023_apass2_pp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export ALIEN_JDL_LPMANCHORRUN=535069
1919
export ALIEN_JDL_LPMANCHORPRODUCTION=LHC23f
2020
export ALIEN_JDL_LPMANCHORYEAR=2023
2121

22-
export NTIMEFRAMES=2
22+
export NTIMEFRAMES=1
2323
export NSIGEVENTS=50
2424
export SPLITID=100
2525
export PRODSPLIT=153

0 commit comments

Comments
 (0)