Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventPools: Timeout option and stat file #1852

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions MC/bin/o2dpg_sim_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,13 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
SGNGENtask['cmd'] = cmd


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

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

# adjust for alternate (RECO) software environments
Expand Down
Loading