Fork me on GitHub

source: svn/trunk/Utilities/HepMC/interface/SimpleVector.h@ 597

Last change on this file since 597 was 572, checked in by cp3-support, 13 years ago

upgrade HepMC to version 2.06.05

File size: 6.2 KB
Line 
1//////////////////////////////////////////////////////////////////////////
2// SimpleVector.h
3//////////////////////////////////////////////////////////////////////////
4#ifndef HEPMC_SIMPLEVECTOR_H
5#define HEPMC_SIMPLEVECTOR_H
6
7//////////////////////////////////////////////////////////////////////////
8// garren@fnal.gov, July 2006
9//
10// This header provides a place to hold the doubles which are part of one of
11// three types of physics vectors:
12// momentum 4 vector
13// position or displacement 4 vector
14// position or displacement 3 vector
15//
16// For compatibility with existing code,
17// the basic expected geometrical access methods are povided
18// Also, both FourVector and ThreeVector have a templated constructor that will
19// take another vector (HepLorentzVector, GenVector, ...)
20// --> this vector must have the following methods: x(), y(), z()
21// --> FourVector also requires the t() method
22//
23//////////////////////////////////////////////////////////////////////////
24
25
26#include "enable_if.h"
27#include "is_arithmetic.h"
28
29
30namespace HepMC {
31
32//! FourVector is a simple representation of a physics 4 vector
33
34///
35/// \class FourVector
36/// For compatibility with existing code,
37/// the basic expected geometrical access methods are povided.
38/// Also, there is a templated constructor that will
39/// take another vector (HepLorentzVector, GenVector, ...)
40/// which must have the following methods: x(), y(), z(), t().
41///
42class FourVector {
43
44public:
45
46 /// constructor requiring at least x, y, and z
47 FourVector( double xin, double yin, double zin, double tin=0)
48 : m_x(xin), m_y(yin), m_z(zin), m_t(tin) {}
49
50 /// constructor requiring only t
51 FourVector(double t)
52 : m_x(0), m_y(0), m_z(0), m_t(t) {}
53
54 FourVector()
55 : m_x(0), m_y(0), m_z(0), m_t(0) {}
56
57 /// templated constructor
58 /// this is used ONLY if T is not arithmetic
59 template <class T >
60 FourVector( const T& v,
61 typename detail::disable_if< detail::is_arithmetic<T>::value, void >::type * = 0 )
62 : m_x(v.x()), m_y(v.y()), m_z(v.z()), m_t(v.t()) {}
63
64 /// copy constructor
65 FourVector(const FourVector & v)
66 : m_x(v.x()), m_y(v.y()), m_z(v.z()), m_t(v.t()) {}
67
68 void swap( FourVector & other ); //!< swap
69
70 double px() const { return m_x; } //!< return px
71 double py() const { return m_y; } //!< return py
72 double pz() const { return m_z; } //!< return pz
73 double e() const { return m_t; } //!< return E
74
75 double x() const { return m_x; } //!< return x
76 double y() const { return m_y; } //!< return y
77 double z() const { return m_z; } //!< return z
78 double t() const { return m_t; } //!< return t
79
80 double m2() const; //!< Invariant mass squared.
81 double m() const; //!< Invariant mass. If m2() is negative then -sqrt(-m2()) is returned.
82
83 double perp2() const; //!< Transverse component of the spatial vector squared.
84 double perp() const; //!< Transverse component of the spatial vector (R in cylindrical system).
85
86 // Get spatial vector components in spherical coordinate system.
87 double theta() const; //!< The polar angle.
88 double phi() const; //!< The azimuth angle.
89 double rho() const; //!< spatial vector component magnitude
90
91 FourVector & operator = (const FourVector &); //!< make a copy
92
93 bool operator == (const FourVector &) const; //!< equality
94 bool operator != (const FourVector &) const; //!< inequality
95
96 double pseudoRapidity() const; //!< Returns the pseudo-rapidity, i.e. -ln(tan(theta/2))
97 double eta() const; //!< Pseudorapidity (of the space part)
98
99 /// set x, y, z, and t
100 void set (double x, double y, double z, double t);
101
102 void setX(double x) { m_x=x; } //!< set x
103 void setY(double y) { m_y=y; } //!< set y
104 void setZ(double z) { m_z=z; } //!< set z
105 void setT(double t) { m_t=t; } //!< set t
106
107 void setPx(double x) { m_x=x; } //!< set px
108 void setPy(double y) { m_y=y; } //!< set py
109 void setPz(double z) { m_z=z; } //!< set pz
110 void setE(double t) { m_t=t; } //!< set E
111
112private:
113
114 double m_x;
115 double m_y;
116 double m_z;
117 double m_t;
118
119};
120
121//! ThreeVector is a simple representation of a position or displacement 3 vector
122
123///
124/// \class ThreeVector
125/// For compatibility with existing code,
126/// the basic expected geometrical access methods are povided.
127/// Also, there is a templated constructor that will
128/// take another vector (HepLorentzVector, GenVector, ...)
129/// which must have the following methods: x(), y(), z().
130///
131class ThreeVector {
132
133public:
134
135 /// construct using x, y, and z (only x is required)
136 ThreeVector( double xin, double yin =0, double zin =0 )
137 : m_x(xin), m_y(yin), m_z(zin) {}
138
139 ThreeVector( )
140 : m_x(0), m_y(0), m_z(0) {}
141
142 /// templated constructor
143 /// this is used ONLY if T is not arithmetic
144 template <class T >
145 ThreeVector( const T& v,
146 typename detail::disable_if< detail::is_arithmetic<T>::value, void >::type * = 0 )
147 : m_x(v.x()), m_y(v.y()), m_z(v.z()) {}
148
149 /// copy constructor
150 ThreeVector(const ThreeVector & v)
151 : m_x(v.x()), m_y(v.y()), m_z(v.z()) {}
152
153 void swap( ThreeVector & other ); //!< swap
154
155 double x() const { return m_x; } //!< return x
156 double y() const { return m_y; } //!< return y
157 double z() const { return m_z; } //!< return z
158
159 void setX(double x) { m_x=x; } //!< set x
160 void setY(double y) { m_y=y; } //!< set y
161 void setZ(double z) { m_z=z; } //!< set z
162 void set( double x, double y, double z); //!< set x, y, and z
163
164 double phi() const; //!< The azimuth angle.
165 double theta() const; //!< The polar angle.
166 double r() const; //!< The magnitude
167
168 void setPhi(double); //!< Set phi keeping magnitude and theta constant (BaBar).
169 void setTheta(double); //!< Set theta keeping magnitude and phi constant (BaBar).
170
171 double perp2() const; //!< The transverse component squared (rho^2 in cylindrical coordinate system).
172 double perp() const; //!< The transverse component (rho in cylindrical coordinate system).
173
174 ThreeVector & operator = (const ThreeVector &); //!< make a copy
175
176 bool operator == (const ThreeVector &) const; //!< equality
177 bool operator != (const ThreeVector &) const; //!< inequality
178
179private:
180
181 double m_x;
182 double m_y;
183 double m_z;
184
185};
186
187
188} // HepMC
189
190#include "SimpleVector.icc"
191
192#endif // HEPMC_SIMPLEVECTOR_H
193
Note: See TracBrowser for help on using the repository browser.