Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:20

0001 // -*- C++ -*-
0002 //
0003 // Unitsystem.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad, David Grellscheid
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef ThePEG_Units_H
0010 #define ThePEG_Units_H
0011 
0012 #include "ThePEG/Vectors/Lorentz5Vector.fh"
0013 #include "ThePEG/Vectors/LorentzVector.fh"
0014 #include "ThePEG/Vectors/ThreeVector.fh"
0015 #include "ThePEG/Vectors/Transverse.fh"
0016 
0017 #include "PhysicalQty.h"
0018 #include "PhysicalQtyOps.h"
0019 #include "PhysicalQtyComplex.h"
0020 
0021 
0022 namespace ThePEG {
0023 
0024 /**
0025  * The Units namespace contains the declaration of a number of classes
0026  * for variables with dimension. Currently they are all typedefs of
0027  * double, but in the future the SIUnits package will be used.
0028  *
0029  * The file Utilities/UnitIO.h defines helper-classes and helper
0030  * functions to read and write variables with dimensions. As an
0031  * example, to read and write an energy variable <code>e</code> in
0032  * units of GeV, use: <code>os << ounit(e, GeV)</code> and <code>is >>
0033  * iunit(e, GeV)</code>
0034 */
0035 namespace Units {
0036 
0037 /// adapter for the old style of naming quantities
0038 template<long int L, long int E, long int Q, long int DL=1, long int DE=1, long int DQ=1>
0039 using Qty = ThePEG::Qty<std::ratio<L,DL>, std::ratio<E,DE>, std::ratio<Q,DQ>>;
0040 
0041 /** Energy. */
0042 typedef Qty<0,1,0> Energy;
0043 
0044 /** Mass has the same unit as Energy <=> c == 1. */
0045 typedef Energy Mass;
0046 
0047 /** Length. */
0048 typedef Qty<1,0,0> Length;
0049 
0050 /** Time has the same unit as Length. <=> c == 1. */
0051 typedef Length Time;
0052 
0053 /** Inverse Length. */
0054 typedef Qty<-1,0,0> InvLength;
0055 
0056 /** Velocities are dimensionless fractions of c. */
0057 typedef double Velocity;
0058 
0059 /** Charge. */
0060 typedef Qty<0,0,1> Charge;
0061 
0062 /** Angular momentum. */
0063 typedef Qty<1,1,0> AngularMomentum;
0064 
0065 /** Tension. */
0066 typedef Qty<-1,1,0> Tension;
0067 
0068 /** Area will be assumed to be Length\f$^2\f$. */
0069 typedef Qty<2,0,0> Area;
0070 
0071 /** Inverse Area. */
0072 typedef Qty<-2,0,0> InvArea;
0073 
0074 /** Cross section is an area. */
0075 typedef Area CrossSection;
0076 
0077 /**
0078  * @name Higher powers of energy.
0079  * Even higher powers can be created with similar typedefs.
0080  */
0081 //@{
0082 typedef Qty<0, 2, 0> Energy2;
0083 typedef Qty<0, 3, 0> Energy3;
0084 typedef Qty<0, 4, 0> Energy4;
0085 typedef Qty<0, 5, 0> Energy5;
0086 typedef Qty<0, 6, 0> Energy6;
0087 typedef Qty<0, 7, 0> Energy7;
0088 typedef Qty<0, 8, 0> Energy8;
0089 typedef Qty<0, 9, 0> Energy9;
0090 typedef Qty<0,10, 0> Energy10;
0091 typedef Qty<0,11, 0> Energy11;
0092 typedef Qty<0,12, 0> Energy12;
0093 
0094 typedef Qty<0, 1,0, 1,2,1> SqrtEnergy;
0095 typedef Qty<0,-1,0, 1,2,1> InvSqrtEnergy;
0096 
0097 typedef Qty<0, -1, 0> InvEnergy;
0098 typedef Qty<0, -2, 0> InvEnergy2;
0099 typedef Qty<0, -3, 0> InvEnergy3;
0100 typedef Qty<0, -4, 0> InvEnergy4;
0101 typedef Qty<0, -5, 0> InvEnergy5;
0102 typedef Qty<0, -6, 0> InvEnergy6;
0103 typedef Qty<0, -7, 0> InvEnergy7;
0104 typedef Qty<0, -8, 0> InvEnergy8;
0105 typedef Qty<0, -9, 0> InvEnergy9;
0106 typedef Qty<0,-10, 0> InvEnergy10;
0107 typedef Qty<0,-11, 0> InvEnergy11;
0108 typedef Qty<0,-12, 0> InvEnergy12;
0109 //@}
0110 
0111 /** CrossSection*Energy2. */
0112 typedef Qty<2,2,0> Energy2XSec;
0113 
0114 /** CrossSection/Energy2. */
0115 typedef Qty<2,-2,0> DiffXSec;
0116 
0117 /** CrossSection/Energy4. */
0118 typedef Qty<2,-4,0> Diff2XSec;
0119 
0120 /** CrossSection/Energy6 */
0121 typedef Qty<2,-6,0> Diff3XSec;
0122 
0123 /** Scale is the same as a squared energy. */
0124 typedef Energy2 Scale;
0125 
0126 /** A point in three-dimensional euclidean space. */
0127 typedef ThreeVector<Length> Point;
0128 
0129 /** A distance in three-dimensional euclidean space. */
0130 typedef ThreeVector<Length> Distance;
0131 
0132 /** A direction in three-dimensional euclidean space. */
0133 typedef ThreeVector<double> Axis;
0134 
0135 /** A momentum in three-dimensional euclidean space. */
0136 typedef ThreeVector<Energy> Momentum3;
0137 
0138 /** A three-dimensional boost vector. */
0139 typedef ThreeVector<double> Boost;
0140 
0141 /** A distance in four-dimensional space-time. */
0142 typedef LorentzVector<Length> LorentzDistance;
0143 
0144 /** A distance in four-dimensional space-time with an explicit
0145  *  invariant time component. */
0146 typedef Lorentz5Vector<Length> Lorentz5Distance;
0147 
0148 /** A point in four-dimensional space-time. */
0149 typedef LorentzVector<Length> LorentzPoint;
0150 
0151 /** A momentum in four-dimensional space-time. */
0152 typedef LorentzVector<Energy> LorentzMomentum;
0153 
0154 /** A momentum in four-dimensional space-time with an explicit
0155  *  invariant mass component. */
0156 typedef Lorentz5Vector<Energy> Lorentz5Momentum;
0157 
0158 /** Transverse components of a momentum. */
0159 typedef Transverse<Energy> TransverseMomentum;
0160 
0161 /// @name Pre-defined basic units.
0162 //@{
0163 constexpr Length operator "" _mm( long double x ) {
0164   return Length{Length::baseunit(), static_cast<double>(x)};
0165 }
0166 constexpr Length operator "" _mm( unsigned long long x ) {
0167   return Length{Length::baseunit(), static_cast<double>(x)};
0168 }
0169 
0170 constexpr Length meter      = 1.0e+3_mm;
0171 constexpr Length millimeter = 1_mm;
0172 constexpr Length mm         = 1_mm;
0173 constexpr Length centimeter = 10_mm;
0174 constexpr Length micrometer = 1.0e-3_mm;
0175 constexpr Length nanometer  = 1.0e-6_mm;
0176 constexpr Length picometer  = 1.0e-9_mm;
0177 constexpr Length femtometer = 1.0e-12_mm;
0178  
0179 constexpr Energy operator "" _MeV( long double x ) {
0180   return Energy{Energy::baseunit(), static_cast<double>(x)};
0181 }
0182 constexpr Energy operator "" _MeV( unsigned long long x ) {
0183   return Energy{Energy::baseunit(), static_cast<double>(x)};
0184 }
0185 
0186 constexpr Energy operator "" _GeV( long double x ) {
0187   return Energy{1000_MeV, static_cast<double>(x)};
0188 }
0189 constexpr Energy operator "" _GeV( unsigned long long x ) {
0190   return Energy{1000_MeV, static_cast<double>(x)};
0191 }
0192 
0193 constexpr Energy operator "" _TeV( long double x ) {
0194   return Energy{1000_GeV, static_cast<double>(x)};
0195 }
0196 constexpr Energy operator "" _TeV( unsigned long long x ) {
0197   return Energy{1000_GeV, static_cast<double>(x)};
0198 }
0199 
0200 constexpr Energy keV = 1.0e-3_MeV;
0201 constexpr Energy MeV = 1_MeV;
0202 constexpr Energy GeV = 1_GeV;
0203 constexpr Energy TeV = 1_TeV;
0204 
0205 
0206 
0207 constexpr Energy2 operator "" _MeV2( long double x ) {
0208   return Energy2{Energy2::baseunit(),   static_cast<double>(x)};
0209 }
0210 constexpr Energy2 operator "" _MeV2( unsigned long long x ) {
0211   return Energy2{Energy2::baseunit(),   static_cast<double>(x)};
0212 }
0213 
0214 constexpr Energy2 operator "" _GeV2( long double x ) {
0215   return Energy2{1.0e+6_MeV2, static_cast<double>(x)};
0216 }
0217 constexpr Energy2 operator "" _GeV2( unsigned long long x ) {
0218   return Energy2{1.0e+6_MeV2, static_cast<double>(x)};
0219 }
0220 
0221 constexpr Energy2 MeV2 = 1_MeV2;
0222 constexpr Energy2 GeV2 = 1_GeV2;
0223 
0224 constexpr InvEnergy InvGeV = 1/GeV;
0225 
0226 
0227 constexpr Area operator "" _pb( long double x ) {
0228   return Area{1.0e-34 * Area::baseunit(), static_cast<double>(x)};
0229 }
0230 constexpr Area operator "" _pb( unsigned long long x ) {
0231   return Area{1.0e-34 * Area::baseunit(), static_cast<double>(x)};
0232 }
0233 
0234 constexpr Area femtobarn = 1.0e-03_pb;
0235 constexpr Area picobarn  = 1_pb;
0236 constexpr Area nanobarn  = 1.0e+03_pb;
0237 constexpr Area microbarn = 1.0e+06_pb;
0238 constexpr Area millibarn = 1.0e+09_pb;
0239 constexpr Area barn      = 1.0e+12_pb; 
0240 
0241 constexpr Charge eplus = Charge::baseunit();
0242 //@}
0243 
0244 /// Planck's constant times c (PDG 2006 value 197.326968(17) MeV fm)
0245 constexpr Qty<1,1,0> hbarc = 197.326968e-15 * MeV * meter;
0246 /// Planck's constant (PDG 2006 value 197.326968(17) MeV fm)
0247 constexpr Qty<1,1,0> hbar_Planck = hbarc / 1.0; // c is one
0248 }
0249 
0250 /** 
0251  * Use symbols from this namespace to make forced breaks of unit
0252  * consistency explicit.
0253  */
0254 namespace UnitRemoval {
0255   /// @name Helper units to make breaks of unit consistency explicit.
0256   //@{
0257   constexpr Units::Energy E = Units::Energy::baseunit();
0258 
0259   constexpr Units::Energy2 E2 = E*E;
0260   constexpr Units::Energy3 E3 = E*E2;
0261   constexpr Units::Energy4 E4 = E2*E2;
0262 
0263   constexpr Units::InvEnergy InvE = 1.0/E;
0264   constexpr Units::InvEnergy2 InvE2 = 1.0/E2;
0265   constexpr Units::InvEnergy3 InvE3 = 1.0/E3;
0266   constexpr Units::InvEnergy4 InvE4 = 1.0/E4;
0267 
0268   constexpr Units::SqrtEnergy SqrtE = Units::SqrtEnergy::baseunit();
0269   constexpr Units::InvSqrtEnergy InvSqrtE = Units::InvSqrtEnergy::baseunit();
0270   //@}
0271 }
0272 
0273 }
0274 
0275 #endif /* ThePEG_Units_H */