30 #include <pybind11/pybind11.h>
31 #include <pybind11/stl.h>
33 namespace ActsExamples {
37 namespace py = pybind11;
40 double thetaToEta(
double theta) {
42 return -1 * std::log(std::tan(theta / 2.));
44 double etaToTheta(
double eta) {
45 return 2 * std::atan(std::exp(-eta));
49 namespace Acts::Python {
52 auto mex = ctx.
get(
"examples");
56 std::shared_ptr<ActsExamples::EventGenerator>>(
57 mex,
"EventGenerator")
58 .def(py::init<const Config&, Acts::Logging::Level>(),
59 py::arg(
"config"), py::arg(
"level"))
60 .def_property_readonly(
64 std::shared_ptr<ActsExamples::EventGenerator::VertexGenerator>>(
65 gen,
"VertexGenerator");
68 std::shared_ptr<ActsExamples::EventGenerator::ParticlesGenerator>>(
69 gen,
"ParticlesGenerator");
72 std::shared_ptr<ActsExamples::EventGenerator::MultiplicityGenerator>>(
73 gen,
"MultiplicityGenerator");
75 using EventGenerator = ActsExamples::EventGenerator;
77 py::class_<Generator>(
gen,
"Generator")
79 .def(
py::init<std::shared_ptr<EventGenerator::MultiplicityGenerator>,
80 std::shared_ptr<EventGenerator::VertexGenerator>,
81 std::shared_ptr<EventGenerator::ParticlesGenerator>>(),
82 py::arg(
"multiplicity"), py::arg(
"vertex"), py::arg(
"particles"))
84 .def_readwrite(
"vertex", &Generator::vertex)
87 py::class_<Config>(
gen,
"Config")
96 std::shared_ptr<ActsExamples::GaussianVertexGenerator>>(
97 mex,
"GaussianVertexGenerator")
100 ActsExamples::GaussianVertexGenerator
g;
105 py::arg(
"stddev"), py::arg(
"mean"))
110 ActsExamples::EventGenerator::VertexGenerator,
111 std::shared_ptr<ActsExamples::FixedVertexGenerator>>(
112 mex,
"FixedVertexGenerator")
115 ActsExamples::FixedVertexGenerator
g;
122 py::class_<ActsExamples::SimParticle>(mex,
"SimParticle");
123 py::class_<ActsExamples::SimParticleContainer>(mex,
"SimParticleContainer");
130 std::shared_ptr<ActsExamples::ParametricParticleGenerator>>(
131 mex,
"ParametricParticleGenerator")
132 .def(py::init<const Config&>());
134 py::class_<Config>(
gen,
"Config")
137 .def_readwrite(
"phiMax", &Config::phiMax)
138 .def_readwrite(
"thetaMin", &Config::thetaMin)
139 .def_readwrite(
"thetaMax", &Config::thetaMax)
140 .def_readwrite(
"etaUniform", &Config::etaUniform)
141 .def_readwrite(
"pMin", &Config::pMin)
142 .def_readwrite(
"pMax", &Config::pMax)
143 .def_readwrite(
"pTransverse", &Config::pTransverse)
145 .def_readwrite(
"randomizeCharge", &Config::randomizeCharge)
146 .def_readwrite(
"numParticles", &Config::numParticles)
152 return std::pair{cfg.pMin, cfg.pMax};
155 cfg.pMin =
value.first;
156 cfg.pMax =
value.second;
161 return std::pair{cfg.phiMin, cfg.phiMax};
164 cfg.phiMin =
value.first;
165 cfg.phiMax =
value.second;
170 return std::pair{cfg.thetaMin, cfg.thetaMax};
173 cfg.thetaMin =
value.first;
174 cfg.thetaMax =
value.second;
179 return std::pair{thetaToEta(cfg.thetaMin),
180 thetaToEta(cfg.thetaMax)};
183 cfg.thetaMin = etaToTheta(
value.first);
184 cfg.thetaMax = etaToTheta(
value.second);
190 std::shared_ptr<ActsExamples::FixedMultiplicityGenerator>>(
191 mex,
"FixedMultiplicityGenerator")
194 ActsExamples::FixedMultiplicityGenerator
g;
202 ActsExamples::EventGenerator::MultiplicityGenerator,
203 std::shared_ptr<ActsExamples::PoissonMultiplicityGenerator>>(
204 mex,
"PoissonMultiplicityGenerator")
207 ActsExamples::PoissonMultiplicityGenerator
g;