Skip to content
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
7 changes: 5 additions & 2 deletions run/SimExamples/HepMC_EPOS4/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ An in-depth explanation of the mechanisms behind the HepMC(3) data handling can
HepMC_fifo folder of the MC examples. The scripts use the `cmd` parameter of `GeneratorHepMC`
to spawn the EPOS4 generation via the `epos.sh` script.

EPOS4 uses the outdated HepMC2 libraries, so this had to be specified in the steering scripts
EPOS 4.0.0 uses the outdated HepMC2 libraries, so this had to be specified in the steering scripts
of the generators configuration. If `HepMC.version=2` is removed then the scripts will not work
anymore. This is to say that the balance achieved with the configurations provided is easily
destroyed if the user base edits parts that are not understood completely.
The latest EPOS 4.0.3 and EPOS4HQ both use HepMC3, so the version is automatically
updated when these generators are used.

# Scripts description

Expand Down Expand Up @@ -47,6 +49,7 @@ If no parameters are provided to the scripts, they will run with default values
- **-n , --nevents** → changes the number of events in the .optns file or gets the one in the file if no events are provided
- **-i , --input** → .optns filename to feed EPOS4, no extension must be set in the filename
- **-j , --jobs** → sets the number of workers (jobs)
- **-hq** → enables EPOS4HQ generation
- **-h , --help** → prints usage instructions
- **-e , --ecm** → sets the center-of-mass energy in the options file

Expand All @@ -62,6 +65,6 @@ Now the three scripts start to differ:
- **rundpg.sh** → first the o2dpg_sim_workflow.py script will be launched generating the json configuration, then the o2_dpg_workflow_runner.py script will start the workflow
- **rundpl.sh** → o2-sim-dpl-eventgen is executed piping its results to o2-sim-mctracks-to-aod and afterwards to o2-analysis-mctracks-to-aod-simple-task

The last few lines of the scripts contain the execution of o2-sim, DPG worflow creator/runner and DPL software respectively, so this part can be modified by the users following their requirements. It's important not to delete from the configuration keys `GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none;HepMC.version=2;` and it would be better to provide additional configurations via the -m flag. EPOS4 cannot set a maximum impact parameter value, so it's better to leave the bMaxSwitch to none, while the others serve the sole purpose of running successfully the generator using auto generated FIFOs.
The last few lines of the scripts contain the execution of o2-sim, DPG worflow creator/runner and DPL software respectively, so this part can be modified by the users following their requirements. It's important not to delete from the configuration keys `GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none$HEPMC;` and it would be better to provide additional configurations via the -m flag. EPOS4 cannot set a maximum impact parameter value, so it's better to leave the bMaxSwitch to none, while the others serve the sole purpose of running successfully the generator using auto generated FIFOs.


36 changes: 29 additions & 7 deletions run/SimExamples/HepMC_EPOS4/epos.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/bin/sh
#!/bin/bash
# Script based on CRMC example
# EPOS4 option files must contain ihepmc set to 2 to print HepMC
# data on stdout. -hepmc flag is not needed anymore, but -hepstd is fundamental
# in order not to print useless information on stdout (a z-*optns*.mtr file will be created)

optns="example"
seed=$RANDOM
seed=1
EPOS4=""

if [ -z "$EPO4VSN" ]; then
# Error: EPO4VSN environment variable is not set
exit 1
fi

if [ "$EPO4VSN" = "4.0.0" ]; then
EPOS4="$EPOS4_ROOT/epos4/scripts/epos"
else
EPOS4="$EPOS4_ROOT/bin/epos"
fi

while test $# -gt 0 ; do
case $1 in
Expand All @@ -18,13 +30,23 @@ done

if [ ! -f $optns.optns ]; then
echo "Error: Options file $optns.optns not found"
exit 1
exit 2
fi

if grep -Fq "set ihq 1" $optns.optns; then
if [ -z "$EPO4HQVSN" ]; then
# Error: EPOS4HQ version not found
exit 3
else
# Running with EPOS4HQ
EPOS4="$EPO4HQ/bin/eposhq"
fi
fi

if [ $seed -eq 0 ]; then
echo "Seed can't be 0, random number will be used"
seed=$RANDOM
# Seed can't be 0, random number will be used
seed="$RANDOM"
fi

