Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add displaced vertex generator #3446

Merged
merged 11 commits into from
Aug 24, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,37 @@ struct GaussianPrimaryVertexPositionGenerator
}
};

//
struct GaussianDisplacedVertexPositionGenerator
: public EventGenerator::PrimaryVertexPositionGenerator {
double rMean = 0;
double rStdDev = 1;
double zMean = 0;
double zStdDev = 1;
double tMean = 0;
double tStdDev = 1;

Acts::Vector4 operator()(RandomEngine& rng) const override {
double min_value = -M_PI; // -π
double max_value = M_PI; // π

std::uniform_real_distribution<> uniform(min_value, max_value);

std::normal_distribution<double> rDist(rMean, rStdDev);
std::normal_distribution<double> zDist(zMean, zStdDev);
std::normal_distribution<double> tDist(tMean, tStdDev);

// Generate random values from normal distributions
double r = rDist(rng);
double phi = uniform(rng); // Random angle in radians
double z = zDist(rng);
double t = tDist(rng);

// Convert cylindrical coordinates to Cartesian coordinates
double x = r * std::cos(phi);
double y = r * std::sin(phi);

return Acts::Vector4(x, y, z, t);
}
};
} // namespace ActsExamples
37 changes: 37 additions & 0 deletions Examples/Python/src/Generators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,43 @@ void addGenerators(Context& ctx) {
&ActsExamples::GaussianPrimaryVertexPositionGenerator::stddev)
.def_readwrite(
"mean", &ActsExamples::GaussianPrimaryVertexPositionGenerator::mean);
py::class_<
ActsExamples::GaussianDisplacedVertexPositionGenerator,
ActsExamples::EventGenerator::PrimaryVertexPositionGenerator,
std::shared_ptr<ActsExamples::GaussianDisplacedVertexPositionGenerator>>(
mex, "GaussianDisplacedVertexPositionGenerator")
.def(py::init<>())
.def(py::init([](double rMean, double rStdDev, double zMean,
double zStdDev, double tMean, double tStdDev) {
ActsExamples::GaussianDisplacedVertexPositionGenerator g;
g.rMean = rMean;
g.rStdDev = rStdDev;
g.zMean = zMean;
g.zStdDev = zStdDev;
g.tMean = tMean;
g.tStdDev = tStdDev;
return g;
}),
py::arg("rMean"), py::arg("rStdDev"), py::arg("zMean"),
py::arg("zStdDev"), py::arg("tMean"), py::arg("tStdDev"))
.def_readwrite(
"rMean",
&ActsExamples::GaussianDisplacedVertexPositionGenerator::rMean)
.def_readwrite(
"rStdDev",
&ActsExamples::GaussianDisplacedVertexPositionGenerator::rStdDev)
.def_readwrite(
"zMean",
&ActsExamples::GaussianDisplacedVertexPositionGenerator::zMean)
.def_readwrite(
"zStdDev",
&ActsExamples::GaussianDisplacedVertexPositionGenerator::zStdDev)
.def_readwrite(
"tMean",
&ActsExamples::GaussianDisplacedVertexPositionGenerator::tMean)
.def_readwrite(
"tStdDev",
&ActsExamples::GaussianDisplacedVertexPositionGenerator::tStdDev);

py::class_<
ActsExamples::FixedPrimaryVertexPositionGenerator,
Expand Down
Loading
Loading