Skip to content

Commit f6e248e

Browse files
sawenzelalcaliva
authored andcommitted
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. (cherry picked from commit 43c9be8)
1 parent ad7e213 commit f6e248e

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
@@ -780,8 +780,13 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
780780
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
781781
SGNGENtask['cmd'] = cmd
782782

783-
784-
SGNGENtask['cmd'] +='${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode ' + vtxmode \
783+
generationtimeout = -1 # possible timeout for event pool generation
784+
if args.make_evtpool:
785+
JOBTTL=environ.get('JOBTTL', None)
786+
if JOBTTL != None:
787+
generationtimeout = 0.95*int(JOBTTL) # for GRID jobs, determine timeout automatically
788+
SGNGENtask['cmd'] +=('','timeout ' + str(generationtimeout) + ' ')[args.make_evtpool and generationtimeout>0] \
789+
+ '${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode ' + vtxmode \
785790
+ ' --run ' + str(args.run) + ' ' + str(CONFKEY) + str(TRIGGER) \
786791
+ ' -g ' + str(GENERATOR) + ' ' + str(INIFILE) + ' -o genevents ' + embeddinto \
787792
+ ('', ' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] \
@@ -793,6 +798,10 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
793798
workflow['stages'].append(SGNGENtask)
794799
signalneeds = signalneeds + [SGNGENtask['name']]
795800
if args.make_evtpool:
801+
if generationtimeout > 0:
802+
# final adjustment of command for event pools and timeout --> we need to analyse the return code
803+
# if we have a timeout then we finish what we can and are also happy with return code 124
804+
SGNGENtask['cmd'] += ' ; RC=$? ; [[ ${RC} == 0 || ${RC} == 124 ]]'
796805
continue
797806

798807
# GeneratorFromO2Kine parameters are needed only before the transport
@@ -1583,6 +1592,8 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
15831592
tfpool=['tf' + str(tf) + '/genevents_Kine.root' for tf in range(1, NTIMEFRAMES + 1)]
15841593
POOL_merge_task = createTask(name='poolmerge', needs=wfneeds, lab=["POOL"], mem='2000', cpu='1')
15851594
POOL_merge_task['cmd'] = '${O2DPG_ROOT}/UTILS/root_merger.py -o evtpool.root -i ' + ','.join(tfpool)
1595+
# also create the stat file with the event count
1596+
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 ]]'
15861597
workflow['stages'].append(POOL_merge_task)
15871598

15881599
# adjust for alternate (RECO) software environments

0 commit comments

Comments
 (0)