Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Factorize GX2F delta param calculation #2774

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading