Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveVector.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveVector.h"
13#include "TVector3.h"
14
15/** \class TEveVectorT
16\ingroup TEve
17Minimal, templated three-vector.
18No TObject inheritance and virtual functions.
19Also used in VSD.
20*/
21
24
25////////////////////////////////////////////////////////////////////////////////
26/// Dump to stdout as "(x, y, z)\n".
27
28template<typename TT> void TEveVectorT<TT>::Dump() const
29{
30 printf("(%f, %f, %f)\n", fX, fY, fZ);
31}
32
33////////////////////////////////////////////////////////////////////////////////
34/// Set from TVector3.
35
36template<typename TT> void TEveVectorT<TT>::Set(const TVector3& v)
37{
38 fX = v.x(); fY = v.y(); fZ = v.z();
40
41////////////////////////////////////////////////////////////////////////////////
42/// Calculate eta of the point, pretending it's a momentum vector.
43
44template<typename TT> TT TEveVectorT<TT>::Eta() const
45{
46 TT cosTheta = CosTheta();
47 if (cosTheta*cosTheta < 1) return -0.5* TMath::Log( (1.0-cosTheta)/(1.0+cosTheta) );
48 Warning("Eta","transverse momentum = 0, returning +/- 1e10");
49 return (fZ >= 0) ? 1e10 : -1e10;
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// Normalize the vector to length if current length is non-zero.
54/// Returns the old magnitude.
55
56template<typename TT> TT TEveVectorT<TT>::Normalize(TT length)
57{
58 TT m = Mag();
59 if (m != 0)
60 {
61 length /= m;
62 fX *= length; fY *= length; fZ *= length;
63 }
64 return m;
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// Returns an orthogonal vector (not normalized).
69
70template<typename TT> TEveVectorT<TT> TEveVectorT<TT>::Orthogonal() const
71{
72 Float_t xx = fX < 0 ? -fX : fX;
73 Float_t yy = fY < 0 ? -fY : fY;
74 Float_t zz = fZ < 0 ? -fZ : fZ;
75 if (xx < yy) {
76 return xx < zz ? TEveVectorT<TT>(0,fZ,-fY) : TEveVectorT<TT>(fY,-fX,0);
77 } else {
78 return yy < zz ? TEveVectorT<TT>(-fZ,0,fX) : TEveVectorT<TT>(fY,-fX,0);
79 }
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Set vectors a and b to be normal to this and among themselves,
84/// both of length 1.
87{
88 TEveVectorT<TT> v(*this);
89 v.Normalize();
90 a = v.Orthogonal();
91 a.Normalize();
92 b = v.Cross(a);
93 b.Normalize();
94}
95
96template class TEveVectorT<Float_t>;
97template class TEveVectorT<Double_t>;
98
99/** \class TEveVector4T
100\ingroup TEve
101Minimal, templated four-vector.
102No TObject inheritance and virtual functions.
103Also used in VSD.
104*/
105
108
109////////////////////////////////////////////////////////////////////////////////
110/// Dump to stdout as "(x, y, z; t)\n".
111
112template<typename TT> void TEveVector4T<TT>::Dump() const
113{
114 printf("(%f, %f, %f; %f)\n", TP::fX, TP::fY, TP::fZ, fT);
117template class TEveVector4T<Float_t>;
118template class TEveVector4T<Double_t>;
119
120/** \class TEveVector2T
121\ingroup TEve
122Minimal, templated two-vector.
123No TObject inheritance and virtual functions.
124Also used in VSD.
125*/
126
129
130////////////////////////////////////////////////////////////////////////////////
131/// Normalize the vector to length if current length is non-zero.
132
133template<typename TT> void TEveVector2T<TT>::Normalize(TT length)
134{
135 Float_t m = Mag();
136 if (m != 0)
137 {
138 m = length / m;
139 fX *= m; fY *= m;
140 }
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Dump to stdout as "(x, y)\n".
145
146template<typename TT> void TEveVector2T<TT>::Dump() const
147{
148 printf("(%f, %f)\n", fX, fY);
149}
150
151template class TEveVector2T<Float_t>;
152template class TEveVector2T<Double_t>;
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
float Float_t
Definition RtypesCore.h:57
#define ClassImp(name)
Definition Rtypes.h:377
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Minimal, templated two-vector.
Definition TEveVector.h:311
void Dump() const
Dump to stdout as "(x, y)\n".
void Normalize(TT length=1)
Normalize the vector to length if current length is non-zero.
Minimal, templated four-vector.
Definition TEveVector.h:243
void Dump() const
Dump to stdout as "(x, y, z; t)\n".
Minimal, templated three-vector.
Definition TEveVector.h:28
void OrthoNormBase(TEveVectorT &a, TEveVectorT &b) const
Set vectors a and b to be normal to this and among themselves, both of length 1.
TT Normalize(TT length=1)
Normalize the vector to length if current length is non-zero.
TT Eta() const
Calculate eta of the point, pretending it's a momentum vector.
TEveVectorT Orthogonal() const
Returns an orthogonal vector (not normalized).
void Dump() const
Dump to stdout as "(x, y, z)\n".
void Set(const Float_t *v)
Definition TEveVector.h:82
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Definition TMath.h:756
TMarker m
Definition textangle.C:8