Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CovarianceTransport.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CovarianceTransport.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
12 
14  const Surface& surface,
15  const Vector3& position,
16  const BoundVector& boundParameters,
17  const BoundSquareMatrix& boundCovariance)
18  : applyTransport(true), atSurface(&surface), atPosition(position) {
19  covariance.template emplace<BoundSquareMatrix>(boundCovariance);
20  boundToFreeJacobian = surface.boundToFreeJacobian(gctx, boundParameters);
21 }
22 
24  const Vector3& direction,
25  const BoundSquareMatrix& boundCovariance)
26  : applyTransport(true), atPosition(position) {
27  covariance.emplace<BoundSquareMatrix>(boundCovariance);
29 }
30 
32  const FreeSquareMatrix& freeCovariance)
33  : applyTransport(true), atPosition(freeParameters.segment<3>(eFreePos0)) {
34  covariance.emplace<FreeSquareMatrix>(freeCovariance);
36  detail::anglesToDirectionJacobian(freeParameters.segment<3>(eFreeDir0));
38  detail::directionToAnglesJacobian(freeParameters.segment<3>(eFreeDir0));
39 }
40 
41 std::tuple<Acts::VariantCovariance, Acts::VariantTransportJacobian>
43  const Surface& surface,
44  const FreeVector& freeParameters,
45  CovarianceCache& cCache) {
46  if (cCache.boundToFreeJacobian.has_value()) {
47  // Create the full transport jacobian: bound/curvilinear to bound
48  const auto ftJacobian = detail::boundToBoundTransportJacobian(
49  gctx, freeParameters, cCache.boundToFreeJacobian.value(),
51  // Perform the transport
52  const auto& covariance = std::get<BoundSquareMatrix>(cCache.covariance);
53  BoundSquareMatrix newCovariance =
54  ftJacobian * covariance * ftJacobian.transpose();
55  return {newCovariance, ftJacobian};
56  } else {
57  // Create the full transport jacobian: free to bound
58  const auto ftJacobian = detail::freeToBoundTransportJacobian(
59  gctx, freeParameters, cCache.directionToAnglesJacobian.value(),
60  cCache.anglesToDirectionJacobian.value(), cCache.freeTransportJacobian,
62  // Perform the transport
63  const auto& covariance = std::get<FreeSquareMatrix>(cCache.covariance);
64  BoundSquareMatrix newCovariance =
65  ftJacobian * covariance * ftJacobian.transpose();
66  return {newCovariance, ftJacobian};
67  }
68 }
69 
70 std::tuple<Acts::VariantCovariance, Acts::VariantTransportJacobian>
72  CovarianceCache& cCache) {
73  if (cCache.boundToFreeJacobian.has_value()) {
74  // Create the full transport jacobian: bound/curvilinear to
75  // curvilinear
77  direction, cCache.boundToFreeJacobian.value(),
79  // Perform the transport
80  const auto& covariance = std::get<BoundSquareMatrix>(cCache.covariance);
81  BoundSquareMatrix newCovariance =
82  ftJacobian * covariance * ftJacobian.transpose();
83  return {newCovariance, ftJacobian};
84  } else {
85  // Create the full transport jacobian: free to curvilinear
86  const auto ftJacobian = detail::freeToCurvilinearTransportJacobian(
87  direction, cCache.directionToAnglesJacobian.value(),
88  cCache.anglesToDirectionJacobian.value(), cCache.freeTransportJacobian,
89  cCache.freeToPathDerivatives);
90  // Perform the transport
91  const auto& covariance = std::get<FreeSquareMatrix>(cCache.covariance);
92  BoundSquareMatrix newCovariance =
93  ftJacobian * covariance * ftJacobian.transpose();
94  return {newCovariance, ftJacobian};
95  }
96 }
97 
98 std::tuple<Acts::VariantCovariance, Acts::VariantTransportJacobian>
100  if (cCache.boundToFreeJacobian.has_value()) {
101  // Create the full transport jacobian: bound/curvilinear to free
102  const auto ftJacobian = detail::boundToFreeTransportJacobian(
103  cCache.boundToFreeJacobian.value(), cCache.freeTransportJacobian);
104  // Perform the transport
105  const auto& covariance = std::get<BoundSquareMatrix>(cCache.covariance);
106  FreeSquareMatrix newCovariance =
107  ftJacobian * covariance * ftJacobian.transpose();
108  return {newCovariance, ftJacobian};
109  } else {
110  // Create the full transport jacobian: free to free
111  const auto ftJacobian = detail::freeToFreeTransportJacobian(
112  cCache.directionToAnglesJacobian.value(),
113  cCache.anglesToDirectionJacobian.value(), cCache.freeTransportJacobian);
114  // Perform the transport
115  const auto& covariance = std::get<FreeSquareMatrix>(cCache.covariance);
116  FreeSquareMatrix newCovariance =
117  ftJacobian * covariance * ftJacobian.transpose();
118  return {newCovariance, ftJacobian};
119  }
120 }