From 2139f26a309be73be6549032313b198f296f4dfc Mon Sep 17 00:00:00 2001 From: swenzel Date: Mon, 18 Mar 2024 13:57:37 +0100 Subject: [PATCH] (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`. --- MC/bin/o2dpg_sim_workflow.py | 37 ++++++++++++++----- MC/run/ANCHOR/anchorMC.sh | 2 +- .../tests/test_anchor_2023_apass2_pp.sh | 2 +- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index 56a05499c..23466133d 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -121,7 +121,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') @@ -691,7 +692,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 "" @@ -700,18 +700,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_TF, 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_TF) + ' -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_TF, 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_TF) + ' ' + 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 diff --git a/MC/run/ANCHOR/anchorMC.sh b/MC/run/ANCHOR/anchorMC.sh index 13512fea7..f89d6456e 100755 --- a/MC/run/ANCHOR/anchorMC.sh +++ b/MC/run/ANCHOR/anchorMC.sh @@ -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" diff --git a/MC/run/ANCHOR/tests/test_anchor_2023_apass2_pp.sh b/MC/run/ANCHOR/tests/test_anchor_2023_apass2_pp.sh index e528b8a0a..fef70338b 100755 --- a/MC/run/ANCHOR/tests/test_anchor_2023_apass2_pp.sh +++ b/MC/run/ANCHOR/tests/test_anchor_2023_apass2_pp.sh @@ -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