Skip to content

Commit ebdba43

Browse files
preghenellasawenzel
authored andcommitted
An example to run Pythia8 heavy-ion with impact-parameter trigger
1 parent a2ec5de commit ebdba43

4 files changed

Lines changed: 75 additions & 0 deletions

File tree

run/SimExamples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
<!-- doxy
88
* \subpage refrunSimExamplesSignal_ImpactB
9+
* \subpage refrunSimExamplesTrigger_ImpactB_Pythia8
910
* \subpage refrunSimExamplesAdaptive_Pythia8
1011
* \subpage refrunSimExamplesAliRoot_Hijing
1112
* \subpage refrunSimExamplesHepMC_STARlight
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- doxy
2+
\page refrunSimExamplesTrigger_ImpactB_Pythia8 Example Trigger_ImpactB_Pythia8
3+
/doxy -->
4+
5+
This is a simple simulation example showing how to run event simulation using the Pythia8 event generator in heavy-ion mode and use an external custom trigger.
6+
The external trigger makes use of the `DeepTrigger` functionality to allow the user to access the internals of the event generator to define the trigger.
7+
In this example, information about the impact parameter of the currently-generated Pythia8 heavy-ion event is used.
8+
The trigger selection defines impact parameters to be accepted according to a min-max range that can be adjusted from the command line.
9+
10+
The definition and configuration of the external `DeepTrigger` is performed by the function `trigger_impactb_pythia8(double bMin = 0., double bMax = 20.)` defined in the macro `trigger_impactb_pythia8.macro`.
11+
12+
The macro file is specified via the argument of `--extTrgFile` whereas the specific function call to retrieve the configuration is specified via the argument of `--extTrgFunc`.
13+
14+
# WARNING
15+
Using a trigger is not always the most efficient way to deal with event generation.
16+
It is always advisable to find a way to bias the event-geneator process to save CPU time.
17+
In this case, the selection of a specific impact-parameter range in Pythia8 can lead to
18+
a large time spent in the event generation rather than in the simulation.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This is a simple simulation example showing how to run event simulation using
4+
# the Pythia8 event generator in heavy-ion mode and use an external custom trigger.
5+
# The external trigger makes use of the `DeepTrigger` functionality to allow the
6+
# user to access the internals of the event generator to define the trigger.
7+
#
8+
# In this example, information about the impact parameter of the currently-generated
9+
# Pythia8 heavy-ion event is used.
10+
# The trigger selection defines impact parameters to be accepted according to a
11+
# min-max range that can be adjusted from the command line.
12+
13+
# The definition and configuration of the external `DeepTrigger` is performed by
14+
# the function `trigger_impactb_pythia8(double bMin = 0., double bMax = 20.)`
15+
# defined in the macro `trigger_impactb_pythia8.macro`.
16+
17+
# The macro file is specified via the argument of `--extTrgFile` whereas the specific
18+
# function call to retrieve the configuration is specified via the argument of `--extTrgFunc`.
19+
20+
set -x
21+
22+
NEV=10
23+
BMIN=15.
24+
BMAX=20.
25+
o2-sim -j 20 -n ${NEV} -g pythia8hi -m PIPE ITS TPC --trigger external --extTrgFile trigger_impactb_pythia8.macro --extTrgFunc "trigger_impactb_pythia8(${BMIN}, ${BMAX})"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// \author R+Preghenella - May 2020
2+
3+
#include "Generators/Trigger.h"
4+
#include "Pythia8/Pythia.h"
5+
#include "Pythia8/HIUserHooks.h"
6+
#include "FairLogger.h"
7+
8+
o2::eventgen::DeepTrigger
9+
trigger_impactb_pythia8(double bmin = 5., double bmax = 10.)
10+
{
11+
return [bmin, bmax](void* interface, std::string name) -> bool {
12+
if (!name.compare("pythia8")) {
13+
auto py8 = reinterpret_cast<Pythia8::Pythia*>(interface);
14+
#if PYTHIA_VERSION_INTEGER < 8300
15+
auto hiinfo = py8->info.hiinfo;
16+
#else
17+
auto hiinfo = py8->info.hiInfo;
18+
#endif
19+
if (!hiinfo) {
20+
LOG(FATAL) << "Cannot define impact parameter: is \'pythia8\' running in heavy-ion mode?";
21+
}
22+
auto b = hiinfo->b();
23+
auto selected = (b > bmin && b < bmax);
24+
LOG(INFO) << "Impact parameter = " << b << " fm: " << (selected ? "selected" : "rejected");
25+
return selected;
26+
} else {
27+
LOG(FATAL) << "Cannot define impact parameter for generator interface \'" << name << "\'";
28+
}
29+
return false;
30+
};
31+
}

0 commit comments

Comments
 (0)