cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Momentum.h
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2013-2022 Laurent Forthomme
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef CepGen_Physics_Momentum_h
20#define CepGen_Physics_Momentum_h
21
22#include <array>
23#include <iosfwd>
24
25namespace cepgen {
26 class Vector;
33 class Momentum : private std::array<double, 4> {
34 public:
36 explicit Momentum(double x = 0., double y = 0., double z = 0., double t = -1.);
38 explicit Momentum(double* p);
40 explicit Momentum(const Vector&);
41
42 bool operator==(const Momentum&) const;
43 inline bool operator!=(const Momentum& oth) const { return !operator==(oth); }
44
45 //--- static definitions
46
48 static Momentum fromPtEtaPhiE(double pt, double eta, double phi, double e = -1.);
50 static Momentum fromPtEtaPhiM(double pt, double eta, double phi, double m);
52 static Momentum fromPThetaPhiE(double p, double theta, double phi, double e = -1.);
54 static Momentum fromPxPyPzE(double px, double py, double pz, double e);
56 static Momentum fromPxPyPzM(double px, double py, double pz, double m);
58 static Momentum fromPxPyYM(double px, double py, double rap, double m);
60 static Momentum fromPtYPhiM(double pt, double rap, double phi, double m);
61
62 //--- vector and scalar operators
63
65 double threeProduct(const Momentum&) const;
67 double fourProduct(const Momentum&) const;
69 double crossProduct(const Momentum&) const;
71 Momentum operator+(const Momentum&) const;
75 Momentum operator-() const;
77 Momentum operator-(const Momentum&) const;
81 double operator*(const Momentum&) const;
83 Momentum operator%(const Momentum&) const;
85 double operator*=(const Momentum&);
87 Momentum operator*(double c) const;
89 Momentum& operator*=(double c);
91 friend Momentum operator*(double, const Momentum&);
93 friend std::ostream& operator<<(std::ostream&, const Momentum&);
94
96 operator Vector() const;
97
99 Momentum& betaGammaBoost(double gamma, double betagamma);
102
103 //--- setters and getters
104
106 Momentum& setP(double px, double py, double pz, double e);
108 Momentum& setP(double px, double py, double pz);
110 Momentum& setPx(double px);
112 inline double px() const { return (*this)[X]; }
114 Momentum& setPy(double py);
116 inline double py() const { return (*this)[Y]; }
118 Momentum& setPz(double pz);
120 inline double pz() const { return (*this)[Z]; }
122 double pt() const;
124 double pt2() const;
126 Momentum transverse() const;
128 std::array<double, 5> pVector() const;
130 inline double p() const { return p_; }
132 inline double p2() const { return p_ * p_; }
134 Momentum& setEnergy(double);
136 inline double energy() const { return (*this)[E]; }
138 inline double energy2() const { return (*this)[E] * (*this)[E]; }
140 double energyT() const;
142 double energyT2() const;
144 Momentum& setMass2(double);
146 double mass2() const;
148 Momentum& setMass(double);
151 double mass() const;
153 double massT2() const;
155 double massT() const;
157 double theta() const;
159 double phi() const;
161 double eta() const;
163 double rapidity() const;
164
166 double deltaEta(const Momentum&) const;
168 double deltaPhi(const Momentum&) const;
170 double deltaPt(const Momentum&) const;
172 double deltaR(const Momentum&) const;
173
175 double beta() const;
177 double gamma2() const;
179 double gamma() const;
180
183 Momentum& computeEnergyFromMass(double on_shell_mass);
186 Momentum& computePzFromMass(double on_shell_mass);
187
189 Momentum& truncate(double tolerance = 1.e-10);
190
192 Momentum& rotatePhi(double phi, double sign);
194 Momentum& rotateThetaPhi(double theta, double phi);
196 inline Momentum& mirrorX() {
197 (*this)[X] *= -1.;
198 return *this;
199 }
201 inline Momentum& mirrorY() {
202 (*this)[Y] *= -1.;
203 return *this;
204 }
206 inline Momentum& mirrorZ() {
207 (*this)[Z] *= -1.;
208 return *this;
209 }
210
211 private:
212 enum coord_t { X = 0, Y = 1, Z = 2, E = 3 };
214 Momentum& computeP();
216 double p_{0.};
217 };
218} // namespace cepgen
219
220#endif
Container for a particle's 4-momentum, along with useful methods to ease the development of any matri...
Definition Momentum.h:33
double pt2() const
Squared transverse momentum (in GeV )
Definition Momentum.cpp:234
double pz() const
Longitudinal momentum (in GeV)
Definition Momentum.h:120
double operator*=(const Momentum &)
Scalar product of the 3-momentum with another 3-momentum.
double threeProduct(const Momentum &) const
Scalar product of the 3-momentum with another 3-momentum.
Definition Momentum.cpp:138
Momentum & setMass2(double)
Compute the energy from the mass.
Definition Momentum.cpp:178
double deltaR(const Momentum &) const
Angular distance between two momenta.
Definition Momentum.cpp:259
double deltaEta(const Momentum &) const
Pseudorapidity distance between two momenta.
Definition Momentum.cpp:251
double energyT2() const
Squared tranverse energy component (in GeV )
Definition Momentum.cpp:213
double rapidity() const
Rapidity.
Definition Momentum.cpp:246
Momentum & setPy(double py)
Set the momentum along the -axis (in GeV)
Definition Momentum.cpp:161
Momentum & betaGammaBoost(double gamma, double betagamma)
Forward boost.
Definition Momentum.cpp:297
double deltaPt(const Momentum &) const
Transverse momentum distance between two momenta.
Definition Momentum.cpp:257
Momentum & operator+=(const Momentum &)
Add a 4-momentum through a 4-vector sum.
Definition Momentum.cpp:104
double gamma2() const
Squared gamma scalar value.
Definition Momentum.cpp:280
Momentum & rotateThetaPhi(double theta, double phi)
Rotate the particle's momentum by a polar/azimuthal angle.
Definition Momentum.cpp:330
double deltaPhi(const Momentum &) const
Azimutal angle opening between two momenta.
Definition Momentum.cpp:253
double eta() const
Pseudo-rapidity.
Definition Momentum.cpp:240
Momentum & lorentzBoost(const Momentum &p)
Forward Lorentz boost.
Definition Momentum.cpp:304
Momentum & computeEnergyFromMass(double on_shell_mass)
Compute the mass from 4-momentum.
Definition Momentum.cpp:186
friend Momentum operator*(double, const Momentum &)
Left-multiply all 4-momentum coordinates by a scalar.
Definition Momentum.cpp:134
double px() const
Momentum along the -axis (in GeV)
Definition Momentum.h:112
static Momentum fromPxPyYM(double px, double py, double rap, double m)
Build a 4-momentum from its transverse momentum, rapidity and mass.
Definition Momentum.cpp:88
double gamma() const
Gamma scalar value.
Definition Momentum.cpp:295
double p2() const
Squared 3-momentum norm (in GeV )
Definition Momentum.h:132
Momentum & mirrorX()
Apply a transformation.
Definition Momentum.h:196
double py() const
Momentum along the -axis (in GeV)
Definition Momentum.h:116
static Momentum fromPxPyPzM(double px, double py, double pz, double m)
Build a 4-momentum from its three momentum coordinates and mass.
Definition Momentum.cpp:84
double beta() const
Beta scalar value.
Definition Momentum.cpp:265
static Momentum fromPxPyPzE(double px, double py, double pz, double e)
Build a 4-momentum from its four momentum and energy coordinates.
Definition Momentum.cpp:82
Momentum & setP(double px, double py, double pz, double e)
Set all the components of the 4-momentum (in GeV)
Definition Momentum.cpp:180
Momentum & setEnergy(double)
Set the energy (in GeV)
Definition Momentum.cpp:171
double crossProduct(const Momentum &) const
Vector product of the 3-momentum with another 3-momentum.
Definition Momentum.cpp:152
double massT2() const
Squared transverse mass (in GeV )
Definition Momentum.cpp:224
double energy2() const
Squared energy (in GeV )
Definition Momentum.h:138
Momentum & mirrorY()
Apply a transformation.
Definition Momentum.h:201
double massT() const
Transverse mass (in GeV)
Definition Momentum.cpp:226
double pt() const
Transverse momentum (in GeV)
Definition Momentum.cpp:232
Momentum & setPz(double pz)
Set the longitudinal momentum (in GeV)
Definition Momentum.cpp:166
Momentum & setMass(double)
Compute the energy from the mass.
Definition Momentum.cpp:176
Momentum transverse() const
Transverse coordinates of a momentum.
Definition Momentum.cpp:236
double fourProduct(const Momentum &) const
Scalar product of the 4-momentum with another 4-momentum.
Definition Momentum.cpp:145
Momentum & setPx(double px)
Set the momentum along the -axis (in GeV)
Definition Momentum.cpp:156
static Momentum fromPtEtaPhiM(double pt, double eta, double phi, double m)
Build a 3-momentum from its three pseudo-cylindrical coordinates.
Definition Momentum.cpp:73
double phi() const
Azimuthal angle (angle in the transverse plane)
Definition Momentum.cpp:230
double p() const
3-momentum norm (in GeV)
Definition Momentum.h:130
Momentum operator+(const Momentum &) const
Compute the 4-vector sum of two 4-momenta.
Definition Momentum.cpp:100
Momentum operator%(const Momentum &) const
Vector product of two 3-momenta.
Definition Momentum.cpp:122
double mass() const
Mass (in GeV) as computed from its energy and momentum.
Definition Momentum.cpp:222
Momentum & truncate(double tolerance=1.e-10)
Apply a threshold to all values with a given tolerance.
Definition Momentum.cpp:197
double energyT() const
Tranverse energy component (in GeV)
Definition Momentum.cpp:218
Momentum & operator-=(const Momentum &)
Subtract a 4-momentum through a 4-vector sum.
Definition Momentum.cpp:115
friend std::ostream & operator<<(std::ostream &, const Momentum &)
Human-readable format for a particle's momentum.
Definition Momentum.cpp:353
std::array< double, 5 > pVector() const
5-vector of double precision floats (in GeV)
Definition Momentum.cpp:204
Momentum & mirrorZ()
Apply a transformation.
Definition Momentum.h:206
static Momentum fromPtYPhiM(double pt, double rap, double phi, double m)
Build a 4-momentum from its transverse momentum, azimuthal angle, rapidity and mass.
Definition Momentum.cpp:93
Momentum & computePzFromMass(double on_shell_mass)
Compute the longitudinal coordinate from energy-mass-transverse momentum constraints.
Definition Momentum.cpp:188
static Momentum fromPtEtaPhiE(double pt, double eta, double phi, double e=-1.)
Build a 3-momentum from its three pseudo-cylindrical coordinates.
Definition Momentum.cpp:69
Momentum & rotatePhi(double phi, double sign)
Rotate the transverse components by an angle phi (and reflect the y coordinate)
Definition Momentum.cpp:324
bool operator!=(const Momentum &oth) const
Inequality operator.
Definition Momentum.h:43
double energy() const
Energy (in GeV)
Definition Momentum.h:136
double theta() const
Polar angle (angle with respect to the longitudinal direction)
Definition Momentum.cpp:228
bool operator==(const Momentum &) const
Equality operator.
Definition Momentum.cpp:63
static Momentum fromPThetaPhiE(double p, double theta, double phi, double e=-1.)
Build a 4-momentum from its scalar momentum, and its polar and azimuthal angles.
Definition Momentum.cpp:77
Momentum operator-() const
Unary inverse operator.
Definition Momentum.cpp:109
double mass2() const
Squared mass (in GeV ) as computed from its energy and momentum.
Definition Momentum.cpp:220
Specialisation of a matrix.
Definition Algebra.h:139
Common namespace for this Monte Carlo generator.