Skip to content

Commit 43c9be8

Browse files
authored
EventPools: Timeout option and stat file (#1852)
This commit introduces the possibility to create event pools under a given TTL. So even, if the event search times out, events already found will be saved to the pool. This feature allows to make best use of a TTL GRID job and there is no danger of overestimating an event count in the script. The actual number of events found in an event pool job is now also reported in a special 0_0_0_N.stat file, just like in ordinary AO2D productions. This will help for (MonaLisa) accounting.
1 parent 738007c commit 43c9be8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

MC/bin/o2dpg_sim_workflow.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,13 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
791791
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
792792
SGNGENtask['cmd'] = cmd
793793

794-
795-
SGNGENtask['cmd'] +='${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode ' + vtxmode \
794+
generationtimeout = -1 # possible timeout for event pool generation
795+
if args.make_evtpool:
796+
JOBTTL=environ.get('JOBTTL', None)
797+
if JOBTTL != None:
798+
generationtimeout = 0.95*int(JOBTTL) # for GRID jobs, determine timeout automatically
799+
SGNGENtask['cmd'] +=('','timeout ' + str(generationtimeout) + ' ')[args.make_evtpool and generationtimeout>0] \
800+
+ '${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode ' + vtxmode \
796801
+ ' --run ' + str(args.run) + ' ' + str(CONFKEY) + str(TRIGGER) \
797802
+ ' -g ' + str(GENERATOR) + ' ' + str(INIFILE) + ' -o genevents ' + embeddinto \
798803
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] \
@@ -804,6 +809,10 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
804809
workflow['stages'].append(SGNGENtask)
805810
signalneeds = signalneeds + [SGNGENtask['name']]
806811
if args.make_evtpool:
812+
if generationtimeout > 0:
813+
# final adjustment of command for event pools and timeout --> we need to analyse the return code
814+
# if we have a timeout then we finish what we can and are also happy with return code 124
815+
SGNGENtask['cmd'] += ' ; RC=$? ; [[ ${RC} == 0 || ${RC} == 124 ]]'
807816
continue
808817

809818
# GeneratorFromO2Kine parameters are needed only before the transport
@@ -1594,6 +1603,8 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
15941603
tfpool=['tf' + str(tf) + '/genevents_Kine.root' for tf in range(1, NTIMEFRAMES + 1)]
15951604
POOL_merge_task = createTask(name='poolmerge', needs=wfneeds, lab=["POOL"], mem='2000', cpu='1')
15961605
POOL_merge_task['cmd'] = '${O2DPG_ROOT}/UTILS/root_merger.py -o evtpool.root -i ' + ','.join(tfpool)
1606+
# also create the stat file with the event count
1607+
POOL_merge_task['cmd'] += '; RC=$?; root -l -q -b -e "auto f=TFile::Open(\\\"evtpool.root\\\"); auto t=(TTree*)f->Get(\\\"o2sim\\\"); int n=t->GetEntries(); std::ofstream((\\\"0_0_0_\\\"+std::to_string(n)+\\\".stat\\\").c_str()).close();" ; [[ ${RC} == 0 ]]'
15971608
workflow['stages'].append(POOL_merge_task)
15981609

15991610
# adjust for alternate (RECO) software environments

0 commit comments

Comments
 (0)