TVector3


class description - source file - inheritance tree

class TVector3 : public TObject


    public:
TVector3 TVector3(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0) TVector3 TVector3(Double_t*) TVector3 TVector3(Float_t*) TVector3 TVector3(TVector3&) TVector3 operator-() TVector3 Unit() TVector3 Orthogonal() TVector3 Cross(TVector3& p) void ~TVector3() Double_t Angle(TVector3& q) TClass* Class() Double_t CosTheta() Double_t DeltaPhi(TVector3& v) Double_t DeltaR(TVector3& v) Double_t Dot(TVector3& p) Double_t DrEtaPhi(TVector3& v) Double_t Eta() TVector2 EtaPhiVector() virtual TClass* IsA() Double_t Mag() Double_t Mag2() Bool_t operator!=(TVector3& v) Double_t operator()(int) TVector3& operator*=(Double_t a) TVector3& operator*=(TRotation&) TVector3& operator+=(TVector3& p) TVector3& operator-=(TVector3& p) TVector3& operator=(TVector3& p) Bool_t operator==(TVector3& v) Double_t operator[](int i) Double_t Perp() Double_t Perp(TVector3& p) Double_t Perp2() Double_t Perp2(TVector3& p) Double_t Phi() Double_t PseudoRapidity() Double_t Pt() Double_t Pt(TVector3& p) void Rotate(Double_t, TVector3&) void RotateUz(TVector3&) void RotateX(Double_t) void RotateY(Double_t) void RotateZ(Double_t) void SetMag(Double_t ma) void SetPerp(Double_t r) void SetPhi(Double_t ph) void SetTheta(Double_t th) void SetX(Double_t x) void SetXYZ(Double_t x, Double_t y, Double_t z) void SetY(Double_t y) void SetZ(Double_t z) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) Double_t Theta() TVector3& Transform(TRotation&) Double_t X() TVector2 XYvector() Double_t Y() Double_t Z()

Data Members

private:
Double_t fX Double_t fY Double_t fZ

Class Description

*-*-*-*-*-*-*-*-*-*-*-*The Physics Vector package *-*-*-*-*-*-*-*-*-*-*-*
*-*                    ==========================                       *
*-* The Physics Vector package consists of five classes:                *
*-*   - TVector2                                                        *
*-*   - TVector3                                                        *
*-*   - TRotation                                                       *
*-*   - TLorentzVector                                                  *
*-*   - TLorentzRotation                                                *
*-* It is a combination of CLHEPs Vector package written by             *
*-* Leif Lonnblad, Andreas Nilsson and Evgueni Tcherniaev               *
*-* and a ROOT package written by Pasha Murat.                          *
*-* for CLHEP see:  http://wwwinfo.cern.ch/asd/lhc++/clhep/             *
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

