BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtVector4R.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtVector4R.cc
12//
13// Description: Real implementation of 4-vectors
14//
15// Modification history:
16//
17// DJL/RYD September 25, 1996 Module created
18//
19//------------------------------------------------------------------------
20//
21#include "EvtVector4R.hh"
22#include "EvtPatches.hh"
23#include "EvtTensor4C.hh"
24#include "EvtVector3R.hh"
25#include "EvtVector4C.hh"
26#include <assert.h>
27#include <iostream>
28#include <math.h>
29
30using std::ostream;
31
32EvtVector4R::EvtVector4R( double e, double p1, double p2, double p3 ) {
33
34 v[0] = e;
35 v[1] = p1;
36 v[2] = p2;
37 v[3] = p3;
38}
39
40double EvtVector4R::mass() const {
41
42 double m2 = v[0] * v[0] - v[1] * v[1] - v[2] * v[2] - v[3] * v[3];
43
44 if ( m2 > 0.0 ) { return sqrt( m2 ); }
45 else { return 0.0; }
46}
47
48EvtVector4R rotateEuler( const EvtVector4R& rs, double alpha, double beta, double gamma ) {
49
50 EvtVector4R tmp( rs );
51 tmp.applyRotateEuler( alpha, beta, gamma );
52 return tmp;
53}
54
55EvtVector4R boostTo( const EvtVector4R& rs, const EvtVector4R& p4 ) {
56
57 EvtVector4R tmp( rs );
58 tmp.applyBoostTo( p4 );
59 return tmp;
60}
61
62EvtVector4R boostTo( const EvtVector4R& rs, const EvtVector3R& boost ) {
63
64 EvtVector4R tmp( rs );
65 tmp.applyBoostTo( boost );
66 return tmp;
67}
68
69void EvtVector4R::applyRotateEuler( double phi, double theta, double ksi ) {
70
71 double sp = sin( phi );
72 double st = sin( theta );
73 double sk = sin( ksi );
74 double cp = cos( phi );
75 double ct = cos( theta );
76 double ck = cos( ksi );
77
78 double x =
79 ( ck * ct * cp - sk * sp ) * v[1] + ( -sk * ct * cp - ck * sp ) * v[2] + st * cp * v[3];
80 double y =
81 ( ck * ct * sp + sk * cp ) * v[1] + ( -sk * ct * sp + ck * cp ) * v[2] + st * sp * v[3];
82 double z = -ck * st * v[1] + sk * st * v[2] + ct * v[3];
83
84 v[1] = x;
85 v[2] = y;
86 v[3] = z;
87}
88
89ostream& operator<<( ostream& s, const EvtVector4R& v ) {
90
91 s << "(" << v.v[0] << "," << v.v[1] << "," << v.v[2] << "," << v.v[3] << ")";
92
93 return s;
94}
95
97
98 double e = p4.get( 0 );
99
100 EvtVector3R boost( p4.get( 1 ) / e, p4.get( 2 ) / e, p4.get( 3 ) / e );
101
102 applyBoostTo( boost );
103
104 return;
105}
106
108
109 double bx, by, bz, gamma, b2;
110
111 bx = boost.get( 0 );
112 by = boost.get( 1 );
113 bz = boost.get( 2 );
114
115 double bxx = bx * bx;
116 double byy = by * by;
117 double bzz = bz * bz;
118
119 b2 = bxx + byy + bzz;
120
121 if ( b2 == 0.0 ) { return; }
122
123 assert( b2 < 1.0 );
124
125 gamma = 1.0 / sqrt( 1 - b2 );
126
127 double gb2 = ( gamma - 1.0 ) / b2;
128
129 double gb2xy = gb2 * bx * by;
130 double gb2xz = gb2 * bx * bz;
131 double gb2yz = gb2 * by * bz;
132
133 double gbx = gamma * bx;
134 double gby = gamma * by;
135 double gbz = gamma * bz;
136
137 double e2 = v[0];
138 double px2 = v[1];
139 double py2 = v[2];
140 double pz2 = v[3];
141
142 v[0] = gamma * e2 + gbx * px2 + gby * py2 + gbz * pz2;
143
144 v[1] = gbx * e2 + gb2 * bxx * px2 + px2 + gb2xy * py2 + gb2xz * pz2;
145
146 v[2] = gby * e2 + gb2 * byy * py2 + py2 + gb2xy * px2 + gb2yz * pz2;
147
148 v[3] = gbz * e2 + gb2 * bzz * pz2 + pz2 + gb2yz * py2 + gb2xz * px2;
149
150 return;
151}
152
154
155 // Calcs the cross product. Added by djl on July 27, 1995.
156 // Modified for real vectros by ryd Aug 28-96
157
158 EvtVector4R temp;
159
160 temp.v[0] = 0.0;
161 temp.v[1] = v[2] * p2.v[3] - v[3] * p2.v[2];
162 temp.v[2] = v[3] * p2.v[1] - v[1] * p2.v[3];
163 temp.v[3] = v[1] * p2.v[2] - v[2] * p2.v[1];
164
165 return temp;
166}
167
168double EvtVector4R::d3mag() const
169
170// returns the 3 momentum mag.
171{
172 double temp;
173
174 temp = v[1] * v[1] + v[2] * v[2] + v[3] * v[3];
175
176 temp = sqrt( temp );
177
178 return temp;
179} // r3mag
180
181double EvtVector4R::dot( const EvtVector4R& p2 ) const {
182
183 // Returns the dot product of the 3 momentum. Added by
184 // djl on July 27, 1995. for real!!!
185
186 double temp;
187
188 temp = v[1] * p2.v[1];
189 temp += v[2] * p2.v[2];
190 temp += v[3] * p2.v[3];
191
192 return temp;
193
194} // dot
195
196// Functions below added by AJB
197
198// Calculate ( \vec{p1} cross \vec{p2} ) \cdot \vec{p3} in rest frame of object
200 const EvtVector4R& p3 ) const {
201 EvtVector4C lc = dual( directProd( *this, p1 ) ).cont2( p2 );
202 EvtVector4R l( real( lc.get( 0 ) ), real( lc.get( 1 ) ), real( lc.get( 2 ) ),
203 real( lc.get( 3 ) ) );
204
205 return -1.0 / mass() * ( l * p3 );
206}
207
208// Calculate the 3-d dot product of 4-vectors p1 and p2 in the rest frame of
209// 4-vector p0
210double EvtVector4R::dotr3( const EvtVector4R& p1, const EvtVector4R& p2 ) const {
211 return 1 / mass2() * ( ( *this ) * p1 ) * ( ( *this ) * p2 ) - p1 * p2;
212}
213
214// Calculate the 3-d magnitude squared of 4-vector p1 in the rest frame of
215// 4-vector p0
216double EvtVector4R::mag2r3( const EvtVector4R& p1 ) const {
217 return Square( ( *this ) * p1 ) / mass2() - p1.mass2();
218}
219
220// Calculate the 3-d magnitude 4-vector p1 in the rest frame of 4-vector p0.
221double EvtVector4R::magr3( const EvtVector4R& p1 ) const { return sqrt( mag2r3( p1 ) ); }
222
223// calculate the polor angle
225 return ( v[1] == 0 && v[2] == 0 && v[3] == 0 )
226 ? 0
227 : atan2( sqrt( v[1] * v[1] + v[2] * v[2] ), v[3] );
228}
229
230// calculate the azimuthal angle
231double EvtVector4R::phi() { return ( v[1] == 0 && v[2] == 0 ) ? 0 : atan2( v[2], v[1] ); }
double p2[4]
double p1[4]
Double_t e2
Evt3Rank3C directProd(const EvtVector3C &c1, const EvtVector3C &c2, const EvtVector3C &c3)
double alpha
EvtTensor4C dual(const EvtTensor4C &t2)
EvtVector4R boostTo(const EvtVector4R &rs, const EvtVector4R &p4)
EvtVector4R rotateEuler(const EvtVector4R &rs, double alpha, double beta, double gamma)
ostream & operator<<(ostream &s, const EvtVector4R &v)
XmlRpcServer s
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35
EvtVector4C cont2(const EvtVector4C &v4) const
double get(int i) const
const EvtComplex & get(int) const
double phi()
double dot(const EvtVector4R &v2) const
void applyRotateEuler(double alpha, double beta, double gamma)
double mass() const
double magr3(const EvtVector4R &p1) const
double get(int i) const
EvtVector4R cross(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 mag2r3(const EvtVector4R &p1) const
double mass2() const
void applyBoostTo(const EvtVector4R &p4)
double theta()
double double * m2
Definition qcdloop1.h:83