ThePEG  1.8.0
Transverse.h
1 // -*- C++ -*-
2 //
3 // Transverse.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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 
37  typedef pair<Value,Value> BasePair;
38 
39 public:
40 
46  Transverse() : BasePair(Value(), Value()) {}
47 
51  Transverse(const BasePair & p) : BasePair(p) {}
52 
56  Transverse(Value x, Value y) : BasePair(x, y) {}
57 
61  Transverse(const ThreeVector<Value> & p) : BasePair(p.x(), p.y()) {}
62 
66  Transverse(const LorentzVector<Value> & p) : BasePair(p.x(), p.y()) {}
67 
71  Transverse(const Lorentz5Vector<Value> & p) : BasePair(p.x(), p.y()) {}
73 
79  const Transverse & operator=(const BasePair & p) {
80  BasePair::operator=(p);
81  return *this;
82  }
83 
88  BasePair::operator=(BasePair(p.x(), p.y()));
89  return *this;
90  }
91 
96  BasePair::operator=(BasePair(p.x(), p.y()));
97  return *this;
98  }
99 
104  BasePair::operator=(BasePair(p.x(), p.y()));
105  return *this;
106  }
107 
109 
115  Transverse operator-() const { return Transverse(-x(), -y()); }
116 
120  Transverse operator-(const Transverse & pt) const {
121  return Transverse(x() - pt.x(), y() - pt.y());
122  }
123 
128  BasePair::first -= pt.x();
129  BasePair::second -= pt.y();
130  return *this;
131  }
132 
137  return Transverse(x() + pt.x(), y() + pt.y());
138  }
139 
144  BasePair::first += pt.x();
145  BasePair::second += pt.y();
146  return *this;
147  }
148 
152  inline Transverse & operator*=(double a) {
153  BasePair::first *= a;
154  BasePair::second *= a;
155  return *this;
156  }
157 
161  inline Transverse & operator/=(double a) {
162  BasePair::first /= a;
163  BasePair::second /= a;
164  return *this;
165  }
167 
173  Value x() const { return BasePair::first; }
174 
178  Value y() const { return BasePair::second; }
179 
183  Value2 pt2() const { return sqr(x()) + sqr(y()); }
184 
188  Value pt() const { return sqrt(pt2()); }
189 
193  double phi() const { return atan2(y(), x()); }
195 
196 };
197 
199 template <typename OStream, typename T, typename UT>
200 void ounitstream(OStream & os, const Transverse<T> & p, UT & u) {
201  os << ounit(p.x(), u) << ounit(p.y(), u);
202 }
203 
205 template <typename IStream, typename T, typename UT>
206 void iunitstream(IStream & is, Transverse<T> & p, UT & u) {
207  T x, y;
208  is >> iunit(x, u) >> iunit(y, u);
209  p = Transverse<T>(x, y);
210 }
211 
213 template <typename Value>
214 inline Transverse<Value>
215 operator*(Transverse<Value> a, double b) {
216  return a *= b;
217 }
218 
220 template <typename Value>
221 inline Transverse<Value>
222 operator*(double b, Transverse<Value> a) {
223  return a *= b;
224 }
225 
227 template <typename ValueA, typename ValueB>
228 inline
230 operator*(ValueB a, const Transverse<ValueA> & v) {
231  typedef typename BinaryOpTraits<ValueB,ValueA>::MulT ResultT;
232  return Transverse<ResultT>(a*v.x(), a*v.y());
233 }
234 
236 template <typename ValueA, typename ValueB>
237 inline
239 operator*(const Transverse<ValueA> & v, ValueB a) {
240  typedef typename BinaryOpTraits<ValueB,ValueA>::MulT ResultT;
241  return Transverse<ResultT>(a*v.x(), a*v.y());
242 }
243 
245 template <typename Value>
246 inline Transverse<double>
247 operator/(const Transverse<Value> & v, Value a) {
248  return Transverse<double>(v.x()/a, v.y()/a);
249 }
250 
252 template <typename ValueA, typename ValueB>
253 inline
255 operator/(const Transverse<ValueA> & v, ValueB b) {
256  typedef typename BinaryOpTraits<ValueA,ValueB>::DivT ResultT;
257  return Transverse<ResultT>(v.x()/b, v.y()/b);
258 }
259 
260 }
261 
262 #endif /* ThePEG_Transverse_H */
A 4-component Lorentz vector.
Definition: LorentzVector.h:35
Transverse & operator/=(double a)
Divide-assign with a scalar.
Definition: Transverse.h:161
const Transverse & operator=(const BasePair &p)
Assignment from underlying representation.
Definition: Transverse.h:79
Transverse(const BasePair &p)
Constructor from underlying representation.
Definition: Transverse.h:51
void ounitstream(OStream &os, const vector< T, Alloc > &v, UT &u)
Ouput a vector of objects with the specified unit.
Definition: Containers.h:275
A 3-component vector.
Definition: ThreeVector.h:33
Transverse()
Default constructor.
Definition: Transverse.h:46
Transverse & operator+=(const Transverse &pt)
Assign-add.
Definition: Transverse.h:143
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
Transverse & operator-=(const Transverse &pt)
Assign-subtract.
Definition: Transverse.h:127
Transverse(const LorentzVector< Value > &p)
Constructor taking the transverse parts of a LorentzVector.
Definition: Transverse.h:66
const Transverse & operator=(const LorentzVector< Value > &p)
Assignment taking the transverse parts of a LorentzVector.
Definition: Transverse.h:95
double phi() const
The azimuth angle.
Definition: Transverse.h:193
void iunitstream(IStream &is, vector< T, Alloc > &v, UT &u)
Input a vector of objects with the specified unit.
Definition: Containers.h:289
Transverse operator-(const Transverse &pt) const
Binary minus.
Definition: Transverse.h:120
Transverse(const ThreeVector< Value > &p)
Constructor taking the transverse parts of a ThreeVector.
Definition: Transverse.h:61
pair< Value, Value > BasePair
Template argument typedef.
Definition: Transverse.h:37
Value x() const
The x-component.
Definition: Transverse.h:173
Transverse operator-() const
Unary minus.
Definition: Transverse.h:115
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:90
Transverse(Value x, Value y)
Constructor from x and y components.
Definition: Transverse.h:56
Value y() const
The y-component.
Definition: Transverse.h:178
BinaryOpTraits< Value, Value >::MulT Value2
Template argument typedef.
Definition: Transverse.h:35
Transverse represents the transverse components of a LorentzVector.
Definition: Transverse.h:30
const Transverse & operator=(const ThreeVector< Value > &p)
Assignment taking the transverse parts of a ThreeVector.
Definition: Transverse.h:87
Value x() const
Component access.
Value pt() const
The magnitude.
Definition: Transverse.h:188
Transverse(const Lorentz5Vector< Value > &p)
Constructor taking the transverse parts of a Lorentz5Vector.
Definition: Transverse.h:71
The Lorentz5Vector inherits from the LorentzVector class.
Transverse operator+(const Transverse &pt) const
Addition.
Definition: Transverse.h:136
Value2 pt2() const
The magnitude squared.
Definition: Transverse.h:183
BinaryOpTraits should be specialized with typdefs called MulT and DivT which gives the type resulting...
Definition: PhysicalQty.h:239
Transverse & operator*=(double a)
Multiply-assign with a scalar.
Definition: Transverse.h:152
const Transverse & operator=(const Lorentz5Vector< Value > &p)
Assignment taking the transverse parts of a Lorentz5Vector.
Definition: Transverse.h:103
IUnit< T, UT > iunit(T &t, const UT &ut)
Helper function creating a IUnit object given an object and a unit.
Definition: UnitIO.h:97