File indexing completed on 2026-01-09 09:25:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Definitions/Units.hpp"
0010
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/EventData/TrackParameters.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014
0015
0016
0017 void basicUnits() {
0018
0019
0020 double length = 1 * Acts::UnitConstants::m;
0021 double momentum = 100 * Acts::UnitConstants::MeV;
0022
0023
0024 double lengthInMm = length / Acts::UnitConstants::mm;
0025 double lengthInM = length / Acts::UnitConstants::m;
0026
0027 static_cast<void>(length);
0028 static_cast<void>(momentum);
0029 static_cast<void>(lengthInMm);
0030 static_cast<void>(lengthInM);
0031 }
0032
0033 void userLiterals() {
0034
0035 using namespace Acts::UnitLiterals;
0036
0037
0038 double length = 1_m;
0039 double momentum = 1.25_TeV;
0040
0041
0042 double lengthInUm = length / 1_um;
0043 double momentumInMeV = momentum / 1_MeV;
0044
0045 static_cast<void>(length);
0046 static_cast<void>(momentum);
0047 static_cast<void>(lengthInUm);
0048 static_cast<void>(momentumInMeV);
0049 }
0050
0051 void comprehensiveExample() {
0052
0053 using namespace Acts::UnitLiterals;
0054
0055
0056 double width = 12 * Acts::UnitConstants::mm;
0057 double mmuon = 105.7 * Acts::UnitConstants::MeV;
0058
0059
0060 double length = 23_cm;
0061 double time = 1214.2_ns;
0062 double angle = 123_degree;
0063 double particleMomentum = 2.5_TeV;
0064 double mass = 511_keV;
0065 double velocity = 345_m / 1_s;
0066 double bfield = 3.9_T;
0067
0068
0069
0070
0071 static_cast<void>(width);
0072 static_cast<void>(mmuon);
0073 static_cast<void>(length);
0074 static_cast<void>(time);
0075 static_cast<void>(angle);
0076 static_cast<void>(particleMomentum);
0077 static_cast<void>(mass);
0078 static_cast<void>(velocity);
0079 static_cast<void>(bfield);
0080 }
0081
0082 void outputConversion() {
0083 Acts::GeometryContext gctx;
0084 Acts::BoundTrackParameters trackPars =
0085 Acts::BoundTrackParameters::createCurvilinear(
0086 Acts::Vector4::Zero(), Acts::Vector3::UnitX(), 1, std::nullopt,
0087 Acts::ParticleHypothesis::pion());
0088
0089 using namespace Acts::UnitLiterals;
0090
0091
0092
0093
0094
0095 double t_in_ns = trackPars.time() / Acts::UnitConstants::ns;
0096
0097
0098 double x_in_mm = trackPars.position(gctx)[Acts::eBoundLoc0] / 1_mm;
0099 double p_in_TeV = trackPars.absoluteMomentum() / 1_TeV;
0100
0101 static_cast<void>(t_in_ns);
0102 static_cast<void>(x_in_mm);
0103 static_cast<void>(p_in_TeV);
0104 }
0105
0106 void physicalConstants() {
0107
0108
0109 constexpr double c = Acts::PhysicalConstants::c;
0110
0111
0112
0113 constexpr double hbar = Acts::PhysicalConstants::hbar;
0114
0115 static_cast<void>(c);
0116 static_cast<void>(hbar);
0117 }
0118
0119 void goodPractice() {
0120
0121 using namespace Acts::UnitLiterals;
0122
0123
0124 double momentum = 100 * Acts::UnitConstants::GeV;
0125 double distance = 5 * Acts::UnitConstants::m;
0126
0127
0128 double momentumInMeV = 10.0;
0129
0130
0131 double energyGeV = 100.0;
0132
0133
0134 double output_in_meters = distance / 1_m;
0135
0136 static_cast<void>(momentum);
0137 static_cast<void>(momentumInMeV);
0138 static_cast<void>(energyGeV);
0139 static_cast<void>(output_in_meters);
0140 }