Skip to content

Commit

Permalink
refactor: Factorize GX2F delta param calculation (#2774)
Browse files Browse the repository at this point in the history
This allows compiling the fairly expensive `colPivHouseholderQr` expression to be compiled in a separate translation unit.
  • Loading branch information
paulgessinger authored Dec 6, 2023
1 parent a8a0576 commit 12de1e2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
20 changes: 6 additions & 14 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ void collector(typename traj_t::TrackStateProxy& trackStateProxy,
}
}

BoundVector calculateDeltaParams(bool zeroField, const BoundMatrix& aMatrix,
const BoundVector& bVector);

/// Global Chi Square fitter (GX2F) implementation.
///
/// @tparam propagator_t Type of the propagation class
Expand Down Expand Up @@ -718,20 +721,8 @@ class Gx2Fitter {
}

// calculate delta params [a] * delta = b
deltaParams = BoundVector::Zero();
if (gx2fOptions.zeroField) {
constexpr std::size_t reducedMatrixSize = 4;
deltaParams.topLeftCorner<reducedMatrixSize, 1>() =
aMatrix.topLeftCorner<reducedMatrixSize, reducedMatrixSize>()
.colPivHouseholderQr()
.solve(bVector.topLeftCorner<reducedMatrixSize, 1>());
} else {
constexpr std::size_t reducedMatrixSize = 5;
deltaParams.topLeftCorner<reducedMatrixSize, 1>() =
aMatrix.topLeftCorner<reducedMatrixSize, reducedMatrixSize>()
.colPivHouseholderQr()
.solve(bVector.topLeftCorner<reducedMatrixSize, 1>());
}
deltaParams =
calculateDeltaParams(gx2fOptions.zeroField, aMatrix, bVector);

ACTS_VERBOSE("aMatrix:\n"
<< aMatrix << "\n"
Expand Down Expand Up @@ -822,5 +813,6 @@ class Gx2Fitter {
return track;
}
};

} // namespace Experimental
} // namespace Acts
1 change: 1 addition & 0 deletions Core/src/TrackFitting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ target_sources(
GsfUtils.cpp
BetheHeitlerApprox.cpp
GsfMixtureReduction.cpp
GlobalChiSquareFitter.cpp
)
34 changes: 34 additions & 0 deletions Core/src/TrackFitting/GlobalChiSquareFitter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "Acts/TrackFitting/GlobalChiSquareFitter.hpp"

#include "Acts/Definitions/TrackParametrization.hpp"

namespace Acts::Experimental {

BoundVector calculateDeltaParams(bool zeroField, const BoundMatrix& aMatrix,
const BoundVector& bVector) {
BoundVector deltaParams = BoundVector::Zero();
if (zeroField) {
constexpr std::size_t reducedMatrixSize = 4;
deltaParams.topLeftCorner<reducedMatrixSize, 1>() =
aMatrix.topLeftCorner<reducedMatrixSize, reducedMatrixSize>()
.colPivHouseholderQr()
.solve(bVector.topLeftCorner<reducedMatrixSize, 1>());
} else {
constexpr std::size_t reducedMatrixSize = 5;
deltaParams.topLeftCorner<reducedMatrixSize, 1>() =
aMatrix.topLeftCorner<reducedMatrixSize, reducedMatrixSize>()
.colPivHouseholderQr()
.solve(bVector.topLeftCorner<reducedMatrixSize, 1>());
}

return deltaParams;
}
} // namespace Acts::Experimental

0 comments on commit 12de1e2

Please sign in to comment.