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
EvtVector4C.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
22
24
25#include <assert.h>
26#include <iostream>
27#include <math.h>
28using std::ostream;
29
31{
32 m_v[0] = EvtComplex( 0.0 );
33 m_v[1] = EvtComplex( 0.0 );
34 m_v[2] = EvtComplex( 0.0 );
35 m_v[3] = EvtComplex( 0.0 );
36}
37
39 const EvtComplex& e2, const EvtComplex& e3 )
40{
41 m_v[0] = e0;
42 m_v[1] = e1;
43 m_v[2] = e2;
44 m_v[3] = e3;
45}
46
47EvtVector4C rotateEuler( const EvtVector4C& rs, double alpha, double beta,
48 double gamma )
49{
50 EvtVector4C tmp( rs );
51 tmp.applyRotateEuler( alpha, beta, gamma );
52 return tmp;
53}
54
56{
57 EvtVector4C tmp( rs );
58 tmp.applyBoostTo( p4 );
59 return tmp;
60}
61
62EvtVector4C boostTo( const EvtVector4C& rs, const EvtVector3R boost )
63{
64 EvtVector4C tmp( rs );
65 tmp.applyBoostTo( boost );
66 return tmp;
67}
68
70{
71 double e = p4.get( 0 );
72
73 EvtVector3R boost( p4.get( 1 ) / e, p4.get( 2 ) / e, p4.get( 3 ) / e );
74
75 applyBoostTo( boost );
76
77 return;
78}
79
81{
82 double bx, by, bz, gamma, b2;
83
84 bx = boost.get( 0 );
85 by = boost.get( 1 );
86 bz = boost.get( 2 );
87
88 double bxx = bx * bx;
89 double byy = by * by;
90 double bzz = bz * bz;
91
92 b2 = bxx + byy + bzz;
93
94 if ( b2 == 0.0 ) {
95 return;
96 }
97
98 assert( b2 < 1.0 );
99
100 gamma = 1.0 / sqrt( 1 - b2 );
101
102 double gb2 = ( gamma - 1.0 ) / b2;
103
104 double gb2xy = gb2 * bx * by;
105 double gb2xz = gb2 * bx * bz;
106 double gb2yz = gb2 * by * bz;
107
108 double gbx = gamma * bx;
109 double gby = gamma * by;
110 double gbz = gamma * bz;
111
112 EvtComplex e2 = m_v[0];
113 EvtComplex px2 = m_v[1];
114 EvtComplex py2 = m_v[2];
115 EvtComplex pz2 = m_v[3];
116
117 m_v[0] = gamma * e2 + gbx * px2 + gby * py2 + gbz * pz2;
118
119 m_v[1] = gbx * e2 + gb2 * bxx * px2 + px2 + gb2xy * py2 + gb2xz * pz2;
120
121 m_v[2] = gby * e2 + gb2 * byy * py2 + py2 + gb2xy * px2 + gb2yz * pz2;
122
123 m_v[3] = gbz * e2 + gb2 * bzz * pz2 + pz2 + gb2yz * py2 + gb2xz * px2;
124
125 return;
126}
127
128void EvtVector4C::applyRotateEuler( double phi, double theta, double ksi )
129{
130 double sp = sin( phi );
131 double st = sin( theta );
132 double sk = sin( ksi );
133 double cp = cos( phi );
134 double ct = cos( theta );
135 double ck = cos( ksi );
136
137 EvtComplex x = ( ck * ct * cp - sk * sp ) * m_v[1] +
138 ( -sk * ct * cp - ck * sp ) * m_v[2] + st * cp * m_v[3];
139 EvtComplex y = ( ck * ct * sp + sk * cp ) * m_v[1] +
140 ( -sk * ct * sp + ck * cp ) * m_v[2] + st * sp * m_v[3];
141 EvtComplex z = -ck * st * m_v[1] + sk * st * m_v[2] + ct * m_v[3];
142
143 m_v[1] = x;
144 m_v[2] = y;
145 m_v[3] = z;
146}
147
148ostream& operator<<( ostream& s, const EvtVector4C& v )
149{
150 s << "(" << v.m_v[0] << "," << v.m_v[1] << "," << v.m_v[2] << ","
151 << v.m_v[3] << ")";
152
153 return s;
154}
ostream & operator<<(ostream &s, const EvtVector4C &v)
EvtVector4C rotateEuler(const EvtVector4C &rs, double alpha, double beta, double gamma)
EvtVector4C boostTo(const EvtVector4C &rs, const EvtVector4R p4)
double get(int i) const
void applyRotateEuler(double alpha, double beta, double gamma)
EvtComplex m_v[4]
void applyBoostTo(const EvtVector4R &p4)
double get(int i) const