ATLAS Offline Software
Loading...
Searching...
No Matches
UnitConverters.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef ACTSINTEROPS_UNITCONVERTER_H
5#define ACTSINTEROPS_UNITCONVERTER_H
6
7
9#include "GaudiKernel/SystemOfUnits.h"
11
12#include "Acts/Definitions/Units.hpp"
13#include "Acts/Definitions/Algebra.hpp"
14#include "Acts/Definitions/Common.hpp"
15
16#include <utility>
17
18namespace ActsTrk{
21 inline constexpr double energyToActs(const double athenaE) {
22 using namespace Acts::UnitLiterals;
23 constexpr double energyCnv = 1_MeV / Gaudi::Units::MeV;
24 return energyCnv * athenaE;
25 }
26
28 inline constexpr double energyToAthena(const double actsE) {
29 using namespace Acts::UnitLiterals;
30 constexpr double energyCnv = Gaudi::Units::MeV / 1_MeV;
31 return energyCnv * actsE;
32 }
33
35 inline constexpr double lengthToActs(const double athenaL) {
36 using namespace Acts::UnitLiterals;
37 constexpr double lengthCnv = 1_mm / Gaudi::Units::mm;
38 return lengthCnv * athenaL;
39 }
40
42 inline constexpr double lengthToAthena(const double actsL) {
43 using namespace Acts::UnitLiterals;
44 constexpr double lengthCnv = Gaudi::Units::mm / 1_mm;
45 return lengthCnv * actsL;
46 }
47
49 inline constexpr double timeToActs(const double athenaT) {
50 using namespace Acts::UnitLiterals;
51 constexpr double timeCnv = 1_ns / Gaudi::Units::ns;
52 return timeCnv * athenaT;
53 }
54
56 inline constexpr double timeToAthena(const double actsT) {
57 using namespace Acts::UnitLiterals;
58 constexpr double timeCnv = Gaudi::Units::ns/ 1_ns;
59 return timeCnv * actsT;
60 }
61
63 inline Acts::Vector3 convertDirToActs(const Amg::Vector3D& athenaDir) {
64 return athenaDir;
65 }
66
68 inline Amg::Vector3D convertDirFromActs(const Acts::Vector3& actsDir) {
69 return actsDir;
70 }
71
74 inline Acts::Vector4 convertPosToActs(const Amg::Vector3D& athenaPos,
75 const double athenaTime =0.) {
76 Acts::Vector4 pos{Acts::Vector4::Zero()};
77 pos[Acts::eTime] = timeToActs(athenaTime);
78 pos[Acts::ePos0] = lengthToActs(athenaPos.x());
79 pos[Acts::ePos1] = lengthToActs(athenaPos.y());
80 pos[Acts::ePos2] = lengthToActs(athenaPos.z());
81 return pos;
82 }
83
86 inline std::pair<Amg::Vector3D, double> convertPosFromActs(const Acts::Vector4& actsPos) {
87 Amg::Vector3D pos{Amg::Vector3D::Zero()};
88 pos[Amg::x] = lengthToAthena(actsPos[Acts::ePos0]);
89 pos[Amg::y] = lengthToAthena(actsPos[Acts::ePos1]);
90 pos[Amg::z] = lengthToAthena(actsPos[Acts::ePos2]);
91 return std::make_pair(std::move(pos), timeToAthena(actsPos[Acts::eTime]));
92 }
93
97 inline Acts::Vector4 convertMomToActs(const Amg::Vector3D& threeMom, const double mass = 0.) {
98 using namespace Acts::UnitLiterals;
99 Acts::Vector4 fourMom{Acts::Vector4::Zero()};
100 fourMom[Acts::eEnergy] = energyToActs(std::sqrt(threeMom.dot(threeMom) + mass*mass));
101 fourMom[Acts::eMom0] = energyToActs(threeMom.x());
102 fourMom[Acts::eMom1] = energyToActs(threeMom.y());
103 fourMom[Acts::eMom2] = energyToActs(threeMom.z());
104 return fourMom;
105 }
106
109 inline std::pair<Amg::Vector3D, double> convertMomFromActs(const Acts::Vector4& actsMom) {
110 Amg::Vector3D threeMom{Amg::Vector3D::Zero()};
111 threeMom[Amg::x] = energyToAthena(actsMom[Acts::eMom0]);
112 threeMom[Amg::y] = energyToAthena(actsMom[Acts::eMom1]);
113 threeMom[Amg::z] = energyToAthena(actsMom[Acts::eMom2]);
114 return std::make_pair(std::move(threeMom), energyToAthena(actsMom[Acts::eEnergy]));
115 }
116}
117#endif
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
constexpr double energyToActs(const double athenaE)
Converts an energy scalar from Athena to Acts units.
constexpr double timeToAthena(const double actsT)
Converts a time unit from Acts to Athena units.
constexpr double lengthToActs(const double athenaL)
Converts a length scalar from Acts to Athena units.
Amg::Vector3D convertDirFromActs(const Acts::Vector3 &actsDir)
Converts a direction vector from acts units into athena units.
constexpr double energyToAthena(const double actsE)
Converts an energy scalar from Acts to Athena units.
std::pair< Amg::Vector3D, double > convertMomFromActs(const Acts::Vector4 &actsMom)
Converts an Acts four-momentum vector into an pair of an Athena three-momentum and the paritcle's ene...
std::pair< Amg::Vector3D, double > convertPosFromActs(const Acts::Vector4 &actsPos)
Converts an Acts 4-vector into a pair of an Athena spatial vector and the passed time.
constexpr double lengthToAthena(const double actsL)
Converts a length scalar from Acts to Athena units.
constexpr double timeToActs(const double athenaT)
Converts a time unit from Athena to Acts units.
Acts::Vector4 convertMomToActs(const Amg::Vector3D &threeMom, const double mass=0.)
Converts a three momentum vector from Athena together with the associated particle mass into an Acts ...
Acts::Vector3 convertDirToActs(const Amg::Vector3D &athenaDir)
Converts a direction vector from athena units into acts units.
Acts::Vector4 convertPosToActs(const Amg::Vector3D &athenaPos, const double athenaTime=0.)
Converts a position vector & time from Athena units into Acts units.
Eigen::Matrix< double, 3, 1 > Vector3D