22 class TVector3 :
public TObject {
26 typedef Double_t Scalar;
30 TVector3(Double_t x, Double_t y, Double_t z);
33 TVector3(
const Double_t *);
34 TVector3(
const Float_t *);
37 TVector3(
const TVector3 &);
40 virtual ~TVector3() {};
43 Double_t operator () (
int)
const;
44 inline Double_t operator [] (
int)
const;
47 Double_t & operator () (
int);
48 inline Double_t & operator [] (
int);
51 inline Double_t x()
const;
52 inline Double_t y()
const;
53 inline Double_t z()
const;
54 inline Double_t X()
const;
55 inline Double_t Y()
const;
56 inline Double_t Z()
const;
57 inline Double_t Px()
const;
58 inline Double_t Py()
const;
59 inline Double_t Pz()
const;
62 inline void SetX(Double_t);
63 inline void SetY(Double_t);
64 inline void SetZ(Double_t);
65 inline void SetXYZ(Double_t x, Double_t y, Double_t z);
66 void SetPtEtaPhi(Double_t pt, Double_t eta, Double_t phi);
67 void SetPtThetaPhi(Double_t pt, Double_t theta, Double_t phi);
69 inline void GetXYZ(Double_t *carray)
const;
70 inline void GetXYZ(Float_t *carray)
const;
77 Double_t Theta()
const;
80 inline Double_t CosTheta()
const;
83 inline Double_t Mag2()
const;
86 Double_t Mag()
const {
return TMath::Sqrt(Mag2()); }
89 void SetPhi(Double_t);
92 void SetTheta(Double_t);
95 inline void SetMag(Double_t);
98 inline Double_t Perp2()
const;
101 inline Double_t Pt()
const;
102 Double_t Perp()
const;
105 inline void SetPerp(Double_t);
108 inline Double_t Perp2(
const TVector3 &)
const;
111 inline Double_t Pt(
const TVector3 &)
const;
112 Double_t Perp(
const TVector3 &)
const;
115 inline Double_t DeltaPhi(
const TVector3 &)
const;
116 Double_t DeltaR(
const TVector3 &)
const;
117 inline Double_t DrEtaPhi(
const TVector3 &)
const;
118 inline TVector2 EtaPhiVector()
const;
119 void SetMagThetaPhi(Double_t mag, Double_t theta, Double_t phi);
121 inline TVector3 & operator = (
const TVector3 &);
124 inline Bool_t operator == (
const TVector3 &)
const;
125 inline Bool_t operator != (
const TVector3 &)
const;
128 inline TVector3 & operator += (
const TVector3 &);
131 inline TVector3 & operator -= (
const TVector3 &);
134 inline TVector3 operator - ()
const;
137 inline TVector3 & operator *= (Double_t);
140 TVector3 Unit()
const;
143 inline TVector3 Orthogonal()
const;
146 inline Double_t Dot(
const TVector3 &)
const;
149 inline TVector3 Cross(
const TVector3 &)
const;
152 Double_t Angle(
const TVector3 &)
const;
155 Double_t PseudoRapidity()
const;
158 inline Double_t Eta()
const;
160 void RotateX(Double_t);
163 void RotateY(Double_t);
166 void RotateZ(Double_t);
169 void RotateUz(
const TVector3&);
172 void Rotate(Double_t,
const TVector3 &);
175 TVector3 & operator *= (
const TRotation &);
176 TVector3 & Transform(
const TRotation &);
179 inline TVector2 XYvector()
const;
181 void Print(Option_t* option=
"")
const;
191 friend class TLorentzVector;
194 TVector3 operator + (const TVector3 &, const TVector3 &);
197 TVector3 operator - (const TVector3 &, const TVector3 &);
200 Double_t operator * (const TVector3 &, const TVector3 &);
203 TVector3 operator * (const TVector3 &, Double_t a);
204 TVector3 operator * (Double_t a, const TVector3 &);
207 TVector3 operator * (const TMatrix &, const TVector3 &);
210 inline Double_t & TVector3::operator[] (
int i) {
return operator()(i); }
211 inline Double_t TVector3::operator[] (
int i)
const {
return operator()(i); }
213 inline Double_t TVector3::x()
const {
return fX; }
214 inline Double_t TVector3::y()
const {
return fY; }
215 inline Double_t TVector3::z()
const {
return fZ; }
216 inline Double_t TVector3::X()
const {
return fX; }
217 inline Double_t TVector3::Y()
const {
return fY; }
218 inline Double_t TVector3::Z()
const {
return fZ; }
219 inline Double_t TVector3::Px()
const {
return fX; }
220 inline Double_t TVector3::Py()
const {
return fY; }
221 inline Double_t TVector3::Pz()
const {
return fZ; }
223 inline void TVector3::SetX(Double_t xx) { fX = xx; }
224 inline void TVector3::SetY(Double_t yy) { fY = yy; }
225 inline void TVector3::SetZ(Double_t zz) { fZ = zz; }
227 inline void TVector3::SetXYZ(Double_t xx, Double_t yy, Double_t zz) {
233 inline void TVector3::GetXYZ(Double_t *carray)
const {
239 inline void TVector3::GetXYZ(Float_t *carray)
const {
247 inline TVector3::TVector3()
248 : fX(0.0), fY(0.0), fZ(0.0) {}
250 inline TVector3::TVector3(
const TVector3 & p) : TObject(p),
251 fX(p.fX), fY(p.fY), fZ(p.fZ) {}
253 inline TVector3::TVector3(Double_t xx, Double_t yy, Double_t zz)
254 : fX(xx), fY(yy), fZ(zz) {}
256 inline TVector3::TVector3(
const Double_t * x0)
257 : fX(x0[0]), fY(x0[1]), fZ(x0[2]) {}
259 inline TVector3::TVector3(
const Float_t * x0)
260 : fX(x0[0]), fY(x0[1]), fZ(x0[2]) {}
263 inline Double_t TVector3::operator () (
int i)
const {
272 Error(
"operator()(i)",
"bad index (%d) returning 0",i);
277 inline Double_t & TVector3::operator () (
int i) {
286 Error(
"operator()(i)",
"bad index (%d) returning &fX",i);
291 inline TVector3 & TVector3::operator = (
const TVector3 & p) {
298 inline Bool_t TVector3::operator == (
const TVector3& v)
const {
299 return (v.fX==fX && v.fY==fY && v.fZ==fZ) ? kTRUE : kFALSE;
302 inline Bool_t TVector3::operator != (
const TVector3& v)
const {
303 return (v.fX!=fX || v.fY!=fY || v.fZ!=fZ) ? kTRUE : kFALSE;
306 inline TVector3& TVector3::operator += (
const TVector3 & p) {
313 inline TVector3& TVector3::operator -= (
const TVector3 & p) {
320 inline TVector3 TVector3::operator - ()
const {
321 return TVector3(-fX, -fY, -fZ);
324 inline TVector3& TVector3::operator *= (Double_t a) {
331 inline Double_t TVector3::Dot(
const TVector3 & p)
const {
332 return fX*p.fX + fY*p.fY + fZ*p.fZ;
335 inline TVector3 TVector3::Cross(
const TVector3 & p)
const {
336 return TVector3(fY*p.fZ-p.fY*fZ, fZ*p.fX-p.fZ*fX, fX*p.fY-p.fX*fY);
339 inline Double_t TVector3::Mag2()
const {
return fX*fX + fY*fY + fZ*fZ; }
342 inline TVector3 TVector3::Orthogonal()
const {
343 Double_t xx = fX < 0.0 ? -fX : fX;
344 Double_t yy = fY < 0.0 ? -fY : fY;
345 Double_t zz = fZ < 0.0 ? -fZ : fZ;
347 return xx < zz ? TVector3(0,fZ,-fY) : TVector3(fY,-fX,0);
349 return yy < zz ? TVector3(-fZ,0,fX) : TVector3(fY,-fX,0);
353 inline Double_t TVector3::Perp2()
const {
return fX*fX + fY*fY; }
356 inline Double_t TVector3::Pt()
const {
return Perp(); }
358 inline Double_t TVector3::Perp2(
const TVector3 & p)
const {
359 Double_t tot = p.Mag2();
360 Double_t ss = Dot(p);
361 Double_t per = Mag2();
362 if (tot > 0.0) per -= ss*ss/tot;
363 if (per < 0) per = 0;
367 inline Double_t TVector3::Pt(
const TVector3 & p)
const {
371 inline Double_t TVector3::CosTheta()
const {
372 Double_t ptot = Mag();
373 return ptot == 0.0 ? 1.0 : fZ/ptot;
376 inline void TVector3::SetMag(Double_t ma) {
377 Double_t factor = Mag();
379 Warning(
"SetMag",
"zero vector can't be stretched");
388 inline void TVector3::SetPerp(Double_t r) {
396 inline Double_t TVector3::DeltaPhi(
const TVector3 & v)
const {
397 return TVector2::Phi_mpi_pi(Phi()-v.Phi());
400 inline Double_t TVector3::Eta()
const {
401 return PseudoRapidity();
404 inline Double_t TVector3::DrEtaPhi(
const TVector3 & v)
const{
409 inline TVector2 TVector3::EtaPhiVector()
const {
410 return TVector2 (Eta(),Phi());
413 inline TVector2 TVector3::XYvector()
const {
414 return TVector2(fX,fY);