thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
Transverse.h
1// -*- C++ -*-
2//
3// Transverse.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef ThePEG_Transverse_H
10#define ThePEG_Transverse_H
11// This is the declaration of the Transverse class.
12
14#include "ThePEG/Vectors/Lorentz5Vector.h"
15#include "Transverse.fh"
16
17namespace ThePEG {
18
29template <typename Value>
30class Transverse: public pair<Value,Value> {
31
32public:
33
35 using Value2 = decltype(sqr(std::declval<Value>()));
36
38 using BasePair = pair<Value,Value>;
39
40public:
41
47 Transverse() : BasePair(Value(), Value()) {}
48
52 Transverse(const BasePair & p) : BasePair(p) {}
53
57 Transverse(Value x, Value y) : BasePair(x, y) {}
58
62 Transverse(const ThreeVector<Value> & p) : BasePair(p.x(), p.y()) {}
63
67 Transverse(const LorentzVector<Value> & p) : BasePair(p.x(), p.y()) {}
68
72 Transverse(const Lorentz5Vector<Value> & p) : BasePair(p.x(), p.y()) {}
74
80 const Transverse & operator=(const BasePair & p) {
81 BasePair::operator=(p);
82 return *this;
83 }
84
89 BasePair::operator=(BasePair(p.x(), p.y()));
90 return *this;
91 }
92
97 BasePair::operator=(BasePair(p.x(), p.y()));
98 return *this;
99 }
100
105 BasePair::operator=(BasePair(p.x(), p.y()));
106 return *this;
107 }
108
110
116 Transverse operator-() const { return Transverse(-x(), -y()); }
117
122 return Transverse(x() - pt.x(), y() - pt.y());
123 }
124
129 BasePair::first -= pt.x();
130 BasePair::second -= pt.y();
131 return *this;
132 }
133
138 return Transverse(x() + pt.x(), y() + pt.y());
139 }
140
145 BasePair::first += pt.x();
146 BasePair::second += pt.y();
147 return *this;
148 }
149
153 inline Transverse & operator*=(double a) {
154 BasePair::first *= a;
155 BasePair::second *= a;
156 return *this;
157 }
158
162 inline Transverse & operator/=(double a) {
163 BasePair::first /= a;
164 BasePair::second /= a;
165 return *this;
166 }
168
174 Value x() const { return BasePair::first; }
175
179 Value y() const { return BasePair::second; }
180
184 Value2 pt2() const { return sqr(x()) + sqr(y()); }
185
189 Value pt() const { return sqrt(pt2()); }
190
194 double phi() const { return atan2(y(), x()); }
196
197};
198
200template <typename OStream, typename T, typename UT>
201void ounitstream(OStream & os, const Transverse<T> & p, UT & u) {
202 os << ounit(p.x(), u) << ounit(p.y(), u);
203}
204
206template <typename IStream, typename T, typename UT>
207void iunitstream(IStream & is, Transverse<T> & p, UT & u) {
208 T x, y;
209 is >> iunit(x, u) >> iunit(y, u);
210 p = Transverse<T>(x, y);
211}
212
214template <typename Value>
215inline Transverse<Value>
216operator*(Transverse<Value> a, double b) {
217 return a *= b;
218}
219
221template <typename Value>
222inline Transverse<Value>
223operator*(double b, Transverse<Value> a) {
224 return a *= b;
225}
226
228template <typename ValueA, typename ValueB>
229inline auto operator*(ValueB a, const Transverse<ValueA> & v)
230-> Transverse<decltype(a*v.x())>
231{
232 return {a*v.x(), a*v.y()};
233}
234
236template <typename ValueA, typename ValueB>
237inline auto operator*(const Transverse<ValueA> & v, ValueB a)
238-> Transverse<decltype(a*v.x())>
239{
240 return {a*v.x(), a*v.y()};
241}
242
244template <typename Value>
245inline Transverse<double>
246operator/(const Transverse<Value> & v, Value a) {
247 return {v.x()/a, v.y()/a};
248}
249
251template <typename ValueA, typename ValueB>
252inline auto operator/(const Transverse<ValueA> & v, ValueB b)
253-> Transverse<decltype(v.x()/b)>
254{
255 return {v.x()/b, v.y()/b};
256}
257
258}
259
260#endif /* ThePEG_Transverse_H */
This is the main config header file for ThePEG.
The Lorentz5Vector inherits from the LorentzVector class.
Value x() const
Component access.
A 4-component Lorentz vector.
Definition: LorentzVector.h:44
A 3-component vector.
Definition: ThreeVector.h:35
Transverse represents the transverse components of a LorentzVector.
Definition: Transverse.h:30
Transverse & operator*=(double a)
Multiply-assign with a scalar.
Definition: Transverse.h:153
const Transverse & operator=(const LorentzVector< Value > &p)
Assignment taking the transverse parts of a LorentzVector.
Definition: Transverse.h:96
Value pt() const
The magnitude.
Definition: Transverse.h:189
Transverse(const BasePair &p)
Constructor from underlying representation.
Definition: Transverse.h:52
Transverse & operator-=(const Transverse &pt)
Assign-subtract.
Definition: Transverse.h:128
Transverse & operator/=(double a)
Divide-assign with a scalar.
Definition: Transverse.h:162
Transverse(const Lorentz5Vector< Value > &p)
Constructor taking the transverse parts of a Lorentz5Vector.
Definition: Transverse.h:72
const Transverse & operator=(const BasePair &p)
Assignment from underlying representation.
Definition: Transverse.h:80
Value2 pt2() const
The magnitude squared.
Definition: Transverse.h:184
double phi() const
The azimuth angle.
Definition: Transverse.h:194
Transverse()
Default constructor.
Definition: Transverse.h:47
Transverse operator-() const
Unary minus.
Definition: Transverse.h:116
Value x() const
The x-component.
Definition: Transverse.h:174
Transverse(const ThreeVector< Value > &p)
Constructor taking the transverse parts of a ThreeVector.
Definition: Transverse.h:62
Transverse operator-(const Transverse &pt) const
Binary minus.
Definition: Transverse.h:121
Transverse(Value x, Value y)
Constructor from x and y components.
Definition: Transverse.h:57
pair< Value, Value > BasePair
Template argument typedef.
Definition: Transverse.h:38
Value y() const
The y-component.
Definition: Transverse.h:179
decltype(sqr(std::declval< Value >())) Value2
Template argument typedef.
Definition: Transverse.h:35
Transverse operator+(const Transverse &pt) const
Addition.
Definition: Transverse.h:137
const Transverse & operator=(const ThreeVector< Value > &p)
Assignment taking the transverse parts of a ThreeVector.
Definition: Transverse.h:88
const Transverse & operator=(const Lorentz5Vector< Value > &p)
Assignment taking the transverse parts of a Lorentz5Vector.
Definition: Transverse.h:104
Transverse & operator+=(const Transverse &pt)
Assign-add.
Definition: Transverse.h:144
Transverse(const LorentzVector< Value > &p)
Constructor taking the transverse parts of a LorentzVector.
Definition: Transverse.h:67
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
IUnit< T, UT > iunit(T &t, const UT &ut)
Helper function creating a IUnit object given an object and a unit.
Definition: UnitIO.h:91
void iunitstream(IStream &is, vector< T, Alloc > &v, UT &u)
Input a vector of objects with the specified unit.
Definition: Containers.h:289
void ounitstream(OStream &os, const vector< T, Alloc > &v, UT &u)
Ouput a vector of objects with the specified unit.
Definition: Containers.h:275
constexpr auto sqr(const T &x) -> decltype(x *x)
The square function should really have been included in the standard C++ library.
Definition: ThePEG.h:117
OUnit< T, UT > ounit(const T &t, const UT &ut)
Helper function creating a OUnit object given an object and a unit.
Definition: UnitIO.h:84