BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DifFourVector.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: DifFourVector.cxx,v 1.3 2010/03/25 09:55:57 zhangy Exp $
4//
5// Description:
6// Class Implementation for |DifFourVector|
7// What do i do ?
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Author List:
12// A. Snyder
13//
14// Copyright Information:
15// Copyright (C) 1996 SLAC
16//
17// History:
18// Migration for BESIII MDC
19//
20//------------------------------------------------------------------------
21
22#include "MdcRecoUtil/DifFourVector.h"
23using std::cout;
24using std::endl;
25
26DifFourVector::DifFourVector() : E( 0.0 ), P( 0.0, 0.0, 0.0 ) {}
27
29 : E( sqrt( m * m + p * p ) ), P( p ) {}
30DifFourVector::DifFourVector( const double& m, const DifVector& p )
31 : E( sqrt( m * m + p * p ) ), P( p ) {}
32
34
35HepSymMatrix DifFourVector::errorMatrix( const HepSymMatrix& e ) const {
36 HepSymMatrix temp( 4 );
37 temp( 1, 1 ) = correlation( E, E, e );
38 temp( 1, 2 ) = correlation( E, P.x, e );
39 temp( 1, 3 ) = correlation( E, P.y, e );
40 temp( 1, 4 ) = correlation( E, P.z, e );
41 temp( 2, 2 ) = correlation( P.x, P.x, e );
42 temp( 2, 3 ) = correlation( P.x, P.y, e );
43 temp( 2, 4 ) = correlation( P.x, P.z, e );
44 temp( 3, 3 ) = correlation( P.y, P.y, e );
45 temp( 3, 4 ) = correlation( P.y, P.z, e );
46 temp( 4, 4 ) = correlation( P.z, P.z, e );
47 return temp;
48}
49
50HepMatrix DifFourVector::jacobian() const {
51 int npar = E.nPar();
52 HepMatrix temp( 4, npar );
53 for ( int i = 1; i <= npar; i++ )
54 {
55 temp( 1, i ) = E.derivative( i );
56 temp( 2, i ) = P.x.derivative( i );
57 temp( 3, i ) = P.y.derivative( i );
58 temp( 4, i ) = P.z.derivative( i );
59 } // (int i=1; i<=npar; i++)
60 return temp;
61}
62
64 const DifVector xHat( 1, 0, 0 );
65 const DifVector yHat( 0, 1, 0 );
66 const DifVector zHat( 0, 1, 0 );
67 DifVector z = pTo.direction();
68 DifVector y = zHat - z * ( zHat * z );
69 if ( y.length() < 0.01 ) y = xHat - z * ( xHat * z );
70 y.normalize();
71 DifVector x( cross( y, z ) );
72
73 DifNumber px = P * x;
74 DifNumber py = P * y;
75 DifNumber pz = P * z;
76
77 DifNumber gamma = pTo.E / pTo.mass();
78 DifNumber beta = pTo.pMag() / pTo.E;
79
80 DifNumber pzP = gamma * ( pz - beta * E );
81 DifNumber eP = gamma * ( E - beta * pz );
82
83 E = eP;
84 P = px * x + py * y + pzP * z;
85
86 return;
87}
88
89void DifFourVector::boostToMe( std::vector<DifFourVector*>& list ) const {
90 const DifVector xHat( 1, 0, 0 );
91 const DifVector yHat( 0, 1, 0 );
92 const DifVector zHat( 0, 0, 1 );
93 DifVector z = P;
94 z.normalize();
95 DifVector y( zHat - z * ( zHat * z ) );
96 if ( y.lengthSq() < 0.0001 ) y = xHat - z * ( xHat * z );
97 y.normalize();
98 DifVector x( cross( y, z ) );
99
100 DifNumber gamma = E / mass();
101 DifNumber beta = pMag() / E;
102
103 for ( int i = 0; i < (int)list.size(); i++ )
104 {
105 DifFourVector& p4i = *list[i];
106 DifNumber px = p4i.P * x;
107 DifNumber py = p4i.P * y;
108 DifNumber pz = p4i.P * z;
109 DifNumber e = p4i.E;
110
111 DifNumber pzP = gamma * ( pz - beta * e );
112 DifNumber eP = gamma * ( e - beta * pz );
113
114 p4i.E = eP;
115 p4i.P = px * x + py * y + pzP * z;
116 }
117}
118
119void DifFourVector::boostFromMe( std::vector<DifFourVector*>& list ) const {
120 const DifVector xHat( 1, 0, 0 );
121 const DifVector yHat( 0, 1, 0 );
122 const DifVector zHat( 0, 0, 1 );
123 DifVector z = P;
124 z.normalize();
125 DifVector y( zHat - z * ( zHat * z ) );
126 if ( y.lengthSq() < 0.0001 ) y = xHat - z * ( xHat * z );
127 y.normalize();
128 DifVector x( cross( y, z ) );
129
130 DifNumber gamma = E / mass();
131 DifNumber beta = pMag() / E;
132
133 for ( int i = 0; i < (int)list.size(); i++ )
134 {
135 DifFourVector& p4i = *list[i];
136 DifNumber px = p4i.P * x;
137 DifNumber py = p4i.P * y;
138 DifNumber pz = p4i.P * z;
139 DifNumber e = p4i.E;
140
141 DifNumber pzP = gamma * ( pz + beta * e );
142 DifNumber eP = gamma * ( e + beta * pz );
143
144 p4i.E = eP;
145 p4i.P = px * x + py * y + pzP * z;
146 }
147}
148
150 const DifVector xHat( 1, 0, 0 );
151 const DifVector yHat( 0, 1, 0 );
152 const DifVector zHat( 0, 1, 0 );
153 DifVector z = pFrom.direction();
154 DifVector y = zHat - z * ( zHat * z );
155 if ( y.length() < 0.01 ) y = xHat - z * ( xHat * z );
156 y.normalize();
157 DifVector x( cross( y, z ) );
158
159 DifNumber px = P * x;
160 DifNumber py = P * y;
161 DifNumber pz = P * z;
162
163 DifNumber gamma = pFrom.E / pFrom.mass();
164 DifNumber beta = pFrom.pMag() / pFrom.E;
165
166 DifNumber pzP = gamma * ( pz + beta * E );
167 DifNumber eP = gamma * ( E + beta * pz );
168
169 E = eP;
170 P = px * x + py * y + pzP * z;
171}
172
173void DifFourVector::print( /*ostream& o*/ ) const {
174 // SKIP cout << "E:" << endl << E;
175 // SKIP cout << "P:" << endl << P;
176 cout << "SKIP of DifFourVector::print()" << endl; // TEMP
177}
Double_t x[10]
double correlation(const DifNumber &a, const DifNumber &b)
Definition DifNumber.cxx:69
EvtVector3R cross(const EvtVector3R &p1, const EvtVector3R &p2)
**********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
void boostFromMe(std::vector< DifFourVector * > &listToBoost) const
HepMatrix jacobian() const
void boostFrom(const DifFourVector &)
void boostTo(const DifFourVector &)
void boostToMe(std::vector< DifFourVector * > &listToBoost) const
HepSymMatrix errorMatrix(const HepSymMatrix &e) const
DifVector direction() const
void print() const
DifVector & normalize()
DifNumber length() const
DifNumber lengthSq() const