File indexing completed on 2025-08-03 07:48:43
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Utilities/AxisDefinitions.hpp"
0013 #include "ActsExamples/Framework/RandomNumbers.hpp"
0014
0015 #include <functional>
0016 #include <random>
0017
0018 namespace ActsExamples::AlignmentGenerator {
0019
0020
0021
0022
0023
0024
0025
0026 struct UniformRandom {
0027
0028
0029
0030
0031 UniformRandom(RandomSeed seed, double min, double max)
0032 : randomEngine(seed), randomNumbers(min, max) {}
0033
0034
0035 double operator()() { return randomNumbers(randomEngine); }
0036
0037 RandomEngine randomEngine;
0038 std::uniform_real_distribution<double> randomNumbers;
0039 };
0040
0041 struct GaussRandom {
0042
0043
0044
0045
0046 GaussRandom(RandomSeed seed, double mean, double sigma)
0047 : randomEngine(seed), randomNumbers(mean, sigma) {}
0048
0049
0050 double operator()() { return randomNumbers(randomEngine); }
0051
0052 RandomEngine randomEngine;
0053 std::normal_distribution<double> randomNumbers;
0054 };
0055
0056 struct ClippedGaussRandom {
0057
0058
0059
0060
0061
0062
0063 ClippedGaussRandom(RandomSeed seed, double mean, double sigma, double minv,
0064 double maxv)
0065 : randomEngine(seed), randomNumbers(mean, sigma), min(minv), max(maxv) {}
0066
0067
0068 double operator()() {
0069 auto value = randomNumbers(randomEngine);
0070 return std::max(min, std::min(max, value));
0071 }
0072
0073 RandomEngine randomEngine;
0074 std::normal_distribution<double> randomNumbers;
0075 double min;
0076 double max;
0077 };
0078
0079
0080 struct Nominal {
0081
0082 void operator()(Acts::Transform3* ) const {
0083
0084 }
0085 };
0086
0087
0088 struct GlobalShift {
0089
0090 Acts::Vector3 shift = Acts::Vector3::UnitZ();
0091
0092 std::function<double()> randomize = nullptr;
0093
0094
0095 void operator()(Acts::Transform3* transform) const {
0096 double scale =
0097 randomize != nullptr ? randomize() : 1.0;
0098 transform->translation() += scale * shift;
0099 }
0100 };
0101
0102
0103
0104 struct GlobalRotation {
0105
0106 Acts::Vector3 axis =
0107 Acts::Vector3::UnitZ();
0108 double angle = 0.0;
0109
0110 std::function<double()> randomize = nullptr;
0111
0112
0113
0114 void operator()(Acts::Transform3* transform) const {
0115 double angleS = randomize != nullptr ? randomize() * angle : angle;
0116 (*transform) = Acts::AngleAxis3(angleS, axis) * (*transform);
0117 }
0118 };
0119
0120
0121
0122
0123 struct LocalRotation {
0124
0125 Acts::Vector3 axis =
0126 Acts::Vector3::UnitZ();
0127 double angle = 0.0;
0128
0129 std::function<double()> randomize = nullptr;
0130
0131
0132
0133 void operator()(Acts::Transform3* transform) const {
0134 double angleS = randomize != nullptr ? randomize() * angle : angle;
0135 (*transform) *= Acts::AngleAxis3(angleS, axis);
0136 }
0137 };
0138
0139
0140 struct LocalShift {
0141
0142 Acts::AxisDirection axisDirection = Acts::AxisDirection::AxisX;
0143
0144 double shift = 0.0;
0145
0146 std::function<double()> randomize = nullptr;
0147
0148
0149
0150 void operator()(Acts::Transform3* transform) const {
0151 double shiftS = randomize != nullptr ? randomize() * shift : shift;
0152
0153 const auto rotation = transform->rotation();
0154
0155 switch (axisDirection) {
0156 case Acts::AxisDirection::AxisX: {
0157 Acts::Translation3 translation(shiftS * rotation.col(0));
0158 (*transform) = translation * (*transform);
0159 break;
0160 }
0161 case Acts::AxisDirection::AxisY: {
0162 Acts::Translation3 translation(shiftS * rotation.col(1));
0163 (*transform) = translation * (*transform);
0164 break;
0165 }
0166 case Acts::AxisDirection::AxisZ: {
0167 Acts::Translation3 translation(shiftS * rotation.col(2));
0168 (*transform) = translation * (*transform);
0169 break;
0170 }
0171 default:
0172 throw std::runtime_error("LocalShift: Invalid axis direction");
0173 }
0174 }
0175 };
0176
0177 }