-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d610459
commit 6b7c06f
Showing
4 changed files
with
153 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- doxy | ||
\page refrunSimExamplesHybrid Example Hybrid | ||
/doxy --> | ||
|
||
The usage of the Hybrid generator with the o2-sim is presented in this short manual. | ||
All the other generators are implemented as sub-generators and they can be called thanks to a | ||
JSON file, fed to o2-sim via the GeneratorHybrid.configFile parameter. The O2sim package needs to be loaded in order to use this example. | ||
|
||
The example can be run automatically using the runo2sim.sh script, which contains most of the | ||
available generators in O2. The JSON template can be generated using the ${O2DPG_ROOT}/MC/bin/o2_hybrid_gen.py script. To use this example the user can simply copy the entire Hybrid example folder and execute the script after giving it execution permissions (`chmod +x runo2sim.sh`). | ||
|
||
# Files description | ||
|
||
- **runo2sim.sh** → allows to use the hybrid generator example | ||
- **hybridconfig.json** → example JSON file for the hybrid generator configuration | ||
- **example.optns** → options file to be used in EPOS4 implemented as subgenerator in this example (the .optns must be available in the current working directory) |
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,32 @@ | ||
{ | ||
"generators": [ | ||
{ | ||
"cocktail": [ | ||
{ | ||
"name": "pythia8hi", | ||
"triggers": { | ||
"mode": "or", | ||
"specs": [ | ||
{ | ||
"macro": "${PWD}/trigger.macro", | ||
"function": "trigger_impactb_pythia8(0.,5.)" | ||
} | ||
] | ||
}, | ||
"config": "" | ||
}, | ||
{ | ||
"name": "external", | ||
"config": { | ||
"fileName": "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorPromptCharmonia.C", | ||
"funcName": "GeneratorParamPromptJpsiToElectronEvtGen_pp13TeV()", | ||
"iniFile": "" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"fractions": [ | ||
1 | ||
] | ||
} |
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,60 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Hybrid generator simulation example with triggers and cocktail: | ||
# the simulation is configured using a JSON file (hybridconfig.json in this folder), whose | ||
# template can be generated using the script ${O2DPG_ROOT}/MC/bin/o2_hybrid_gen.py. | ||
# Trigger is taken from the trigger.macro and it's a simple impact parameter selection for | ||
# heavy ion collisions | ||
set -x | ||
if [ ! "${O2DPG_ROOT}" ]; then | ||
echo "This needs O2DPG loaded; alienv enter ..." | ||
exit 1 | ||
fi | ||
|
||
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 2 | ||
|
||
NEV=1 | ||
more="" | ||
JOBS=2 | ||
|
||
usage() | ||
{ | ||
cat <<EOF | ||
Usage: $0 [OPTIONS] | ||
Options: | ||
-m,--more CONFIG More configurations ($more) | ||
-n,--nevents EVENTS Number of events ($NEV) | ||
-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 ;; | ||
-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 | ||
|
||
# Starting simulation with Hybrid generator | ||
${O2_ROOT}/bin/o2-sim --noGeant -j $JOBS --field ccdb --vertexMode kCCDB --run 300000 --configKeyValues "MFTBase.buildAlignment=true;GeneratorHybrid.configFile=$PWD/hybridconfig.json;GeneratorHybrid.randomize=false;${more}" -g hybrid -o genevents --timestamp 1546300800000 --seed 836302859 -n $NEV |
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,45 @@ | ||
#include "Generators/Trigger.h" | ||
#include "TParticle.h" | ||
#include <iostream> | ||
|
||
// a very simple trigger example, examining generated particles | ||
o2::eventgen::Trigger trigger() | ||
{ | ||
// | ||
return [](const std::vector<TParticle>& particles) -> bool { | ||
std::cout << "Running trigger on event with size " << particles.size() << "\n"; | ||
if (particles.size() > 10000) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
} | ||
|
||
#include "Pythia8/Pythia.h" | ||
#include "Pythia8/HIInfo.h" | ||
#include <fairlogger/Logger.h> | ||
// a deep trigger example, looking into the internal generator state | ||
o2::eventgen::DeepTrigger | ||
trigger_impactb_pythia8(double bmin = 5., double bmax = 10.) | ||
{ | ||
return [bmin, bmax](void* interface, std::string name) -> bool { | ||
if (!name.compare("pythia8")) { | ||
auto py8 = reinterpret_cast<Pythia8::Pythia*>(interface); | ||
#if PYTHIA_VERSION_INTEGER < 8300 | ||
auto hiinfo = py8->info.hiinfo; | ||
#else | ||
auto hiinfo = py8->info.hiInfo; | ||
#endif | ||
if (!hiinfo) { | ||
LOG(fatal) << "Cannot define impact parameter: is \'pythia8\' running in heavy-ion mode?"; | ||
} | ||
auto b = hiinfo->b(); | ||
auto selected = (b > bmin && b < bmax); | ||
LOG(info) << "Impact parameter = " << b << " fm: " << (selected ? "selected" : "rejected"); | ||
return selected; | ||
} else { | ||
LOG(fatal) << "Cannot define impact parameter for generator interface \'" << name << "\'"; | ||
} | ||
return false; | ||
}; | ||
} |