15 #include <Pythia8/Pythia.h>
18 struct FrameworkRndmEngine :
public Pythia8::RndmEngine {
23 return std::uniform_real_distribution<double>(0.0, 1.0)(rng);
28 std::function<ActsExamples::SimParticleContainer(ActsExamples::RandomEngine&)>
31 auto gen = std::make_shared<Pythia8Generator>(cfg, lvl);
39 m_pythia8(std::make_unique<
Pythia8::Pythia>(
"",
false)) {
41 m_pythia8->settings.flag(
"Print:quiet",
true);
48 m_pythia8->settings.mode(
"Beams:frameType", 1);
59 using namespace Acts::UnitLiterals;
61 SimParticleContainer::sequence_type generated;
62 std::vector<SimParticle::Vector4> vertexPositions;
65 std::lock_guard<std::mutex> lock(m_pythia8Mutex);
67 FrameworkRndmEngine rndmEngine(rng);
68 m_pythia8->rndm.rndmEnginePtr(&rndmEngine);
72 for (
int ip = 0;
ip < m_pythia8->event.size(); ++
ip) {
73 const auto& genParticle = m_pythia8->event[
ip];
76 if (genParticle.statusHepMC() == 4) {
80 if (not genParticle.isFinal()) {
83 if (not genParticle.isVisible()) {
89 genParticle.xProd() * 1_mm, genParticle.yProd() * 1_mm,
90 genParticle.zProd() * 1_mm, genParticle.tProd() * 1_mm);
95 particleId.setParticle(1
u + generated.size());
97 if (genParticle.hasVertex()) {
100 auto it = std::find_if(
101 vertexPositions.begin(), vertexPositions.end(),
103 if (
it == vertexPositions.end()) {
105 vertexPositions.emplace_back(
pos4);
106 particleId.setVertexSecondary(vertexPositions.size());
109 particleId.setVertexSecondary(
110 1
u + std::distance(vertexPositions.begin(),
it));
116 const auto charge = genParticle.charge() * 1_e;
117 const auto mass = genParticle.m0() * 1_GeV;
121 particle.
setDirection(genParticle.px(), genParticle.py(), genParticle.pz());
123 std::hypot(genParticle.px(), genParticle.py(), genParticle.pz()) *
126 generated.push_back(std::move(particle));
130 out.adopt_sequence(std::move(generated));