Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:41

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2021-2024 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 "Acts/TrackFinding/MeasurementSelector.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/EventData/MeasurementHelpers.hpp"
0013 
0014 #include <algorithm>
0015 
0016 namespace Acts {
0017 
0018 MeasurementSelector::MeasurementSelector()
0019     : m_config{{GeometryIdentifier(), MeasurementSelectorCuts{}}} {}
0020 
0021 MeasurementSelector::MeasurementSelector(const MeasurementSelectorCuts& cuts)
0022     : m_config{{GeometryIdentifier(), cuts}} {}
0023 
0024 MeasurementSelector::MeasurementSelector(Config config)
0025     : m_config(std::move(config)) {}
0026 
0027 double MeasurementSelector::calculateChi2(
0028     const double* fullCalibrated, const double* fullCalibratedCovariance,
0029     TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0030                      false>::Parameters predicted,
0031     TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0032                      false>::Covariance predictedCovariance,
0033     TrackStateTraits<MultiTrajectoryTraits::MeasurementSizeMax,
0034                      false>::Projector projector,
0035     unsigned int calibratedSize) const {
0036   return visit_measurement(
0037       calibratedSize,
0038       [&fullCalibrated, &fullCalibratedCovariance, &predicted,
0039        &predictedCovariance, &projector](auto N) -> double {
0040         constexpr std::size_t kMeasurementSize = decltype(N)::value;
0041 
0042         typename TrackStateTraits<kMeasurementSize, true>::Measurement
0043             calibrated{fullCalibrated};
0044 
0045         typename TrackStateTraits<kMeasurementSize, true>::MeasurementCovariance
0046             calibratedCovariance{fullCalibratedCovariance};
0047 
0048         using ParametersVector = ActsVector<kMeasurementSize>;
0049 
0050         // Take the projector (measurement mapping function)
0051         const auto H =
0052             projector.template topLeftCorner<kMeasurementSize, eBoundSize>()
0053                 .eval();
0054 
0055         // Get the residuals
0056         ParametersVector res = calibrated - H * predicted;
0057 
0058         // Get the chi2
0059         return (res.transpose() *
0060                 (calibratedCovariance + H * predictedCovariance * H.transpose())
0061                     .inverse() *
0062                 res)
0063             .eval()(0, 0);
0064       });
0065 }
0066 
0067 }  // namespace Acts