EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransformationFreeToBound.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TransformationFreeToBound.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 
14 
16  const FreeVector& freeParams, const Surface& surface,
17  const GeometryContext& geoCtx) {
18  // initialize the bound vector
19  BoundVector bp = BoundVector::Zero();
20  // convert global to local position on the surface
21  auto position = freeParams.segment<3>(eFreePos0);
22  auto direction = freeParams.segment<3>(eFreeDir0);
23  auto result = surface.globalToLocal(geoCtx, position, direction);
24  if (result.ok()) {
25  auto localPosition = result.value();
26  bp[eBoundLoc0] = localPosition[ePos0];
27  bp[eBoundLoc1] = localPosition[ePos1];
28  } else {
30  Acts::getDefaultLogger("ParameterTransformation", Logging::INFO));
31  ACTS_FATAL(
32  "Inconsistency in global to local transformation from free to bound.")
33  }
34  bp[eBoundTime] = freeParams[eFreeTime];
35  bp[eBoundPhi] = VectorHelpers::phi(direction);
36  bp[eBoundTheta] = VectorHelpers::theta(direction);
37  bp[eBoundQOverP] = freeParams[eFreeQOverP];
38  return bp;
39 }
40 
43  const Acts::Vector3D& direction, FreeScalar qOverP,
45  // initialize the bound vector
46  BoundVector bp = BoundVector::Zero();
47  // convert global to local position on the surface
48  auto result = surface.globalToLocal(geoCtx, position, direction);
49  if (result.ok()) {
50  auto localPosition = result.value();
51  bp[eBoundLoc0] = localPosition[ePos0];
52  bp[eBoundLoc1] = localPosition[ePos1];
53  } else {
55  Acts::getDefaultLogger("ParameterTransformation", Logging::INFO));
56  ACTS_FATAL(
57  "Inconsistency in global to local transformation from free to bound.")
58  }
59  bp[eBoundTime] = time;
60  bp[eBoundPhi] = VectorHelpers::phi(direction);
61  bp[eBoundTheta] = VectorHelpers::theta(direction);
62  bp[eBoundQOverP] = qOverP;
63  return bp;
64 }
65 
68  BoundVector bp = BoundVector::Zero();
69  // local coordinates are zero by construction
70  bp[eBoundTime] = time;
71  bp[eBoundPhi] = phi;
72  bp[eBoundTheta] = theta;
73  bp[eBoundQOverP] = qOverP;
74  return bp;
75 }
76 
78  FreeScalar time, const Vector3D& direction, FreeScalar qOverP) {
79  BoundVector bp = BoundVector::Zero();
80  // local coordinates are zero by construction
81  bp[eBoundTime] = time;
82  bp[eBoundPhi] = VectorHelpers::phi(direction);
83  bp[eBoundTheta] = VectorHelpers::theta(direction);
84  bp[eBoundQOverP] = qOverP;
85  return bp;
86 }