]>
Commit | Line | Data |
---|---|---|
da0e9ce3 | 1 | //-------------------------------------------------------------------------- |
2 | // | |
3 | // Environment: | |
4 | // This software is part of the EvtGen package developed jointly | |
5 | // for the BaBar and CLEO collaborations. If you use all or part | |
6 | // of it, please give an appropriate acknowledgement. | |
7 | // | |
8 | // Copyright Information: See EvtGen/COPYRIGHT | |
9 | // Copyright (C) 1998 Caltech, UCSB | |
10 | // | |
11 | // Module: EvtGen/EvtVector4R.hh | |
12 | // | |
13 | // Description: Class to describe real 4 vectors | |
14 | // | |
15 | // Modification history: | |
16 | // | |
17 | // DJL/RYD September 25, 1996 Module created | |
18 | // | |
19 | //------------------------------------------------------------------------ | |
20 | ||
21 | #ifndef EVTVECTOR4R_HH | |
22 | #define EVTVECTOR4R_HH | |
23 | ||
24 | #include <iostream> | |
25 | #include <math.h> | |
26 | ||
27 | class EvtVector3R; | |
28 | ||
29 | class EvtVector4R { | |
30 | ||
da0e9ce3 | 31 | |
32 | ||
33 | inline friend EvtVector4R operator*(double d,const EvtVector4R& v2); | |
34 | inline friend EvtVector4R operator*(const EvtVector4R& v2,double d); | |
35 | inline friend EvtVector4R operator/(const EvtVector4R& v2,double d); | |
36 | inline friend double operator*(const EvtVector4R& v1,const EvtVector4R& v2); | |
37 | inline friend EvtVector4R operator+(const EvtVector4R& v1,const EvtVector4R& v2); | |
38 | inline friend EvtVector4R operator-(const EvtVector4R& v1,const EvtVector4R& v2); | |
39 | ||
40 | public: | |
0ca57c2f | 41 | EvtVector4R(); |
da0e9ce3 | 42 | EvtVector4R(double e,double px,double py ,double pz); |
43 | inline void set(int i,double d); | |
44 | inline void set(double e,double px,double py ,double pz); | |
45 | inline EvtVector4R& operator*=(double c); | |
46 | inline EvtVector4R& operator/=(double c); | |
47 | inline EvtVector4R& operator=(const EvtVector4R& v2); | |
48 | inline EvtVector4R& operator+=(const EvtVector4R& v2); | |
49 | inline EvtVector4R& operator-=(const EvtVector4R& v2); | |
50 | inline double get(int i) const; | |
51 | inline double cont(const EvtVector4R& v4) const; | |
52 | friend std::ostream& operator<<(std::ostream& s, const EvtVector4R& v); | |
53 | double mass2() const; | |
54 | double mass() const; | |
55 | void applyRotateEuler(double alpha,double beta,double gamma); | |
0ca57c2f | 56 | void applyBoostTo(const EvtVector4R& p4, bool inverse = false); |
57 | void applyBoostTo(const EvtVector3R& boost, bool inverse = false); | |
da0e9ce3 | 58 | EvtVector4R cross(const EvtVector4R& v2); |
59 | double dot(const EvtVector4R& v2) const; | |
60 | double d3mag() const; | |
61 | ||
62 | // Added by AJB - calculate scalars in the rest frame of the current object | |
63 | double scalartripler3( const EvtVector4R& p1, const EvtVector4R& p2, | |
64 | const EvtVector4R& p3 ) const; | |
65 | double dotr3( const EvtVector4R& p1, const EvtVector4R& p2 ) const; | |
66 | double mag2r3( const EvtVector4R& p1 ) const; | |
67 | double magr3( const EvtVector4R& p1 ) const; | |
68 | ||
69 | ||
70 | private: | |
71 | ||
72 | double v[4]; | |
73 | ||
74 | inline double Square( double x ) const { return x*x; } | |
75 | ||
76 | }; | |
77 | ||
0ca57c2f | 78 | EvtVector4R rotateEuler(const EvtVector4R& rs, |
79 | double alpha,double beta,double gamma); | |
80 | EvtVector4R boostTo(const EvtVector4R& rs, | |
81 | const EvtVector4R& p4, bool inverse = false); | |
82 | EvtVector4R boostTo(const EvtVector4R& rs, | |
83 | const EvtVector3R& boost, bool inverse = false); | |
da0e9ce3 | 84 | |
85 | inline EvtVector4R& EvtVector4R::operator=(const EvtVector4R& v2){ | |
86 | ||
87 | v[0]=v2.v[0]; | |
88 | v[1]=v2.v[1]; | |
89 | v[2]=v2.v[2]; | |
90 | v[3]=v2.v[3]; | |
91 | ||
92 | return *this; | |
93 | } | |
94 | ||
95 | inline EvtVector4R& EvtVector4R::operator+=(const EvtVector4R& v2){ | |
96 | ||
97 | v[0]+=v2.v[0]; | |
98 | v[1]+=v2.v[1]; | |
99 | v[2]+=v2.v[2]; | |
100 | v[3]+=v2.v[3]; | |
101 | ||
102 | return *this; | |
103 | } | |
104 | ||
105 | inline EvtVector4R& EvtVector4R::operator-=(const EvtVector4R& v2){ | |
106 | ||
107 | v[0]-=v2.v[0]; | |
108 | v[1]-=v2.v[1]; | |
109 | v[2]-=v2.v[2]; | |
110 | v[3]-=v2.v[3]; | |
111 | ||
112 | return *this; | |
113 | } | |
114 | ||
115 | inline double EvtVector4R::mass2() const{ | |
116 | ||
117 | return v[0]*v[0]-v[1]*v[1]-v[2]*v[2]-v[3]*v[3]; | |
118 | } | |
119 | ||
120 | inline EvtVector4R operator*(double c,const EvtVector4R& v2){ | |
121 | ||
122 | return EvtVector4R(v2)*=c; | |
123 | } | |
124 | ||
125 | inline EvtVector4R operator*(const EvtVector4R& v2,double c){ | |
126 | ||
127 | return EvtVector4R(v2)*=c; | |
128 | } | |
129 | ||
130 | inline EvtVector4R operator/(const EvtVector4R& v2,double c){ | |
131 | ||
132 | return EvtVector4R(v2)/=c; | |
133 | } | |
134 | ||
135 | inline EvtVector4R& EvtVector4R::operator*=(double c){ | |
136 | ||
137 | v[0]*=c; | |
138 | v[1]*=c; | |
139 | v[2]*=c; | |
140 | v[3]*=c; | |
141 | ||
142 | return *this; | |
143 | } | |
144 | ||
145 | inline EvtVector4R& EvtVector4R::operator/=(double c){ | |
146 | ||
147 | double cinv=1.0/c; | |
148 | v[0]*=cinv; | |
149 | v[1]*=cinv; | |
150 | v[2]*=cinv; | |
151 | v[3]*=cinv; | |
152 | ||
153 | return *this; | |
154 | } | |
155 | ||
156 | inline double operator*(const EvtVector4R& v1,const EvtVector4R& v2){ | |
157 | ||
158 | return v1.v[0]*v2.v[0]-v1.v[1]*v2.v[1]- | |
159 | v1.v[2]*v2.v[2]-v1.v[3]*v2.v[3]; | |
160 | } | |
161 | ||
162 | inline double EvtVector4R::cont(const EvtVector4R& v4) const { | |
163 | ||
164 | return v[0]*v4.v[0]-v[1]*v4.v[1]- | |
165 | v[2]*v4.v[2]-v[3]*v4.v[3]; | |
166 | } | |
167 | ||
168 | inline EvtVector4R operator-(const EvtVector4R& v1,const EvtVector4R& v2){ | |
169 | ||
170 | return EvtVector4R(v1)-=v2; | |
171 | } | |
172 | ||
173 | inline EvtVector4R operator+(const EvtVector4R& v1,const EvtVector4R& v2){ | |
174 | ||
175 | return EvtVector4R(v1)+=v2; | |
176 | } | |
177 | ||
178 | inline double EvtVector4R::get(int i) const { | |
179 | return v[i]; | |
180 | } | |
181 | ||
182 | inline void EvtVector4R::set(int i,double d){ | |
183 | ||
184 | v[i]=d; | |
185 | } | |
186 | ||
187 | inline void EvtVector4R::set(double e,double p1,double p2, double p3){ | |
188 | ||
189 | v[0]=e; | |
190 | v[1]=p1; | |
191 | v[2]=p2; | |
192 | v[3]=p3; | |
193 | } | |
194 | ||
195 | #endif | |
196 |