Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:30

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/EventData/MultiTrajectory.hpp"
0014 #include "Acts/EventData/SourceLink.hpp"
0015 #include "Acts/EventData/TrackStatePropMask.hpp"
0016 #include "Acts/EventData/VectorMultiTrajectory.hpp"
0017 #include "Acts/EventData/detail/TestSourceLink.hpp"
0018 #include "Acts/Geometry/GeometryContext.hpp"
0019 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0020 #include "Acts/TrackFitting/GainMatrixUpdater.hpp"
0021 #include "Acts/Utilities/CalibrationContext.hpp"
0022 #include "Acts/Utilities/Result.hpp"
0023 
0024 #include <algorithm>
0025 #include <cmath>
0026 #include <utility>
0027 
0028 namespace {
0029 
0030 using namespace Acts;
0031 using namespace Acts::Test;
0032 using namespace Acts::detail::Test;
0033 
0034 using ParametersVector = Acts::BoundVector;
0035 using CovarianceMatrix = Acts::BoundSquareMatrix;
0036 using Jacobian = Acts::BoundMatrix;
0037 
0038 constexpr double tol = 1e-6;
0039 const Acts::GeometryContext tgContext;
0040 
0041 }  // namespace
0042 
0043 BOOST_AUTO_TEST_SUITE(TrackFittingGainMatrixUpdater)
0044 
0045 BOOST_AUTO_TEST_CASE(Update) {
0046   // Make dummy measurement
0047   Vector2 measPar(-0.1, 0.45);
0048   SquareMatrix2 measCov = Vector2(0.04, 0.1).asDiagonal();
0049   auto sourceLink = TestSourceLink(eBoundLoc0, eBoundLoc1, measPar, measCov);
0050 
0051   // Make dummy track parameters
0052   ParametersVector trkPar;
0053   trkPar << 0.3, 0.5, 0.5 * M_PI, 0.3 * M_PI, 0.01, 0.;
0054   CovarianceMatrix trkCov = CovarianceMatrix::Zero();
0055   trkCov.diagonal() << 0.08, 0.3, 1, 1, 1, 0;
0056 
0057   // Make trajectory w/ one state
0058   VectorMultiTrajectory traj;
0059   auto idx = traj.addTrackState(TrackStatePropMask::All);
0060   auto ts = traj.getTrackState(idx);
0061 
0062   // Fill the state w/ the dummy information
0063   ts.predicted() = trkPar;
0064   ts.predictedCovariance() = trkCov;
0065   ts.pathLength() = 0.;
0066   BOOST_CHECK(!ts.hasUncalibratedSourceLink());
0067   testSourceLinkCalibrator<VectorMultiTrajectory>(
0068       tgContext, CalibrationContext{}, SourceLink{std::move(sourceLink)}, ts);
0069   BOOST_CHECK(ts.hasUncalibratedSourceLink());
0070 
0071   // Check that the state has storage available
0072   BOOST_CHECK(ts.hasPredicted());
0073   BOOST_CHECK(ts.hasFiltered());
0074   BOOST_CHECK(ts.hasCalibrated());
0075 
0076   // Gain matrix update and filtered state
0077   BOOST_CHECK(GainMatrixUpdater()
0078                   .
0079                   operator()<VectorMultiTrajectory>(tgContext, ts)
0080                   .ok());
0081 
0082   // Check for regression. This does NOT test if the math is correct, just that
0083   // the result is the same as when the test was written.
0084 
0085   ParametersVector expPar;
0086   expPar << 0.0333333, 0.4625000, 1.5707963, 0.9424778, 0.0100000, 0.0000000;
0087   CHECK_CLOSE_ABS(ts.filtered(), expPar, tol);
0088 
0089   CovarianceMatrix expCov = CovarianceMatrix::Zero();
0090   expCov.diagonal() << 0.0266667, 0.0750000, 1.0000000, 1.0000000, 1.0000000,
0091       0.0000000;
0092   CHECK_CLOSE_ABS(ts.filteredCovariance(), expCov, tol);
0093 
0094   CHECK_CLOSE_ABS(ts.chi2(), 1.33958, 1e-4);
0095 }
0096 
0097 BOOST_AUTO_TEST_SUITE_END()