EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
src
EvtGenBase
EvtVector4R.cpp
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
#include "
EvtGenBase/EvtVector4R.hh
"
22
23
#include "
EvtGenBase/EvtTensor4C.hh
"
24
#include "
EvtGenBase/EvtVector3R.hh
"
25
#include "
EvtGenBase/EvtVector4C.hh
"
26
27
#include <cmath>
28
#include <iostream>
29
30
using
std::ostream;
31
32
EvtVector4R::EvtVector4R
()
33
{
34
m_v
[0] = 0.0;
35
m_v
[1] = 0.0;
36
m_v
[2] = 0.0;
37
m_v
[3] = 0.0;
38
}
39
40
EvtVector4R::EvtVector4R
(
double
e,
double
p1,
double
p2,
double
p3 )
41
{
42
m_v
[0] = e;
43
m_v
[1] = p1;
44
m_v
[2] = p2;
45
m_v
[3] = p3;
46
}
47
48
double
EvtVector4R::mass
()
const
49
{
50
double
m2 =
m_v
[0] *
m_v
[0] -
m_v
[1] *
m_v
[1] -
m_v
[2] *
m_v
[2] -
51
m_v
[3] *
m_v
[3];
52
53
if
( m2 > 0.0 ) {
54
return
sqrt( m2 );
55
}
else
{
56
return
0.0;
57
}
58
}
59
60
EvtVector4R
rotateEuler
(
const
EvtVector4R
& rs,
double
alpha,
double
beta,
61
double
gamma )
62
{
63
EvtVector4R
tmp( rs );
64
tmp.
applyRotateEuler
( alpha, beta, gamma );
65
return
tmp;
66
}
67
68
EvtVector4R
boostTo
(
const
EvtVector4R
& rs,
const
EvtVector4R
& p4,
bool
inverse )
69
{
70
EvtVector4R
tmp( rs );
71
tmp.
applyBoostTo
( p4, inverse );
72
return
tmp;
73
}
74
75
EvtVector4R
boostTo
(
const
EvtVector4R
& rs,
const
EvtVector3R
& boost,
76
bool
inverse )
77
{
78
EvtVector4R
tmp( rs );
79
tmp.
applyBoostTo
( boost, inverse );
80
return
tmp;
81
}
82
83
void
EvtVector4R::applyRotateEuler
(
double
phi,
double
theta,
double
ksi )
84
{
85
double
sp = sin( phi );
86
double
st = sin( theta );
87
double
sk = sin( ksi );
88
double
cp = cos( phi );
89
double
ct = cos( theta );
90
double
ck = cos( ksi );
91
92
double
x = ( ck * ct * cp - sk * sp ) *
m_v
[1] +
93
( -sk * ct * cp - ck * sp ) *
m_v
[2] + st * cp *
m_v
[3];
94
double
y = ( ck * ct * sp + sk * cp ) *
m_v
[1] +
95
( -sk * ct * sp + ck * cp ) *
m_v
[2] + st * sp *
m_v
[3];
96
double
z = -ck * st *
m_v
[1] + sk * st *
m_v
[2] + ct *
m_v
[3];
97
98
m_v
[1] = x;
99
m_v
[2] = y;
100
m_v
[3] = z;
101
}
102
103
ostream&
operator<<
( ostream& s,
const
EvtVector4R
& v )
104
{
105
s <<
"("
<< v.
m_v
[0] <<
","
<< v.
m_v
[1] <<
","
<< v.
m_v
[2] <<
","
106
<< v.
m_v
[3] <<
")"
;
107
108
return
s;
109
}
110
111
void
EvtVector4R::applyBoostTo
(
const
EvtVector4R
& p4,
bool
inverse )
112
{
113
double
e = p4.
get
( 0 );
114
115
EvtVector3R
boost( p4.
get
( 1 ) / e, p4.
get
( 2 ) / e, p4.
get
( 3 ) / e );
116
117
applyBoostTo
( boost, inverse );
118
119
return
;
120
}
121
122
void
EvtVector4R::applyBoostTo
(
const
EvtVector3R
& boost,
bool
inverse )
123
{
124
double
bx, by, bz, gamma, b2;
125
126
bx = boost.
get
( 0 );
127
by = boost.
get
( 1 );
128
bz = boost.
get
( 2 );
129
130
double
bxx = bx * bx;
131
double
byy = by * by;
132
double
bzz = bz * bz;
133
134
b2 = bxx + byy + bzz;
135
136
if
( b2 > 0.0 && b2 < 1.0 ) {
137
gamma = 1.0 / sqrt( 1.0 - b2 );
138
139
double
gb2 = ( gamma - 1.0 ) / b2;
140
141
double
gb2xy = gb2 * bx * by;
142
double
gb2xz = gb2 * bx * bz;
143
double
gb2yz = gb2 * by * bz;
144
145
double
gbx = gamma * bx;
146
double
gby = gamma * by;
147
double
gbz = gamma * bz;
148
149
double
e2 =
m_v
[0];
150
double
px2 =
m_v
[1];
151
double
py2 =
m_v
[2];
152
double
pz2 =
m_v
[3];
153
154
if
( inverse ) {
155
m_v
[0] = gamma * e2 - gbx * px2 - gby * py2 - gbz * pz2;
156
157
m_v
[1] = -gbx * e2 + gb2 * bxx * px2 + px2 + gb2xy * py2 +
158
gb2xz * pz2;
159
160
m_v
[2] = -gby * e2 + gb2 * byy * py2 + py2 + gb2xy * px2 +
161
gb2yz * pz2;
162
163
m_v
[3] = -gbz * e2 + gb2 * bzz * pz2 + pz2 + gb2yz * py2 +
164
gb2xz * px2;
165
}
else
{
166
m_v
[0] = gamma * e2 + gbx * px2 + gby * py2 + gbz * pz2;
167
168
m_v
[1] = gbx * e2 + gb2 * bxx * px2 + px2 + gb2xy * py2 + gb2xz * pz2;
169
170
m_v
[2] = gby * e2 + gb2 * byy * py2 + py2 + gb2xy * px2 + gb2yz * pz2;
171
172
m_v
[3] = gbz * e2 + gb2 * bzz * pz2 + pz2 + gb2yz * py2 + gb2xz * px2;
173
}
174
}
175
}
176
177
EvtVector4R
EvtVector4R::cross
(
const
EvtVector4R
& p2 )
const
178
{
179
//Calcs the cross product. Added by djl on July 27, 1995.
180
//Modified for real vectros by ryd Aug 28-96
181
182
EvtVector4R
temp;
183
184
temp.
m_v
[0] = 0.0;
185
temp.
m_v
[1] =
m_v
[2] * p2.
m_v
[3] -
m_v
[3] * p2.
m_v
[2];
186
temp.
m_v
[2] =
m_v
[3] * p2.
m_v
[1] -
m_v
[1] * p2.
m_v
[3];
187
temp.
m_v
[3] =
m_v
[1] * p2.
m_v
[2] -
m_v
[2] * p2.
m_v
[1];
188
189
return
temp;
190
}
191
192
double
EvtVector4R::d3mag
() const
193
194
// returns the 3 momentum mag.
195
{
196
double
temp;
197
198
temp =
m_v
[1] *
m_v
[1] +
m_v
[2] *
m_v
[2] +
m_v
[3] *
m_v
[3];
199
200
temp = sqrt( temp );
201
202
return
temp;
203
}
// r3mag
204
205
double
EvtVector4R::dot
(
const
EvtVector4R
& p2 )
const
206
{
207
//Returns the dot product of the 3 momentum. Added by
208
//djl on July 27, 1995. for real!!!
209
210
double
temp;
211
212
temp =
m_v
[1] * p2.
m_v
[1];
213
temp +=
m_v
[2] * p2.
m_v
[2];
214
temp +=
m_v
[3] * p2.
m_v
[3];
215
216
return
temp;
217
218
}
//dot
219
220
// Functions below added by AJB
221
222
// Calculate ( \vec{p1} cross \vec{p2} ) \cdot \vec{p3} in rest frame of object
223
double
EvtVector4R::scalartripler3
(
const
EvtVector4R
& p1,
const
EvtVector4R
& p2,
224
const
EvtVector4R
& p3 )
const
225
{
226
EvtVector4C
lc =
dual
(
EvtGenFunctions::directProd
( *
this
, p1 ) ).
cont2
( p2 );
227
EvtVector4R
l(
real
( lc.
get
( 0 ) ),
real
( lc.
get
( 1 ) ),
228
real
( lc.
get
( 2 ) ),
real
( lc.
get
( 3 ) ) );
229
230
return
-1.0 /
mass
() * ( l * p3 );
231
}
232
233
// Calculate the 3-d dot product of 4-vectors p1 and p2 in the rest frame of
234
// 4-vector p0
235
double
EvtVector4R::dotr3
(
const
EvtVector4R
& p1,
const
EvtVector4R
& p2 )
const
236
{
237
return
1 /
mass2
() * ( ( *this ) * p1 ) * ( ( *
this
) * p2 ) - p1 * p2;
238
}
239
240
// Calculate the 3-d magnitude squared of 4-vector p1 in the rest frame of
241
// 4-vector p0
242
double
EvtVector4R::mag2r3
(
const
EvtVector4R
& p1 )
const
243
{
244
return
Square
( ( *
this
) * p1 ) /
mass2
() - p1.
mass2
();
245
}
246
247
// Calculate the 3-d magnitude 4-vector p1 in the rest frame of 4-vector p0.
248
double
EvtVector4R::magr3
(
const
EvtVector4R
& p1 )
const
249
{
250
return
sqrt(
mag2r3
( p1 ) );
251
}
real
double real(const EvtComplex &c)
Definition
EvtComplex.hh:232
dual
EvtTensor4C dual(const EvtTensor4C &t2)
Definition
EvtTensor4C.cpp:363
EvtTensor4C.hh
EvtVector3R.hh
EvtVector4C.hh
rotateEuler
EvtVector4R rotateEuler(const EvtVector4R &rs, double alpha, double beta, double gamma)
Definition
EvtVector4R.cpp:60
operator<<
ostream & operator<<(ostream &s, const EvtVector4R &v)
Definition
EvtVector4R.cpp:103
boostTo
EvtVector4R boostTo(const EvtVector4R &rs, const EvtVector4R &p4, bool inverse)
Definition
EvtVector4R.cpp:68
EvtVector4R.hh
EvtTensor4C::cont2
EvtVector4C cont2(const EvtVector4C &v4) const
Definition
EvtTensor4C.cpp:460
EvtVector3R
Definition
EvtVector3R.hh:26
EvtVector3R::get
double get(int i) const
Definition
EvtVector3R.hh:121
EvtVector4C
Definition
EvtVector4C.hh:30
EvtVector4C::get
const EvtComplex & get(int) const
Definition
EvtVector4C.hh:125
EvtVector4R
Definition
EvtVector4R.hh:29
EvtVector4R::dot
double dot(const EvtVector4R &v2) const
Definition
EvtVector4R.cpp:205
EvtVector4R::EvtVector4R
EvtVector4R()
Definition
EvtVector4R.cpp:32
EvtVector4R::applyRotateEuler
void applyRotateEuler(double alpha, double beta, double gamma)
Definition
EvtVector4R.cpp:83
EvtVector4R::mass
double mass() const
Definition
EvtVector4R.cpp:48
EvtVector4R::magr3
double magr3(const EvtVector4R &p1) const
Definition
EvtVector4R.cpp:248
EvtVector4R::get
double get(int i) const
Definition
EvtVector4R.hh:163
EvtVector4R::d3mag
double d3mag() const
Definition
EvtVector4R.cpp:192
EvtVector4R::dotr3
double dotr3(const EvtVector4R &p1, const EvtVector4R &p2) const
Definition
EvtVector4R.cpp:235
EvtVector4R::scalartripler3
double scalartripler3(const EvtVector4R &p1, const EvtVector4R &p2, const EvtVector4R &p3) const
Definition
EvtVector4R.cpp:223
EvtVector4R::Square
double Square(double x) const
Definition
EvtVector4R.hh:70
EvtVector4R::mag2r3
double mag2r3(const EvtVector4R &p1) const
Definition
EvtVector4R.cpp:242
EvtVector4R::cross
EvtVector4R cross(const EvtVector4R &v2) const
Definition
EvtVector4R.cpp:177
EvtVector4R::m_v
double m_v[4]
Definition
EvtVector4R.hh:68
EvtVector4R::mass2
double mass2() const
Definition
EvtVector4R.hh:100
EvtVector4R::applyBoostTo
void applyBoostTo(const EvtVector4R &p4, bool inverse=false)
Definition
EvtVector4R.cpp:111
EvtGenFunctions::directProd
EvtTensor3C directProd(const EvtVector3C &c1, const EvtVector3C &c2)
Definition
EvtTensor3C.cpp:153
Generated by
1.17.0