Skip to content

Commit

Permalink
Added possibility to define a general HEPMCOFFSET. Is usefull when si…
Browse files Browse the repository at this point in the history
…mulating different SPLITIDs of a run in separate jobs. (AliceO2Group#1730)

Co-authored-by: Paul Buehler <[email protected]>
  • Loading branch information
pbuehler and Paul Buehler authored Sep 20, 2024
1 parent 6e99a77 commit 9780b46
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
14 changes: 11 additions & 3 deletions MC/bin/o2dpg_sim_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,17 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
cpu=1, mem=1000)

SGNGENtask['cmd']=''
if GENERATOR=="hepmc" and tf > 1:
# determine the skip number
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
if GENERATOR=="hepmc":
if tf == 1:
# determine the offset number
eventOffset = environ.get('HEPMCOFFSET')
print("HEPMCOFFSET: ", eventOffset)
if eventOffset == None:
eventOffset = 0
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/InitHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(eventOffset) + ');'
elif tf > 1:
# determine the skip number
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 kCCDB' \
+ ' --run ' + str(args.run) + ' ' + str(CONFKEY) + str(TRIGGER) \
Expand Down
12 changes: 12 additions & 0 deletions UTILS/InitHepMCEventSkip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Path to the JSON file
JSON_FILE=${1:-HepMC_EventSkip_ALT.json}
EVENTS=$2

# insert event count offset
echo "[]" > ${JSON_FILE} # init json file
JQ_COMMAND="jq '. + [{"HepMCEventOffset": ${EVENTS}}]' ${JSON_FILE} > tmp_123.json; mv tmp_123.json ${JSON_FILE}"
eval ${JQ_COMMAND}

echo ${EVENTS}
19 changes: 18 additions & 1 deletion UTILS/ReadHepMCEventSkip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,22 @@
# Path to the JSON file
JSON_FILE=$1
tf=$2

# get event offset
JQCOMMAND="jq '.[] | select(.HepMCEventOffset) | .HepMCEventOffset' ${JSON_FILE}"
offset=`eval ${JQCOMMAND}`
if [ ! $offset ]
then
offset=0
fi

# count generated events
JQCOMMAND="jq '[.[] | select(.tf < ${tf}) | .HepMCEventCount] | add' ${JSON_FILE}"
eval ${JQCOMMAND}
events=`eval ${JQCOMMAND}`
if [ ! $events ]
then
events=0
fi

# total number of events to skip
echo $((offset + events))

0 comments on commit 9780b46

Please sign in to comment.