File indexing completed on 2026-04-17 07:47:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Definitions/PdgParticle.hpp"
0010 #include "ActsFatras/EventData/Barcode.hpp"
0011 #include "ActsFatras/EventData/GenerationProcess.hpp"
0012 #include "ActsFatras/EventData/Particle.hpp"
0013
0014 #include <sstream>
0015
0016 #include <pybind11/pybind11.h>
0017
0018 namespace py = pybind11;
0019
0020 PYBIND11_MODULE(ActsFatrasPythonBindings, fatras) {
0021 using Barcode = ActsFatras::Barcode;
0022 using Particle = ActsFatras::Particle;
0023
0024 py::class_<Barcode>(fatras, "Barcode")
0025 .def(py::init<>())
0026 .def_static("Invalid", &Barcode::Invalid)
0027 .def("isValid", [](const Barcode& b) { return b.isValid(); })
0028 .def_property(
0029 "vertexPrimary", [](const Barcode& b) { return b.vertexPrimary(); },
0030 [](Barcode& b, Barcode::PrimaryVertexId id) {
0031 b = b.withVertexPrimary(id);
0032 })
0033 .def_property(
0034 "vertexSecondary",
0035 [](const Barcode& b) { return b.vertexSecondary(); },
0036 [](Barcode& b, Barcode::SecondaryVertexId id) {
0037 b = b.withVertexSecondary(id);
0038 })
0039 .def_property(
0040 "particle", [](const Barcode& b) { return b.particle(); },
0041 [](Barcode& b, Barcode::ParticleId id) { b = b.withParticle(id); })
0042 .def_property(
0043 "generation", [](const Barcode& b) { return b.generation(); },
0044 [](Barcode& b, Barcode::GenerationId id) {
0045 b = b.withGeneration(id);
0046 })
0047 .def_property(
0048 "subParticle", [](const Barcode& b) { return b.subParticle(); },
0049 [](Barcode& b, Barcode::SubParticleId id) {
0050 b = b.withSubParticle(id);
0051 })
0052 .def("__repr__", [](const Barcode& b) {
0053 std::ostringstream oss;
0054 oss << b;
0055 return oss.str();
0056 });
0057
0058 py::enum_<ActsFatras::GenerationProcess>(fatras, "GenerationProcess")
0059 .value("eUndefined", ActsFatras::GenerationProcess::eUndefined)
0060 .value("eDecay", ActsFatras::GenerationProcess::eDecay)
0061 .value("ePhotonConversion",
0062 ActsFatras::GenerationProcess::ePhotonConversion)
0063 .value("eBremsstrahlung", ActsFatras::GenerationProcess::eBremsstrahlung)
0064 .value("eNuclearInteraction",
0065 ActsFatras::GenerationProcess::eNuclearInteraction);
0066
0067 py::enum_<ActsFatras::SimulationOutcome>(fatras, "SimulationOutcome")
0068 .value("Alive", ActsFatras::SimulationOutcome::Alive)
0069 .value("KilledInteraction",
0070 ActsFatras::SimulationOutcome::KilledInteraction)
0071 .value("KilledVolumeExit",
0072 ActsFatras::SimulationOutcome::KilledVolumeExit)
0073 .value("KilledTime", ActsFatras::SimulationOutcome::KilledTime)
0074 .value("KilledSecondaryParticle",
0075 ActsFatras::SimulationOutcome::KilledSecondaryParticle);
0076
0077 py::class_<Particle>(fatras, "Particle")
0078 .def(py::init<>())
0079 .def(py::init<Barcode, Acts::PdgParticle, double, double>(),
0080 py::arg("particleId"), py::arg("pdg"), py::arg("charge"),
0081 py::arg("mass"))
0082 .def(py::init<Barcode, Acts::PdgParticle>(), py::arg("particleId"),
0083 py::arg("pdg"))
0084 .def_property_readonly("particleId", &Particle::particleId)
0085 .def_property_readonly("pdg", &Particle::pdg)
0086 .def_property_readonly("absolutePdg", &Particle::absolutePdg)
0087 .def_property_readonly("charge", &Particle::charge)
0088 .def_property_readonly("mass", &Particle::mass)
0089 .def_property_readonly("fourPosition", &Particle::fourPosition)
0090 .def_property_readonly("fourMomentum", &Particle::fourMomentum)
0091 .def_property_readonly("direction", &Particle::direction)
0092 .def_property_readonly("absoluteMomentum", &Particle::absoluteMomentum);
0093 }