a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
FourMomentum.hpp
Go to the documentation of this file.
1/*
2 * FourMomentum.hpp
3 *
4 * Created on: Jul 26, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 * Copyright 2012 Ben O'Leary
7 *
8 * This file is part of LesHouchesParserClasses, released under the
9 * GNU General Public License. Please see the accompanying
10 * README.LHPC_CPP.txt file for a full list of files, brief documentation
11 * on how to use these classes, and further details on the license.
12 */
13
14#ifndef FOURMOMENTUM_HPP_
15#define FOURMOMENTUM_HPP_
16
17#include <list>
18#include <vector>
19#include <sstream>
20#include "ObjectLine.hpp"
21#include "../LHEF/ParticleLine.hpp"
22
23namespace LHPC
24{
25 // this is a class to just provide some easy conversion to 4-momenta, with
26 // some useful functions.
28 {
29 public:
33 {
37 zComponent = 3
38 };
39
41 FourMomentum( double const initialEnergy,
42 double const initialXMomentum,
43 double const initialYMomentum,
44 double const initialZMomentum );
45 FourMomentum( FourMomentum const& copySource );
46 FourMomentum( LHEF::ParticleLine const& copySource );
47 FourMomentum( LHCO::ObjectLine const& copySource );
48 FourMomentum( std::pair< LhefPointer, LhefPointer > const& copySource );
49 FourMomentum( std::vector< LhefPointer > const& copySource );
50 FourMomentum( std::list< LhefPointer > const& copySource );
51 FourMomentum( std::pair< LhcoPointer, LhcoPointer > const& copySource );
52 FourMomentum( std::vector< LhcoPointer > const& copySource );
53 FourMomentum( std::list< LhcoPointer > const& copySource );
55
56 void
57 assignFrom( FourMomentum const& copySource );
58 void
59 operator=( FourMomentum const& copySource ){ assignFrom( copySource ); }
60 void
61 assignFrom( LHEF::ParticleLine const& copySource );
62 void
64 copySource ); }
65 void
66 assignFrom( LHCO::ObjectLine const& copySource );
67 void
68 operator=( LHCO::ObjectLine const& copySource ){ assignFrom(
69 copySource ); }
70 double&
71 operator[]( int const whichComponent );
72 double const&
73 operator[]( int const whichComponent ) const;
74 void
75 operator+=( FourMomentum const& sourceFourMomentum );
76 void
77 operator-=( FourMomentum const& sourceFourMomentum );
78 void
79 operator*=( double const scalingFactor );
80 void
81 operator/=( double const scalingFactor );
83 operator+( FourMomentum const& sourceFourMomentum );
85 operator-( FourMomentum const& sourceFourMomentum );
86 double
87 operator*( FourMomentum const& sourceFourMomentum );
88 double
89 getT() const{ return (*this)[ (int)tComponent ]; }
90 void
91 setT( double const inputValue ){ (*this)[ (int)tComponent ] = inputValue; }
92 double
93 getX() const{ return (*this)[ (int)xComponent ]; }
94 void
95 setX( double const inputValue ){ (*this)[ (int)xComponent ] = inputValue; }
96 double
97 getY() const{ return (*this)[ (int)yComponent ]; }
98 void
99 setY( double const inputValue ){ (*this)[ (int)yComponent ] = inputValue; }
100 double
101 getZ() const{ return (*this)[ (int)zComponent ]; }
102 void
103 setZ( double const inputValue ){ (*this)[ (int)zComponent ] = inputValue; }
104 double
106 double
108 double
110 double
111 getSpatialMagnitude() const;
112 double
114 double
115 getInvariantMass() const;
116 std::string
117 toString() const;
118
119
120 protected:
121 std::vector< double > momentumComponents;
122 };
123
124
125
126
127
128 inline void
130 {
132 }
133
134 inline void
136 {
137 momentumComponents[ (int)tComponent ] = copySource.getEnergy();
138 momentumComponents[ (int)xComponent ] = copySource.getXMomentum();
139 momentumComponents[ (int)yComponent ] = copySource.getYMomentum();
140 momentumComponents[ (int)zComponent ] = copySource.getZMomentum();
141 }
142
143 inline void
145 {
147 = ( copySource.getTransverseMomentum()
148 * cos( copySource.getAzimuthalAngle() ) );
150 = ( copySource.getTransverseMomentum()
151 * sin( copySource.getAzimuthalAngle() ) );
153 = ( copySource.getTransverseMomentum()
154 * sinh( copySource.getPseudorapidity() ) );
156 = sqrt( ( copySource.getInvariantMass() * copySource.getInvariantMass() )
158 }
159
160 inline double&
161 FourMomentum::operator[]( int const whichComponent )
162 {
163 return momentumComponents[ whichComponent ];
164 }
165
166 inline double const&
167 FourMomentum::operator[]( int const whichComponent ) const
168 {
169 return momentumComponents[ whichComponent ];
170 }
171
172 inline void
173 FourMomentum::operator+=( FourMomentum const& sourceFourMomentum )
174 {
176 += sourceFourMomentum[ (int)tComponent ];
178 += sourceFourMomentum[ (int)xComponent ];
180 += sourceFourMomentum[ (int)yComponent ];
182 += sourceFourMomentum[ (int)zComponent ];
183 }
184
185 inline void
186 FourMomentum::operator-=( FourMomentum const& sourceFourMomentum )
187 {
189 -= sourceFourMomentum[ (int)tComponent ];
191 -= sourceFourMomentum[ (int)xComponent ];
193 -= sourceFourMomentum[ (int)yComponent ];
195 -= sourceFourMomentum[ (int)zComponent ];
196 }
197
198 inline void
199 FourMomentum::operator*=( double const scalingFactor )
200 {
201 momentumComponents[ (int)tComponent ] *= scalingFactor;
202 momentumComponents[ (int)xComponent ] *= scalingFactor;
203 momentumComponents[ (int)yComponent ] *= scalingFactor;
204 momentumComponents[ (int)zComponent ] *= scalingFactor;
205 }
206
207 inline void
208 FourMomentum::operator/=( double const scalingFactor )
209 {
210 momentumComponents[ (int)tComponent ] /= scalingFactor;
211 momentumComponents[ (int)xComponent ] /= scalingFactor;
212 momentumComponents[ (int)yComponent ] /= scalingFactor;
213 momentumComponents[ (int)zComponent ] /= scalingFactor;
214 }
215
216 inline FourMomentum
217 FourMomentum::operator+( FourMomentum const& sourceFourMomentum )
218 {
219 FourMomentum returnFourMomentum( *this );
220 returnFourMomentum += sourceFourMomentum;
221 return returnFourMomentum;
222 }
223
224 inline FourMomentum
225 FourMomentum::operator-( FourMomentum const& sourceFourMomentum )
226 {
227 FourMomentum returnFourMomentum( *this );
228 returnFourMomentum -= sourceFourMomentum;
229 return returnFourMomentum;
230 }
231
232 inline double
233 FourMomentum::operator*( FourMomentum const& sourceFourMomentum )
234 {
235 return ( ( momentumComponents[ (int)tComponent ]
236 * sourceFourMomentum[ (int)tComponent ] )
238 * sourceFourMomentum[ (int)xComponent ] )
240 * sourceFourMomentum[ (int)yComponent ] )
242 * sourceFourMomentum[ (int)zComponent ] ) );
243 }
244
245 inline double
247 {
248 return ( ( momentumComponents[ (int)xComponent ]
251 * momentumComponents[ (int)yComponent ] ) );
252 }
253
254 inline double
256 {
257 return sqrt( getTransverseMagnitudeSquared() );
258 }
259
260 inline double
262 {
265 * momentumComponents[ (int)zComponent ] ) );
266 }
267
268 inline double
270 {
271 return sqrt( getSpatialMagnitudeSquared() );
272 }
273
274 inline double
276 {
277 return ( ( momentumComponents[ (int)tComponent ]
280 }
281
282 inline double
284 {
285 return sqrt( getInvariantMassSquared() );
286 }
287
288 inline std::string
290 {
291 std::stringstream stringBuilder;
292 stringBuilder
293 << "( " << getT() << ", " << getX() << ", " << getY() << ", " << getZ()
294 << " )";
295 return stringBuilder.str();
296 }
297
298} /* namespace LHPC */
299#endif /* FOURMOMENTUM_HPP_ */
void operator=(FourMomentum const &copySource)
void setX(double const inputValue)
double getZ() const
double & operator[](int const whichComponent)
void operator=(LHCO::ObjectLine const &copySource)
void operator+=(FourMomentum const &sourceFourMomentum)
void operator*=(double const scalingFactor)
void operator/=(double const scalingFactor)
void operator=(LHEF::ParticleLine const &copySource)
void setY(double const inputValue)
double getInvariantMassSquared() const
double getSpatialMagnitudeSquared() const
FourMomentum operator-(FourMomentum const &sourceFourMomentum)
double getTransverseMagnitudeSquared() const
double getInvariantMass() const
double operator*(FourMomentum const &sourceFourMomentum)
double getSpatialMagnitude() const
void operator-=(FourMomentum const &sourceFourMomentum)
void setT(double const inputValue)
double getY() const
double getX() const
FourMomentum operator+(FourMomentum const &sourceFourMomentum)
double getT() const
std::string toString() const
double getTransverseMagnitude() const
void assignFrom(FourMomentum const &copySource)
LHEF::ParticleLine const * LhefPointer
void setZ(double const inputValue)
LHCO::ObjectLine const * LhcoPointer
std::vector< double > momentumComponents
double getTransverseMomentum() const
Definition: ObjectLine.hpp:213
double getInvariantMass() const
Definition: ObjectLine.hpp:219
double getPseudorapidity() const
Definition: ObjectLine.hpp:201
double getAzimuthalAngle() const
Definition: ObjectLine.hpp:207
double getXMomentum() const
double getYMomentum() const
double getZMomentum() const