Skip to content

Commit

Permalink
Prototype decouple event gen from transport
Browse files Browse the repository at this point in the history
With this, we will be able to parallelize event generation
over timeframes which will help with low CPU efficiences
when event generators are very slow in spitting out events.
  • Loading branch information
sawenzel committed Mar 18, 2024
1 parent 8de3655 commit 5de2b3e
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions MC/bin/o2dpg_sim_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,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,20 +693,47 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
signalneeds = signalneeds + [ BKGtask['name'] ]
else:
signalneeds = signalneeds + [ BKG_HEADER_task['name'] ]

# event generation task
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) \
+ ' -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'
workflow['stages'].append(SGNGENtask)

# sgnmem = 6000 if COLTYPE == 'PbPb' else 4000
# SGNtask=createTask(name='sgnsim_'+str(tf), needs=[SGNGENtask['name']], 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'
# if not isActive('all'):
# SGNtask['cmd'] += ' --readoutDetectors ' + " ".join(activeDetectors)
# if args.pregenCollContext == True:
# SGNtask['cmd'] += ' --fromCollContext collisioncontext.root'
# workflow['stages'].append(SGNtask)

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=createTask(name='sgnsim_'+str(tf), needs=[SGNGENtask['name']], 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) \
+ ' --field ccdb -j ' + str(NWORKERS) + ' -g extkinO2 --extKinFile genevents_Kine.root ' + str(CONFKEY) + ' ' + str(INIFILE) \
+ ' -o ' + signalprefix + ' ' + embeddinto \
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run) \
+ ' --vertexMode kCCDB'
+ ' --vertexMode kNoVertex' # vertexing was already applied in event generation
if not isActive('all'):
SGNtask['cmd'] += ' --readoutDetectors ' + " ".join(activeDetectors)
if args.pregenCollContext == True:
SGNtask['cmd'] += ' --fromCollContext collisioncontext.root'
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
# Alternatively, since we have timeframe isolation, we could just work with standard o2sim_ files
# We need to be careful here and distinguish between embedding and non-embedding cases
Expand Down

0 comments on commit 5de2b3e

Please sign in to comment.