Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-05 08:17:26

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 
0013 namespace Acts::detail::sympy {
0014 
0015 // Scaling convention for the q/p column of the bound-to-free jacobian.
0016 //
0017 // While stepping, the sympy stepper differentiates the free parameters by the
0018 // log of the *current* q/p rather than by the starting q/p:
0019 //
0020 //     scaled(i, eBoundQOverP) = d(free_i) / d(log|q/p|)
0021 //                             = qOverP * plain(i, eBoundQOverP)
0022 //                                      / plain(eFreeQOverP, eBoundQOverP)
0023 //
0024 // The q/p row itself stays plain, which is what makes the conversion exact both
0025 // ways. Why the stepper wants this form: @ref sympy_codegen.
0026 //
0027 // A freshly initialized surface jacobian has e_qop as its q/p column, so
0028 // scaling it is a no-op; code that writes one into the state directly
0029 // (LoopComponentProxy::update) needs no conversion. Singular at q/p == 0, as
0030 // the plain column already is.
0031 
0032 /// Convert a plain bound-to-free jacobian to the scaled form.
0033 ///
0034 /// @param [in,out] jacobian jacobian to convert in place
0035 /// @param [in] qOverP the current q/p
0036 inline void toScaledBoundToFree(BoundToFreeMatrix& jacobian, double qOverP) {
0037   jacobian.block<eFreeQOverP, 1>(0, eBoundQOverP) *=
0038       qOverP / jacobian(eFreeQOverP, eBoundQOverP);
0039 }
0040 
0041 /// Recover the plain bound-to-free jacobian from the scaled form.
0042 ///
0043 /// @param [in,out] jacobian jacobian to convert in place
0044 /// @param [in] qOverP the q/p the column is scaled against
0045 inline void fromScaledBoundToFree(BoundToFreeMatrix& jacobian, double qOverP) {
0046   jacobian.block<eFreeQOverP, 1>(0, eBoundQOverP) *=
0047       jacobian(eFreeQOverP, eBoundQOverP) / qOverP;
0048 }
0049 
0050 /// Move a scaled column onto a new q/p, leaving the plain jacobian it stands
0051 /// for unchanged. Needed whenever q/p changes outside the step kernel.
0052 ///
0053 /// @param [in,out] jacobian jacobian to rescale in place
0054 /// @param [in] oldQOverP the q/p the column is scaled against
0055 /// @param [in] newQOverP the q/p to scale it against instead
0056 inline void rescaleBoundToFree(BoundToFreeMatrix& jacobian, double oldQOverP,
0057                                double newQOverP) {
0058   jacobian.block<eFreeQOverP, 1>(0, eBoundQOverP) *= newQOverP / oldQOverP;
0059 }
0060 
0061 }  // namespace Acts::detail::sympy