00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_Transverse_H
00010 #define ThePEG_Transverse_H
00011
00012
00013 #include "ThePEG/Config/ThePEG.h"
00014 #include "ThePEG/Vectors/Lorentz5Vector.h"
00015 #include "Transverse.fh"
00016
00017 namespace ThePEG {
00018
00029 template <typename Value>
00030 class Transverse: public pair<Value,Value> {
00031
00032 public:
00033
00035 typedef typename BinaryOpTraits<Value,Value>::MulT Value2;
00037 typedef pair<Value,Value> BasePair;
00038
00039 public:
00040
00046 Transverse() : BasePair(Value(), Value()) {}
00047
00051 Transverse(const BasePair & p) : BasePair(p) {}
00052
00056 Transverse(Value x, Value y) : BasePair(x, y) {}
00057
00061 Transverse(const ThreeVector<Value> & p) : BasePair(p.x(), p.y()) {}
00062
00066 Transverse(const LorentzVector<Value> & p) : BasePair(p.x(), p.y()) {}
00067
00071 Transverse(const Lorentz5Vector<Value> & p) : BasePair(p.x(), p.y()) {}
00073
00079 const Transverse & operator=(const BasePair & p) {
00080 BasePair::operator=(p);
00081 return *this;
00082 }
00083
00087 const Transverse & operator=(const ThreeVector<Value> & p) {
00088 BasePair::operator=(BasePair(p.x(), p.y()));
00089 return *this;
00090 }
00091
00095 const Transverse & operator=(const LorentzVector<Value> & p) {
00096 BasePair::operator=(BasePair(p.x(), p.y()));
00097 return *this;
00098 }
00099
00103 const Transverse & operator=(const Lorentz5Vector<Value> & p) {
00104 BasePair::operator=(BasePair(p.x(), p.y()));
00105 return *this;
00106 }
00107
00109
00115 Transverse operator-() const { return Transverse(-x(), -y()); }
00116
00120 Transverse operator-(const Transverse & pt) const {
00121 return Transverse(x() - pt.x(), y() - pt.y());
00122 }
00123
00127 Transverse & operator-=(const Transverse & pt) {
00128 BasePair::first -= pt.x();
00129 BasePair::second -= pt.y();
00130 return *this;
00131 }
00132
00136 Transverse operator+(const Transverse & pt) const {
00137 return Transverse(x() + pt.x(), y() + pt.y());
00138 }
00139
00143 Transverse & operator+=(const Transverse & pt) {
00144 BasePair::first += pt.x();
00145 BasePair::second += pt.y();
00146 return *this;
00147 }
00148
00152 inline Transverse & operator*=(double a) {
00153 BasePair::first *= a;
00154 BasePair::second *= a;
00155 return *this;
00156 }
00157
00161 inline Transverse & operator/=(double a) {
00162 BasePair::first /= a;
00163 BasePair::second /= a;
00164 return *this;
00165 }
00167
00173 Value x() const { return BasePair::first; }
00174
00178 Value y() const { return BasePair::second; }
00179
00183 Value2 pt2() const { return sqr(x()) + sqr(y()); }
00184
00188 Value pt() const { return sqrt(pt2()); }
00189
00193 double phi() const { return atan2(y(), x()); }
00195
00196 };
00197
00199 template <typename OStream, typename T, typename UT>
00200 void ounitstream(OStream & os, const Transverse<T> & p, UT & u) {
00201 os << ounit(p.x(), u) << ounit(p.y(), u);
00202 }
00203
00205 template <typename IStream, typename T, typename UT>
00206 void iunitstream(IStream & is, Transverse<T> & p, UT & u) {
00207 T x, y;
00208 is >> iunit(x, u) >> iunit(y, u);
00209 p = Transverse<T>(x, y);
00210 }
00211
00213 template <typename Value>
00214 inline Transverse<Value>
00215 operator*(Transverse<Value> a, double b) {
00216 return a *= b;
00217 }
00218
00220 template <typename Value>
00221 inline Transverse<Value>
00222 operator*(double b, Transverse<Value> a) {
00223 return a *= b;
00224 }
00225
00227 template <typename ValueA, typename ValueB>
00228 inline
00229 Transverse<typename BinaryOpTraits<ValueA,ValueB>::MulT>
00230 operator*(ValueB a, const Transverse<ValueA> & v) {
00231 typedef typename BinaryOpTraits<ValueB,ValueA>::MulT ResultT;
00232 return Transverse<ResultT>(a*v.x(), a*v.y());
00233 }
00234
00236 template <typename ValueA, typename ValueB>
00237 inline
00238 Transverse<typename BinaryOpTraits<ValueA,ValueB>::MulT>
00239 operator*(const Transverse<ValueA> & v, ValueB a) {
00240 typedef typename BinaryOpTraits<ValueB,ValueA>::MulT ResultT;
00241 return Transverse<ResultT>(a*v.x(), a*v.y());
00242 }
00243
00245 template <typename Value>
00246 inline Transverse<double>
00247 operator/(const Transverse<Value> & v, Value a) {
00248 return Transverse<double>(v.x()/a, v.y()/a);
00249 }
00250
00252 template <typename ValueA, typename ValueB>
00253 inline
00254 Transverse<typename BinaryOpTraits<ValueA,ValueB>::DivT>
00255 operator/(const Transverse<ValueA> & v, ValueB b) {
00256 typedef typename BinaryOpTraits<ValueA,ValueB>::DivT ResultT;
00257 return Transverse<ResultT>(v.x()/b, v.y()/b);
00258 }
00259
00260 }
00261
00262 #endif