/*

TVector3

TVector3 is a general three vector class, which can be used for the description of different vectors in 3D.

Declaration / Access to the components

TVector3 has been implemented as a vector of three Double_t variables, representing the cartesian coordinates. By default all components are initialized to zero:

  TVector3 v1;        // v1 = (0,0,0)
  TVector3 v2(1);     // v2 = (1,0,0)
  TVector3 v3(1,2,3); // v3 = (1,2,3)
  TVector3 v4(v2);    // v4 = v2

It is also possible (but not recommended) to initialize a TVector3 with a Double_t or Float_t C array.

You can get the basic components either by name or by index using operator():

  xx = v1.X();    or    xx = v1(0);
  yy = v1.Y();          yy = v1(1);
  zz = v1.Z();          zz = v1(2);

The memberfunctions SetX(), SetY(), SetZ() and SetXYZ() allow to set the components:

  v1.SetX(1.); v1.SetY(2.); v1.SetZ(3.);
  v1.SetXYZ(1.,2.,3.);
 

Noncartesian coordinates

To get information on the TVector3 in spherical (rho,phi,theta) or cylindrical (z,r,theta) coordinates, the
the member functions Mag() (=magnitude=rho in spherical coordinates), Mag2(), Theta(), CosTheta(), Phi(), Perp() (the transverse component=r in cylindrical coordinates), Perp2() can be used:

  Double_t m  = v.Mag();    // get magnitude (=rho=Sqrt(x*x+y*y+z*z)))
  Double_t m2 = v.Mag2();   // get magnitude squared
  Double_t t  = v.Theta();  // get polar angle
  Double_t ct = v.CosTheta();// get cos of theta
  Double_t p  = v.Phi();    // get azimuth angle
  Double_t pp = v.Perp();   // get transverse component
  Double_t pp2= v.Perp2();  // get transvers component squared

It is also possible to get the transverse component with respect to another vector:

  Double_t ppv1 = v.Perp(v1);
  Double_t pp2v1 = v.Perp2(v1);

The pseudorapiditiy ( eta=-ln (tan (phi/2)) ) can be get by Eta() or PseudoRapidity():
 
  Double_t eta = v.PseudoRapidity();

There are set functions to change one of the noncartesian coordinates:

  v.SetTheta(.5); // keeping rho and phi
  v.SetPhi(.8);   // keeping rho and theta
  v.SetMag(10.);  // keeping theta and phi
  v.SetPerp(3.);  // keeping z and phi
 

Arithmetic / Comparison

The TVector3 class provides the operators to add, subtract, scale and compare vectors:

  v3  = -v1;
  v1  = v2+v3;
  v1 += v3;
  v1  = v1 - v3
  v1 -= v3;
  v1 *= 10;
  v1  = 5*v2;

  if(v1==v2) {...}
  if(v1!=v2) {...}
 

Related Vectors

  v2 = v1.Unit();       // get unit vector parallel to v1
  v2 = v1.Orthogonal(); // get vector orthogonal to v1

Scalar and vector products

  s = v1.Dot(v2);   // scalar product
  s = v1 * v2;      // scalar product
  v = v1.Cross(v2); // vector product

 Angle between two vectors

  Double_t a = v1.Angle(v2);

Rotations

Rotation around axes
  v.RotateX(.5);
  v.RotateY(TMath::Pi());
  v.RotateZ(angle);
Rotation around a vector
  v1.Rotate(TMath::Pi()/4, v2); // rotation around v2
Rotation by TRotation
TVector3 objects can be rotated by objects of the TRotation class using the Transform() member functions,
the operator *= or the operator * of the TRotation class:

  TRotation m;
  ...
  v1.transform(m);
  v1 = m*v1;
  v1 *= m; // Attention v1 = m*v1

Transformation from rotated frame
  TVector3 direction = v.Unit()
  v1.RotateUz(direction); // direction must be TVector3 of unit length

transforms v1 from the rotated frame (z' parallel to direction, x' in the theta plane and y' in the xy plane as well as perpendicular to the theta plane) to the (x,y,z) frame.


*/



TVector3(const TVector3 & p) : fX(p.fX), fY(p.fY), fZ(p.fZ)

TVector3(Double_t x, Double_t y, Double_t z) : fX(x), fY(y), fZ(z)

TVector3(Double_t * x0) : fX(x0[0]), fY(x0[1]), fZ(x0[2])

TVector3(Float_t * x0) : fX(x0[0]), fY(x0[1]), fZ(x0[2])

void RotateX(Double_t angle)

void RotateY(Double_t angle)

void RotateZ(Double_t angle)

void Rotate(Double_t angle, const TVector3 & axis)

void RotateUz(const TVector3& NewUzVector)
 NewUzVector must be normalized !

Double_t PseudoRapidity() const



Inline Functions


           Double_t operator()(int)
           Double_t operator[](int i)
           Double_t X()
           Double_t Y()
           Double_t Z()
               void SetX(Double_t x)
               void SetY(Double_t y)
               void SetZ(Double_t z)
               void SetXYZ(Double_t x, Double_t y, Double_t z)
           Double_t Phi()
           Double_t Theta()
           Double_t CosTheta()
           Double_t Mag2()
           Double_t Mag()
               void SetPhi(Double_t ph)
               void SetTheta(Double_t th)
               void SetMag(Double_t ma)
           Double_t Perp2()
           Double_t Pt()
           Double_t Perp()
               void SetPerp(Double_t r)
           Double_t Perp2(TVector3& p)
           Double_t Pt(TVector3& p)
           Double_t Perp(TVector3& p)
           Double_t DeltaPhi(TVector3& v)
           Double_t DeltaR(TVector3& v)
           Double_t DrEtaPhi(TVector3& v)
           TVector2 EtaPhiVector()
          TVector3& operator=(TVector3& p)
             Bool_t operator==(TVector3& v)
             Bool_t operator!=(TVector3& v)
          TVector3& operator+=(TVector3& p)
          TVector3& operator-=(TVector3& p)
           TVector3 operator-()
          TVector3& operator*=(Double_t a)
           TVector3 Unit()
           TVector3 Orthogonal()
           Double_t Dot(TVector3& p)
           TVector3 Cross(TVector3& p)
           Double_t Angle(TVector3& q)
           Double_t Eta()
          TVector3& operator*=(TRotation&)
          TVector3& Transform(TRotation&)
           TVector2 XYvector()
            TClass* Class()
            TClass* IsA()
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)
               void ~TVector3()


Author: Pasha Murat, Peter Malzacher 12/02/99
Last update: 2.22/09 12/07/99 18.44.02 by Rene Brun


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.