Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FourMomentum.hh
Go to the documentation of this file.
1 ///
2 /// @file FourMomentum.hh
3 /// @brief Hammer four momentum class
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_MATH_FOURMOMENTUM
13 #define HAMMER_MATH_FOURMOMENTUM
14 
15 #include <array>
16 
17 #include <boost/operators.hpp>
18 
21 
22 
23 namespace Hammer {
24 
25  /// @brief 4-momentum class
26  ///
27  /// Defines a 4-momentum and its basic properties and operations
28  ///
29  /// @ingroup Math
31  : public boost::addable<
32  FourMomentum, // fm + fm
33  boost::subtractable<FourMomentum, // fm - fm
34  boost::dividable2<FourMomentum, double, // fm / double
35  boost::multipliable2<FourMomentum, double>>>> { // fm * double,
36  // double * fm
37 
38  public:
39  /// @brief default constructor
40  FourMomentum();
41 
42  /// @brief constructor from an array of numbers
43  /// @param[in] other the array, defined as \f$ \left(E, p_x, p_y, p_z \right) \f$
44  FourMomentum(const std::array<double, 4>& other);
45 
46  /// @brief constructor from specific components
47  /// @param[in] E the energy
48  /// @param[in] px the x momentum component
49  /// @param[in] py the y momentum component
50  /// @param[in] pz the z momentum component
51  FourMomentum(const double E, const double px, const double py, const double pz);
52 
53  public:
54  /// @brief builder method based on 3-momentum and invariant mass
55  /// @param[in] px the x momentum component
56  /// @param[in] py the y momentum component
57  /// @param[in] pz the z momentum component
58  /// @param[in] mass the invariant mass
59  /// @return the built 4-momentum
60  static FourMomentum fromPM(double px, double py, double pz, double mass);
61 
62  /// @brief builder method based on collider-friendly variables
63  /// @param[in] pt the transverse momentum
64  /// @param[in] eta the pseudorapidity
65  /// @param[in] phi the azimuthal angle
66  /// @param[in] mass the invariant mass
67  /// @return the built 4-momentum
68  static FourMomentum fromPtEtaPhiM(double pt, double eta, double phi, double mass);
69 
70  /// @brief builder method based on collider-friendly variables
71  /// @param[in] eta the pseudorapidity
72  /// @param[in] phi the azimuthal angle
73  /// @param[in] mass the invariant mass
74  /// @param[in] E the energy
75  /// @return the built 4-momentum
76  static FourMomentum fromEtaPhiME(double eta, double phi, double mass, double E);
77 
78 #ifdef HAVE_ROOT
79 
80  /// @brief builder method based on collider-friendly variables
81  /// @param[in] v the 4-vector
82  /// @return the built 4-momentum
83  static FourMomentum fromRoot(const TLorentzVector& v);
84 
85 #endif
86 
87  public:
88  /// @brief set the 4-momentum energy
89  /// @param[in] E the new energy
90  /// @return a reference to itself
91  FourMomentum& setE(double E);
92 
93  /// @brief set the 4-momentum momentum x component
94  /// @param[in] px the new momentum x component
95  /// @return a reference to itself
96  FourMomentum& setPx(double px);
97 
98  /// @brief set the 4-momentum momentum y component
99  /// @param[in] py the new momentum y component
100  /// @return a reference to itself
101  FourMomentum& setPy(double py);
102 
103  /// @brief set the 4-momentum momentum z component
104  /// @param[in] pz the new momentum z component
105  /// @return a reference to itself
106  FourMomentum& setPz(double pz);
107 
108  public:
109  /// @brief returns the energy
110  double E() const;
111 
112  /// @brief returns the momentum x component
113  double px() const;
114 
115  /// @brief returns the momentum y component
116  double py() const;
117 
118  /// @brief returns the momentum z component
119  double pz() const;
120 
121  /// @brief returns the invariant mass
122  /// if the invariant mass squared is negative
123  /// returns \f$ - \sqrt{|m^2|} \f$
124  double mass() const;
125 
126  /// @brief returns the squared invariant mass
127  double mass2() const;
128 
129  /// @brief returns the absolute value of the 3-momentum
130  double p() const;
131 
132  /// @brief returns the squared 3-momentum
133  double p2() const;
134 
135  /// @brief returns the transverse momentum
136  double pt() const;
137 
138  /// @brief returns the rapidity (along the z-axis)
139  double rapidity() const;
140 
141  /// @brief returns the azimuthal angle
142  double phi() const;
143 
144  /// @brief returns the pseudorapidity (along the z-axis)
145  double eta() const;
146 
147  /// @brief returns the polar angle (along the z-axis)
148  double theta() const;
149 
150  /// @brief returns the spatial 3-vector as an array
151  std::array<double, 3> pVec() const;
152 
153  public:
154  /// @brief contracts the 4-momentum with another
155  /// @param[in] v the other 4-momentum
156  /// @return the dot product
157  double dot(const FourMomentum& v) const;
158 
159  /// @brief multiplies the components by a constant
160  /// @param[in] a the real constant
161  /// @return a reference to itself
162  FourMomentum& operator*=(double a);
163 
164  /// @brief divides the components by a constant
165  /// @param[in] a the real constant
166  /// @return a reference to itself. Throws if division-by-zero.
167  FourMomentum& operator/=(double a);
168 
169  /// @brief adds the another 4-momentum to itself
170  /// @param[in] v the other 4-momentum
171  /// @return a reference to itself
173 
174  /// @brief subtract the 4-momentum by another
175  /// @param[in] v the other 4-momentum
176  /// @return a reference to itself
178 
179  /// @brief construct a copy of itself with all the signs of the components flipped
180  /// @return a new 4-vector with the components flipped
181  FourMomentum operator-() const;
182 
183  /// @brief construct a copy of itself with all the signs of the spatial components flipped
184  /// @return a new 4-vector with the spatial components flipped
185  FourMomentum PFlip() const;
186 
187  public:
188  /// @brief returns the \f$ \gamma = 1/\sqrt{1-\beta^2} \f$ for the Lorentz transformation to the rest frame
189  /// @return the value. Throws for massless particles.
190  double gamma() const;
191 
192  /// @brief returns the value of the boost to the rest frame
193  /// @return the value. Throws if zero energy.
194  double beta() const;
195 
196  /// @brief returns the boost 3-vector
197  /// @return the vector. Throws if zero energy.
198  std::array<double, 3> boostVector() const;
199 
200  /// @brief returns a boosted 4-vector
201  /// @param[in] v
202  /// @return the boosted 4-vector.
204 
205  /// @brief
206  /// @param[in] v
207  /// @return
209 
210  /// @brief
211  /// @param[in] v
212  /// @return
213  FourMomentum& boostToRestFrameOf(const std::array<double, 3>& v);
214 
215  private:
216 
217  /// @brief
218  /// @param[in] v
219  /// @return
220  void boostBy(const std::array<double, 3>& v);
221 
222  std::array<double, 4> _vec; ///< the contents of the 4-momentum in the notation \f$ (E, p_x, p_y, p_z) \f$.
223  };
224 
225  /// @brief contracts two 4-momenta
226  /// \overload dot
227  /// @param[in] v the first 4-momentum
228  /// @param[in] w the second 4-momentum
229  double dot(const FourMomentum& v, const FourMomentum& w);
230 
231  /// @brief contracts two 4-momenta
232  /// @param[in] v the first 4-momentum
233  /// @param[in] w the second 4-momentum
234  double operator*(const FourMomentum& v, const FourMomentum& w);
235 
236  /// @brief computes the angle between the spatial components of two 4-momenta
237  /// @param[in] v the first 4-momentum
238  /// @param[in] w the second 4-momentum
239  double angle(const FourMomentum& v, const FourMomentum& w);
240 
241  /// @brief computes \f$ \Delta R = \sqrt{\Delta \eta^2 + \Delta \phi^2} \f$
242  /// between two 4-momenta
243  /// @param[in] v the first 4-momentum
244  /// @param[in] w the second 4-momentum
245  double deltaR(const FourMomentum& v, const FourMomentum& w);
246 
247  /// @brief computes the difference between the azimuthal angles of two 4-momenta
248  /// @param[in] v the first 4-momentum
249  /// @param[in] w the second 4-momentum
250  double deltaPhi(const FourMomentum& v, const FourMomentum& w);
251 
252  /// @brief computes the difference between the pseudorapidities of two 4-momenta
253  /// @param[in] v the first 4-momentum
254  /// @param[in] w the second 4-momentum
255  double deltaEta(const FourMomentum& v, const FourMomentum& w);
256 
257  /// @brief contracts four 4-momenta with an 4D epsilon tensor.
258  /// The convetion used is \f$ \epsilon^{0123} = -1 \f$
259  /// @param[in] a the first 4-momentum
260  /// @param[in] b the second 4-momentum
261  /// @param[in] c the third 4-momentum
262  /// @param[in] d the fourth 4-momentum
263  /// @return the contraction
264  double epsilon(const FourMomentum& a, const FourMomentum& b, const FourMomentum& c, const FourMomentum& d);
265 
266  FourMomentum boostToRestFrameOf(const FourMomentum& mom, double vx, double vy, double vz);
267 
268  FourMomentum boostToRestFrameOf(const FourMomentum& mom, const std::array<double, 3>& v);
269 
271 
272  /// @brief
273  /// \overload dot
274  /// @param[in] a the first 4-momentum
275  /// @param[in] b the second 4-momentum
276  double dot(const std::array<double, 3>& a, const std::array<double, 3>& b);
277 
278  double costheta(const std::array<double, 3>& a, const std::array<double, 3>& b);
279 
280 } // namespace Hammer
281 
282 #endif
FourMomentum boostToRestFrameOf(const FourMomentum &mom, double vx, double vy, double vz)
FourMomentum & boostToRestFrameOf(const FourMomentum &v)
returns a boosted 4-vector
FourMomentum()
default constructor
Definition: FourMomentum.cc:24
static FourMomentum fromPM(double px, double py, double pz, double mass)
builder method based on 3-momentum and invariant mass
double eta() const
returns the pseudorapidity (along the z-axis)
double phi() const
returns the azimuthal angle
FourMomentum & operator-=(const FourMomentum &v)
subtract the 4-momentum by another
double p2() const
returns the squared 3-momentum
double p() const
returns the absolute value of the 3-momentum
double gamma() const
returns the for the Lorentz transformation to the rest frame
double E() const
returns the energy
FourMomentum & operator+=(const FourMomentum &v)
adds the another 4-momentum to itself
double costheta(const std::array< double, 3 > &a, const std::array< double, 3 > &b)
Hammer configuration definitions.
double dot(const FourMomentum &v) const
contracts the 4-momentum with another
FourMomentum & setPy(double py)
set the 4-momentum momentum y component
double angle(const FourMomentum &v, const FourMomentum &w)
computes the angle between the spatial components of two 4-momenta
double pt() const
returns the transverse momentum
static FourMomentum fromPtEtaPhiM(double pt, double eta, double phi, double mass)
builder method based on collider-friendly variables
double mass2() const
returns the squared invariant mass
double mass() const
returns the invariant mass if the invariant mass squared is negative returns
FourMomentum & setE(double E)
set the 4-momentum energy
FourMomentum PFlip() const
construct a copy of itself with all the signs of the spatial components flipped
double beta() const
returns the value of the boost to the rest frame
void boostBy(const std::array< double, 3 > &v)
FourMomentum operator-() const
construct a copy of itself with all the signs of the components flipped
double epsilon(const FourMomentum &a, const FourMomentum &b, const FourMomentum &c, const FourMomentum &d)
contracts four 4-momenta with an 4D epsilon tensor.
std::array< double, 4 > _vec
the contents of the 4-momentum in the notation .
double deltaR(const FourMomentum &v, const FourMomentum &w)
computes between two 4-momenta
FourMomentum & boostFromRestFrameOf(const FourMomentum &v)
FourMomentum & operator*=(double a)
multiplies the components by a constant
std::array< double, 3 > pVec() const
returns the spatial 3-vector as an array
Tensor operator*(const Tensor &first, double val)
left multiplies a tensor by a real constant
Definition: Tensor.cc:286
FourMomentum & operator/=(double a)
divides the components by a constant
double deltaPhi(const FourMomentum &v, const FourMomentum &w)
computes the difference between the azimuthal angles of two 4-momenta
FourMomentum & setPz(double pz)
set the 4-momentum momentum z component
std::array< double, 3 > boostVector() const
returns the boost 3-vector
double pz() const
returns the momentum z component
double deltaEta(const FourMomentum &v, const FourMomentum &w)
computes the difference between the pseudorapidities of two 4-momenta
ROOT forward declarations.
double py() const
returns the momentum y component
FourMomentum & setPx(double px)
set the 4-momentum momentum x component
static FourMomentum fromEtaPhiME(double eta, double phi, double mass, double E)
builder method based on collider-friendly variables
double theta() const
returns the polar angle (along the z-axis)
4-momentum class
Definition: FourMomentum.hh:30
double rapidity() const
returns the rapidity (along the z-axis)
double px() const
returns the momentum x component
Tensor dot(const Tensor &first, const Tensor &second, const set< IndexLabel > &indices)
Definition: Tensor.cc:268