#ifndef ROOT_TEveVector
#define ROOT_TEveVector
#include "TMath.h"
class TVector3;
class TEveVector
{
public:
Float_t fX, fY, fZ;
TEveVector() : fX(0), fY(0), fZ(0) {}
TEveVector(const Float_t* v) : fX(v[0]), fY(v[1]), fZ(v[2]) {}
TEveVector(const Double_t* v) : fX(v[0]), fY(v[1]), fZ(v[2]) {}
TEveVector(Float_t x, Float_t y, Float_t z) : fX(x), fY(y), fZ(z) {}
virtual ~TEveVector() {}
void Dump() const;
operator const Float_t*() const { return &fX; }
operator Float_t*() { return &fX; }
TEveVector& operator *=(Float_t s) { fX *= s; fY *= s; fZ *= s; return *this; }
TEveVector& operator +=(const TEveVector& v) { fX += v.fX; fY += v.fY; fZ += v.fZ; return *this; }
TEveVector& operator -=(const TEveVector& v) { fX -= v.fX; fY -= v.fY; fZ -= v.fZ; return *this; }
TEveVector operator + (const TEveVector &) const;
TEveVector operator - (const TEveVector &) const;
TEveVector operator * (Float_t a) const;
Float_t& operator [] (Int_t indx);
Float_t operator [] (Int_t indx) const;
const Float_t* Arr() const { return &fX; }
Float_t* Arr() { return &fX; }
void Set(const Float_t* v) { fX = v[0]; fY = v[1]; fZ = v[2]; }
void Set(const Double_t* v) { fX = v[0]; fY = v[1]; fZ = v[2]; }
void Set(Float_t x, Float_t y, Float_t z) { fX = x; fY = y; fZ = z; }
void Set(Double_t x, Double_t y, Double_t z) { fX = x; fY = y; fZ = z; }
void Set(const TEveVector& v) { fX = v.fX; fY = v.fY; fZ = v.fZ; }
void Set(const TVector3& v);
void NegateXYZ() { fX = - fX; fY = -fY; fZ = -fZ; }
void Normalize(Float_t length=1);
Float_t Phi() const;
Float_t Theta() const;
Float_t CosTheta() const;
Float_t Eta() const;
Float_t Mag() const { return TMath::Sqrt(fX*fX + fY*fY + fZ*fZ);}
Float_t Mag2() const { return fX*fX + fY*fY + fZ*fZ;}
Float_t Perp() const { return TMath::Sqrt(fX*fX + fY*fY);}
Float_t Perp2() const { return fX*fX + fY*fY;}
Float_t R() const { return Perp(); }
Float_t Distance(const TEveVector& v) const;
Float_t SquareDistance(const TEveVector& v) const;
Float_t Dot(const TEveVector& a) const;
TEveVector Cross(const TEveVector& a) const;
TEveVector& Sub(const TEveVector& p, const TEveVector& q);
TEveVector& Mult(const TEveVector& a, Float_t af);
TEveVector Orthogonal() const;
void OrthoNormBase(TEveVector& a, TEveVector& b) const;
ClassDef(TEveVector, 1);
};
inline Float_t TEveVector::Phi() const
{
return fX == 0.0 && fY == 0.0 ? 0.0 : TMath::ATan2(fY, fX);
}
inline Float_t TEveVector::Theta() const
{
return fX == 0.0 && fY == 0.0 && fZ == 0.0 ? 0.0 : TMath::ATan2(Perp(), fZ);
}
inline Float_t TEveVector::CosTheta() const
{
Float_t ptot = Mag(); return ptot == 0.0 ? 1.0 : fZ/ptot;
}
inline Float_t TEveVector::Distance( const TEveVector& b) const
{
return TMath::Sqrt((fX - b.fX)*(fX - b.fX) +
(fY - b.fY)*(fY - b.fY) +
(fZ - b.fZ)*(fZ - b.fZ));
}
inline Float_t TEveVector::SquareDistance(const TEveVector& b) const
{
return ((fX - b.fX) * (fX - b.fX) +
(fY - b.fY) * (fY - b.fY) +
(fZ - b.fZ) * (fZ - b.fZ));
}
inline Float_t TEveVector::Dot(const TEveVector& a) const
{
return a.fX*fX + a.fY*fY + a.fZ*fZ;
}
inline TEveVector TEveVector::Cross(const TEveVector& a) const
{
TEveVector r;
r.fX = fY * a.fZ - fZ * a.fY;
r.fY = fZ * a.fX - fX * a.fZ;
r.fZ = fX * a.fY - fY * a.fX;
return r;
}
inline TEveVector& TEveVector::Sub(const TEveVector& p, const TEveVector& q)
{
fX = p.fX - q.fX;
fY = p.fY - q.fY;
fZ = p.fZ - q.fZ;
return *this;
}
inline TEveVector& TEveVector::Mult(const TEveVector& a, Float_t af)
{
fX = a.fX * af;
fY = a.fY * af;
fZ = a.fZ * af;
return *this;
}
inline Float_t& TEveVector::operator [] (Int_t idx)
{
return (&fX)[idx];
}
inline Float_t TEveVector::operator [] (Int_t idx) const
{
return (&fX)[idx];
}
class TEveVector4 : public TEveVector
{
public:
Float_t fT;
TEveVector4() : TEveVector(), fT(0) {}
TEveVector4(const TEveVector& v) : TEveVector(v), fT(0) {}
TEveVector4(Float_t x, Float_t y, Float_t z, Float_t t=0) :
TEveVector(x, y, z), fT(t) {}
virtual ~TEveVector4() {}
void Dump() const;
TEveVector4 operator + (const TEveVector4 & b) const
{ return TEveVector4(fX + b.fX, fY + b.fY, fZ + b.fZ, fT + b.fT); }
TEveVector4 operator - (const TEveVector4 & b) const
{ return TEveVector4(fX - b.fX, fY - b.fY, fZ - b.fZ, fT - b.fT); }
TEveVector4 operator * (Float_t a) const
{ return TEveVector4(a*fX, a*fY, a*fZ, a*fT); }
TEveVector4& operator += (const TEveVector4 & b)
{ fX += b.fX; fY += b.fY; fZ += b.fZ; fT += b.fT; return *this; }
ClassDef(TEveVector4, 1);
};
class TEvePathMark
{
public:
enum EType_e { kReference, kDaughter, kDecay, kCluster2D };
EType_e fType;
TEveVector fV;
TEveVector fP;
TEveVector fE;
Float_t fTime;
TEvePathMark(EType_e type=kReference) :
fType(type), fV(), fP(), fE(), fTime(0) {}
TEvePathMark(EType_e type, const TEveVector& v, Float_t time=0) :
fType(type), fV(v), fP(), fE(), fTime(time) {}
TEvePathMark(EType_e type, const TEveVector& v, const TEveVector& p, Float_t time=0) :
fType(type), fV(v), fP(p), fE(), fTime(time) {}
TEvePathMark(EType_e type, const TEveVector& v, const TEveVector& p, const TEveVector& e, Float_t time=0) :
fType(type), fV(v), fP(p), fE(e), fTime(time) {}
virtual ~TEvePathMark() {}
const char* TypeName();
ClassDef(TEvePathMark, 1);
};
#endif