ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
coordinate_transformations.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file coordinate_transformations.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2019 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 
9 #pragma once
10 
11 #include <cmath>
15 
16 #ifdef ACTS_COORDINATE_TRANSFORM_PLUGIN
17 
18 #include ACTS_COORDINATE_TRANSFORM_PLUGIN
19 
20 #else
21 
22 namespace Acts {
24 namespace detail {
25 
28 struct coordinate_transformation {
29  using ParVector_t = BoundVector;
30 
43  static ActsVectorD<3> parameters2globalPosition(const GeometryContext& gctx,
44  const ParVector_t& pars,
45  const Surface& s) {
46  ActsVectorD<3> globalPosition;
47  s.localToGlobal(gctx,
48  ActsVectorD<2>(pars(Acts::eLOC_0), pars(Acts::eLOC_1)),
49  parameters2globalMomentum(pars), globalPosition);
50  return globalPosition;
51  }
52 
62  static ActsVectorD<3> parameters2globalMomentum(const ParVector_t& pars) {
63  ActsVectorD<3> momentum;
64  double p = std::abs(1. / pars(Acts::eQOP));
65  double phi = pars(Acts::ePHI);
66  double theta = pars(Acts::eTHETA);
67  momentum << p * sin(theta) * cos(phi), p * sin(theta) * sin(phi),
68  p * cos(theta);
69 
70  return momentum;
71  }
72 
84  static ParVector_t global2curvilinear(const ActsVectorD<3>& /*pos*/,
85  const ActsVectorD<3>& mom,
86  double charge, double time) {
87  using VectorHelpers::phi;
89  ParVector_t parameters;
90  parameters << 0, 0, phi(mom), theta(mom),
91  ((std::abs(charge) < 1e-4) ? 1. : charge) / mom.norm(), time;
92 
93  return parameters;
94  }
95 
110  static ParVector_t global2parameters(const GeometryContext& gctx,
111  const ActsVectorD<3>& pos,
112  const ActsVectorD<3>& mom, double charge,
113  double time, const Surface& s) {
114  using VectorHelpers::phi;
115  using VectorHelpers::theta;
116  ActsVectorD<2> localPosition;
117  s.globalToLocal(gctx, pos, mom, localPosition);
118  ParVector_t result;
119  result << localPosition(0), localPosition(1), phi(mom), theta(mom),
120  ((std::abs(charge) < 1e-4) ? 1. : charge) / mom.norm(), time;
121  return result;
122  }
123 
127  static double parameters2charge(const ParVector_t& pars) {
128  return (pars(Acts::eQOP) > 0) ? 1. : -1.;
129  }
130 };
131 } // namespace detail
133 } // namespace Acts
134 
135 #endif // ACTS_COORDINATE_TRANSFORM_PLUGIN