thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Vectors
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
13
#include "
ThePEG/Config/ThePEG.h
"
14
#include "ThePEG/Vectors/Lorentz5Vector.h"
15
#include "Transverse.fh"
16
17
namespace
ThePEG
{
18
29
template
<
typename
Value>
30
class
Transverse
:
public
pair<Value,Value> {
31
32
public
:
33
35
using
Value2
=
decltype
(
sqr
(std::declval<Value>()));
36
38
using
BasePair
= pair<Value,Value>;
39
40
public
:
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
88
const
Transverse
&
operator=
(
const
ThreeVector<Value>
& p) {
89
BasePair::operator=(
BasePair
(p.x(), p.y()));
90
return
*
this
;
91
}
92
96
const
Transverse
&
operator=
(
const
LorentzVector<Value>
& p) {
97
BasePair::operator=(
BasePair
(p.x(), p.y()));
98
return
*
this
;
99
}
100
104
const
Transverse
&
operator=
(
const
Lorentz5Vector<Value>
& p) {
105
BasePair::operator=(
BasePair
(p.
x
(), p.y()));
106
return
*
this
;
107
}
108
110
116
Transverse
operator-
()
const
{
return
Transverse
(-
x
(), -
y
()); }
117
121
Transverse
operator-
(
const
Transverse
&
pt
)
const
{
122
return
Transverse
(
x
() -
pt
.x(),
y
() -
pt
.y());
123
}
124
128
Transverse
&
operator-=
(
const
Transverse
&
pt
) {
129
BasePair::first -=
pt
.x();
130
BasePair::second -=
pt
.y();
131
return
*
this
;
132
}
133
137
Transverse
operator+
(
const
Transverse
&
pt
)
const
{
138
return
Transverse
(
x
() +
pt
.x(),
y
() +
pt
.y());
139
}
140
144
Transverse
&
operator+=
(
const
Transverse
&
pt
) {
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
200
template
<
typename
OStream,
typename
T,
typename
UT>
201
void
ounitstream
(OStream & os,
const
Transverse<T>
& p, UT & u) {
202
os <<
ounit
(p.
x
(), u) <<
ounit
(p.
y
(), u);
203
}
204
206
template
<
typename
IStream,
typename
T,
typename
UT>
207
void
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
214
template
<
typename
Value>
215
inline
Transverse<Value>
216
operator*(
Transverse<Value>
a,
double
b) {
217
return
a *= b;
218
}
219
221
template
<
typename
Value>
222
inline
Transverse<Value>
223
operator*(
double
b,
Transverse<Value>
a) {
224
return
a *= b;
225
}
226
228
template
<
typename
ValueA,
typename
ValueB>
229
inline
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
236
template
<
typename
ValueA,
typename
ValueB>
237
inline
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
244
template
<
typename
Value>
245
inline
Transverse<double>
246
operator/(
const
Transverse<Value>
& v, Value a) {
247
return
{v.x()/a, v.y()/a};
248
}
249
251
template
<
typename
ValueA,
typename
ValueB>
252
inline
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 */
ThePEG.h
This is the main config header file for ThePEG.
ThePEG::Lorentz5Vector
The Lorentz5Vector inherits from the LorentzVector class.
Definition:
Lorentz5Vector.h:42
ThePEG::Lorentz5Vector::x
Value x() const
Component access.
Definition:
Lorentz5Vector.h:52
ThePEG::LorentzVector
A 4-component Lorentz vector.
Definition:
LorentzVector.h:44
ThePEG::ThreeVector
A 3-component vector.
Definition:
ThreeVector.h:35
ThePEG::Transverse
Transverse represents the transverse components of a LorentzVector.
Definition:
Transverse.h:30
ThePEG::Transverse::operator*=
Transverse & operator*=(double a)
Multiply-assign with a scalar.
Definition:
Transverse.h:153
ThePEG::Transverse::operator=
const Transverse & operator=(const LorentzVector< Value > &p)
Assignment taking the transverse parts of a LorentzVector.
Definition:
Transverse.h:96
ThePEG::Transverse::pt
Value pt() const
The magnitude.
Definition:
Transverse.h:189
ThePEG::Transverse::Transverse
Transverse(const BasePair &p)
Constructor from underlying representation.
Definition:
Transverse.h:52
ThePEG::Transverse::operator-=
Transverse & operator-=(const Transverse &pt)
Assign-subtract.
Definition:
Transverse.h:128
ThePEG::Transverse::operator/=
Transverse & operator/=(double a)
Divide-assign with a scalar.
Definition:
Transverse.h:162
ThePEG::Transverse::Transverse
Transverse(const Lorentz5Vector< Value > &p)
Constructor taking the transverse parts of a Lorentz5Vector.
Definition:
Transverse.h:72
ThePEG::Transverse::operator=
const Transverse & operator=(const BasePair &p)
Assignment from underlying representation.
Definition:
Transverse.h:80
ThePEG::Transverse::pt2
Value2 pt2() const
The magnitude squared.
Definition:
Transverse.h:184
ThePEG::Transverse::phi
double phi() const
The azimuth angle.
Definition:
Transverse.h:194
ThePEG::Transverse::Transverse
Transverse()
Default constructor.
Definition:
Transverse.h:47
ThePEG::Transverse::operator-
Transverse operator-() const
Unary minus.
Definition:
Transverse.h:116
ThePEG::Transverse::x
Value x() const
The x-component.
Definition:
Transverse.h:174
ThePEG::Transverse::Transverse
Transverse(const ThreeVector< Value > &p)
Constructor taking the transverse parts of a ThreeVector.
Definition:
Transverse.h:62
ThePEG::Transverse::operator-
Transverse operator-(const Transverse &pt) const
Binary minus.
Definition:
Transverse.h:121
ThePEG::Transverse::Transverse
Transverse(Value x, Value y)
Constructor from x and y components.
Definition:
Transverse.h:57
ThePEG::Transverse::BasePair
pair< Value, Value > BasePair
Template argument typedef.
Definition:
Transverse.h:38
ThePEG::Transverse::y
Value y() const
The y-component.
Definition:
Transverse.h:179
ThePEG::Transverse::Value2
decltype(sqr(std::declval< Value >())) Value2
Template argument typedef.
Definition:
Transverse.h:35
ThePEG::Transverse::operator+
Transverse operator+(const Transverse &pt) const
Addition.
Definition:
Transverse.h:137
ThePEG::Transverse::operator=
const Transverse & operator=(const ThreeVector< Value > &p)
Assignment taking the transverse parts of a ThreeVector.
Definition:
Transverse.h:88
ThePEG::Transverse::operator=
const Transverse & operator=(const Lorentz5Vector< Value > &p)
Assignment taking the transverse parts of a Lorentz5Vector.
Definition:
Transverse.h:104
ThePEG::Transverse::operator+=
Transverse & operator+=(const Transverse &pt)
Assign-add.
Definition:
Transverse.h:144
ThePEG::Transverse::Transverse
Transverse(const LorentzVector< Value > &p)
Constructor taking the transverse parts of a LorentzVector.
Definition:
Transverse.h:67
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::iunit
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
ThePEG::iunitstream
void iunitstream(IStream &is, vector< T, Alloc > &v, UT &u)
Input a vector of objects with the specified unit.
Definition:
Containers.h:289
ThePEG::ounitstream
void ounitstream(OStream &os, const vector< T, Alloc > &v, UT &u)
Ouput a vector of objects with the specified unit.
Definition:
Containers.h:275
ThePEG::sqr
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
ThePEG::ounit
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
Generated on Thu Jun 20 2024 14:47:02 for ThePEG by
1.9.6