# Or filters the stdout with only HepMC2 useful data
$EPOS4_ROOT/epos4/scripts/epos -hepstd -s $seed $optns | sed -n 's/^\(HepMC::\|[EAUWVP] \)/\1/p'
# OR filters the stdout with only HepMC useful data
$EPOS4 -hepstd -s $seed $optns | sed -n 's/^\(HepMC::\|[EAUWVP] \)/\1/p'
3 changes: 2 additions & 1 deletion run/SimExamples/HepMC_EPOS4/example.optns
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ set nfreeze 1 !number of freeze out events per hydro event
set modsho 1 !printout every modsho events
set centrality 0 !0=min bias
set ihepmc 2 !HepMC output enabled on stdout
set nfull 10
set nfull 10 !Total nEvents to be generated
set ihq 1 !Enable EPOS4HQ
42 changes: 40 additions & 2 deletions run/SimExamples/HepMC_EPOS4/rundpg.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ optns="example"
TF=1
eCM=-1
JOBS=2
HEPMC=""
HQ=false

if [ -z "$EPO4VSN" ]; then
echo "Error: EPOS4 version not found"
exit 7
fi
if [ "$EPO4VSN" == "4.0.0" ]; then
HEPMC=";HepMC.version=2"
else
HEPMC=";HepMC.version=3"
fi

usage()
{
Expand All @@ -38,6 +50,7 @@ Options:
-h,--help Print these instructions
-e,--ecm ENERGY Center-of-Mass energy
-t,--tf TF Timeframes ($TF)
-hq HQ Enable EPOS4HQ
-- Rest of command line sent to o2-sim

COMMAND must be quoted if it contains spaces or other special
Expand All @@ -59,6 +72,7 @@ while test $# -gt 0 ; do
-i|--input) optns=$2 ; shift ;;
-j|--jobs) JOBS=$2 ; shift ;;
-e|--ecm) eCM=$2 ; shift ;;
-hq) HQ=true ; shift ;;
-h|--help) usage; ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py --help ; exit 0 ;;
-t|--tf) TF=$2 ; shift ;;
--) shift ; break ;;
Expand Down Expand Up @@ -115,6 +129,30 @@ else
fi
fi

# Set HQ mode

if [ "$HQ" = true ]; then
echo "Setting HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 1" $optns.optns
else
echo "set ihq 1" >> $optns.optns
fi
if [ -z "$EPO4HQVSN" ]; then
echo "Error: EPOS4HQ version not found"
exit 7
else
HEPMC=";HepMC.version=3"
fi
else
echo "Turning OFF HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 0" $optns.optns
else
echo "set ihq 0" >> $optns.optns
fi
fi

# Copy options file in each timeframe folder
for i in $(seq 1 $TF); do
if [ ! -d tf$i ]; then
Expand All @@ -125,8 +163,8 @@ done

# create workflow

${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM $eCM -ns $NEV -gen hepmc -tf $TF -j $JOBS \
-interactionRate 500000 -confKey "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none;HepMC.version=2;${more}"
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM $eCM -ns $NEV -gen hepmc -tf $TF -j $JOBS -seed $RANDOM \
-interactionRate 500000 -confKey "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none$HEPMC;${more}"

# Run workflow
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt aod --stdout-on-failure
43 changes: 40 additions & 3 deletions run/SimExamples/HepMC_EPOS4/rundpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ more=""
optns="example"
eCM=-1
JOBS=2
HEPMC=""
HQ=false

if [ -z "$EPO4VSN" ]; then
echo "Error: EPOS4 version not found"
exit 7
fi
if [ "$EPO4VSN" == "4.0.0" ]; then
HEPMC=";HepMC.version=2"
else
HEPMC=";HepMC.version=3"
fi

usage()
{
Expand All @@ -35,6 +47,7 @@ Options:
-j,--jobs JOBS Number of jobs ($JOBS)
-e,--ecm ENERGY Center-of-Mass energy
-h,--help Print these instructions
-hq HQ Enable EPOS4HQ
-- Rest of command line sent to o2-sim

COMMAND must be quoted if it contains spaces or other special
Expand All @@ -56,6 +69,7 @@ while test $# -gt 0 ; do
-i|--input) optns=$2 ; shift ;;
-j|--jobs) JOBS=$2 ; shift ;;
-e|--ecm) eCM=$2 ; shift ;;
-hq) HQ=true ; shift ;;
-h|--help) usage; o2-sim-dpl-eventgen --help full ; exit 0 ;;
--) shift ; break ;;
*) echo "Unknown option '$1', did you forget '--'?" >/dev/stderr
Expand Down Expand Up @@ -111,9 +125,32 @@ else
fi
fi

