File indexing completed on 2025-01-18 09:12:02
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Definitions/PdgParticle.hpp"
0010 #include "Acts/EventData/ParticleHypothesis.hpp"
0011 #include "Acts/Plugins/Python/Utilities.hpp"
0012
0013 #include <type_traits>
0014
0015 #include <pybind11/pybind11.h>
0016 #include <pybind11/stl.h>
0017
0018 namespace py = pybind11;
0019
0020 using namespace Acts;
0021
0022 namespace Acts::Python {
0023
0024 void addEventData(Context& ctx) {
0025 auto [m, mex] = ctx.get("main", "examples");
0026
0027 py::class_<Acts::ParticleHypothesis>(m, "ParticleHypothesis")
0028 .def(py::init<PdgParticle, float, float>(), py::arg("pdg"),
0029 py::arg("mass"), py::arg("absCharge"))
0030 .def(py::init([](std::underlying_type_t<Acts::PdgParticle> absPdg,
0031 float mass, float absCharge) {
0032 return Acts::ParticleHypothesis(
0033 static_cast<Acts::PdgParticle>(absPdg), mass, absCharge);
0034 }),
0035 py::arg("absPdg"), py::arg("mass"), py::arg("absCharge"))
0036 .def("__str__",
0037 [](const Acts::ParticleHypothesis& particleHypothesis) {
0038 std::stringstream os;
0039 particleHypothesis.toStream(os);
0040 return os.str();
0041 })
0042 .def("absolutePdg",
0043 [](const Acts::ParticleHypothesis& p) { return p.absolutePdg(); })
0044 .def("mass", [](const Acts::ParticleHypothesis& p) { return p.mass(); })
0045 .def("absoluteCharge",
0046 [](const Acts::ParticleHypothesis& p) { return p.absoluteCharge(); })
0047 .def_property_readonly_static("muon",
0048 [](py::object ) {
0049 return Acts::ParticleHypothesis::muon();
0050 })
0051 .def_property_readonly_static("pion",
0052 [](py::object ) {
0053 return Acts::ParticleHypothesis::pion();
0054 })
0055 .def_property_readonly_static(
0056 "electron",
0057 [](py::object ) {
0058 return Acts::ParticleHypothesis::electron();
0059 })
0060 .def_property_readonly_static("kaon",
0061 [](py::object ) {
0062 return Acts::ParticleHypothesis::kaon();
0063 })
0064 .def_property_readonly_static("proton",
0065 [](py::object ) {
0066 return Acts::ParticleHypothesis::proton();
0067 })
0068 .def_property_readonly_static(
0069 "geantino",
0070 [](py::object ) {
0071 return Acts::ParticleHypothesis::geantino();
0072 })
0073 .def_property_readonly_static(
0074 "chargedGeantino", [](py::object ) {
0075 return Acts::ParticleHypothesis::chargedGeantino();
0076 });
0077 }
0078
0079 }