File indexing completed on 2025-01-18 09:12:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Definitions/Direction.hpp"
0014 #include "Acts/Definitions/TrackParametrization.hpp"
0015 #include "Acts/Definitions/Units.hpp"
0016 #include "Acts/EventData/Charge.hpp"
0017 #include "Acts/EventData/GenericBoundTrackParameters.hpp"
0018 #include "Acts/EventData/GenericCurvilinearTrackParameters.hpp"
0019 #include "Acts/EventData/MultiComponentTrackParameters.hpp"
0020 #include "Acts/EventData/MultiTrajectory.hpp"
0021 #include "Acts/EventData/TrackContainer.hpp"
0022 #include "Acts/EventData/TrackParameters.hpp"
0023 #include "Acts/EventData/TrackProxy.hpp"
0024 #include "Acts/EventData/TrackStatePropMask.hpp"
0025 #include "Acts/EventData/VectorMultiTrajectory.hpp"
0026 #include "Acts/EventData/VectorTrackContainer.hpp"
0027 #include "Acts/EventData/detail/TestSourceLink.hpp"
0028 #include "Acts/Geometry/GeometryIdentifier.hpp"
0029 #include "Acts/Propagator/MultiEigenStepperLoop.hpp"
0030 #include "Acts/Propagator/Navigator.hpp"
0031 #include "Acts/Propagator/Propagator.hpp"
0032 #include "Acts/Propagator/StraightLineStepper.hpp"
0033 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0034 #include "Acts/Surfaces/PlaneSurface.hpp"
0035 #include "Acts/Surfaces/Surface.hpp"
0036 #include "Acts/Tests/CommonHelpers/LineSurfaceStub.hpp"
0037 #include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp"
0038 #include "Acts/TrackFitting/BetheHeitlerApprox.hpp"
0039 #include "Acts/TrackFitting/GainMatrixUpdater.hpp"
0040 #include "Acts/TrackFitting/GaussianSumFitter.hpp"
0041 #include "Acts/TrackFitting/GsfMixtureReduction.hpp"
0042 #include "Acts/TrackFitting/GsfOptions.hpp"
0043 #include "Acts/Utilities/Delegate.hpp"
0044 #include "Acts/Utilities/Holders.hpp"
0045 #include "Acts/Utilities/Result.hpp"
0046 #include "Acts/Utilities/UnitVectors.hpp"
0047 #include "Acts/Utilities/Zip.hpp"
0048
0049 #include <algorithm>
0050 #include <array>
0051 #include <functional>
0052 #include <map>
0053 #include <memory>
0054 #include <optional>
0055 #include <random>
0056 #include <string>
0057 #include <string_view>
0058 #include <tuple>
0059 #include <vector>
0060
0061 #include "FitterTestsCommon.hpp"
0062
0063 namespace {
0064
0065 using namespace Acts;
0066 using namespace Acts::Test;
0067 using namespace Acts::detail::Test;
0068 using namespace Acts::UnitLiterals;
0069
0070 static const auto electron = ParticleHypothesis::electron();
0071
0072 Acts::GainMatrixUpdater kfUpdater;
0073
0074 FitterTester tester;
0075
0076 GsfExtensions<VectorMultiTrajectory> getExtensions() {
0077 GsfExtensions<VectorMultiTrajectory> extensions;
0078 extensions.calibrator
0079 .connect<&testSourceLinkCalibrator<VectorMultiTrajectory>>();
0080 extensions.updater
0081 .connect<&Acts::GainMatrixUpdater::operator()<VectorMultiTrajectory>>(
0082 &kfUpdater);
0083 extensions.surfaceAccessor
0084 .connect<&TestSourceLink::SurfaceAccessor::operator()>(
0085 &tester.surfaceAccessor);
0086 extensions.mixtureReducer.connect<&Acts::reduceMixtureWithKLDistance>();
0087 return extensions;
0088 }
0089
0090 using Stepper = Acts::MultiEigenStepperLoop<>;
0091 using Propagator = Acts::Propagator<Stepper, Acts::Navigator>;
0092 using BetheHeitlerApprox = AtlasBetheHeitlerApprox<6, 5>;
0093 using GSF =
0094 GaussianSumFitter<Propagator, BetheHeitlerApprox, VectorMultiTrajectory>;
0095
0096 const GSF gsfZero(makeConstantFieldPropagator<Stepper>(tester.geometry, 0_T),
0097 makeDefaultBetheHeitlerApprox());
0098
0099 std::default_random_engine rng(42);
0100
0101 auto makeDefaultGsfOptions() {
0102 GsfOptions<VectorMultiTrajectory> opts{tester.geoCtx, tester.magCtx,
0103 tester.calCtx};
0104 opts.extensions = getExtensions();
0105 opts.propagatorPlainOptions =
0106 PropagatorPlainOptions(tester.geoCtx, tester.magCtx);
0107 return opts;
0108 }
0109
0110
0111
0112
0113 struct MultiCmpsParsInterface : public BoundTrackParameters {
0114 MultiComponentBoundTrackParameters multi_pars;
0115
0116 MultiCmpsParsInterface(const MultiComponentBoundTrackParameters &p)
0117 : BoundTrackParameters(p.referenceSurface().getSharedPtr(),
0118 p.parameters(), p.covariance(), electron),
0119 multi_pars(p) {}
0120
0121 operator MultiComponentBoundTrackParameters() const { return multi_pars; }
0122 };
0123
0124 auto makeParameters() {
0125
0126 Acts::BoundVector stddev;
0127 stddev[Acts::eBoundLoc0] = 100_um;
0128 stddev[Acts::eBoundLoc1] = 100_um;
0129 stddev[Acts::eBoundTime] = 25_ns;
0130 stddev[Acts::eBoundPhi] = 2_degree;
0131 stddev[Acts::eBoundTheta] = 2_degree;
0132 stddev[Acts::eBoundQOverP] = 1 / 100_GeV;
0133 Acts::BoundSquareMatrix cov = stddev.cwiseProduct(stddev).asDiagonal();
0134
0135
0136 Acts::Vector4 mPos4(-3_m, 0., 0., 42_ns);
0137 Acts::CurvilinearTrackParameters cp(mPos4, 0_degree, 90_degree, 1_e / 1_GeV,
0138 cov, electron);
0139
0140
0141 Acts::BoundVector deltaLOC0 = Acts::BoundVector::Zero();
0142 deltaLOC0[eBoundLoc0] = 0.5_mm;
0143
0144 Acts::BoundVector deltaLOC1 = Acts::BoundVector::Zero();
0145 deltaLOC1[eBoundLoc1] = 0.5_mm;
0146
0147 Acts::BoundVector deltaQOP = Acts::BoundVector::Zero();
0148 deltaQOP[eBoundQOverP] = 0.01_GeV;
0149
0150 std::vector<std::tuple<double, BoundVector, BoundSquareMatrix>> cmps = {
0151 {0.2, cp.parameters(), cov},
0152 {0.2, cp.parameters() + deltaLOC0 + deltaLOC1 + deltaQOP, cov},
0153 {0.2, cp.parameters() + deltaLOC0 - deltaLOC1 - deltaQOP, cov},
0154 {0.2, cp.parameters() - deltaLOC0 + deltaLOC1 + deltaQOP, cov},
0155 {0.2, cp.parameters() - deltaLOC0 - deltaLOC1 - deltaQOP, cov}};
0156
0157 return MultiCmpsParsInterface(MultiComponentBoundTrackParameters(
0158 cp.referenceSurface().getSharedPtr(), cmps, electron));
0159 }
0160
0161 }
0162
0163 BOOST_AUTO_TEST_SUITE(TrackFittingGsf)
0164
0165 BOOST_AUTO_TEST_CASE(ZeroFieldNoSurfaceForward) {
0166 auto multi_pars = makeParameters();
0167 auto options = makeDefaultGsfOptions();
0168
0169 tester.test_ZeroFieldNoSurfaceForward(gsfZero, options, multi_pars, rng, true,
0170 false, false);
0171 }
0172
0173 BOOST_AUTO_TEST_CASE(ZeroFieldWithSurfaceForward) {
0174 auto multi_pars = makeParameters();
0175 auto options = makeDefaultGsfOptions();
0176
0177 tester.test_ZeroFieldWithSurfaceForward(gsfZero, options, multi_pars, rng,
0178 true, false, false);
0179 }
0180
0181 BOOST_AUTO_TEST_CASE(ZeroFieldWithSurfaceBackward) {
0182 auto multi_pars = makeParameters();
0183 auto options = makeDefaultGsfOptions();
0184
0185 tester.test_ZeroFieldWithSurfaceBackward(gsfZero, options, multi_pars, rng,
0186 true, false, false);
0187 }
0188
0189 BOOST_AUTO_TEST_CASE(ZeroFieldWithSurfaceAtExit) {
0190 auto multi_pars = makeParameters();
0191 auto options = makeDefaultGsfOptions();
0192
0193 tester.test_ZeroFieldWithSurfaceBackward(gsfZero, options, multi_pars, rng,
0194 true, false, false);
0195 }
0196
0197 BOOST_AUTO_TEST_CASE(ZeroFieldShuffled) {
0198 auto multi_pars = makeParameters();
0199 auto options = makeDefaultGsfOptions();
0200
0201 tester.test_ZeroFieldShuffled(gsfZero, options, multi_pars, rng, true, false,
0202 false);
0203 }
0204
0205 BOOST_AUTO_TEST_CASE(ZeroFieldWithHole) {
0206 auto options = makeDefaultGsfOptions();
0207 auto multi_pars = makeParameters();
0208
0209 tester.test_ZeroFieldWithHole(gsfZero, options, multi_pars, rng, true, false,
0210 false);
0211 }
0212
0213 BOOST_AUTO_TEST_CASE(ZeroFieldWithOutliers) {
0214
0215
0216 TestOutlierFinder tof{5_mm};
0217 auto options = makeDefaultGsfOptions();
0218 options.extensions.outlierFinder
0219 .connect<&TestOutlierFinder::operator()<VectorMultiTrajectory>>(&tof);
0220
0221 auto multi_pars = makeParameters();
0222
0223 tester.test_ZeroFieldWithOutliers(gsfZero, options, multi_pars, rng, true,
0224 false, false);
0225 }
0226
0227 BOOST_AUTO_TEST_CASE(WithFinalMultiComponentState) {
0228 Acts::TrackContainer tracks{Acts::VectorTrackContainer{},
0229 Acts::VectorMultiTrajectory{}};
0230 using namespace Acts::GsfConstants;
0231 std::string key(kFinalMultiComponentStateColumn);
0232 tracks.template addColumn<FinalMultiComponentState>(key);
0233
0234 auto multi_pars = makeParameters();
0235 auto measurements =
0236 createMeasurements(tester.simPropagator, tester.geoCtx, tester.magCtx,
0237 multi_pars, tester.resolutions, rng);
0238 auto sourceLinks = tester.prepareSourceLinks(measurements.sourceLinks);
0239 auto options = makeDefaultGsfOptions();
0240
0241
0242 Acts::Vector3 center(-3._m, 0., 0.);
0243 Acts::Vector3 normal(1., 0., 0.);
0244 auto targetSurface = Acts::CurvilinearSurface(center, normal).planeSurface();
0245
0246 options.referenceSurface = targetSurface.get();
0247
0248 auto res = gsfZero.fit(sourceLinks.begin(), sourceLinks.end(), multi_pars,
0249 options, tracks);
0250
0251 BOOST_REQUIRE(res.ok());
0252 BOOST_CHECK(res->template component<FinalMultiComponentState>(
0253 kFinalMultiComponentStateColumn)
0254 .has_value());
0255 }
0256
0257 BOOST_AUTO_TEST_SUITE_END()