source: trunk/MagicSoft/Mars/mbase/MQuaternion.h@ 9366

Last change on this file since 9366 was 9234, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.0 KB
Line 
1#ifndef MARS_MQuaternion
2#define MARS_MQuaternion
3
4#if 1
5
6// We prefer to derive from TQuaternion instead of TLorantzVector
7// because TQuaternion implements vector algebra with just the 3D vector
8
9#ifndef ROOT_TQuaternion
10#include <TQuaternion.h>
11#endif
12
13class MQuaternion : public TQuaternion
14{
15public:
16 MQuaternion(const TQuaternion &q) : TQuaternion(q) { }
17 MQuaternion(const TVector3 &v, Double_t t=0) : TQuaternion(v, t) { }
18 void operator*=(const TRotation &r)
19 {
20 fVectorPart *= r;
21 }
22 Double_t X() const { return fVectorPart.X(); }
23 Double_t Y() const { return fVectorPart.Y(); }
24 Double_t Z() const { return fVectorPart.Z(); }
25 Double_t T() const { return fRealPart; }
26
27 // It seems to be a little bit faster than X*X+Y*Y
28 Double_t R2() const { return XYvector().Mod2(); }
29 Double_t R() const { return XYvector().Mod(); }
30
31 void PropagateDz(const MQuaternion &w, const Double_t dz)
32 {
33 *this += dz/w.Z()*w;
34 }
35
36 // Propagates the particle by a distance f in z along
37 // its trajectory w, if f is positive, in the opposite
38 // direction otherwise.
39 void PropagateZ(const MQuaternion &w, const Double_t z)
40 {
41 PropagateDz(w, z-Z());
42
43 // z=3400, Z= 1700, t=0, c=1 -= 3400/-5*-5 -= 3400 Z=0, c>0
44 // += 1700/-5*-5 += 1700 Z=1700, c>0
45 // z=3400, Z=-1700, t=0, c=1 -= -3400/-5*-5 -= -1700 Z=0, c<0
46
47 // z=3400, Z= 1700, t=0, c=1 -= (3400-1700)/-5*-5 -= 3400 Z=0, c>0
48 }
49
50 // Move the photon along its trajectory to the x/y plane
51 // so that z=0. Therefor stretch the vector until
52 // its z-component vanishes.
53 //p -= p.Z()/u.Z()*u;
54 void PropagateZ0(const MQuaternion &w)
55 {
56 // If z>0 we still have to move by a distance of z.
57 // If z<0 we have to move in the opposite direction.
58 // --> z has the right sign for PropagateZ
59 PropagateDz(w, -Z());
60
61 // Z= 1700, t=0, c=1 -= 1700/-5*-5 -= 1700 +c Z=0, c>0
62 // Z=-1700, t=0, c=1 -= -1700/-5*-5 -= -1700 -c Z=0, c<0
63
64
65 // Z= 1700, t=0, c=1 -= 1700/ 5* 5 -= 1700 -c Z=0, c<0
66 // Z=-1700, t=0, c=1 -= -1700/ 5* 5 -= -1700 +c Z=0, c>0
67
68 //PropagateZ(w, Z());
69 }
70
71 TVector2 XYvector() const { return fVectorPart.XYvector(); }
72
73 //void Normalize() { fVectorPart *= TMath::Sqrt(1 - R2())/Z(); }
74
75 ClassDef(MQuaternion, 1)
76};
77
78#else
79
80#ifndef ROOT_TLorentzVector
81#include <TLorentzVector.h>
82#endif
83
84class MQuaternion : public TLorentzVector
85{
86public:
87 //MQuaternion(const TLorentzVector &q) : TLorentzVector(q) { }
88 MQuaternion(const TVector3 &v, Double_t t=0) : TLorentzVector(v, t) { }
89 /*
90 void operator*=(const TRotation &r)
91 {
92 fVectorPart *= r;
93 }
94 Double_t X() const { return fVectorPart.X(); }
95 Double_t Y() const { return fVectorPart.Y(); }
96 Double_t Z() const { return fVectorPart.Z(); }
97 Double_t T() const { return fRealPart; }
98 */
99
100 // It seems to be a little bit faster than X*X+Y*Y
101 Double_t R2() const { return Perp2(); }
102 Double_t R() const { return Perp(); }
103
104 // Propagates the particle by a distance f in z along
105 // its trajectory w, if f is positive, in the opposite
106 // direction otherwise.
107 void PropagateZ(const MQuaternion &w, const Double_t f)
108 {
109 *this += f/TMath::Abs(w.Z())*w;
110 }
111
112 // Move the photon along its trajectory to the x/y plane
113 // so that z=0. Therefor stretch the vector until
114 // its z-component vanishes.
115 //p -= p.Z()/u.Z()*u;
116 void PropagateZ0(const MQuaternion &w)
117 {
118 // If z>0 we still have to move by a distance of z.
119 // If z<0 we have to move in th eopposite direction.
120 // --> z has the right sign for PropagateZ
121 PropagateZ(w, Z());
122 }
123
124 TVector2 XYvector() const { return Vect().XYvector(); }
125
126 //void Normalize() { fVectorPart *= TMath::Sqrt(1 - R2())/Z(); }
127
128 ClassDef(MQuaternion, 0)
129};
130
131#endif
132
133#endif
Note: See TracBrowser for help on using the repository browser.