-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom fifo names feature + jetscape usage example
- Loading branch information
1 parent
789968c
commit ecec4fc
Showing
8 changed files
with
297 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- doxy | ||
\page refrunSimExamplesHepMC_JETSCAPE Example HepMC_JETSCAPE | ||
/doxy --> | ||
|
||
The usage of JETSCAPE 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 JETSCAPE generation via the `jetscape.sh` script. It is important to turn on the | ||
HepMC3 output format in the xml configuration file, as done in jetscape_user_example.xml, otherwise | ||
the simulation will not work. | ||
|
||
# Scripts description | ||
|
||
Two scripts are available to run the simulations | ||
- **jetscape.sh** → starts the actual JETSCAPE generation | ||
- **runo2sim.sh** → allows the generation of events using o2-sim | ||
|
||
In addition an jetscape_user_example.xml file is provided to start JETSCAPE with user parameters. | ||
The user could easily create scripts similar to the one provided for the EPOS4 tutorial for DPL or O2DPG | ||
based simulations. | ||
|
||
## jetscape.sh | ||
|
||
It can be run without the help of the other scripts to simply generate an .hepmc file. | ||
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 the .xml user configuration file to JETSCAPE, `-s` feeds the generator with a user seed, and the HepMC output filename is set using the `-o` flag. The script edits automatically some specific parts of the provided input XML file. | ||
|
||
## runo2sim.sh | ||
|
||
This script works only with O2sim versions containing the FIFO custom name creation fix (the specific build will be added here in the future) otherwise it will crash or not complete the simulation. | ||
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 .xml file or gets the one in the file if no events are provided | ||
- **-i , --input** → .xml filename to feed JETSCAPE, no extension must be set in the filename | ||
- **-j , --jobs** → sets the number of workers (jobs) | ||
- **-h , --help** → prints usage instructions | ||
|
||
The last few lines of the script contain the execution of o2-sim, 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 $xml;GeneratorFileOrCmd.fileNames=test_out.hepmc;GeneratorFileOrCmd.outputSwitch=-o;GeneratorFileOrCmd.bMaxSwitch=none;GeneratorFileOrCmd.nEventsSwitch=none;` because the script might not work anymore, and it would be better to provide additional configurations via the -m flag. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/sh | ||
# Script based on EPOS4 example | ||
# This script is used to run JETSCAPE with the given XML file | ||
# setting the seed and HepMC output filename. Contrary to the | ||
# epos example, the HepMC output is generated in a custom named file | ||
# not passing from the stdout. | ||
|
||
xml="example" | ||
seed=$RANDOM | ||
hepmc="jetout.hepmc" | ||
|
||
usage() | ||
{ | ||
cat <<EOF | ||
Usage: $0 [OPTIONS] | ||
Options: | ||
-i,--input INPUT XML user file fed to JETSCAPE ($xml) | ||
-o,--output OUTPUT HepMC output file ($hepmc) | ||
-s,--seed SEED RNG seed ($seed) | ||
-h,--help Print these instructions | ||
-- Rest of command line sent to o2-sim | ||
EOF | ||
} | ||
|
||
while test $# -gt 0 ; do | ||
case $1 in | ||
-i|--input) xml=$2 ; shift ;; | ||
-o|--output) hepmc=$2 ; shift ;; | ||
-s|--seed) seed=$2 ; shift ;; | ||
-h|--help) usage; exit 0 ;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ ! -f $xml.xml ]; then | ||
echo "Error: Options file $xml.xml not found" | ||
exit 1 | ||
fi | ||
|
||
if [ $seed -eq 0 ]; then | ||
echo "Seed can't be 0, random number will be used" | ||
seed=$RANDOM | ||
else | ||
if grep -Fq "<seed>" $xml.xml; then | ||
sed -i "/<seed>/c\ <seed>$seed</seed>" $xml.xml | ||
else | ||
sed -i "/<\/jetscape>/i\ <Random>\n <seed>$seed</seed>\n </Random>" $xml.xml | ||
fi | ||
echo "Seed set to $seed" | ||
fi | ||
|
||
# Check if hepmc output has been set | ||
if [ ! -z "$hepmc" ]; then | ||
# Remove extension | ||
newhep=$(echo $hepmc | sed 's/.hepmc//') | ||
if grep -Fq "<outputFilename>" $xml.xml; then | ||
sed -i "/<outputFilename>/c\ <outputFilename>$newhep</outputFilename>" $xml.xml | ||
else | ||
sed -i "/<jetscape>/a\ <outputFilename>$newhep</outputFilename>" $xml.xml | ||
fi | ||
echo "HepMC output file set to $hepmc" | ||
else | ||
echo "Error: HepMC output file not set" | ||
exit 2 | ||
fi | ||
|
||
# Master XML file pulled directly from the JETSCAPE directory | ||
runJetscape $xml.xml $JETSCAPE_ROOT/config/jetscape_master.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0"?> | ||
|
||
<jetscape> | ||
|
||
<nEvents>1000</nEvents> | ||
|
||
<Random> | ||
<seed>1</seed> | ||
</Random> | ||
|
||
<outputFilename>jetscape</outputFilename> | ||
|
||
<!--Do not delete HepMC setting--> | ||
<JetScapeWriterHepMC> on </JetScapeWriterHepMC> | ||
|
||
<!-- Hard Process --> | ||
<Hard> | ||
<PythiaGun> | ||
<pTHatMin>235</pTHatMin> | ||
<pTHatMax>1000</pTHatMax> | ||
<eCM>5020</eCM> | ||
</PythiaGun> | ||
</Hard> | ||
|
||
<!--Eloss Modules --> | ||
<Eloss> | ||
<Matter> | ||
<Q0> 1.0 </Q0> | ||
<in_vac> 1 </in_vac> | ||
<vir_factor> 0.25 </vir_factor> | ||
<recoil_on> 0 </recoil_on> | ||
<broadening_on> 0 </broadening_on> | ||
<brick_med> 0 </brick_med> | ||
</Matter> | ||
</Eloss> | ||
|
||
<!-- Jet Hadronization Module --> | ||
<JetHadronization> | ||
<name>colorless</name> | ||
</JetHadronization> | ||
|
||
</jetscape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This is a simple simulation example showing how to | ||
# start JETSCAPE generation automatically using cmd with hepmc output on FIFO | ||
# and simultaneosly use o2-sim for transport | ||
|
||
# JETSCAPE and O2 must be loaded | ||
set -x | ||
if [ ! "${JETSCAPE_ROOT}" ]; then | ||
echo "This needs JETSCAPE loaded; alienv enter ..." | ||
exit 1 | ||
fi | ||
|
||
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 2 | ||
|
||
cmd="$PWD/jetscape.sh" | ||
NEV=-1 | ||
more="" | ||
xml="example" | ||
JOBS=2 | ||
|
||
usage() | ||
{ | ||
cat <<EOF | ||
Usage: $0 [OPTIONS] | ||
Options: | ||
-m,--more CONFIG More configurations ($more) | ||
-n,--nevents EVENTS Number of events ($nev) | ||
-i,--input INPUT XML configuration file fed to JETSCAPE ($xml) | ||
-j,--jobs JOBS Number of jobs ($JOBS) | ||
-h,--help Print these instructions | ||
-- Rest of command line sent to o2-sim | ||
COMMAND must be quoted if it contains spaces or other special | ||
characters | ||
Below follows the help output of o2-sim | ||
EOF | ||
} | ||
|
||
if [ "$#" -lt 2 ]; then | ||
echo "Running with default values" | ||
fi | ||
|
||
while test $# -gt 0 ; do | ||
case $1 in | ||
-m|--more) more="$2" ; shift ;; | ||
-n|--nevents) NEV=$2 ; shift ;; | ||
-i|--input) xml=$2 ; shift ;; | ||
-j|--jobs) JOBS=$2 ; shift ;; | ||
-h|--help) usage; o2-sim --help full ; exit 0 ;; | ||
--) shift ; break ;; | ||
*) echo "Unknown option '$1', did you forget '--'?" >/dev/stderr | ||
exit 3 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
echo "XML User file: $xml" | ||
|
||
if [ ! -f $xml.xml ]; then | ||
echo "Error: Options file $xml.xml not found" | ||
exit 4 | ||
fi | ||
|
||
# Set number of events in the XML file | ||
if [ ! $NEV -eq -1 ]; then | ||
echo "Setting number of events to $NEV" | ||
if grep -Fq "<nEvents>" $xml.xml; then | ||
sed -i "/<nEvents>/c\ <nEvents>$NEV</nEvents>" $xml.xml | ||
else | ||
sed -i "/<jetscape>/a\ <nEvents>$NEV</nEvents>" $xml.xml | ||
fi | ||
else | ||
echo "Number of events not set, checking xml file..." | ||
if grep -Fq "<nEvents>" $xml.xml; then | ||
NEV=$(grep -F "<nEvents>" $xml.xml | awk '{print $2}') | ||
echo "Number of events set to $NEV" | ||
else | ||
echo "Error: Number of events not set in JETSCAPE" | ||
exit 5 | ||
fi | ||
fi | ||
|
||
# Starting simulation | ||
o2-sim -j $JOBS -n ${NEV} -g hepmc --seed $RANDOM \ | ||
--configKeyValues "GeneratorFileOrCmd.cmd=$cmd -i $xml;GeneratorFileOrCmd.fileNames=test_out.hepmc;GeneratorFileOrCmd.outputSwitch=-o;GeneratorFileOrCmd.bMaxSwitch=none;GeneratorFileOrCmd.nEventsSwitch=none;${more}" |