ROOT 6.12/07 Reference Guide |
TVector3 is a general three vector class, which can be used for the description of different vectors in 3D.
TVector3 has been implemented as a vector of three Double_t variables, representing the cartesian coordinates. By default all components are initialized to zero:
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():
The member functions SetX(), SetY(), SetZ() and SetXYZ() allow to set the components:
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:
It is also possible to get the transverse component with respect to another vector:
The pseudo-rapidity ( eta=-ln (tan (theta/2)) ) can be obtained by Eta() or PseudoRapidity():
There are set functions to change one of the non-cartesian coordinates:
The TVector3 class provides the operators to add, subtract, scale and compare vectors:
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:
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.
Definition at line 22 of file TVector3.h.
Public Types | |
typedef Double_t | Scalar |
Public Types inherited from TObject | |
enum | { kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kInconsistent = 0x08000000, kBitMask = 0x00ffffff } |
enum | { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) } |
enum | EDeprecatedStatusBits { kObjInCanvas = BIT(3) } |
enum | EStatusBits { kCanDelete = BIT(0), kMustCleanup = BIT(3), kIsReferenced = BIT(4), kHasUUID = BIT(5), kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13) } |
Public Member Functions | |
TVector3 () | |
Constructors. More... | |
TVector3 (Double_t x, Double_t y, Double_t z) | |
TVector3 (const Double_t *) | |
TVector3 (const Float_t *) | |
TVector3 (const TVector3 &) | |
virtual | ~TVector3 () |
Double_t | Angle (const TVector3 &) const |
Return the angle w.r.t. another 3-vector. More... | |
Double_t | CosTheta () const |
TVector3 | Cross (const TVector3 &) const |
Double_t | DeltaPhi (const TVector3 &) const |
Double_t | DeltaR (const TVector3 &) const |
Return deltaR with respect to v. More... | |
Double_t | Dot (const TVector3 &) const |
Double_t | DrEtaPhi (const TVector3 &) const |
Double_t | Eta () const |
TVector2 | EtaPhiVector () const |
void | GetXYZ (Double_t *carray) const |
void | GetXYZ (Float_t *carray) const |
Double_t | Mag () const |
Double_t | Mag2 () const |
Bool_t | operator!= (const TVector3 &) const |
Double_t | operator() (int) const |
Double_t & | operator() (int) |
TVector3 & | operator*= (Double_t) |
TVector3 & | operator*= (const TRotation &) |
Multiplication operator. More... | |
TVector3 & | operator+= (const TVector3 &) |
TVector3 | operator- () const |
TVector3 & | operator-= (const TVector3 &) |
TVector3 & | operator= (const TVector3 &) |
Bool_t | operator== (const TVector3 &) const |
Double_t | operator[] (int) const |
Double_t & | operator[] (int) |
TVector3 | Orthogonal () const |
Double_t | Perp () const |
Return the transverse component (R in cylindrical coordinate system) More... | |
Double_t | Perp (const TVector3 &) const |
Return the transverse component (R in cylindrical coordinate system) More... | |
Double_t | Perp2 () const |
Double_t | Perp2 (const TVector3 &) const |
Double_t | Phi () const |
Return the azimuth angle. Returns phi from -pi to pi. More... | |
void | Print (Option_t *option="") const |
Print vector parameters. More... | |
Double_t | PseudoRapidity () const |
Double_t m = Mag(); return 0.5*log( (m+fZ)/(m-fZ) ); guard against Pt=0. More... | |
Double_t | Pt () const |
Double_t | Pt (const TVector3 &) const |
Double_t | Px () const |
Double_t | Py () const |
Double_t | Pz () const |
void | Rotate (Double_t, const TVector3 &) |
Rotate vector. More... | |
void | RotateUz (const TVector3 &) |
NewUzVector must be normalized ! More... | |
void | RotateX (Double_t) |
Rotate vector around X. More... | |
void | RotateY (Double_t) |
Rotate vector around Y. More... | |
void | RotateZ (Double_t) |
Rotate vector around Z. More... | |
void | SetMag (Double_t) |
void | SetMagThetaPhi (Double_t mag, Double_t theta, Double_t phi) |
Setter with mag, theta, phi. More... | |
void | SetPerp (Double_t) |
void | SetPhi (Double_t) |
Set phi keeping mag and theta constant (BaBar). More... | |
void | SetPtEtaPhi (Double_t pt, Double_t eta, Double_t phi) |
Set Pt, Eta and Phi. More... | |
void | SetPtThetaPhi (Double_t pt, Double_t theta, Double_t phi) |
Set Pt, Theta and Phi. More... | |
void | SetTheta (Double_t) |
Set theta keeping mag and phi constant (BaBar). More... | |
void | SetX (Double_t) |
void | SetXYZ (Double_t x, Double_t y, Double_t z) |
void | SetY (Double_t) |
void | SetZ (Double_t) |
Double_t | Theta () const |
Return the polar angle. More... | |
TVector3 & | Transform (const TRotation &) |
Transform this vector with a TRotation. More... | |
TVector3 | Unit () const |
Return unit vector parallel to this. More... | |
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 |
Public Member Functions inherited from TObject | |
TObject () | |
TObject constructor. More... | |
TObject (const TObject &object) | |
TObject copy ctor. More... | |
virtual | ~TObject () |
TObject destructor. More... | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. More... | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. More... | |
virtual void | Browse (TBrowser *b) |
Browse object. May be overridden for another default action. More... | |
ULong_t | CheckedHash () |
Checked and record whether for this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object. More... | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. More... | |
virtual void | Clear (Option_t *="") |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. More... | |
virtual Int_t | Compare (const TObject *obj) const |
Compare abstract method. More... | |
virtual void | Copy (TObject &object) const |
Copy this to obj. More... | |
virtual void | Delete (Option_t *option="") |
Delete this object. More... | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Computes distance from point (px,py) to the object. More... | |
virtual void | Draw (Option_t *option="") |
Default Draw method for all objects. More... | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. More... | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad) . More... | |
virtual void | Dump () const |
Dump contents of object on stdout. More... | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. More... | |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
Execute method on this object with the given parameter string, e.g. More... | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. More... | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). More... | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. More... | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. More... | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. More... | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. More... | |
virtual const char * | GetIconName () const |
Returns mime type name of object. More... | |
virtual const char * | GetName () const |
Returns name of object. More... | |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). More... | |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
Returns title of object. More... | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. More... | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. More... | |
virtual ULong_t | Hash () const |
Return hash value for this object. More... | |
Bool_t | HasInconsistentHash () const |
Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e. More... | |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. More... | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". More... | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. More... | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. More... | |
void | InvertBit (UInt_t f) |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). More... | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More... | |
R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
virtual Bool_t | IsSortable () const |
R__ALWAYS_INLINE Bool_t | IsZombie () const |
virtual void | ls (Option_t *option="") const |
The ls function lists the contents of a class on stdout. More... | |
void | MayNotUse (const char *method) const |
Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More... | |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. More... | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. More... | |
void | operator delete (void *ptr) |
Operator delete. More... | |
void | operator delete[] (void *ptr) |
Operator delete []. More... | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. More... | |
virtual void | Paint (Option_t *option="") |
This method must be overridden if a class wants to paint itself. More... | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. More... | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. More... | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove this object from a list. More... | |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. More... | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save a primitive as a C++ statement(s) on output stream "out". More... | |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. More... | |
void | SetBit (UInt_t f) |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. More... | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. More... | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. More... | |
R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More... | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. More... | |
Private Attributes | |
Double_t | fX |
Double_t | fY |
Double_t | fZ |
Friends | |
class | TLorentzVector |
Additional Inherited Members | |
Static Public Member Functions inherited from TObject | |
static Long_t | GetDtorOnly () |
Return destructor only flag. More... | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. More... | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. More... | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. More... | |
Protected Member Functions inherited from TObject | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). More... | |
void | MakeZombie () |
#include <TVector3.h>
typedef Double_t TVector3::Scalar |
Definition at line 26 of file TVector3.h.
|
inline |
Constructors.
Definition at line 247 of file TVector3.h.
Definition at line 253 of file TVector3.h.
|
inline |
Definition at line 256 of file TVector3.h.
|
inline |
Definition at line 259 of file TVector3.h.
|
inline |
Definition at line 250 of file TVector3.h.
|
inlinevirtual |
Definition at line 40 of file TVector3.h.
Return the angle w.r.t. another 3-vector.
Definition at line 197 of file TVector3.cxx.
|
inline |
Definition at line 371 of file TVector3.h.
Definition at line 335 of file TVector3.h.
Definition at line 396 of file TVector3.h.
Return deltaR with respect to v.
Definition at line 372 of file TVector3.cxx.
Definition at line 331 of file TVector3.h.
Definition at line 404 of file TVector3.h.
|
inline |
Definition at line 400 of file TVector3.h.
|
inline |
Definition at line 409 of file TVector3.h.
Definition at line 233 of file TVector3.h.
Definition at line 239 of file TVector3.h.
|
inline |
Definition at line 86 of file TVector3.h.
|
inline |
Definition at line 339 of file TVector3.h.
|
inline |
Definition at line 302 of file TVector3.h.
|
inline |
Definition at line 263 of file TVector3.h.
|
inline |
Definition at line 277 of file TVector3.h.
Definition at line 324 of file TVector3.h.
Multiplication operator.
Definition at line 183 of file TVector3.cxx.
Definition at line 306 of file TVector3.h.
|
inline |
Definition at line 320 of file TVector3.h.
Definition at line 313 of file TVector3.h.
Definition at line 291 of file TVector3.h.
Definition at line 298 of file TVector3.h.
|
inline |
Definition at line 211 of file TVector3.h.
|
inline |
Definition at line 210 of file TVector3.h.
|
inline |
Definition at line 342 of file TVector3.h.
Double_t TVector3::Perp | ( | ) | const |
Return the transverse component (R in cylindrical coordinate system)
Definition at line 213 of file TVector3.cxx.
Return the transverse component (R in cylindrical coordinate system)
Definition at line 222 of file TVector3.cxx.
|
inline |
Definition at line 353 of file TVector3.h.
Definition at line 358 of file TVector3.h.
Double_t TVector3::Phi | ( | ) | const |
Return the azimuth angle. Returns phi from -pi to pi.
Definition at line 230 of file TVector3.cxx.
Double_t TVector3::PseudoRapidity | ( | ) | const |
Double_t m = Mag(); return 0.5*log( (m+fZ)/(m-fZ) ); guard against Pt=0.
Definition at line 320 of file TVector3.cxx.
|
inline |
Definition at line 356 of file TVector3.h.
Definition at line 367 of file TVector3.h.
|
inline |
Definition at line 219 of file TVector3.h.
|
inline |
Definition at line 220 of file TVector3.h.
|
inline |
Definition at line 221 of file TVector3.h.
Rotate vector.
Definition at line 290 of file TVector3.cxx.
NewUzVector must be normalized !
Definition at line 299 of file TVector3.cxx.
Rotate vector around X.
Definition at line 257 of file TVector3.cxx.
Rotate vector around Y.
Definition at line 268 of file TVector3.cxx.
Rotate vector around Z.
Definition at line 279 of file TVector3.cxx.
Definition at line 376 of file TVector3.h.
Setter with mag, theta, phi.
Definition at line 382 of file TVector3.cxx.
Definition at line 388 of file TVector3.h.
Set phi keeping mag and theta constant (BaBar).
Definition at line 362 of file TVector3.cxx.
Set Pt, Eta and Phi.
Definition at line 332 of file TVector3.cxx.
Set Pt, Theta and Phi.
Definition at line 340 of file TVector3.cxx.
Set theta keeping mag and phi constant (BaBar).
Definition at line 350 of file TVector3.cxx.
Definition at line 223 of file TVector3.h.
Definition at line 227 of file TVector3.h.
Definition at line 224 of file TVector3.h.
Definition at line 225 of file TVector3.h.
Double_t TVector3::Theta | ( | ) | const |
Return the polar angle.
Definition at line 238 of file TVector3.cxx.
Transform this vector with a TRotation.
Definition at line 190 of file TVector3.cxx.
TVector3 TVector3::Unit | ( | ) | const |
Return unit vector parallel to this.
Definition at line 246 of file TVector3.cxx.
|
inline |
Definition at line 213 of file TVector3.h.
|
inline |
Definition at line 216 of file TVector3.h.
|
inline |
Definition at line 413 of file TVector3.h.
|
inline |
Definition at line 214 of file TVector3.h.
|
inline |
Definition at line 217 of file TVector3.h.
|
inline |
Definition at line 215 of file TVector3.h.
|
inline |
Definition at line 218 of file TVector3.h.
|
friend |
Definition at line 191 of file TVector3.h.
|
private |
Definition at line 185 of file TVector3.h.
|
private |
Definition at line 185 of file TVector3.h.
|
private |
Definition at line 185 of file TVector3.h.