# Starting simulation => seed is fed automatically to epos with the --seed flag. HepMC.version = 2 is mandatory
# Set HQ mode

if [ "$HQ" = true ]; then
echo "Setting HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 1" $optns.optns
else
echo "set ihq 1" >> $optns.optns
fi
if [ -z "$EPO4HQVSN" ]; then
echo "Error: EPOS4HQ version not found"
exit 7
else
HEPMC=";HepMC.version=3"
fi
else
echo "Turning OFF HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 0" $optns.optns
else
echo "set ihq 0" >> $optns.optns
fi
fi

# Starting simulation => seed is fed automatically to epos with the --seed flag. HepMC.version = 2 is mandatory for version 4.0.0
# otherwise the simulation won't work.
# Seed is automatically set to Random by the epos.sh script because the --seed option with o2-sim-dpl-eventgen does not feed the number to GeneratorHepMC

o2-sim-dpl-eventgen -b --nEvents ${NEV} --generator hepmc --configKeyValues "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none;HepMC.version=2;${more}" |\
o2-sim-dpl-eventgen -b --nEvents ${NEV} --generator hepmc --configKeyValues "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none$HEPMC;${more}" |\
o2-sim-mctracks-to-aod -b | o2-analysis-mctracks-to-aod-simple-task -b
42 changes: 40 additions & 2 deletions run/SimExamples/HepMC_EPOS4/runo2sim.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ more=""
optns="example"
eCM=-1
JOBS=2
HEPMC=""
HQ=false

if [ -z "$EPO4VSN" ]; then
echo "Error: EPOS4 version not found"
exit 7
fi
if [ "$EPO4VSN" == "4.0.0" ]; then
HEPMC=";HepMC.version=2"
else
HEPMC=";HepMC.version=3"
fi

usage()
{
Expand All @@ -35,6 +47,7 @@ Options:
-j,--jobs JOBS Number of jobs ($JOBS)
-e,--ecm ENERGY Center-of-Mass energy
-h,--help Print these instructions
-hq HQ Enable EPOS4HQ
-- Rest of command line sent to o2-sim

COMMAND must be quoted if it contains spaces or other special
Expand All @@ -56,6 +69,7 @@ while test $# -gt 0 ; do
-i|--input) optns=$2 ; shift ;;
-j|--jobs) JOBS=$2 ; shift ;;
-e|--ecm) eCM=$2 ; shift ;;
-hq) HQ=true ; shift ;;
-h|--help) usage; o2-sim --help full ; exit 0 ;;
--) shift ; break ;;
*) echo "Unknown option '$1', did you forget '--'?" >/dev/stderr
Expand Down Expand Up @@ -111,7 +125,31 @@ else
fi
fi

# Starting simulation => seed is fed automatically to epos with the --seed flag. HepMC.version = 2 is mandatory
# Set HQ mode

if [ "$HQ" = true ]; then
echo "Setting HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 1" $optns.optns
else
echo "set ihq 1" >> $optns.optns
fi
if [ -z "$EPO4HQVSN" ]; then
echo "Error: EPOS4HQ version not found"
exit 7
else
HEPMC=";HepMC.version=3"
fi
else
echo "Turning OFF HQ mode"
if grep -Fq "ihq" $optns.optns; then
sed -i "/ihq/c\set ihq 0" $optns.optns
else
echo "set ihq 0" >> $optns.optns
fi
fi

# Starting simulation => seed is fed automatically to epos with the --seed flag. HepMC.version = 2 is mandatory for version 4.0.0
# otherwise the simulation won't work
o2-sim -j $JOBS -n ${NEV} -g hepmc --seed $RANDOM \
--configKeyValues "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none;HepMC.version=2;${more}"
--configKeyValues "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none$HEPMC;${more}"