From 8d3acd2542525bfe7e89b390ad4e5dd085c95fc1 Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Thu, 26 Sep 2024 13:52:02 +0200 Subject: [PATCH 1/3] Added examples to run EPOS4 on-the-fly --- run/SimExamples/HepMC_EPOS4/README.md | 67 +++++++++++ run/SimExamples/HepMC_EPOS4/epos.sh | 30 +++++ run/SimExamples/HepMC_EPOS4/example.optns | 32 ++++++ run/SimExamples/HepMC_EPOS4/rundpg.sh | 132 ++++++++++++++++++++++ run/SimExamples/HepMC_EPOS4/rundpl.sh | 120 ++++++++++++++++++++ run/SimExamples/HepMC_EPOS4/runo2sim.sh | 118 +++++++++++++++++++ 6 files changed, 499 insertions(+) create mode 100644 run/SimExamples/HepMC_EPOS4/README.md create mode 100755 run/SimExamples/HepMC_EPOS4/epos.sh create mode 100644 run/SimExamples/HepMC_EPOS4/example.optns create mode 100644 run/SimExamples/HepMC_EPOS4/rundpg.sh create mode 100755 run/SimExamples/HepMC_EPOS4/rundpl.sh create mode 100644 run/SimExamples/HepMC_EPOS4/runo2sim.sh diff --git a/run/SimExamples/HepMC_EPOS4/README.md b/run/SimExamples/HepMC_EPOS4/README.md new file mode 100644 index 0000000000000..18f6179feff02 --- /dev/null +++ b/run/SimExamples/HepMC_EPOS4/README.md @@ -0,0 +1,67 @@ + + +The usage of EPOS4 with the O2 machinery is presented in this short manual. +An in-depth explanation of the mechanisms behind the HepMC(3) data handling can be found in the +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 +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. + +# Scripts description + +Four scripts are available to run the simulations +- **epos.sh** → starts the actual EPOS4 generation +- **runo2sim.sh** → allows the generation of events using o2-sim +- **rundpg.sh** → starts the DPG machinery for event generation +- **rundpl.sh** → starts the event generation with DPL + +In addition an example.optns file is provided to start EPOS4, but more can be found in the generator example folder +or in the website [epos4learn.web.cern.ch](https://epos4learn.docs.cern.ch/) where an extensive tutorial on the generator is provided. + +## epos.sh + +It can be run without the help of the other scripts to simply generate an .hepmc file or print +to the stdout the HepMC results. It it worth nothing though that EPOS4 must be loaded (via cvmfs through AliGenerators or O2sim for example) or installed. In this case the user should simply redirect the stdout to a file: +``` +./epos.sh -i test -s 234345 > test.hepmc +``` +This example shows all the functionalities of the script (which are implemented in a similar way inside +the generation steering scripts). In particular the `-i` flag allows to provide .optns parameters to EPOS4, +`-s` feeds the generator with a user seed, and the HepMC output is given by test.hepmc by redirecting the +stdout which will contain only the HepMC data thanks to the `-hepstd` flag set automatically in epos.sh and +the `set ihepmc 2` option which **MUST** be set in the option file (otherwise either an hepmc file will be created - ihepmc 1 - or nothing will be generated - missing ihepmc or != 1|2 ). +It is important to note that setting an empty/null seed in the generator out of the box makes EPOS4 crash, so a protection was added in our steering epos.sh script which now generates a random number if 0 is provided. + +## runo2sim.sh, rundpg.sh and rundpl.sh + +The three scripts have little differences (especially in the first part), so they will be described together. +They work after loading any O2sim version after the 20/09/2024 (included), since multiple modifications had to be performed on both EPOS4 and the introduction of AliGenO2 in order to be able to load both O2sim and EPOS4 simultaneously. +If no parameters are provided to the scripts, they will run with default values (energy and nevents provided in the example.optns file), but few flags are available to change the settings of the generation: +- **-m , --more** → feeds the simulation with advanced parameters provided to the configuration key flags +- **-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) +- **-h , --help** → prints usage instructions +- **-e , --ecm** → sets the center-of-mass energy in the options file + +In the `rundpg.sh` script an additional flag is available +- **-t , --tf** → number of timeframes to be generated + +In this case the options file will be copied in each tf$n folder, otherwise the epos script won't be able to run with multiple timeframes. +In o2sim and DPG scripts the randomly generated seed is set directly, instead this is not feasible with the DPL one, given that the --seed option is not able +to redirect this number to GeneratorHepMC. So a seed 0 is automatically given to epos.sh which generates a random number in return. +Now the three scripts start to differ: + +- **runo2sim.sh** → o2-sim is launched +- **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. + + diff --git a/run/SimExamples/HepMC_EPOS4/epos.sh b/run/SimExamples/HepMC_EPOS4/epos.sh new file mode 100755 index 0000000000000..ff477bdd177b6 --- /dev/null +++ b/run/SimExamples/HepMC_EPOS4/epos.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# 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 + +while test $# -gt 0 ; do + case $1 in + -i|--input) optns=$2 ; shift ;; + -s|--seed) seed=$2 ; shift ;; + -h|--help) usage; exit 0 ;; + esac + shift +done + +if [ ! -f $optns.optns ]; then + echo "Error: Options file $optns.optns not found" + exit 1 +fi + +if [ $seed -eq 0 ]; then + echo "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' diff --git a/run/SimExamples/HepMC_EPOS4/example.optns b/run/SimExamples/HepMC_EPOS4/example.optns new file mode 100644 index 0000000000000..ef777faf7db54 --- /dev/null +++ b/run/SimExamples/HepMC_EPOS4/example.optns @@ -0,0 +1,32 @@ +!-------------------------------------------------------------------- +! proton-proton collision no hydro no hadronic cascade +!-------------------------------------------------------------------- + +!--------------------------------------- +! Define run +!--------------------------------------- + +application hadron !hadron-hadron, hadron-nucleus, or nucleus-nucleus +set laproj 1 !projectile atomic number +set maproj 1 !projectile mass number +set latarg 1 !target atomic number +set matarg 1 !target mass number +set ecms 7000 !sqrt(s)_pp +set istmax 25 !max status considered for storage + +ftime on !string formation time non-zero +!suppressed decays: +nodecays + 110 20 2130 -2130 2230 -2230 1130 -1130 1330 -1330 2330 -2330 3331 -3331 +end + +set ninicon 1 !number of initial conditions used for hydro evolution +core off !core/corona not activated +hydro off !hydro not activated +eos off !eos not activated +hacas off !hadronic cascade not activated +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 diff --git a/run/SimExamples/HepMC_EPOS4/rundpg.sh b/run/SimExamples/HepMC_EPOS4/rundpg.sh new file mode 100644 index 0000000000000..74e0973f98a67 --- /dev/null +++ b/run/SimExamples/HepMC_EPOS4/rundpg.sh @@ -0,0 +1,132 @@ +#!/usr/bin/env bash +# +# This script shows how to start the DPG simulation machinery starting EPOS4 +# automatically while using the FIFOs generated internally by GeneratorHepMC + +# This script works only with O2sim version starting from the 20/09/2024 + +set -x +if [ ! "${EPOS4_ROOT}" ]; then + echo "This needs EPOS4 loaded; alienv enter ..." + exit 1 +fi + +# make sure O2DPG + O2 is loaded +[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1 +[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1 + + +cmd="$PWD/epos.sh" +NEV=-1 +more="" +optns="example" +TF=1 +eCM=-1 +JOBS=2 + +usage() +{ + cat </dev/stderr + exit 3 + ;; + esac + shift +done + +echo "Options file: $optns" + +if [ ! -f $optns.optns ]; then + echo "Error: Options file $optns.optns not found" + exit 4 +fi + +# Set number of events in optns file +if [ ! $NEV -eq -1 ]; then + echo "Setting number of events to $NEV" + if grep -Fq "nfull" $optns.optns; then + sed -i "/nfull/c\set nfull $NEV" $optns.optns + else + echo "set nfull $NEV" >> $optns.optns + fi +else + echo "Number of events not set, checking optns file..." + if grep -Fq "nfull" $optns.optns; then + NEV=$(grep -F "nfull" $optns.optns | awk '{print $3}') + echo "Number of events set to $NEV" + else + echo "Error: Number of events not set in EPOS4" + exit 5 + fi +fi + +# Set ECM + +if [ ! $eCM -eq -1 ]; then + echo "Setting eCM to $eCM" + if grep -Fq "ecms" $optns.optns; then + sed -i "/ecms/c\set ecms $eCM" $optns.optns + else + echo "set ecms $eCM" >> $optns.optns + fi +else + echo "Energy not set, checking optns file..." + if grep -Fq "ecms" $optns.optns; then + eCM=$(grep -F "ecms" $optns.optns | awk '{print $3}') + echo "Energy set to $eCM" + else + echo "Error: eCM not set in EPOS4" + exit 6 + fi +fi + +# Copy options file in each timeframe folder +for i in $(seq 1 $TF); do + if [ ! -d tf$i ]; then + mkdir tf$i + fi + cp $optns.optns tf$i/$optns.optns +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}" + +# 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 new file mode 100755 index 0000000000000..f74a3920ad1f2 --- /dev/null +++ b/run/SimExamples/HepMC_EPOS4/rundpl.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash +# +# This is a simple simulation example showing how to + +# start EPOS4 generation automatically using cmd with hepmc output on FIFO +# and simultaneosly use o2-sim for transport + +# This script works only with O2sim version starting from the 20/09/2024 + +# EPOS4 and O2 must be loaded +set -x +if [ ! "${EPOS4_ROOT}" ]; then + echo "This needs EPOS4 loaded; alienv enter ..." + exit 1 +fi + +[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 2 + +cmd="$PWD/epos.sh" +NEV=-1 +more="" +optns="example" +eCM=-1 +JOBS=2 + +usage() +{ + cat </dev/stderr + exit 3 + ;; + esac + shift +done + +echo "Options file: $optns" + +if [ ! -f $optns.optns ]; then + echo "Error: Options file $optns.optns not found" + exit 4 +fi + +# Set number of events in optns file +if [ ! $NEV -eq -1 ]; then + echo "Setting number of events to $NEV" + if grep -Fq "nfull" $optns.optns; then + sed -i "/nfull/c\set nfull $NEV" $optns.optns + else + echo "set nfull $NEV" >> $optns.optns + fi +else + echo "Number of events not set, checking optns file..." + if grep -Fq "nfull" $optns.optns; then + NEV=$(grep -F "nfull" $optns.optns | awk '{print $3}') + echo "Number of events set to $NEV" + else + echo "Error: Number of events not set in EPOS4" + exit 5 + fi +fi + +# Set ECM + +if [ ! $eCM -eq -1 ]; then + echo "Setting eCM to $eCM" + if grep -Fq "ecms" $optns.optns; then + sed -i "/ecms/c\set ecms $eCM" $optns.optns + else + echo "set ecms $eCM" >> $optns.optns + fi +else + echo "Energy not set, checking optns file..." + if grep -Fq "ecms" $optns.optns; then + eCM=$(grep -F "ecms" $optns.optns | awk '{print $3}') + echo "Energy set to $eCM" + else + echo "Error: eCM not set in EPOS4" + exit 6 + fi +fi + +# Starting simulation => seed is fed automatically to epos with the --seed flag. HepMC.version = 2 is mandatory +# 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-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 new file mode 100644 index 0000000000000..1fcd8ff491fc3 --- /dev/null +++ b/run/SimExamples/HepMC_EPOS4/runo2sim.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +# +# This is a simple simulation example showing how to + +# start EPOS4 generation automatically using cmd with hepmc output on FIFO +# and simultaneosly use o2-sim for transport + +# This script works only with O2sim version starting from the 20/09/2024 + +# EPOS4 and O2 must be loaded +set -x +if [ ! "${EPOS4_ROOT}" ]; then + echo "This needs EPOS4 loaded; alienv enter ..." + exit 1 +fi + +[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 2 + +cmd="$PWD/epos.sh" +NEV=-1 +more="" +optns="example" +eCM=-1 +JOBS=2 + +usage() +{ + cat </dev/stderr + exit 3 + ;; + esac + shift +done + +echo "Options file: $optns" + +if [ ! -f $optns.optns ]; then + echo "Error: Options file $optns.optns not found" + exit 4 +fi + +# Set number of events in optns file +if [ ! $NEV -eq -1 ]; then + echo "Setting number of events to $NEV" + if grep -Fq "nfull" $optns.optns; then + sed -i "/nfull/c\set nfull $NEV" $optns.optns + else + echo "set nfull $NEV" >> $optns.optns + fi +else + echo "Number of events not set, checking optns file..." + if grep -Fq "nfull" $optns.optns; then + NEV=$(grep -F "nfull" $optns.optns | awk '{print $3}') + echo "Number of events set to $NEV" + else + echo "Error: Number of events not set in EPOS4" + exit 5 + fi +fi + +# Set ECM + +if [ ! $eCM -eq -1 ]; then + echo "Setting eCM to $eCM" + if grep -Fq "ecms" $optns.optns; then + sed -i "/ecms/c\set ecms $eCM" $optns.optns + else + echo "set ecms $eCM" >> $optns.optns + fi +else + echo "Energy not set, checking optns file..." + if grep -Fq "ecms" $optns.optns; then + eCM=$(grep -F "ecms" $optns.optns | awk '{print $3}') + echo "Energy set to $eCM" + else + echo "Error: eCM not set in EPOS4" + exit 6 + fi +fi + +# Starting simulation => seed is fed automatically to epos with the --seed flag. HepMC.version = 2 is mandatory +# 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}" From 784d53200ab585764ea2ae9aebdbbd4493ef2462 Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Fri, 27 Sep 2024 10:55:27 +0200 Subject: [PATCH 2/3] Files updates following coding guidelines --- run/SimExamples/HepMC_EPOS4/README.md | 47 ++++++++++++----------- run/SimExamples/HepMC_EPOS4/epos.sh | 10 ++--- run/SimExamples/HepMC_EPOS4/example.optns | 16 ++++---- run/SimExamples/HepMC_EPOS4/rundpg.sh | 10 ++--- run/SimExamples/HepMC_EPOS4/rundpl.sh | 11 +++--- run/SimExamples/HepMC_EPOS4/runo2sim.sh | 9 ++--- 6 files changed, 51 insertions(+), 52 deletions(-) diff --git a/run/SimExamples/HepMC_EPOS4/README.md b/run/SimExamples/HepMC_EPOS4/README.md index 18f6179feff02..73bb57d44ff16 100644 --- a/run/SimExamples/HepMC_EPOS4/README.md +++ b/run/SimExamples/HepMC_EPOS4/README.md @@ -2,46 +2,47 @@ \page refrunSimExamplesHepMC_EPOS4 Example HepMC_EPOS4 /doxy --> -The usage of EPOS4 with the O2 machinery is presented in this short manual. +The usage of EPOS4 with the O2 machinery is presented in this short manual. An in-depth explanation of the mechanisms behind the HepMC(3) data handling can be found in the -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. +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 -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. +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. # Scripts description Four scripts are available to run the simulations -- **epos.sh** → starts the actual EPOS4 generation +- **epos.sh** → starts the actual EPOS4 generation - **runo2sim.sh** → allows the generation of events using o2-sim - **rundpg.sh** → starts the DPG machinery for event generation - **rundpl.sh** → starts the event generation with DPL -In addition an example.optns file is provided to start EPOS4, but more can be found in the generator example folder -or in the website [epos4learn.web.cern.ch](https://epos4learn.docs.cern.ch/) where an extensive tutorial on the generator is provided. +In addition an example.optns file is provided to start EPOS4, but more can be found in the generator example folder +or in the website [epos4learn.web.cern.ch](https://epos4learn.docs.cern.ch/) where an extensive tutorial on the generator is provided. ## epos.sh -It can be run without the help of the other scripts to simply generate an .hepmc file or print +It can be run without the help of the other scripts to simply generate an .hepmc file or print to the stdout the HepMC results. It it worth nothing though that EPOS4 must be loaded (via cvmfs through AliGenerators or O2sim for example) or installed. In this case the user should simply redirect the stdout to a file: ``` ./epos.sh -i test -s 234345 > test.hepmc ``` This example shows all the functionalities of the script (which are implemented in a similar way inside -the generation steering scripts). In particular the `-i` flag allows to provide .optns parameters to EPOS4, -`-s` feeds the generator with a user seed, and the HepMC output is given by test.hepmc by redirecting the -stdout which will contain only the HepMC data thanks to the `-hepstd` flag set automatically in epos.sh and -the `set ihepmc 2` option which **MUST** be set in the option file (otherwise either an hepmc file will be created - ihepmc 1 - or nothing will be generated - missing ihepmc or != 1|2 ). -It is important to note that setting an empty/null seed in the generator out of the box makes EPOS4 crash, so a protection was added in our steering epos.sh script which now generates a random number if 0 is provided. +the generation steering scripts). In particular the `-i` flag allows to provide .optns parameters to EPOS4, +`-s` feeds the generator with a user seed, and the HepMC output is given by test.hepmc by redirecting the +stdout which will contain only the HepMC data thanks to the `-hepstd` flag set automatically in epos.sh and +the `set ihepmc 2` option which **MUST** be set in the option file (otherwise either an hepmc file will be created - ihepmc 1 - or nothing will be generated - missing ihepmc or != 1|2 ). + +It is important to note that setting an empty/null seed in the generator out of the box makes EPOS4 crash, so a protection was added in our steering epos.sh script which now generates a random number if 0 is provided. ## runo2sim.sh, rundpg.sh and rundpl.sh -The three scripts have little differences (especially in the first part), so they will be described together. -They work after loading any O2sim version after the 20/09/2024 (included), since multiple modifications had to be performed on both EPOS4 and the introduction of AliGenO2 in order to be able to load both O2sim and EPOS4 simultaneously. -If no parameters are provided to the scripts, they will run with default values (energy and nevents provided in the example.optns file), but few flags are available to change the settings of the generation: +The three scripts have little differences (especially in the first part), so they will be described together. They work after loading any O2sim version after the 20/09/2024 (included), since multiple modifications had to be performed on both EPOS4 and the introduction of AliGenO2 in order to be able to load both O2sim and EPOS4 simultaneously. + +If no parameters are provided to the scripts, they will run with default values (energy and nevents provided in the example.optns file), but few flags are available to change the settings of the generation: - **-m , --more** → feeds the simulation with advanced parameters provided to the configuration key flags - **-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 @@ -50,11 +51,11 @@ If no parameters are provided to the scripts, they will run with default values - **-e , --ecm** → sets the center-of-mass energy in the options file In the `rundpg.sh` script an additional flag is available -- **-t , --tf** → number of timeframes to be generated +- **-t , --tf** → number of timeframes to be generated In this case the options file will be copied in each tf$n folder, otherwise the epos script won't be able to run with multiple timeframes. -In o2sim and DPG scripts the randomly generated seed is set directly, instead this is not feasible with the DPL one, given that the --seed option is not able -to redirect this number to GeneratorHepMC. So a seed 0 is automatically given to epos.sh which generates a random number in return. +In o2sim and DPG scripts the randomly generated seed is set directly, instead this is not feasible with the DPL one, given that the --seed option is not able to redirect this number to GeneratorHepMC. So a seed 0 is automatically given to epos.sh which generates a random number in return. + Now the three scripts start to differ: - **runo2sim.sh** → o2-sim is launched @@ -62,6 +63,6 @@ Now the three scripts start to differ: - **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. +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 ff477bdd177b6..093f806f9fabf 100755 --- a/run/SimExamples/HepMC_EPOS4/epos.sh +++ b/run/SimExamples/HepMC_EPOS4/epos.sh @@ -1,7 +1,7 @@ #!/bin/sh -# Script based on CRMC example +# 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 +# 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" @@ -9,9 +9,9 @@ seed=$RANDOM while test $# -gt 0 ; do case $1 in - -i|--input) optns=$2 ; shift ;; - -s|--seed) seed=$2 ; shift ;; - -h|--help) usage; exit 0 ;; + -i|--input) optns=$2 ; shift ;; + -s|--seed) seed=$2 ; shift ;; + -h|--help) usage; exit 0 ;; esac shift done diff --git a/run/SimExamples/HepMC_EPOS4/example.optns b/run/SimExamples/HepMC_EPOS4/example.optns index ef777faf7db54..c2b067941e4e8 100644 --- a/run/SimExamples/HepMC_EPOS4/example.optns +++ b/run/SimExamples/HepMC_EPOS4/example.optns @@ -6,27 +6,27 @@ ! Define run !--------------------------------------- -application hadron !hadron-hadron, hadron-nucleus, or nucleus-nucleus +application hadron !hadron-hadron, hadron-nucleus, or nucleus-nucleus set laproj 1 !projectile atomic number set maproj 1 !projectile mass number set latarg 1 !target atomic number set matarg 1 !target mass number set ecms 7000 !sqrt(s)_pp -set istmax 25 !max status considered for storage +set istmax 25 !max status considered for storage ftime on !string formation time non-zero -!suppressed decays: -nodecays - 110 20 2130 -2130 2230 -2230 1130 -1130 1330 -1330 2330 -2330 3331 -3331 +!suppressed decays: +nodecays + 110 20 2130 -2130 2230 -2230 1130 -1130 1330 -1330 2330 -2330 3331 -3331 end set ninicon 1 !number of initial conditions used for hydro evolution core off !core/corona not activated hydro off !hydro not activated eos off !eos not activated -hacas off !hadronic cascade not activated -set nfreeze 1 !number of freeze out events per hydro event +hacas off !hadronic cascade not activated +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 centrality 0 !0=min bias set ihepmc 2 !HepMC output enabled on stdout set nfull 10 diff --git a/run/SimExamples/HepMC_EPOS4/rundpg.sh b/run/SimExamples/HepMC_EPOS4/rundpg.sh index 74e0973f98a67..630d0be08ca5d 100644 --- a/run/SimExamples/HepMC_EPOS4/rundpg.sh +++ b/run/SimExamples/HepMC_EPOS4/rundpg.sh @@ -36,7 +36,7 @@ Options: -i,--input INPUT Options file fed to EPOS4 ($optns) -j,--jobs JOBS Number of jobs ($JOBS) -h,--help Print these instructions - -e,--ecm ENERGY Center-of-Mass energy + -e,--ecm ENERGY Center-of-Mass energy -t,--tf TF Timeframes ($TF) -- Rest of command line sent to o2-sim @@ -58,7 +58,7 @@ while test $# -gt 0 ; do -n|--nevents) NEV=$2 ; shift ;; -i|--input) optns=$2 ; shift ;; -j|--jobs) JOBS=$2 ; shift ;; - -e|--ecm) eCM=$2 ; shift ;; + -e|--ecm) eCM=$2 ; shift ;; -h|--help) usage; ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py --help ; exit 0 ;; -t|--tf) TF=$2 ; shift ;; --) shift ; break ;; @@ -92,7 +92,7 @@ else else echo "Error: Number of events not set in EPOS4" exit 5 - fi + fi fi # Set ECM @@ -126,7 +126,7 @@ 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}" + -interactionRate 500000 -confKey "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none;HepMC.version=2;${more}" -# Run workflow +# 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 f74a3920ad1f2..c3851175d08f4 100755 --- a/run/SimExamples/HepMC_EPOS4/rundpl.sh +++ b/run/SimExamples/HepMC_EPOS4/rundpl.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash # -# This is a simple simulation example showing how to - +# This is a simple simulation example showing how to # start EPOS4 generation automatically using cmd with hepmc output on FIFO # and simultaneosly use o2-sim for transport # This script works only with O2sim version starting from the 20/09/2024 -# EPOS4 and O2 must be loaded +# EPOS4 and O2 must be loaded set -x if [ ! "${EPOS4_ROOT}" ]; then echo "This needs EPOS4 loaded; alienv enter ..." @@ -34,7 +33,7 @@ Options: -n,--nevents EVENTS Number of events ($nev) -i,--input INPUT Options file fed to EPOS4 ($optns) -j,--jobs JOBS Number of jobs ($JOBS) - -e,--ecm ENERGY Center-of-Mass energy + -e,--ecm ENERGY Center-of-Mass energy -h,--help Print these instructions -- Rest of command line sent to o2-sim @@ -89,7 +88,7 @@ else else echo "Error: Number of events not set in EPOS4" exit 5 - fi + fi fi # Set ECM @@ -113,7 +112,7 @@ else fi # Starting simulation => seed is fed automatically to epos with the --seed flag. HepMC.version = 2 is mandatory -# otherwise the simulation won't work. +# 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}" |\ diff --git a/run/SimExamples/HepMC_EPOS4/runo2sim.sh b/run/SimExamples/HepMC_EPOS4/runo2sim.sh index 1fcd8ff491fc3..31698f39a87f0 100644 --- a/run/SimExamples/HepMC_EPOS4/runo2sim.sh +++ b/run/SimExamples/HepMC_EPOS4/runo2sim.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash # -# This is a simple simulation example showing how to - +# This is a simple simulation example showing how to # start EPOS4 generation automatically using cmd with hepmc output on FIFO # and simultaneosly use o2-sim for transport # This script works only with O2sim version starting from the 20/09/2024 -# EPOS4 and O2 must be loaded +# EPOS4 and O2 must be loaded set -x if [ ! "${EPOS4_ROOT}" ]; then echo "This needs EPOS4 loaded; alienv enter ..." @@ -34,7 +33,7 @@ Options: -n,--nevents EVENTS Number of events ($nev) -i,--input INPUT Options file fed to EPOS4 ($optns) -j,--jobs JOBS Number of jobs ($JOBS) - -e,--ecm ENERGY Center-of-Mass energy + -e,--ecm ENERGY Center-of-Mass energy -h,--help Print these instructions -- Rest of command line sent to o2-sim @@ -89,7 +88,7 @@ else else echo "Error: Number of events not set in EPOS4" exit 5 - fi + fi fi # Set ECM From 43b013a784457b5f5fd0d4699ac6fd0d310b222f Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Fri, 27 Sep 2024 11:00:21 +0200 Subject: [PATCH 3/3] Fix for coding guidelines --- run/SimExamples/HepMC_EPOS4/README.md | 9 ++++----- run/SimExamples/HepMC_EPOS4/epos.sh | 6 +++--- run/SimExamples/HepMC_EPOS4/rundpg.sh | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/run/SimExamples/HepMC_EPOS4/README.md b/run/SimExamples/HepMC_EPOS4/README.md index 73bb57d44ff16..94c50572cff9f 100644 --- a/run/SimExamples/HepMC_EPOS4/README.md +++ b/run/SimExamples/HepMC_EPOS4/README.md @@ -3,8 +3,8 @@ /doxy --> The usage of EPOS4 with the O2 machinery is presented in this short manual. -An in-depth explanation of the mechanisms behind the HepMC(3) data handling can be found in the -HepMC_fifo folder of the MC examples. The scripts use the `cmd` parameter of `GeneratorHepMC` +An in-depth explanation of the mechanisms behind the HepMC(3) data handling can be found in the +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 @@ -53,7 +53,7 @@ If no parameters are provided to the scripts, they will run with default values In the `rundpg.sh` script an additional flag is available - **-t , --tf** → number of timeframes to be generated -In this case the options file will be copied in each tf$n folder, otherwise the epos script won't be able to run with multiple timeframes. +In this case the options file will be copied in each tf$n folder, otherwise the epos script won't be able to run with multiple timeframes. In o2sim and DPG scripts the randomly generated seed is set directly, instead this is not feasible with the DPL one, given that the --seed option is not able to redirect this number to GeneratorHepMC. So a seed 0 is automatically given to epos.sh which generates a random number in return. Now the three scripts start to differ: @@ -62,7 +62,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.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. diff --git a/run/SimExamples/HepMC_EPOS4/epos.sh b/run/SimExamples/HepMC_EPOS4/epos.sh index 093f806f9fabf..46a7dbfa27e5c 100755 --- a/run/SimExamples/HepMC_EPOS4/epos.sh +++ b/run/SimExamples/HepMC_EPOS4/epos.sh @@ -9,9 +9,9 @@ seed=$RANDOM while test $# -gt 0 ; do case $1 in - -i|--input) optns=$2 ; shift ;; - -s|--seed) seed=$2 ; shift ;; - -h|--help) usage; exit 0 ;; + -i|--input) optns=$2 ; shift ;; + -s|--seed) seed=$2 ; shift ;; + -h|--help) usage; exit 0 ;; esac shift done diff --git a/run/SimExamples/HepMC_EPOS4/rundpg.sh b/run/SimExamples/HepMC_EPOS4/rundpg.sh index 630d0be08ca5d..93993f66bfbd6 100644 --- a/run/SimExamples/HepMC_EPOS4/rundpg.sh +++ b/run/SimExamples/HepMC_EPOS4/rundpg.sh @@ -58,7 +58,7 @@ while test $# -gt 0 ; do -n|--nevents) NEV=$2 ; shift ;; -i|--input) optns=$2 ; shift ;; -j|--jobs) JOBS=$2 ; shift ;; - -e|--ecm) eCM=$2 ; shift ;; + -e|--ecm) eCM=$2 ; shift ;; -h|--help) usage; ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py --help ; exit 0 ;; -t|--tf) TF=$2 ; shift ;; --) shift ; break ;; @@ -126,7 +126,7 @@ 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}" + -interactionRate 500000 -confKey "GeneratorFileOrCmd.cmd=$cmd -i $optns;GeneratorFileOrCmd.bMaxSwitch=none;HepMC.version=2;${more}" # Run workflow ${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt aod --stdout-on-failure