Skip to content

Commit de8ee55

Browse files
pbuehlerPaul Buehler
authored andcommitted
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> (cherry picked from commit 9780b46)
1 parent 1fef20e commit de8ee55

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
@@ -713,9 +713,17 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True):
713713
cpu=1, mem=1000)
714714

715715
SGNGENtask['cmd']=''
716-
if GENERATOR=="hepmc" and tf > 1:
717-
# determine the skip number
718-
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
716+
if GENERATOR=="hepmc":
717+
if tf == 1:
718+
# determine the offset number
719+
eventOffset = environ.get('HEPMCOFFSET')
720+
print("HEPMCOFFSET: ", eventOffset)
721+
if eventOffset == None:
722+
eventOffset = 0
723+
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/InitHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(eventOffset) + ');'
724+
elif tf > 1:
725+
# determine the skip number
726+
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
719727
SGNGENtask['cmd'] = cmd
720728
SGNGENtask['cmd'] +='${O2_ROOT}/bin/o2-sim --noGeant -j 1 --field ccdb --vertexMode kCCDB' \
721729
+ ' --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)