-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Included deep trigger example with impact parameter
- Loading branch information
1 parent
ebb4854
commit 5e9bdb8
Showing
2 changed files
with
51 additions
and
13 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
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; | ||
}; | ||
} |