From 6568977e52e8e0fb350ac4c0f19f9c799f29652f Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Mon, 14 Apr 2025 15:06:19 +0200 Subject: [PATCH] Updated EPOS4 example using different versions and HQ --- run/SimExamples/HepMC_EPOS4/README.md | 7 ++-- run/SimExamples/HepMC_EPOS4/epos.sh | 36 +++++++++++++++---- run/SimExamples/HepMC_EPOS4/example.optns | 3 +- run/SimExamples/HepMC_EPOS4/rundpg.sh | 42 ++++++++++++++++++++-- run/SimExamples/HepMC_EPOS4/rundpl.sh | 43 +++++++++++++++++++++-- run/SimExamples/HepMC_EPOS4/runo2sim.sh | 42 ++++++++++++++++++++-- 6 files changed, 156 insertions(+), 17 deletions(-) mode change 100644 => 100755 run/SimExamples/HepMC_EPOS4/README.md mode change 100644 => 100755 run/SimExamples/HepMC_EPOS4/example.optns mode change 100644 => 100755 run/SimExamples/HepMC_EPOS4/rundpg.sh mode change 100644 => 100755 run/SimExamples/HepMC_EPOS4/runo2sim.sh diff --git a/run/SimExamples/HepMC_EPOS4/README.md b/run/SimExamples/HepMC_EPOS4/README.md old mode 100644 new mode 100755 index 94c50572cff9f..8609501a6981a --- a/run/SimExamples/HepMC_EPOS4/README.md +++ b/run/SimExamples/HepMC_EPOS4/README.md @@ -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 @@ -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 @@ -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. diff --git a/run/SimExamples/HepMC_EPOS4/epos.sh b/run/SimExamples/HepMC_EPOS4/epos.sh index 46a7dbfa27e5c..a4185b756bf56 100755 --- a/run/SimExamples/HepMC_EPOS4/epos.sh +++ b/run/SimExamples/HepMC_EPOS4/epos.sh @@ -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 @@ -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' diff --git a/run/SimExamples/HepMC_EPOS4/example.optns b/run/SimExamples/HepMC_EPOS4/example.optns old mode 100644 new mode 100755 index c2b067941e4e8..9df738d15fcff --- a/run/SimExamples/HepMC_EPOS4/example.optns +++ b/run/SimExamples/HepMC_EPOS4/example.optns @@ -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 diff --git a/run/SimExamples/HepMC_EPOS4/rundpg.sh b/run/SimExamples/HepMC_EPOS4/rundpg.sh old mode 100644 new mode 100755 index 93993f66bfbd6..ea6d29ce0fa54 --- a/run/SimExamples/HepMC_EPOS4/rundpg.sh +++ b/run/SimExamples/HepMC_EPOS4/rundpg.sh @@ -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() { @@ -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 @@ -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 ;; @@ -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 @@ -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 diff --git a/run/SimExamples/HepMC_EPOS4/rundpl.sh b/run/SimExamples/HepMC_EPOS4/rundpl.sh index c3851175d08f4..919eedf1a2340 100755 --- a/run/SimExamples/HepMC_EPOS4/rundpl.sh +++ b/run/SimExamples/HepMC_EPOS4/rundpl.sh @@ -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() { @@ -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 @@ -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 @@ -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 diff --git a/run/SimExamples/HepMC_EPOS4/runo2sim.sh b/run/SimExamples/HepMC_EPOS4/runo2sim.sh old mode 100644 new mode 100755 index 31698f39a87f0..a241f9affba19 --- a/run/SimExamples/HepMC_EPOS4/runo2sim.sh +++ b/run/SimExamples/HepMC_EPOS4/runo2sim.sh @@ -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() { @@ -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 @@ -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 @@ -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}"