#ifndef ROOT_TVector3
#define ROOT_TVector3
#ifndef ROOT_TError
#include "TError.h"
#endif
#ifndef ROOT_TVector2
#include "TVector2.h"
#endif
#ifndef ROOT_TMatrix
#include "TMatrix.h"
#endif
class TRotation;
class TVector3 : public TObject {
public:
TVector3(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0);
TVector3(const Double_t *);
TVector3(const Float_t *);
TVector3(const TVector3 &);
virtual ~TVector3();
Double_t operator () (int) const;
inline Double_t operator [] (int) const;
Double_t & operator () (int);
inline Double_t & operator [] (int);
inline Double_t x() const;
inline Double_t y() const;
inline Double_t z() const;
inline Double_t X() const;
inline Double_t Y() const;
inline Double_t Z() const;
inline Double_t Px() const;
inline Double_t Py() const;
inline Double_t Pz() const;
inline void SetX(Double_t);
inline void SetY(Double_t);
inline void SetZ(Double_t);
inline void SetXYZ(Double_t x, Double_t y, Double_t z);
void SetPtEtaPhi(Double_t pt, Double_t eta, Double_t phi);
void SetPtThetaPhi(Double_t pt, Double_t theta, Double_t phi);
inline void GetXYZ(Double_t *carray) const;
inline void GetXYZ(Float_t *carray) const;
Double_t Phi() const;
Double_t Theta() const;
inline Double_t CosTheta() const;
inline Double_t Mag2() const;
Double_t Mag() const;
void SetPhi(Double_t);
void SetTheta(Double_t);
inline void SetMag(Double_t);
inline Double_t Perp2() const;
inline Double_t Pt() const;
Double_t Perp() const;
inline void SetPerp(Double_t);
inline Double_t Perp2(const TVector3 &) const;
inline Double_t Pt(const TVector3 &) const;
Double_t Perp(const TVector3 &) const;
inline Double_t DeltaPhi(const TVector3 &) const;
Double_t DeltaR(const TVector3 &) const;
inline Double_t DrEtaPhi(const TVector3 &) const;
inline TVector2 EtaPhiVector() const;
void SetMagThetaPhi(Double_t mag, Double_t theta, Double_t phi);
inline TVector3 & operator = (const TVector3 &);
inline Bool_t operator == (const TVector3 &) const;
inline Bool_t operator != (const TVector3 &) const;
inline TVector3 & operator += (const TVector3 &);
inline TVector3 & operator -= (const TVector3 &);
inline TVector3 operator - () const;
inline TVector3 & operator *= (Double_t);
TVector3 Unit() const;
inline TVector3 Orthogonal() const;
inline Double_t Dot(const TVector3 &) const;
inline TVector3 Cross(const TVector3 &) const;
Double_t Angle(const TVector3 &) const;
Double_t PseudoRapidity() const;
inline Double_t Eta() const;
void RotateX(Double_t);
void RotateY(Double_t);
void RotateZ(Double_t);
void RotateUz(const TVector3&);
void Rotate(Double_t, const TVector3 &);
TVector3 & operator *= (const TRotation &);
TVector3 & Transform(const TRotation &);
inline TVector2 XYvector() const;
void Print(Option_t* option="") const;
private:
Double_t fX, fY, fZ;
ClassDef(TVector3,3)
};
TVector3 operator + (const TVector3 &, const TVector3 &);
TVector3 operator - (const TVector3 &, const TVector3 &);
Double_t operator * (const TVector3 &, const TVector3 &);
TVector3 operator * (const TVector3 &, Double_t a);
TVector3 operator * (Double_t a, const TVector3 &);
TVector3 operator * (const TMatrix &, const TVector3 &);
Double_t & TVector3::operator[] (int i) { return operator()(i); }
Double_t TVector3::operator[] (int i) const { return operator()(i); }
inline Double_t TVector3::x() const { return fX; }
inline Double_t TVector3::y() const { return fY; }
inline Double_t TVector3::z() const { return fZ; }
inline Double_t TVector3::X() const { return fX; }
inline Double_t TVector3::Y() const { return fY; }
inline Double_t TVector3::Z() const { return fZ; }
inline Double_t TVector3::Px() const { return fX; }
inline Double_t TVector3::Py() const { return fY; }
inline Double_t TVector3::Pz() const { return fZ; }
inline void TVector3::SetX(Double_t xx) { fX = xx; }
inline void TVector3::SetY(Double_t yy) { fY = yy; }
inline void TVector3::SetZ(Double_t zz) { fZ = zz; }
inline void TVector3::SetXYZ(Double_t xx, Double_t yy, Double_t zz) {
fX = xx;
fY = yy;
fZ = zz;
}
inline void TVector3::GetXYZ(Double_t *carray) const {
carray[0] = fX;
carray[1] = fY;
carray[2] = fZ;
}
inline void TVector3::GetXYZ(Float_t *carray) const {
carray[0] = fX;
carray[1] = fY;
carray[2] = fZ;
}
inline TVector3 & TVector3::operator = (const TVector3 & p) {
fX = p.fX;
fY = p.fY;
fZ = p.fZ;
return *this;
}
inline Bool_t TVector3::operator == (const TVector3& v) const {
return (v.fX==fX && v.fY==fY && v.fZ==fZ) ? kTRUE : kFALSE;
}
inline Bool_t TVector3::operator != (const TVector3& v) const {
return (v.fX!=fX || v.fY!=fY || v.fZ!=fZ) ? kTRUE : kFALSE;
}
inline TVector3& TVector3::operator += (const TVector3 & p) {
fX += p.fX;
fY += p.fY;
fZ += p.fZ;
return *this;
}
inline TVector3& TVector3::operator -= (const TVector3 & p) {
fX -= p.fX;
fY -= p.fY;
fZ -= p.fZ;
return *this;
}
inline TVector3 TVector3::operator - () const {
return TVector3(-fX, -fY, -fZ);
}
inline TVector3& TVector3::operator *= (Double_t a) {
fX *= a;
fY *= a;
fZ *= a;
return *this;
}
inline Double_t TVector3::Dot(const TVector3 & p) const {
return fX*p.fX + fY*p.fY + fZ*p.fZ;
}
inline TVector3 TVector3::Cross(const TVector3 & p) const {
return TVector3(fY*p.fZ-p.fY*fZ, fZ*p.fX-p.fZ*fX, fX*p.fY-p.fX*fY);
}
inline Double_t TVector3::Mag2() const { return fX*fX + fY*fY + fZ*fZ; }
inline TVector3 TVector3::Orthogonal() const {
Double_t xx = fX < 0.0 ? -fX : fX;
Double_t yy = fY < 0.0 ? -fY : fY;
Double_t zz = fZ < 0.0 ? -fZ : fZ;
if (xx < yy) {
return xx < zz ? TVector3(0,fZ,-fY) : TVector3(fY,-fX,0);
} else {
return yy < zz ? TVector3(-fZ,0,fX) : TVector3(fY,-fX,0);
}
}
inline Double_t TVector3::Perp2() const { return fX*fX + fY*fY; }
inline Double_t TVector3::Pt() const { return Perp(); }
inline Double_t TVector3::Perp2(const TVector3 & p) const {
Double_t tot = p.Mag2();
Double_t ss = Dot(p);
Double_t per = Mag2();
if (tot > 0.0) per -= ss*ss/tot;
if (per < 0) per = 0;
return per;
}
inline Double_t TVector3::Pt(const TVector3 & p) const {
return Perp(p);
}
inline Double_t TVector3::CosTheta() const {
Double_t ptot = Mag();
return ptot == 0.0 ? 1.0 : fZ/ptot;
}
inline void TVector3::SetMag(Double_t ma) {
Double_t factor = Mag();
if (factor == 0) {
Warning("SetMag","zero vector can't be stretched");
} else {
factor = ma/factor;
SetX(fX*factor);
SetY(fY*factor);
SetZ(fZ*factor);
}
}
inline void TVector3::SetPerp(Double_t r) {
Double_t p = Perp();
if (p != 0.0) {
fX *= r/p;
fY *= r/p;
}
}
inline Double_t TVector3::DeltaPhi(const TVector3 & v) const {
return TVector2::Phi_mpi_pi(Phi()-v.Phi());
}
inline Double_t TVector3::Eta() const {
return PseudoRapidity();
}
inline Double_t TVector3::DrEtaPhi(const TVector3 & v) const{
return DeltaR(v);
}
inline TVector2 TVector3::EtaPhiVector() const {
return TVector2 (Eta(),Phi());
}
inline TVector2 TVector3::XYvector() const {
return TVector2(fX,fY);
}
#endif