]>
Commit | Line | Data |
---|---|---|
67427ff7 | 1 | /*************************************************************************** |
2 | * | |
3 | * $Id$ | |
4 | * | |
5 | * Author: Brian Lasiuk, Thomas Ullrich, April 1998 | |
6 | *************************************************************************** | |
7 | * | |
8 | * Description: | |
9 | * | |
10 | * Remarks: Since not all compilers support member templates | |
11 | * we have to specialize the templated member on these | |
12 | * platforms. If member templates are not supported the | |
13 | * ST_NO_MEMBER_TEMPLATES flag has to be set. tu. | |
14 | * | |
15 | * In the near future when all compilers can handle member | |
16 | * templates this class should be cleaned up. A lot of | |
17 | * redundant code can be removed as soon as the compilers | |
18 | * are up-to-date. tu | |
19 | * | |
20 | *************************************************************************** | |
21 | * | |
22 | * $Log$ | |
d0e92d9a | 23 | * Revision 1.1.1.1 2007/04/25 15:38:41 panos |
24 | * Importing the HBT code dir | |
25 | * | |
67427ff7 | 26 | * Revision 1.1.1.1 2007/03/07 10:14:49 mchojnacki |
27 | * First version on CVS | |
28 | * | |
29 | * Revision 1.11 2005/09/22 20:09:20 fisyak | |
30 | * Make AliFemtoLorentzVector persistent | |
31 | * | |
32 | * Revision 1.10 2005/07/06 18:49:56 fisyak | |
33 | * Replace AliFemtoHelixD, AliFemtoLorentzVectorD,AliFemtoLorentzVectorF,AliFemtoMatrixD,AliFemtoMatrixF,AliFemtoPhysicalHelixD,AliFemtoThreeVectorD,AliFemtoThreeVectorF by templated version | |
34 | * | |
35 | * Revision 1.9 2005/03/28 06:02:45 perev | |
36 | * Defence FPE added | |
37 | * | |
38 | * Revision 1.8 2003/09/02 17:59:35 perev | |
39 | * gcc 3.2 updates + WarnOff | |
40 | * | |
41 | * Revision 1.7 2003/05/01 19:24:31 ullrich | |
42 | * Corrected problem in boost(). | |
43 | * | |
44 | * Revision 1.6 1999/10/15 15:56:36 ullrich | |
45 | * Changed output format in operator<<, added operator>> | |
46 | * | |
47 | * Revision 1.5 1999/06/04 18:01:36 ullrich | |
48 | * New operators operator() and operator[] which can be used | |
49 | * as lvalues. | |
50 | * | |
51 | * Revision 1.4 1999/04/14 23:12:07 fisyak | |
52 | * Add __CINT__ to handle references | |
53 | * | |
54 | * Revision 1.3 1999/02/17 11:38:36 ullrich | |
55 | * Removed specialization for 'long double'. | |
56 | * | |
57 | * Revision 1.2 1999/02/14 23:11:42 fisyak | |
58 | * Fixes for Rootcint | |
59 | * | |
60 | * Revision 1.1 1999/01/30 03:59:02 fisyak | |
61 | * Root Version of AliFemtoarClassLibrary | |
62 | * | |
63 | * Revision 1.1 1999/01/23 00:27:52 ullrich | |
64 | * Initial Revision | |
65 | * | |
66 | **************************************************************************/ | |
59c8f7b2 | 67 | /*// |
68 | //// General class for a Lorentz four-vector | |
69 | ///*/ | |
67427ff7 | 70 | #ifndef ST_LORENTZ_VECTOR_HH |
71 | #define ST_LORENTZ_VECTOR_HH | |
72 | ||
73 | #include "AliFemtoThreeVector.h" | |
74 | template<class T> class AliFemtoLorentzVector { | |
75 | public: | |
76 | AliFemtoLorentzVector(T = 0, T = 0, T = 0, T = 0); | |
77 | virtual ~AliFemtoLorentzVector(); | |
78 | ||
79 | #ifndef ST_NO_MEMBER_TEMPLATES | |
80 | template<class X> AliFemtoLorentzVector(const AliFemtoThreeVector<X>&, T); | |
81 | template<class X> AliFemtoLorentzVector(T, const AliFemtoThreeVector<X>&); | |
82 | ||
83 | template<class X> AliFemtoLorentzVector(const AliFemtoLorentzVector<X>&); | |
84 | template<class X> AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<X>&); | |
85 | // AliFemtoLorentzVector(const AliFemtoLorentzVector<T>&); use default | |
86 | // AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<T>&); use default | |
87 | #else | |
88 | AliFemtoLorentzVector(const AliFemtoThreeVector<float>&, T); | |
89 | AliFemtoLorentzVector(T, const AliFemtoThreeVector<float>&); | |
90 | AliFemtoLorentzVector(const AliFemtoLorentzVector<float>&); | |
91 | ||
92 | AliFemtoLorentzVector(const AliFemtoThreeVector<double>&, T); | |
93 | AliFemtoLorentzVector(T, const AliFemtoThreeVector<double>&); | |
94 | AliFemtoLorentzVector(const AliFemtoLorentzVector<double>&); | |
95 | ||
96 | AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<float>&); | |
97 | AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<double>&); | |
98 | #endif | |
99 | ||
100 | T x() const; | |
101 | T y() const; | |
102 | T z() const; | |
103 | T t() const; | |
104 | T px() const; | |
105 | T py() const; | |
106 | T pz() const; | |
107 | T e() const; | |
108 | T operator() (size_t) const; | |
109 | T operator[] (size_t) const; | |
110 | ||
111 | T& operator() (size_t); | |
112 | T& operator[] (size_t); | |
113 | ||
114 | const AliFemtoThreeVector<T>& vect() const; | |
115 | ||
a19edcc9 | 116 | void SetX(T); |
117 | void SetY(T); | |
118 | void SetZ(T); | |
119 | void SetPx(T); | |
120 | void SetPy(T); | |
121 | void SetPz(T); | |
122 | void SetE(T); | |
123 | void SetT(T); | |
67427ff7 | 124 | |
125 | #ifndef ST_NO_MEMBER_TEMPLATES | |
a19edcc9 | 126 | template <class X> void SetVect(const AliFemtoThreeVector<X>&); |
67427ff7 | 127 | #else |
a19edcc9 | 128 | void SetVect(const AliFemtoThreeVector<float>&); |
129 | void SetVect(const AliFemtoThreeVector<double>&); | |
67427ff7 | 130 | #endif |
131 | ||
59c8f7b2 | 132 | T Perp() const; |
133 | T Perp2() const; | |
134 | T PseudoRapidity() const; | |
135 | T Phi() const; | |
136 | T Theta() const; | |
137 | T CosTheta() const; | |
67427ff7 | 138 | |
59c8f7b2 | 139 | T Plus() const; |
140 | T Minus() const; | |
67427ff7 | 141 | |
142 | T m() const; | |
143 | T m2() const; | |
144 | T mt() const; | |
145 | T mt2() const; | |
59c8f7b2 | 146 | T Rapidity() const; |
67427ff7 | 147 | |
148 | #ifndef ST_NO_MEMBER_TEMPLATES | |
149 | template<class X> AliFemtoLorentzVector<T> boost(const AliFemtoLorentzVector<X>&) const; | |
150 | #else | |
151 | AliFemtoLorentzVector<T> boost(const AliFemtoLorentzVector<float>&) const; | |
152 | AliFemtoLorentzVector<T> boost(const AliFemtoLorentzVector<double>&) const; | |
153 | #endif | |
154 | ||
155 | AliFemtoLorentzVector<T> operator- (); | |
156 | AliFemtoLorentzVector<T> operator+ (); | |
157 | AliFemtoLorentzVector<T>& operator*= (double); | |
158 | AliFemtoLorentzVector<T>& operator/= (double); | |
159 | ||
160 | #ifndef ST_NO_MEMBER_TEMPLATES | |
161 | template<class X> bool operator == (const AliFemtoLorentzVector<X>&) const; | |
162 | template<class X> bool operator != (const AliFemtoLorentzVector<X>&) const; | |
163 | template<class X> AliFemtoLorentzVector<T>& operator+= (const AliFemtoLorentzVector<X>&); | |
164 | template<class X> AliFemtoLorentzVector<T>& operator-= (const AliFemtoLorentzVector<X>&); | |
165 | #else | |
166 | bool operator == (const AliFemtoLorentzVector<float>&) const; | |
167 | bool operator != (const AliFemtoLorentzVector<float>&) const; | |
168 | bool operator == (const AliFemtoLorentzVector<double>&) const; | |
169 | bool operator != (const AliFemtoLorentzVector<double>&) const; | |
170 | ||
171 | AliFemtoLorentzVector<T>& operator+= (const AliFemtoLorentzVector<float>&); | |
172 | AliFemtoLorentzVector<T>& operator-= (const AliFemtoLorentzVector<float>&); | |
173 | AliFemtoLorentzVector<T>& operator+= (const AliFemtoLorentzVector<double>&); | |
174 | AliFemtoLorentzVector<T>& operator-= (const AliFemtoLorentzVector<double>&); | |
175 | #endif | |
176 | ||
177 | protected: | |
283ac554 | 178 | AliFemtoThreeVector<T> fThreeVector; // The three-vector component |
179 | T fX4; // The fourth component | |
67427ff7 | 180 | #ifdef __ROOT__ |
181 | ClassDef(AliFemtoLorentzVector,3) | |
182 | #endif | |
183 | }; | |
184 | #ifndef __CINT__ | |
185 | // | |
186 | // Implementation of member functions | |
187 | // | |
188 | template<class T> | |
189 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T x, T y, T z, T t) | |
283ac554 | 190 | : fThreeVector(x, y, z), fX4(t) { /* nop */ } |
67427ff7 | 191 | |
192 | template<class T> | |
193 | AliFemtoLorentzVector<T>::~AliFemtoLorentzVector() { /* nopt */ } | |
194 | ||
195 | template<class T> | |
196 | const AliFemtoThreeVector<T>& AliFemtoLorentzVector<T>::vect() const | |
197 | { | |
283ac554 | 198 | return fThreeVector; |
67427ff7 | 199 | } |
200 | ||
201 | template<class T> | |
202 | T AliFemtoLorentzVector<T>::m2() const | |
203 | { | |
283ac554 | 204 | return (fX4*fX4 - fThreeVector*fThreeVector); |
67427ff7 | 205 | } |
206 | ||
207 | template<class T> | |
59c8f7b2 | 208 | T AliFemtoLorentzVector<T>::Plus() const { return (e() + pz()); } |
67427ff7 | 209 | |
210 | template<class T> | |
59c8f7b2 | 211 | T AliFemtoLorentzVector<T>::Minus() const { return (e() - pz()); } |
67427ff7 | 212 | |
213 | template<class T> | |
214 | T AliFemtoLorentzVector<T>::m() const | |
215 | { | |
216 | T mass2 = m2(); | |
217 | if (mass2 < 0) | |
218 | return -::sqrt(-mass2); | |
219 | else | |
220 | return ::sqrt(mass2); | |
221 | } | |
222 | ||
223 | template<class T> | |
224 | T AliFemtoLorentzVector<T>::mt2() const | |
225 | { | |
59c8f7b2 | 226 | return this->Perp2() + m2(); |
67427ff7 | 227 | } |
228 | ||
229 | template<class T> | |
230 | T AliFemtoLorentzVector<T>::mt() const | |
231 | { | |
232 | // | |
233 | // change to more optimal code ? | |
234 | // return e()*e() - pz()*pz(); | |
235 | T massPerp2 = mt2(); | |
236 | if (massPerp2 < 0) | |
237 | return -::sqrt(-massPerp2); | |
238 | else | |
239 | return ::sqrt(massPerp2); | |
240 | } | |
241 | ||
242 | template<class T> | |
283ac554 | 243 | void AliFemtoLorentzVector<T>::SetPx(T x) {fThreeVector.SetX(x);} |
67427ff7 | 244 | |
245 | template<class T> | |
283ac554 | 246 | void AliFemtoLorentzVector<T>::SetPy(T y) {fThreeVector.SetY(y);} |
67427ff7 | 247 | |
248 | template<class T> | |
283ac554 | 249 | void AliFemtoLorentzVector<T>::SetPz(T z) {fThreeVector.SetZ(z);} |
67427ff7 | 250 | |
251 | template<class T> | |
283ac554 | 252 | void AliFemtoLorentzVector<T>::SetX(T x) {fThreeVector.SetX(x);} |
67427ff7 | 253 | |
254 | template<class T> | |
283ac554 | 255 | void AliFemtoLorentzVector<T>::SetY(T y) {fThreeVector.SetY(y);} |
67427ff7 | 256 | |
257 | template<class T> | |
283ac554 | 258 | void AliFemtoLorentzVector<T>::SetZ(T z) {fThreeVector.SetZ(z);} |
67427ff7 | 259 | |
260 | template<class T> | |
283ac554 | 261 | void AliFemtoLorentzVector<T>::SetT(T t) {fX4 = t;} |
67427ff7 | 262 | |
263 | template<class T> | |
283ac554 | 264 | void AliFemtoLorentzVector<T>::SetE(T e) {fX4 = e;} |
67427ff7 | 265 | |
266 | template<class T> | |
283ac554 | 267 | T AliFemtoLorentzVector<T>::x() const {return fThreeVector.x();} |
67427ff7 | 268 | |
269 | template<class T> | |
283ac554 | 270 | T AliFemtoLorentzVector<T>::y() const {return fThreeVector.y();} |
67427ff7 | 271 | |
272 | template<class T> | |
283ac554 | 273 | T AliFemtoLorentzVector<T>::z() const {return fThreeVector.z();} |
67427ff7 | 274 | |
275 | template<class T> | |
283ac554 | 276 | T AliFemtoLorentzVector<T>::px() const {return fThreeVector.x();} |
67427ff7 | 277 | |
278 | template<class T> | |
283ac554 | 279 | T AliFemtoLorentzVector<T>::py() const {return fThreeVector.y();} |
67427ff7 | 280 | |
281 | template<class T> | |
283ac554 | 282 | T AliFemtoLorentzVector<T>::pz() const {return fThreeVector.z();} |
67427ff7 | 283 | |
284 | template<class T> | |
283ac554 | 285 | T AliFemtoLorentzVector<T>::e() const {return fX4;} |
67427ff7 | 286 | |
287 | template<class T> | |
283ac554 | 288 | T AliFemtoLorentzVector<T>::t() const {return fX4;} |
67427ff7 | 289 | |
290 | template<class T> | |
283ac554 | 291 | T AliFemtoLorentzVector<T>::Perp() const {return fThreeVector.Perp();} |
67427ff7 | 292 | |
293 | template<class T> | |
283ac554 | 294 | T AliFemtoLorentzVector<T>::Perp2() const {return fThreeVector.Perp2();} |
67427ff7 | 295 | |
296 | template<class T> | |
283ac554 | 297 | T AliFemtoLorentzVector<T>::PseudoRapidity() const {return fThreeVector.PseudoRapidity();} |
67427ff7 | 298 | |
299 | template<class T> | |
283ac554 | 300 | T AliFemtoLorentzVector<T>::Phi() const {return fThreeVector.Phi();} |
67427ff7 | 301 | |
302 | template<class T> | |
283ac554 | 303 | T AliFemtoLorentzVector<T>::Theta() const {return fThreeVector.Theta();} |
67427ff7 | 304 | |
305 | template<class T> | |
283ac554 | 306 | T AliFemtoLorentzVector<T>::CosTheta() const {return fThreeVector.CosTheta();} |
67427ff7 | 307 | |
308 | template<class T> | |
309 | T AliFemtoLorentzVector<T>::operator() (size_t i) const | |
310 | { | |
311 | if (i < 3) | |
283ac554 | 312 | return fThreeVector(i); |
67427ff7 | 313 | else if (i == 3) |
283ac554 | 314 | return fX4; |
67427ff7 | 315 | else { |
316 | #ifndef ST_NO_EXCEPTIONS | |
317 | throw out_of_range("AliFemtoLorentzVector<T>::operator(): bad index"); | |
318 | #else | |
319 | cerr << "AliFemtoLorentzVector<T>::operator(): bad index." << endl; | |
320 | #endif | |
321 | return 0; | |
322 | } | |
323 | } | |
324 | ||
325 | template<class T> | |
326 | T& AliFemtoLorentzVector<T>::operator() (size_t i) | |
327 | { | |
328 | if (i < 3) | |
283ac554 | 329 | return fThreeVector(i); |
67427ff7 | 330 | else if (i == 3) |
283ac554 | 331 | return fX4; |
67427ff7 | 332 | else { |
333 | #ifndef ST_NO_EXCEPTIONS | |
334 | throw out_of_range("AliFemtoLorentzVector<T>::operator(): bad index"); | |
335 | #else | |
336 | cerr << "AliFemtoLorentzVector<T>::operator(): bad index." << endl; | |
337 | #endif | |
283ac554 | 338 | return fX4; |
67427ff7 | 339 | } |
340 | } | |
341 | ||
342 | template<class T> | |
343 | T AliFemtoLorentzVector<T>::operator[] (size_t i) const | |
344 | { | |
345 | if (i < 3) | |
283ac554 | 346 | return fThreeVector[i]; |
67427ff7 | 347 | else if (i == 3) |
283ac554 | 348 | return fX4; |
67427ff7 | 349 | else { |
350 | #ifndef ST_NO_EXCEPTIONS | |
351 | throw out_of_range("AliFemtoLorentzVector<T>::operator[]: bad index"); | |
352 | #else | |
353 | cerr << "AliFemtoLorentzVector<T>::operator[]: bad index." << endl; | |
354 | #endif | |
355 | return 0; | |
356 | } | |
357 | } | |
358 | ||
359 | template<class T> | |
360 | T& AliFemtoLorentzVector<T>::operator[] (size_t i) | |
361 | { | |
362 | if (i < 3) | |
283ac554 | 363 | return fThreeVector[i]; |
67427ff7 | 364 | else if (i == 3) |
283ac554 | 365 | return fX4; |
67427ff7 | 366 | else { |
367 | #ifndef ST_NO_EXCEPTIONS | |
368 | throw out_of_range("AliFemtoLorentzVector<T>::operator[]: bad index"); | |
369 | #else | |
370 | cerr << "AliFemtoLorentzVector<T>::operator[]: bad index." << endl; | |
371 | #endif | |
283ac554 | 372 | return fX4; |
67427ff7 | 373 | } |
374 | } | |
375 | ||
376 | template<class T> | |
59c8f7b2 | 377 | T AliFemtoLorentzVector<T>::Rapidity() const |
67427ff7 | 378 | { |
283ac554 | 379 | return 0.5*::log((fX4+fThreeVector.z())/(fX4-fThreeVector.z())+1e-20); |
67427ff7 | 380 | } |
381 | ||
382 | template<class T> | |
383 | AliFemtoLorentzVector<T> AliFemtoLorentzVector<T>::operator- () | |
384 | { | |
283ac554 | 385 | return AliFemtoLorentzVector<T>(-fX4,-fThreeVector); |
67427ff7 | 386 | } |
387 | ||
388 | template<class T> | |
389 | AliFemtoLorentzVector<T> AliFemtoLorentzVector<T>::operator+ () | |
390 | { | |
391 | return *this; | |
392 | } | |
393 | ||
394 | template<class T> | |
395 | AliFemtoLorentzVector<T>& AliFemtoLorentzVector<T>::operator*= (double c) | |
396 | { | |
283ac554 | 397 | fThreeVector *= c; |
398 | fX4 *= c; | |
67427ff7 | 399 | return *this; |
400 | } | |
401 | ||
402 | template<class T> | |
403 | AliFemtoLorentzVector<T>& AliFemtoLorentzVector<T>::operator/= (double c) | |
404 | { | |
283ac554 | 405 | fThreeVector /= c; |
406 | fX4 /= c; | |
67427ff7 | 407 | return *this; |
408 | } | |
409 | ||
410 | #ifndef ST_NO_MEMBER_TEMPLATES | |
411 | #ifndef WIN32 | |
412 | ||
413 | template<class T> | |
414 | template<class X> | |
415 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<X> &vec, T t) | |
283ac554 | 416 | : fThreeVector(vec), fX4(t) { /* nop */ } |
67427ff7 | 417 | |
418 | template<class T> | |
419 | template<class X> | |
420 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<X> &vec) | |
283ac554 | 421 | : fThreeVector(vec), fX4(t) { /* nop */ } |
67427ff7 | 422 | |
423 | template<class T> | |
424 | template<class X> | |
425 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<X> &vec) | |
283ac554 | 426 | : fThreeVector(vec.vect()), fX4(vec.t()) { /* nop */ } |
67427ff7 | 427 | |
428 | template<class T> | |
429 | template<class X> | |
430 | AliFemtoLorentzVector<T> | |
431 | AliFemtoLorentzVector<T>::boost(const AliFemtoLorentzVector<X>& pframe) const | |
432 | { | |
433 | T mass = abs(pframe); | |
434 | AliFemtoThreeVector<T> eta = (-1./mass)*pframe.vect(); // gamma*beta | |
435 | T gamma = fabs(pframe.e())/mass; | |
436 | AliFemtoThreeVector<T> pl = ((this->vect()*eta)/(eta*eta))*eta; // longitudinal momentum | |
437 | return AliFemtoLorentzVector<T>(gamma*this->e() - this->vect()*eta, | |
438 | this->vect() + (gamma-1.)*pl - this->e()*eta); | |
439 | } | |
440 | ||
441 | template<class T> | |
442 | template<class X> | |
a19edcc9 | 443 | void AliFemtoLorentzVector<T>::SetVect(const AliFemtoThreeVector<X>& v) |
67427ff7 | 444 | { |
283ac554 | 445 | fThreeVector = v; |
67427ff7 | 446 | } |
447 | ||
448 | template<class T> | |
449 | template<class X> | |
450 | AliFemtoLorentzVector<T>& | |
451 | AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<X>& vec) | |
452 | { | |
19708f0f | 453 | if(this != &vec) { |
283ac554 | 454 | fThreeVector = vec.vect(); |
455 | fX4 = vec.t(); | |
19708f0f | 456 | } |
457 | return *this; | |
67427ff7 | 458 | } |
459 | ||
460 | template<class T> | |
461 | template<class X> | |
462 | bool | |
463 | AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<X>& v) const | |
464 | { | |
283ac554 | 465 | return (fThreeVector == v.vect()) && (fX4 == v.t()); |
67427ff7 | 466 | } |
467 | ||
468 | template<class T> | |
469 | template<class X> | |
470 | bool | |
471 | AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<X>& v) const | |
472 | { | |
473 | return !(*this == v); | |
474 | } | |
475 | ||
476 | template<class T> | |
477 | template<class X> | |
478 | AliFemtoLorentzVector<T>& | |
479 | AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<X>& v) | |
480 | { | |
283ac554 | 481 | fThreeVector += v.vect(); |
482 | fX4 += v.t(); | |
67427ff7 | 483 | return *this; |
484 | } | |
485 | ||
486 | template<class T> | |
487 | template<class X> | |
488 | AliFemtoLorentzVector<T>& | |
489 | AliFemtoLorentzVector<T>::operator-= (const AliFemtoLorentzVector<X>& v) | |
490 | { | |
283ac554 | 491 | fThreeVector -= v.vect(); |
492 | fX4 -= v.t(); | |
67427ff7 | 493 | return *this; |
494 | } | |
495 | ||
496 | #endif | |
497 | #else | |
498 | ||
499 | template<class T> | |
500 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<float> &vec, T t) | |
283ac554 | 501 | : fThreeVector(vec), fX4(t) { /* nop */ } |
67427ff7 | 502 | |
503 | template<class T> | |
504 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<double> &vec, T t) | |
283ac554 | 505 | : fThreeVector(vec), fX4(t) { /* nop */ } |
67427ff7 | 506 | |
507 | template<class T> | |
508 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<float> &vec) | |
283ac554 | 509 | : fThreeVector(vec), fX4(t) { /* nop */ } |
67427ff7 | 510 | |
511 | template<class T> | |
512 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<double> &vec) | |
283ac554 | 513 | : fThreeVector(vec), fX4(t) { /* nop */ } |
67427ff7 | 514 | |
515 | template<class T> | |
516 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<float> &vec) | |
283ac554 | 517 | : fThreeVector(vec.vect()), fX4(vec.t()) { /* nop */ } |
67427ff7 | 518 | |
519 | template<class T> | |
520 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<double> &vec) | |
283ac554 | 521 | : fThreeVector(vec.vect()), fX4(vec.t()) { /* nop */ } |
67427ff7 | 522 | |
523 | template<class T> | |
524 | AliFemtoLorentzVector<T> | |
525 | AliFemtoLorentzVector<T>::boost(const AliFemtoLorentzVector<float>& pframe) const | |
526 | { | |
527 | T mass = abs(pframe); | |
528 | AliFemtoThreeVector<T> eta = (-1./mass)*pframe.vect(); // gamma*beta | |
529 | T gamma = fabs(pframe.e())/mass; | |
530 | AliFemtoThreeVector<T> pl = ((this->vect()*eta)/(eta*eta))*eta; // longitudinal momentum | |
531 | return AliFemtoLorentzVector<T>(gamma*this->e() - this->vect()*eta, | |
532 | this->vect() + (gamma-1.)*pl - this->e()*eta); | |
533 | } | |
534 | ||
535 | template<class T> | |
536 | AliFemtoLorentzVector<T> | |
537 | AliFemtoLorentzVector<T>::boost(const AliFemtoLorentzVector<double>& pframe) const | |
538 | { | |
539 | T mass = abs(pframe); | |
540 | AliFemtoThreeVector<T> eta = (-1./mass)*pframe.vect(); // gamma*beta | |
541 | T gamma = fabs(pframe.e())/mass; | |
542 | AliFemtoThreeVector<T> pl = ((this->vect()*eta)/(eta*eta))*eta; // longitudinal momentum | |
543 | return AliFemtoLorentzVector<T>(gamma*this->e() - this->vect()*eta, | |
544 | this->vect() + (gamma-1.)*pl - this->e()*eta); | |
545 | } | |
546 | ||
547 | template<class T> | |
a19edcc9 | 548 | void AliFemtoLorentzVector<T>::SetVect(const AliFemtoThreeVector<float>& v) |
67427ff7 | 549 | { |
283ac554 | 550 | fThreeVector = v; |
67427ff7 | 551 | } |
552 | ||
553 | template<class T> | |
a19edcc9 | 554 | void AliFemtoLorentzVector<T>::SetVect(const AliFemtoThreeVector<double>& v) |
67427ff7 | 555 | { |
283ac554 | 556 | fThreeVector = v; |
67427ff7 | 557 | } |
558 | ||
559 | template<class T> | |
560 | AliFemtoLorentzVector<T>& | |
561 | AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<float>& vec) | |
562 | { | |
283ac554 | 563 | fThreeVector = vec.vect(); |
564 | fX4 = vec.t(); | |
67427ff7 | 565 | return *this; |
566 | } | |
567 | ||
568 | template<class T> | |
569 | AliFemtoLorentzVector<T>& | |
570 | AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<double>& vec) | |
571 | { | |
283ac554 | 572 | fThreeVector = vec.vect(); |
573 | fX4 = vec.t(); | |
67427ff7 | 574 | return *this; |
575 | } | |
576 | ||
577 | template<class T> | |
578 | bool | |
579 | AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<float>& v) const | |
580 | { | |
283ac554 | 581 | return (this->vect() == v.vect()) && (fX4 == v.t()); |
67427ff7 | 582 | } |
583 | ||
584 | template<class T> | |
585 | bool | |
586 | AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<double>& v) const | |
587 | { | |
283ac554 | 588 | return (fThreeVector == v.vect()) && (fX4 == v.t()); |
67427ff7 | 589 | } |
590 | ||
591 | template<class T> | |
592 | bool | |
593 | AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<float>& v) const | |
594 | { | |
595 | return !(*this == v); | |
596 | } | |
597 | ||
598 | template<class T> | |
599 | bool | |
600 | AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<double>& v) const | |
601 | { | |
602 | return !(*this == v); | |
603 | } | |
604 | ||
605 | template<class T> | |
606 | AliFemtoLorentzVector<T>& | |
607 | AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<float>& v) | |
608 | { | |
283ac554 | 609 | fThreeVector += v.vect(); |
610 | fX4 += v.t(); | |
67427ff7 | 611 | return *this; |
612 | } | |
613 | ||
614 | template<class T> | |
615 | AliFemtoLorentzVector<T>& | |
616 | AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<double>& v) | |
617 | { | |
283ac554 | 618 | fThreeVector += v.vect(); |
619 | fX4 += v.t(); | |
67427ff7 | 620 | return *this; |
621 | } | |
622 | ||
623 | template<class T> | |
624 | AliFemtoLorentzVector<T>& | |
625 | AliFemtoLorentzVector<T>::operator-= (const AliFemtoLorentzVector<float>& v) | |
626 | { | |
283ac554 | 627 | fThreeVector -= v.vect(); |
628 | fX4 -= v.t(); | |
67427ff7 | 629 | return *this; |
630 | } | |
631 | ||
632 | template<class T> | |
633 | AliFemtoLorentzVector<T>& | |
634 | AliFemtoLorentzVector<T>::operator-= (const AliFemtoLorentzVector<double>& v) | |
635 | { | |
283ac554 | 636 | fThreeVector -= v.vect(); |
637 | fX4 -= v.t(); | |
67427ff7 | 638 | return *this; |
639 | } | |
640 | ||
641 | #endif // ST_NO_MEMBER_TEMPLATES | |
642 | #endif /* ! __CINT__ */ | |
643 | #ifdef __CINT__ | |
644 | template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
645 | template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
646 | template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
647 | template<> AliFemtoLorentzVector<float> operator+ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
648 | template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
649 | template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
650 | template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
651 | template<> AliFemtoLorentzVector<float> operator- (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
652 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
653 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
654 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
655 | template<> AliFemtoLorentzVector<float> operator* (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
656 | template<> AliFemtoLorentzVector<double> operator* (const double v1, const AliFemtoLorentzVector<double>& v2); | |
657 | template<> AliFemtoLorentzVector<double> operator* (const double v1, const AliFemtoLorentzVector<float>& v2); | |
658 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const double v2); | |
659 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<float>& v1, const double v2); | |
660 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
661 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
662 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
663 | template<> AliFemtoLorentzVector<float> operator/ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
664 | template<> AliFemtoLorentzVector<double> operator/ (const double v1, const AliFemtoLorentzVector<double>& v2); | |
665 | template<> AliFemtoLorentzVector<double> operator/ (const double v1, const AliFemtoLorentzVector<float>& v2); | |
666 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const double v2); | |
667 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<float>& v1, const double v2); | |
668 | template<> istream& operator>> (istream& is, const AliFemtoLorentzVector<double>& v); | |
669 | template<> ostream& operator<< (ostream& os, const AliFemtoLorentzVector<double>& v); | |
670 | template<> istream& operator>> (istream& is, const AliFemtoLorentzVector<float>& v); | |
671 | template<> ostream& operator<< (ostream& os, const AliFemtoLorentzVector<float>& v); | |
672 | template<> double abs(const AliFemtoLorentzVector<double>& v); | |
673 | template<> float abs(const AliFemtoLorentzVector<float>& v); | |
674 | #else | |
675 | // | |
676 | // Non-member operators | |
677 | // | |
678 | template<class T, class X> | |
679 | AliFemtoLorentzVector<T> | |
680 | operator+ (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2) | |
681 | { | |
682 | return AliFemtoLorentzVector<T>(v1) += v2; | |
683 | } | |
684 | ||
685 | template<class T, class X> | |
686 | AliFemtoLorentzVector<T> | |
687 | operator- (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2) | |
688 | { | |
689 | return AliFemtoLorentzVector<T>(v1) -= v2; | |
690 | } | |
691 | ||
692 | template<class T, class X> | |
693 | T | |
694 | operator* (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2) | |
695 | { | |
696 | return v1.t()*v2.t() - v1.vect()*v2.vect(); | |
697 | } | |
698 | ||
699 | template<class T> | |
700 | AliFemtoLorentzVector<T> | |
701 | operator* (const AliFemtoLorentzVector<T>& v, double c) | |
702 | { | |
703 | return AliFemtoLorentzVector<T>(v) *= c; | |
704 | } | |
705 | ||
706 | template<class T> | |
707 | AliFemtoLorentzVector<T> operator* (double c, const AliFemtoLorentzVector<T>& v) | |
708 | { | |
709 | return AliFemtoLorentzVector<T>(v) *= c; | |
710 | } | |
711 | ||
712 | template<class T, class X> | |
713 | AliFemtoLorentzVector<T> operator/ (const AliFemtoLorentzVector<T>& v, X c) | |
714 | { | |
715 | return AliFemtoLorentzVector<T>(v) /= c; | |
716 | } | |
717 | ||
718 | template<class T> | |
719 | ostream& operator<< (ostream& os, const AliFemtoLorentzVector<T>& v) | |
720 | { | |
721 | return os << v.vect() << "\t\t" << v.t(); | |
722 | } | |
723 | ||
724 | template<class T> | |
725 | istream& operator>>(istream& is, AliFemtoLorentzVector<T>& v) | |
726 | { | |
727 | T x, y, z, t; | |
728 | is >> x >> y >> z >> t; | |
a19edcc9 | 729 | v.SetX(x); |
730 | v.SetY(y); | |
731 | v.SetZ(z); | |
732 | v.SetT(t); | |
67427ff7 | 733 | return is; |
734 | } | |
735 | ||
736 | // | |
737 | // Non-member functions | |
738 | // | |
739 | template<class T> | |
740 | T abs(const AliFemtoLorentzVector<T>& v) {return v.m();} | |
741 | ||
742 | #endif /* __CINT__ */ | |
743 | #endif |