BOSS 7.0.2
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::endl;
24using std::cout;
25
26
28 :E(0.0),P(0.0,0.0,0.0)
29{}
30
32(const DifNumber& m,const DifVector& p)
33 :E(sqrt(m*m+p*p)),P(p)
34{}
36(const double& m,const DifVector& p)
37 :E(sqrt(m*m+p*p)),P(p)
38{}
39
41 :E(v.E),P(v.P)
42{}
43
44HepSymMatrix DifFourVector::errorMatrix(const HepSymMatrix& e)const {
45 HepSymMatrix temp(4);
46 temp(1,1)=correlation(E,E,e);
47 temp(1,2)=correlation(E,P.x,e);
48 temp(1,3)=correlation(E,P.y,e);
49 temp(1,4)=correlation(E,P.z,e);
50 temp(2,2)=correlation(P.x,P.x,e);
51 temp(2,3)=correlation(P.x,P.y,e);
52 temp(2,4)=correlation(P.x,P.z,e);
53 temp(3,3)=correlation(P.y,P.y,e);
54 temp(3,4)=correlation(P.y,P.z,e);
55 temp(4,4)=correlation(P.z,P.z,e);
56 return temp;
57}
58
59HepMatrix DifFourVector::jacobian()const{
60 int npar=E.nPar();
61 HepMatrix temp(4,npar);
62 for(int i=1; i<=npar; i++){
63 temp(1,i)=E.derivative(i);
64 temp(2,i)=P.x.derivative(i);
65 temp(3,i)=P.y.derivative(i);
66 temp(4,i)=P.z.derivative(i);
67 } // (int i=1; i<=npar; i++)
68 return temp;
69}
70
71void
73{
74 const DifVector xHat(1,0,0);
75 const DifVector yHat(0,1,0);
76 const DifVector zHat(0,1,0);
77 DifVector z=pTo.direction();
78 DifVector y=zHat-z*(zHat*z);
79 if(y.length()<0.01) y=xHat-z*(xHat*z);
80 y.normalize();
81 DifVector x(cross(y,z));
82
83 DifNumber px=P*x;
84 DifNumber py=P*y;
85 DifNumber pz=P*z;
86
87 DifNumber gamma=pTo.E/pTo.mass();
88 DifNumber beta=pTo.pMag()/pTo.E;
89
90 DifNumber pzP=gamma*(pz-beta*E);
91 DifNumber eP=gamma*(E-beta*pz);
92
93 E=eP;
94 P=px*x+py*y+pzP*z;
95
96 return;
97
98}
99
100void
101DifFourVector::boostToMe(std::vector<DifFourVector*>& list)const{
102 const DifVector xHat(1,0,0);
103 const DifVector yHat(0,1,0);
104 const DifVector zHat(0,0,1);
105 DifVector z=P;
106 z.normalize();
107 DifVector y(zHat-z*(zHat*z));
108 if(y.lengthSq()<0.0001) y=xHat-z*(xHat*z);
109 y.normalize();
110 DifVector x(cross(y,z));
111
112 DifNumber gamma=E/mass();
113 DifNumber beta=pMag()/E;
114
115 for(int i=0;i<(int)list.size();i++) {
116 DifFourVector& p4i=*list[i];
117 DifNumber px=p4i.P*x;
118 DifNumber py=p4i.P*y;
119 DifNumber pz=p4i.P*z;
120 DifNumber e=p4i.E;
121
122 DifNumber pzP=gamma*(pz-beta*e);
123 DifNumber eP=gamma*(e-beta*pz);
124
125 p4i.E=eP;
126 p4i.P=px*x+py*y+pzP*z;
127
128 }
129
130}
131
132
133void
134DifFourVector::boostFromMe(std::vector<DifFourVector*>& list)const{
135 const DifVector xHat(1,0,0);
136 const DifVector yHat(0,1,0);
137 const DifVector zHat(0,0,1);
138 DifVector z=P;
139 z.normalize();
140 DifVector y(zHat-z*(zHat*z));
141 if(y.lengthSq()<0.0001) y=xHat-z*(xHat*z);
142 y.normalize();
143 DifVector x(cross(y,z));
144
145 DifNumber gamma=E/mass();
146 DifNumber beta=pMag()/E;
147
148 for(int i=0;i<(int)list.size();i++) {
149 DifFourVector& p4i=*list[i];
150 DifNumber px=p4i.P*x;
151 DifNumber py=p4i.P*y;
152 DifNumber pz=p4i.P*z;
153 DifNumber e=p4i.E;
154
155 DifNumber pzP=gamma*(pz+beta*e);
156 DifNumber eP=gamma*(e+beta*pz);
157
158 p4i.E=eP;
159 p4i.P=px*x+py*y+pzP*z;
160
161 }
162
163}
164
165void
167{
168 const DifVector xHat(1,0,0);
169 const DifVector yHat(0,1,0);
170 const DifVector zHat(0,1,0);
171 DifVector z=pFrom.direction();
172 DifVector y=zHat-z*(zHat*z);
173 if(y.length()<0.01) y=xHat-z*(xHat*z);
174 y.normalize();
175 DifVector x(cross(y,z));
176
177 DifNumber px=P*x;
178 DifNumber py=P*y;
179 DifNumber pz=P*z;
180
181 DifNumber gamma=pFrom.E/pFrom.mass();
182 DifNumber beta=pFrom.pMag()/pFrom.E;
183
184 DifNumber pzP=gamma*(pz+beta*E);
185 DifNumber eP=gamma*(E+beta*pz);
186
187 E=eP;
188 P=px*x+py*y+pzP*z;
189}
190
191
192void DifFourVector::print(/*ostream& o*/)const {
193//SKIP cout << "E:" << endl << E;
194//SKIP cout << "P:" << endl << P;
195 cout << "SKIP of DifFourVector::print()" <<endl;//TEMP
196}
197
double P(RecMdcKalTrack *trk)
Double_t x[10]
double correlation(const DifNumber &a, const DifNumber &b)
Definition: DifNumber.cxx:72
EvtVector3R cross(const EvtVector3R &p1, const EvtVector3R &p2)
Definition: EvtVector3R.cc:84
**********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