Analysis Software
Documentation for sPHENIX simulation 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 
15 #include <algorithm>
16 
18  const FreeVector& freeParams, const Surface& surface,
20  // initialize the bound vector
21  BoundVector bp = BoundVector::Zero();
22  // convert global to local position on the surface
23  auto position = freeParams.segment<3>(eFreePos0);
24  auto direction = freeParams.segment<3>(eFreeDir0);
25  auto result = surface.globalToLocal(geoCtx, position, direction, tolerance);
26  if (!result.ok()) {
27  return Result<Acts::BoundVector>::failure(result.error());
28  }
29 
30  auto localPosition = result.value();
31  bp[eBoundLoc0] = localPosition[ePos0];
32  bp[eBoundLoc1] = localPosition[ePos1];
33 
34  bp[eBoundTime] = freeParams[eFreeTime];
35  bp[eBoundPhi] = VectorHelpers::phi(direction);
36  bp[eBoundTheta] = VectorHelpers::theta(direction);
37  bp[eBoundQOverP] = freeParams[eFreeQOverP];
39 }
40 
43  const Acts::Vector3& direction, ActsScalar qOverP,
46  // initialize the bound vector
47  BoundVector bp = BoundVector::Zero();
48  // convert global to local position on the surface
49  auto result = surface.globalToLocal(geoCtx, position, direction, tolerance);
50  if (!result.ok()) {
51  return Result<Acts::BoundVector>::failure(result.error());
52  }
53 
54  auto localPosition = result.value();
55  bp[eBoundLoc0] = localPosition[ePos0];
56  bp[eBoundLoc1] = localPosition[ePos1];
57 
58  bp[eBoundTime] = time;
59  bp[eBoundPhi] = VectorHelpers::phi(direction);
60  bp[eBoundTheta] = VectorHelpers::theta(direction);
61  bp[eBoundQOverP] = qOverP;
63 }
64 
67  BoundVector bp = BoundVector::Zero();
68  // local coordinates are zero by construction
69  bp[eBoundTime] = time;
70  bp[eBoundPhi] = phi;
71  bp[eBoundTheta] = theta;
72  bp[eBoundQOverP] = qOverP;
73  return bp;
74 }
75 
77  ActsScalar time, const Vector3& direction, ActsScalar qOverP) {
78  BoundVector bp = BoundVector::Zero();
79  // local coordinates are zero by construction
80  bp[eBoundTime] = time;
81  bp[eBoundPhi] = VectorHelpers::phi(direction);
82  bp[eBoundTheta] = VectorHelpers::theta(direction);
83  bp[eBoundQOverP] = qOverP;
84  return bp;
85 }