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

Added possibility to define a general HEPMCOFFSET. #1730

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
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
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))