
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 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.);
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 pseudo-rapidity ( eta=-ln (tan (theta/2)) ) can be obtained 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
v3 = -v1;
v1 = v2+v3;
v1 += v3;
v1 = v1 - v3
v1 -= v3;
v1 *= 10;
v1 = 5*v2;
if(v1==v2) {...}
if(v1!=v2) {...}
TRotation m;
...
v1.transform(m);
v1 = m*v1;
v1 *= m; // Attention v1 = m*v1
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 Double_t*) | |
| TVector3(const Float_t*) | |
| TVector3(const TVector3&) | |
| TVector3(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0) | |
| virtual | ~TVector3() |
| void | TObject::AbstractMethod(const char* method) const |
| Double_t | Angle(const TVector3&) const |
| virtual void | TObject::AppendPad(Option_t* option = "") |
| virtual void | TObject::Browse(TBrowser* b) |
| static TClass* | Class() |
| virtual const char* | TObject::ClassName() const |
| virtual void | TObject::Clear(Option_t* = "") |
| virtual TObject* | TObject::Clone(const char* newname = "") const |
| virtual Int_t | TObject::Compare(const TObject* obj) const |
| virtual void | TObject::Copy(TObject& object) const |
| Double_t | CosTheta() const |
| TVector3 | Cross(const TVector3& p) const |
| virtual void | TObject::Delete(Option_t* option = "")MENU |
| Double_t | DeltaPhi(const TVector3& v) const |
| Double_t | DeltaR(const TVector3&) const |
| virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
| Double_t | Dot(const TVector3& p) const |
| virtual void | TObject::Draw(Option_t* option = "") |
| virtual void | TObject::DrawClass() constMENU |
| virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
| Double_t | DrEtaPhi(const TVector3& v) const |
| virtual void | TObject::Dump() constMENU |
| virtual void | TObject::Error(const char* method, const char* msgfmt) const |
| Double_t | Eta() const |
| TVector2 | EtaPhiVector() const |
| virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
| virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
| virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
| virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
| virtual TObject* | TObject::FindObject(const char* name) const |
| virtual TObject* | TObject::FindObject(const TObject* obj) const |
| virtual Option_t* | TObject::GetDrawOption() const |
| static Long_t | TObject::GetDtorOnly() |
| virtual const char* | TObject::GetIconName() const |
| virtual const char* | TObject::GetName() const |
| virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
| static Bool_t | TObject::GetObjectStat() |
| virtual Option_t* | TObject::GetOption() const |
| virtual const char* | TObject::GetTitle() const |
| virtual UInt_t | TObject::GetUniqueID() const |
| void | GetXYZ(Double_t* carray) const |
| void | GetXYZ(Float_t* carray) const |
| virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
| virtual ULong_t | TObject::Hash() const |
| virtual void | TObject::Info(const char* method, const char* msgfmt) const |
| virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
| virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
| virtual void | TObject::Inspect() constMENU |
| void | TObject::InvertBit(UInt_t f) |
| virtual TClass* | IsA() const |
| virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
| virtual Bool_t | TObject::IsFolder() const |
| Bool_t | TObject::IsOnHeap() const |
| virtual Bool_t | TObject::IsSortable() const |
| Bool_t | TObject::IsZombie() const |
| virtual void | TObject::ls(Option_t* option = "") const |
| Double_t | Mag() const |
| Double_t | Mag2() const |
| void | TObject::MayNotUse(const char* method) const |
| virtual Bool_t | TObject::Notify() |
| void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
| static void | TObject::operator delete(void* ptr) |
| static void | TObject::operator delete(void* ptr, void* vp) |
| static void | TObject::operator delete[](void* ptr) |
| static void | TObject::operator delete[](void* ptr, void* vp) |
| void* | TObject::operator new(size_t sz) |
| void* | TObject::operator new(size_t sz, void* vp) |
| void* | TObject::operator new[](size_t sz) |
| void* | TObject::operator new[](size_t sz, void* vp) |
| Bool_t | operator!=(const TVector3& v) const |
| Double_t | operator()(int) const |
| Double_t& | operator()(int) |
| TVector3& | operator*=(Double_t a) |
| TVector3& | operator*=(const TRotation&) |
| TVector3& | operator+=(const TVector3& p) |
| TVector3 | operator-() const |
| TVector3& | operator-=(const TVector3& p) |
| TVector3& | operator=(const TVector3& p) |
| Bool_t | operator==(const TVector3& v) const |
| Double_t | operator[](int i) const |
| Double_t& | operator[](int i) |
| TVector3 | Orthogonal() const |
| virtual void | TObject::Paint(Option_t* option = "") |
| Double_t | Perp() const |
| Double_t | Perp(const TVector3&) const |
| Double_t | Perp2() const |
| Double_t | Perp2(const TVector3& p) const |
| Double_t | Phi() const |
| virtual void | TObject::Pop() |
| virtual void | Print(Option_t* option = "") const |
| Double_t | PseudoRapidity() const |
| Double_t | Pt() const |
| Double_t | Pt(const TVector3& p) const |
| Double_t | Px() const |
| Double_t | Py() const |
| Double_t | Pz() const |
| virtual Int_t | TObject::Read(const char* name) |
| virtual void | TObject::RecursiveRemove(TObject* obj) |
| void | TObject::ResetBit(UInt_t f) |
| void | Rotate(Double_t, const TVector3&) |
| void | RotateUz(const TVector3&) |
| void | RotateX(Double_t) |
| void | RotateY(Double_t) |
| void | RotateZ(Double_t) |
| virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
| virtual void | TObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "") |
| void | TObject::SetBit(UInt_t f) |
| void | TObject::SetBit(UInt_t f, Bool_t set) |
| virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
| static void | TObject::SetDtorOnly(void* obj) |
| void | SetMag(Double_t ma) |
| void | SetMagThetaPhi(Double_t mag, Double_t theta, Double_t phi) |
| static void | TObject::SetObjectStat(Bool_t stat) |
| void | SetPerp(Double_t r) |
| void | SetPhi(Double_t) |
| void | SetPtEtaPhi(Double_t pt, Double_t eta, Double_t phi) |
| void | SetPtThetaPhi(Double_t pt, Double_t theta, Double_t phi) |
| void | SetTheta(Double_t) |
| virtual void | TObject::SetUniqueID(UInt_t uid) |
| void | SetX(Double_t xx) |
| void | SetXYZ(Double_t xx, Double_t yy, Double_t zz) |
| void | SetY(Double_t yy) |
| void | SetZ(Double_t zz) |
| virtual void | ShowMembers(TMemberInspector&) |
| virtual void | Streamer(TBuffer&) |
| void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
| virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
| Bool_t | TObject::TestBit(UInt_t f) const |
| Int_t | TObject::TestBits(UInt_t f) const |
| Double_t | Theta() const |
| TVector3& | Transform(const TRotation&) |
| TVector3 | Unit() const |
| virtual void | TObject::UseCurrentStyle() |
| virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
| virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
| virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
| Double_t | x() const |
| Double_t | X() const |
| TVector2 | XYvector() const |
| Double_t | y() const |
| Double_t | Y() const |
| Double_t | z() const |
| Double_t | Z() const |
| virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
| void | TObject::MakeZombie() |
| enum TObject::EStatusBits { | kCanDelete | |
| kMustCleanup | ||
| kObjInCanvas | ||
| kIsReferenced | ||
| kHasUUID | ||
| kCannotPick | ||
| kNoContextMenu | ||
| kInvalidObject | ||
| }; | ||
| enum TObject::[unnamed] { | kIsOnHeap | |
| kNotDeleted | ||
| kZombie | ||
| kBitMask | ||
| kSingleKey | ||
| kOverwrite | ||
| kWriteDelete | ||
| }; |

return the transverse component (R in cylindrical coordinate system)