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