Skip to content

Commit 9780b46

Browse files
pbuehlerPaul Buehler
andauthored
Added possibility to define a general HEPMCOFFSET. Is usefull when simulating different SPLITIDs of a run in separate jobs. (#1730)
Co-authored-by: Paul Buehler <paul.buhler@cern.ch>
1 parent 6e99a77 commit 9780b46

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

MC/bin/o2dpg_sim_workflow.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,17 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
724724
cpu=1, mem=1000)
725725

726726
SGNGENtask['cmd']=''
727-
if GENERATOR=="hepmc" and tf > 1:
728-
# determine the skip number
729-
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
727+
if GENERATOR=="hepmc":
728+
if tf == 1:
729+
# determine the offset number
730+
eventOffset = environ.get('HEPMCOFFSET')
731+
print("HEPMCOFFSET: ", eventOffset)
732+
if eventOffset == None:
733+
eventOffset = 0
734+
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/InitHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(eventOffset) + ');'
735+
elif tf > 1:
736+
# determine the skip number
737+
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
730738
SGNGENtask['cmd'] = cmd
731739
SGNGENtask['cmd'] +='${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode kCCDB' \
732740
+ ' --run ' + str(args.run) + ' ' + str(CONFKEY) + str(TRIGGER) \

UTILS/InitHepMCEventSkip.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Path to the JSON file
4+
JSON_FILE=${1:-HepMC_EventSkip_ALT.json}
5+
EVENTS=$2
6+
7+
# insert event count offset
8+
echo "[]" > ${JSON_FILE} # init json file
9+
JQ_COMMAND="jq '. + [{"HepMCEventOffset": ${EVENTS}}]' ${JSON_FILE} > tmp_123.json; mv tmp_123.json ${JSON_FILE}"
10+
eval ${JQ_COMMAND}
11+
12+
echo ${EVENTS}

UTILS/ReadHepMCEventSkip.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,22 @@
33
# Path to the JSON file
44
JSON_FILE=$1
55
tf=$2
6+
7+
# get event offset
8+
JQCOMMAND="jq '.[] | select(.HepMCEventOffset) | .HepMCEventOffset' ${JSON_FILE}"
9+
offset=`eval ${JQCOMMAND}`
10+
if [ ! $offset ]
11+
then
12+
offset=0
13+
fi
14+
15+
# count generated events
616
JQCOMMAND="jq '[.[] | select(.tf < ${tf}) | .HepMCEventCount] | add' ${JSON_FILE}"
7-
eval ${JQCOMMAND}
17+
events=`eval ${JQCOMMAND}`
18+
if [ ! $events ]
19+
then
20+
events=0
21+
fi
22+
23+
# total number of events to skip
24+
echo $((offset + events))

0 commit comments

Comments
 (0)