EvtGen 2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Loading...
Searching...
No Matches
EvtVector4R.hh
Go to the documentation of this file.
1
2/***********************************************************************
3* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4* *
5* This file is part of EvtGen. *
6* *
7* EvtGen is free software: you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation, either version 3 of the License, or *
10* (at your option) any later version. *
11* *
12* EvtGen is distributed in the hope that it will be useful, *
13* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15* GNU General Public License for more details. *
16* *
17* You should have received a copy of the GNU General Public License *
18* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19***********************************************************************/
20
21#ifndef EVTVECTOR4R_HH
22#define EVTVECTOR4R_HH
23
24#include <iostream>
25#include <math.h>
26
27class EvtVector3R;
28
30 inline friend EvtVector4R operator*( double d, const EvtVector4R& v2 );
31 inline friend EvtVector4R operator*( const EvtVector4R& v2, double d );
32 inline friend EvtVector4R operator/( const EvtVector4R& v2, double d );
33 inline friend double operator*( const EvtVector4R& v1, const EvtVector4R& v2 );
34 inline friend EvtVector4R operator+( const EvtVector4R& v1,
35 const EvtVector4R& v2 );
36 inline friend EvtVector4R operator-( const EvtVector4R& v1,
37 const EvtVector4R& v2 );
38
39 public:
41 EvtVector4R( double e, double px, double py, double pz );
42 inline void set( int i, double d );
43 inline void set( double e, double px, double py, double pz );
44 inline EvtVector4R& operator*=( double c );
45 inline EvtVector4R& operator/=( double c );
46 inline EvtVector4R& operator+=( const EvtVector4R& v2 );
47 inline EvtVector4R& operator-=( const EvtVector4R& v2 );
48 inline double get( int i ) const;
49 inline double cont( const EvtVector4R& v4 ) const;
50 friend std::ostream& operator<<( std::ostream& s, const EvtVector4R& v );
51 double mass2() const;
52 double mass() const;
53 void applyRotateEuler( double alpha, double beta, double gamma );
54 void applyBoostTo( const EvtVector4R& p4, bool inverse = false );
55 void applyBoostTo( const EvtVector3R& boost, bool inverse = false );
56 EvtVector4R cross( const EvtVector4R& v2 ) const;
57 double dot( const EvtVector4R& v2 ) const;
58 double d3mag() const;
59
60 // Added by AJB - calculate scalars in the rest frame of the current object
61 double scalartripler3( const EvtVector4R& p1, const EvtVector4R& p2,
62 const EvtVector4R& p3 ) const;
63 double dotr3( const EvtVector4R& p1, const EvtVector4R& p2 ) const;
64 double mag2r3( const EvtVector4R& p1 ) const;
65 double magr3( const EvtVector4R& p1 ) const;
66
67 private:
68 double m_v[4];
69
70 inline double Square( double x ) const { return x * x; }
71};
72
73EvtVector4R rotateEuler( const EvtVector4R& rs, double alpha, double beta,
74 double gamma );
75EvtVector4R boostTo( const EvtVector4R& rs, const EvtVector4R& p4,
76 bool inverse = false );
77EvtVector4R boostTo( const EvtVector4R& rs, const EvtVector3R& boost,
78 bool inverse = false );
79
81{
82 m_v[0] += v2.m_v[0];
83 m_v[1] += v2.m_v[1];
84 m_v[2] += v2.m_v[2];
85 m_v[3] += v2.m_v[3];
86
87 return *this;
88}
89
91{
92 m_v[0] -= v2.m_v[0];
93 m_v[1] -= v2.m_v[1];
94 m_v[2] -= v2.m_v[2];
95 m_v[3] -= v2.m_v[3];
96
97 return *this;
98}
99
100inline double EvtVector4R::mass2() const
101{
102 return m_v[0] * m_v[0] - m_v[1] * m_v[1] - m_v[2] * m_v[2] - m_v[3] * m_v[3];
103}
104
105inline EvtVector4R operator*( double c, const EvtVector4R& v2 )
106{
107 return EvtVector4R( v2 ) *= c;
108}
109
110inline EvtVector4R operator*( const EvtVector4R& v2, double c )
111{
112 return EvtVector4R( v2 ) *= c;
113}
114
115inline EvtVector4R operator/( const EvtVector4R& v2, double c )
116{
117 return EvtVector4R( v2 ) /= c;
118}
119
121{
122 m_v[0] *= c;
123 m_v[1] *= c;
124 m_v[2] *= c;
125 m_v[3] *= c;
126
127 return *this;
128}
129
131{
132 double cinv = 1.0 / c;
133 m_v[0] *= cinv;
134 m_v[1] *= cinv;
135 m_v[2] *= cinv;
136 m_v[3] *= cinv;
137
138 return *this;
139}
140
141inline double operator*( const EvtVector4R& v1, const EvtVector4R& v2 )
142{
143 return v1.m_v[0] * v2.m_v[0] - v1.m_v[1] * v2.m_v[1] -
144 v1.m_v[2] * v2.m_v[2] - v1.m_v[3] * v2.m_v[3];
145}
146
147inline double EvtVector4R::cont( const EvtVector4R& v4 ) const
148{
149 return m_v[0] * v4.m_v[0] - m_v[1] * v4.m_v[1] - m_v[2] * v4.m_v[2] -
150 m_v[3] * v4.m_v[3];
151}
152
153inline EvtVector4R operator-( const EvtVector4R& v1, const EvtVector4R& v2 )
154{
155 return EvtVector4R( v1 ) -= v2;
156}
157
158inline EvtVector4R operator+( const EvtVector4R& v1, const EvtVector4R& v2 )
159{
160 return EvtVector4R( v1 ) += v2;
161}
162
163inline double EvtVector4R::get( int i ) const
164{
165 return m_v[i];
166}
167
168inline void EvtVector4R::set( int i, double d )
169{
170 m_v[i] = d;
171}
172
173inline void EvtVector4R::set( double e, double p1, double p2, double p3 )
174{
175 m_v[0] = e;
176 m_v[1] = p1;
177 m_v[2] = p2;
178 m_v[3] = p3;
179}
180
181#endif
EvtVector4R operator-(const EvtVector4R &v1, const EvtVector4R &v2)
EvtVector4R rotateEuler(const EvtVector4R &rs, double alpha, double beta, double gamma)
EvtVector4R operator/(const EvtVector4R &v2, double c)
EvtVector4R operator+(const EvtVector4R &v1, const EvtVector4R &v2)
EvtVector4R boostTo(const EvtVector4R &rs, const EvtVector4R &p4, bool inverse=false)
EvtVector4R operator*(double c, const EvtVector4R &v2)
double dot(const EvtVector4R &v2) const
friend EvtVector4R operator-(const EvtVector4R &v1, const EvtVector4R &v2)
EvtVector4R & operator-=(const EvtVector4R &v2)
void applyRotateEuler(double alpha, double beta, double gamma)
double mass() const
double magr3(const EvtVector4R &p1) const
double get(int i) const
EvtVector4R & operator+=(const EvtVector4R &v2)
double d3mag() const
double dotr3(const EvtVector4R &p1, const EvtVector4R &p2) const
double scalartripler3(const EvtVector4R &p1, const EvtVector4R &p2, const EvtVector4R &p3) const
double Square(double x) const
double mag2r3(const EvtVector4R &p1) const
friend std::ostream & operator<<(std::ostream &s, const EvtVector4R &v)
EvtVector4R cross(const EvtVector4R &v2) const
friend EvtVector4R operator+(const EvtVector4R &v1, const EvtVector4R &v2)
EvtVector4R & operator*=(double c)
double cont(const EvtVector4R &v4) const
EvtVector4R & operator/=(double c)
double m_v[4]
double mass2() const
friend EvtVector4R operator/(const EvtVector4R &v2, double d)
friend EvtVector4R operator*(double d, const EvtVector4R &v2)
void set(int i, double d)
void applyBoostTo(const EvtVector4R &p4, bool inverse=false)