]>
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 | **************************************************************************/ | |
67 | #ifndef ST_LORENTZ_VECTOR_HH | |
68 | #define ST_LORENTZ_VECTOR_HH | |
69 | ||
70 | #include "AliFemtoThreeVector.h" | |
71 | template<class T> class AliFemtoLorentzVector { | |
72 | public: | |
73 | AliFemtoLorentzVector(T = 0, T = 0, T = 0, T = 0); | |
74 | virtual ~AliFemtoLorentzVector(); | |
75 | ||
76 | #ifndef ST_NO_MEMBER_TEMPLATES | |
77 | template<class X> AliFemtoLorentzVector(const AliFemtoThreeVector<X>&, T); | |
78 | template<class X> AliFemtoLorentzVector(T, const AliFemtoThreeVector<X>&); | |
79 | ||
80 | template<class X> AliFemtoLorentzVector(const AliFemtoLorentzVector<X>&); | |
81 | template<class X> AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<X>&); | |
82 | // AliFemtoLorentzVector(const AliFemtoLorentzVector<T>&); use default | |
83 | // AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<T>&); use default | |
84 | #else | |
85 | AliFemtoLorentzVector(const AliFemtoThreeVector<float>&, T); | |
86 | AliFemtoLorentzVector(T, const AliFemtoThreeVector<float>&); | |
87 | AliFemtoLorentzVector(const AliFemtoLorentzVector<float>&); | |
88 | ||
89 | AliFemtoLorentzVector(const AliFemtoThreeVector<double>&, T); | |
90 | AliFemtoLorentzVector(T, const AliFemtoThreeVector<double>&); | |
91 | AliFemtoLorentzVector(const AliFemtoLorentzVector<double>&); | |
92 | ||
93 | AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<float>&); | |
94 | AliFemtoLorentzVector<T>& operator=(const AliFemtoLorentzVector<double>&); | |
95 | #endif | |
96 | ||
97 | T x() const; | |
98 | T y() const; | |
99 | T z() const; | |
100 | T t() const; | |
101 | T px() const; | |
102 | T py() const; | |
103 | T pz() const; | |
104 | T e() const; | |
105 | T operator() (size_t) const; | |
106 | T operator[] (size_t) const; | |
107 | ||
108 | T& operator() (size_t); | |
109 | T& operator[] (size_t); | |
110 | ||
111 | const AliFemtoThreeVector<T>& vect() const; | |
112 | ||
113 | void setX(T); | |
114 | void setY(T); | |
115 | void setZ(T); | |
116 | void setPx(T); | |
117 | void setPy(T); | |
118 | void setPz(T); | |
119 | void setE(T); | |
120 | void setT(T); | |
121 | ||
122 | #ifndef ST_NO_MEMBER_TEMPLATES | |
123 | template <class X> void setVect(const AliFemtoThreeVector<X>&); | |
124 | #else | |
125 | void setVect(const AliFemtoThreeVector<float>&); | |
126 | void setVect(const AliFemtoThreeVector<double>&); | |
127 | #endif | |
128 | ||
129 | T perp() const; | |
130 | T perp2() const; | |
131 | T pseudoRapidity() const; | |
132 | T phi() const; | |
133 | T theta() const; | |
134 | T cosTheta() const; | |
135 | ||
136 | T plus() const; | |
137 | T minus() const; | |
138 | ||
139 | T m() const; | |
140 | T m2() const; | |
141 | T mt() const; | |
142 | T mt2() const; | |
143 | T rapidity() const; | |
144 | ||
145 | #ifndef ST_NO_MEMBER_TEMPLATES | |
146 | template<class X> AliFemtoLorentzVector<T> boost(const AliFemtoLorentzVector<X>&) const; | |
147 | #else | |
148 | AliFemtoLorentzVector<T> boost(const AliFemtoLorentzVector<float>&) const; | |
149 | AliFemtoLorentzVector<T> boost(const AliFemtoLorentzVector<double>&) const; | |
150 | #endif | |
151 | ||
152 | AliFemtoLorentzVector<T> operator- (); | |
153 | AliFemtoLorentzVector<T> operator+ (); | |
154 | AliFemtoLorentzVector<T>& operator*= (double); | |
155 | AliFemtoLorentzVector<T>& operator/= (double); | |
156 | ||
157 | #ifndef ST_NO_MEMBER_TEMPLATES | |
158 | template<class X> bool operator == (const AliFemtoLorentzVector<X>&) const; | |
159 | template<class X> bool operator != (const AliFemtoLorentzVector<X>&) const; | |
160 | template<class X> AliFemtoLorentzVector<T>& operator+= (const AliFemtoLorentzVector<X>&); | |
161 | template<class X> AliFemtoLorentzVector<T>& operator-= (const AliFemtoLorentzVector<X>&); | |
162 | #else | |
163 | bool operator == (const AliFemtoLorentzVector<float>&) const; | |
164 | bool operator != (const AliFemtoLorentzVector<float>&) const; | |
165 | bool operator == (const AliFemtoLorentzVector<double>&) const; | |
166 | bool operator != (const AliFemtoLorentzVector<double>&) const; | |
167 | ||
168 | AliFemtoLorentzVector<T>& operator+= (const AliFemtoLorentzVector<float>&); | |
169 | AliFemtoLorentzVector<T>& operator-= (const AliFemtoLorentzVector<float>&); | |
170 | AliFemtoLorentzVector<T>& operator+= (const AliFemtoLorentzVector<double>&); | |
171 | AliFemtoLorentzVector<T>& operator-= (const AliFemtoLorentzVector<double>&); | |
172 | #endif | |
173 | ||
174 | protected: | |
175 | AliFemtoThreeVector<T> mThreeVector; | |
176 | T mX4; | |
177 | #ifdef __ROOT__ | |
178 | ClassDef(AliFemtoLorentzVector,3) | |
179 | #endif | |
180 | }; | |
181 | #ifndef __CINT__ | |
182 | // | |
183 | // Implementation of member functions | |
184 | // | |
185 | template<class T> | |
186 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T x, T y, T z, T t) | |
187 | : mThreeVector(x, y, z), mX4(t) { /* nop */ } | |
188 | ||
189 | template<class T> | |
190 | AliFemtoLorentzVector<T>::~AliFemtoLorentzVector() { /* nopt */ } | |
191 | ||
192 | template<class T> | |
193 | const AliFemtoThreeVector<T>& AliFemtoLorentzVector<T>::vect() const | |
194 | { | |
195 | return mThreeVector; | |
196 | } | |
197 | ||
198 | template<class T> | |
199 | T AliFemtoLorentzVector<T>::m2() const | |
200 | { | |
201 | return (mX4*mX4 - mThreeVector*mThreeVector); | |
202 | } | |
203 | ||
204 | template<class T> | |
205 | T AliFemtoLorentzVector<T>::plus() const { return (e() + pz()); } | |
206 | ||
207 | template<class T> | |
208 | T AliFemtoLorentzVector<T>::minus() const { return (e() - pz()); } | |
209 | ||
210 | template<class T> | |
211 | T AliFemtoLorentzVector<T>::m() const | |
212 | { | |
213 | T mass2 = m2(); | |
214 | if (mass2 < 0) | |
215 | return -::sqrt(-mass2); | |
216 | else | |
217 | return ::sqrt(mass2); | |
218 | } | |
219 | ||
220 | template<class T> | |
221 | T AliFemtoLorentzVector<T>::mt2() const | |
222 | { | |
223 | return this->perp2() + m2(); | |
224 | } | |
225 | ||
226 | template<class T> | |
227 | T AliFemtoLorentzVector<T>::mt() const | |
228 | { | |
229 | // | |
230 | // change to more optimal code ? | |
231 | // return e()*e() - pz()*pz(); | |
232 | T massPerp2 = mt2(); | |
233 | if (massPerp2 < 0) | |
234 | return -::sqrt(-massPerp2); | |
235 | else | |
236 | return ::sqrt(massPerp2); | |
237 | } | |
238 | ||
239 | template<class T> | |
240 | void AliFemtoLorentzVector<T>::setPx(T x) {mThreeVector.setX(x);} | |
241 | ||
242 | template<class T> | |
243 | void AliFemtoLorentzVector<T>::setPy(T y) {mThreeVector.setY(y);} | |
244 | ||
245 | template<class T> | |
246 | void AliFemtoLorentzVector<T>::setPz(T z) {mThreeVector.setZ(z);} | |
247 | ||
248 | template<class T> | |
249 | void AliFemtoLorentzVector<T>::setX(T x) {mThreeVector.setX(x);} | |
250 | ||
251 | template<class T> | |
252 | void AliFemtoLorentzVector<T>::setY(T y) {mThreeVector.setY(y);} | |
253 | ||
254 | template<class T> | |
255 | void AliFemtoLorentzVector<T>::setZ(T z) {mThreeVector.setZ(z);} | |
256 | ||
257 | template<class T> | |
258 | void AliFemtoLorentzVector<T>::setT(T t) {mX4 = t;} | |
259 | ||
260 | template<class T> | |
261 | void AliFemtoLorentzVector<T>::setE(T e) {mX4 = e;} | |
262 | ||
263 | template<class T> | |
264 | T AliFemtoLorentzVector<T>::x() const {return mThreeVector.x();} | |
265 | ||
266 | template<class T> | |
267 | T AliFemtoLorentzVector<T>::y() const {return mThreeVector.y();} | |
268 | ||
269 | template<class T> | |
270 | T AliFemtoLorentzVector<T>::z() const {return mThreeVector.z();} | |
271 | ||
272 | template<class T> | |
273 | T AliFemtoLorentzVector<T>::px() const {return mThreeVector.x();} | |
274 | ||
275 | template<class T> | |
276 | T AliFemtoLorentzVector<T>::py() const {return mThreeVector.y();} | |
277 | ||
278 | template<class T> | |
279 | T AliFemtoLorentzVector<T>::pz() const {return mThreeVector.z();} | |
280 | ||
281 | template<class T> | |
282 | T AliFemtoLorentzVector<T>::e() const {return mX4;} | |
283 | ||
284 | template<class T> | |
285 | T AliFemtoLorentzVector<T>::t() const {return mX4;} | |
286 | ||
287 | template<class T> | |
288 | T AliFemtoLorentzVector<T>::perp() const {return mThreeVector.perp();} | |
289 | ||
290 | template<class T> | |
291 | T AliFemtoLorentzVector<T>::perp2() const {return mThreeVector.perp2();} | |
292 | ||
293 | template<class T> | |
294 | T AliFemtoLorentzVector<T>::pseudoRapidity() const {return mThreeVector.pseudoRapidity();} | |
295 | ||
296 | template<class T> | |
297 | T AliFemtoLorentzVector<T>::phi() const {return mThreeVector.phi();} | |
298 | ||
299 | template<class T> | |
300 | T AliFemtoLorentzVector<T>::theta() const {return mThreeVector.theta();} | |
301 | ||
302 | template<class T> | |
303 | T AliFemtoLorentzVector<T>::cosTheta() const {return mThreeVector.cosTheta();} | |
304 | ||
305 | template<class T> | |
306 | T AliFemtoLorentzVector<T>::operator() (size_t i) const | |
307 | { | |
308 | if (i < 3) | |
309 | return mThreeVector(i); | |
310 | else if (i == 3) | |
311 | return mX4; | |
312 | else { | |
313 | #ifndef ST_NO_EXCEPTIONS | |
314 | throw out_of_range("AliFemtoLorentzVector<T>::operator(): bad index"); | |
315 | #else | |
316 | cerr << "AliFemtoLorentzVector<T>::operator(): bad index." << endl; | |
317 | #endif | |
318 | return 0; | |
319 | } | |
320 | } | |
321 | ||
322 | template<class T> | |
323 | T& AliFemtoLorentzVector<T>::operator() (size_t i) | |
324 | { | |
325 | if (i < 3) | |
326 | return mThreeVector(i); | |
327 | else if (i == 3) | |
328 | return mX4; | |
329 | else { | |
330 | #ifndef ST_NO_EXCEPTIONS | |
331 | throw out_of_range("AliFemtoLorentzVector<T>::operator(): bad index"); | |
332 | #else | |
333 | cerr << "AliFemtoLorentzVector<T>::operator(): bad index." << endl; | |
334 | #endif | |
335 | return mX4; | |
336 | } | |
337 | } | |
338 | ||
339 | template<class T> | |
340 | T AliFemtoLorentzVector<T>::operator[] (size_t i) const | |
341 | { | |
342 | if (i < 3) | |
343 | return mThreeVector[i]; | |
344 | else if (i == 3) | |
345 | return mX4; | |
346 | else { | |
347 | #ifndef ST_NO_EXCEPTIONS | |
348 | throw out_of_range("AliFemtoLorentzVector<T>::operator[]: bad index"); | |
349 | #else | |
350 | cerr << "AliFemtoLorentzVector<T>::operator[]: bad index." << endl; | |
351 | #endif | |
352 | return 0; | |
353 | } | |
354 | } | |
355 | ||
356 | template<class T> | |
357 | T& AliFemtoLorentzVector<T>::operator[] (size_t i) | |
358 | { | |
359 | if (i < 3) | |
360 | return mThreeVector[i]; | |
361 | else if (i == 3) | |
362 | return mX4; | |
363 | else { | |
364 | #ifndef ST_NO_EXCEPTIONS | |
365 | throw out_of_range("AliFemtoLorentzVector<T>::operator[]: bad index"); | |
366 | #else | |
367 | cerr << "AliFemtoLorentzVector<T>::operator[]: bad index." << endl; | |
368 | #endif | |
369 | return mX4; | |
370 | } | |
371 | } | |
372 | ||
373 | template<class T> | |
374 | T AliFemtoLorentzVector<T>::rapidity() const | |
375 | { | |
376 | return 0.5*::log((mX4+mThreeVector.z())/(mX4-mThreeVector.z())+1e-20); | |
377 | } | |
378 | ||
379 | template<class T> | |
380 | AliFemtoLorentzVector<T> AliFemtoLorentzVector<T>::operator- () | |
381 | { | |
382 | return AliFemtoLorentzVector<T>(-mX4,-mThreeVector); | |
383 | } | |
384 | ||
385 | template<class T> | |
386 | AliFemtoLorentzVector<T> AliFemtoLorentzVector<T>::operator+ () | |
387 | { | |
388 | return *this; | |
389 | } | |
390 | ||
391 | template<class T> | |
392 | AliFemtoLorentzVector<T>& AliFemtoLorentzVector<T>::operator*= (double c) | |
393 | { | |
394 | mThreeVector *= c; | |
395 | mX4 *= c; | |
396 | return *this; | |
397 | } | |
398 | ||
399 | template<class T> | |
400 | AliFemtoLorentzVector<T>& AliFemtoLorentzVector<T>::operator/= (double c) | |
401 | { | |
402 | mThreeVector /= c; | |
403 | mX4 /= c; | |
404 | return *this; | |
405 | } | |
406 | ||
407 | #ifndef ST_NO_MEMBER_TEMPLATES | |
408 | #ifndef WIN32 | |
409 | ||
410 | template<class T> | |
411 | template<class X> | |
412 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<X> &vec, T t) | |
413 | : mThreeVector(vec), mX4(t) { /* nop */ } | |
414 | ||
415 | template<class T> | |
416 | template<class X> | |
417 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<X> &vec) | |
418 | : mThreeVector(vec), mX4(t) { /* nop */ } | |
419 | ||
420 | template<class T> | |
421 | template<class X> | |
422 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<X> &vec) | |
423 | : mThreeVector(vec.vect()), mX4(vec.t()) { /* nop */ } | |
424 | ||
425 | template<class T> | |
426 | template<class X> | |
427 | AliFemtoLorentzVector<T> | |
428 | AliFemtoLorentzVector<T>::boost(const AliFemtoLorentzVector<X>& pframe) const | |
429 | { | |
430 | T mass = abs(pframe); | |
431 | AliFemtoThreeVector<T> eta = (-1./mass)*pframe.vect(); // gamma*beta | |
432 | T gamma = fabs(pframe.e())/mass; | |
433 | AliFemtoThreeVector<T> pl = ((this->vect()*eta)/(eta*eta))*eta; // longitudinal momentum | |
434 | return AliFemtoLorentzVector<T>(gamma*this->e() - this->vect()*eta, | |
435 | this->vect() + (gamma-1.)*pl - this->e()*eta); | |
436 | } | |
437 | ||
438 | template<class T> | |
439 | template<class X> | |
440 | void AliFemtoLorentzVector<T>::setVect(const AliFemtoThreeVector<X>& v) | |
441 | { | |
442 | mThreeVector = v; | |
443 | } | |
444 | ||
445 | template<class T> | |
446 | template<class X> | |
447 | AliFemtoLorentzVector<T>& | |
448 | AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<X>& vec) | |
449 | { | |
450 | mThreeVector = vec.vect(); | |
451 | mX4 = vec.t(); | |
452 | return *this; | |
453 | } | |
454 | ||
455 | template<class T> | |
456 | template<class X> | |
457 | bool | |
458 | AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<X>& v) const | |
459 | { | |
460 | return (mThreeVector == v.vect()) && (mX4 == v.t()); | |
461 | } | |
462 | ||
463 | template<class T> | |
464 | template<class X> | |
465 | bool | |
466 | AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<X>& v) const | |
467 | { | |
468 | return !(*this == v); | |
469 | } | |
470 | ||
471 | template<class T> | |
472 | template<class X> | |
473 | AliFemtoLorentzVector<T>& | |
474 | AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<X>& v) | |
475 | { | |
476 | mThreeVector += v.vect(); | |
477 | mX4 += v.t(); | |
478 | return *this; | |
479 | } | |
480 | ||
481 | template<class T> | |
482 | template<class X> | |
483 | AliFemtoLorentzVector<T>& | |
484 | AliFemtoLorentzVector<T>::operator-= (const AliFemtoLorentzVector<X>& v) | |
485 | { | |
486 | mThreeVector -= v.vect(); | |
487 | mX4 -= v.t(); | |
488 | return *this; | |
489 | } | |
490 | ||
491 | #endif | |
492 | #else | |
493 | ||
494 | template<class T> | |
495 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<float> &vec, T t) | |
496 | : mThreeVector(vec), mX4(t) { /* nop */ } | |
497 | ||
498 | template<class T> | |
499 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<double> &vec, T t) | |
500 | : mThreeVector(vec), mX4(t) { /* nop */ } | |
501 | ||
502 | template<class T> | |
503 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<float> &vec) | |
504 | : mThreeVector(vec), mX4(t) { /* nop */ } | |
505 | ||
506 | template<class T> | |
507 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<double> &vec) | |
508 | : mThreeVector(vec), mX4(t) { /* nop */ } | |
509 | ||
510 | template<class T> | |
511 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<float> &vec) | |
512 | : mThreeVector(vec.vect()), mX4(vec.t()) { /* nop */ } | |
513 | ||
514 | template<class T> | |
515 | AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<double> &vec) | |
516 | : mThreeVector(vec.vect()), mX4(vec.t()) { /* nop */ } | |
517 | ||
518 | template<class T> | |
519 | AliFemtoLorentzVector<T> | |
520 | AliFemtoLorentzVector<T>::boost(const AliFemtoLorentzVector<float>& pframe) const | |
521 | { | |
522 | T mass = abs(pframe); | |
523 | AliFemtoThreeVector<T> eta = (-1./mass)*pframe.vect(); // gamma*beta | |
524 | T gamma = fabs(pframe.e())/mass; | |
525 | AliFemtoThreeVector<T> pl = ((this->vect()*eta)/(eta*eta))*eta; // longitudinal momentum | |
526 | return AliFemtoLorentzVector<T>(gamma*this->e() - this->vect()*eta, | |
527 | this->vect() + (gamma-1.)*pl - this->e()*eta); | |
528 | } | |
529 | ||
530 | template<class T> | |
531 | AliFemtoLorentzVector<T> | |
532 | AliFemtoLorentzVector<T>::boost(const AliFemtoLorentzVector<double>& pframe) const | |
533 | { | |
534 | T mass = abs(pframe); | |
535 | AliFemtoThreeVector<T> eta = (-1./mass)*pframe.vect(); // gamma*beta | |
536 | T gamma = fabs(pframe.e())/mass; | |
537 | AliFemtoThreeVector<T> pl = ((this->vect()*eta)/(eta*eta))*eta; // longitudinal momentum | |
538 | return AliFemtoLorentzVector<T>(gamma*this->e() - this->vect()*eta, | |
539 | this->vect() + (gamma-1.)*pl - this->e()*eta); | |
540 | } | |
541 | ||
542 | template<class T> | |
543 | void AliFemtoLorentzVector<T>::setVect(const AliFemtoThreeVector<float>& v) | |
544 | { | |
545 | mThreeVector = v; | |
546 | } | |
547 | ||
548 | template<class T> | |
549 | void AliFemtoLorentzVector<T>::setVect(const AliFemtoThreeVector<double>& v) | |
550 | { | |
551 | mThreeVector = v; | |
552 | } | |
553 | ||
554 | template<class T> | |
555 | AliFemtoLorentzVector<T>& | |
556 | AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<float>& vec) | |
557 | { | |
558 | mThreeVector = vec.vect(); | |
559 | mX4 = vec.t(); | |
560 | return *this; | |
561 | } | |
562 | ||
563 | template<class T> | |
564 | AliFemtoLorentzVector<T>& | |
565 | AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<double>& vec) | |
566 | { | |
567 | mThreeVector = vec.vect(); | |
568 | mX4 = vec.t(); | |
569 | return *this; | |
570 | } | |
571 | ||
572 | template<class T> | |
573 | bool | |
574 | AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<float>& v) const | |
575 | { | |
576 | return (this->vect() == v.vect()) && (mX4 == v.t()); | |
577 | } | |
578 | ||
579 | template<class T> | |
580 | bool | |
581 | AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<double>& v) const | |
582 | { | |
583 | return (mThreeVector == v.vect()) && (mX4 == v.t()); | |
584 | } | |
585 | ||
586 | template<class T> | |
587 | bool | |
588 | AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<float>& v) const | |
589 | { | |
590 | return !(*this == v); | |
591 | } | |
592 | ||
593 | template<class T> | |
594 | bool | |
595 | AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<double>& v) const | |
596 | { | |
597 | return !(*this == v); | |
598 | } | |
599 | ||
600 | template<class T> | |
601 | AliFemtoLorentzVector<T>& | |
602 | AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<float>& v) | |
603 | { | |
604 | mThreeVector += v.vect(); | |
605 | mX4 += v.t(); | |
606 | return *this; | |
607 | } | |
608 | ||
609 | template<class T> | |
610 | AliFemtoLorentzVector<T>& | |
611 | AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<double>& v) | |
612 | { | |
613 | mThreeVector += v.vect(); | |
614 | mX4 += v.t(); | |
615 | return *this; | |
616 | } | |
617 | ||
618 | template<class T> | |
619 | AliFemtoLorentzVector<T>& | |
620 | AliFemtoLorentzVector<T>::operator-= (const AliFemtoLorentzVector<float>& v) | |
621 | { | |
622 | mThreeVector -= v.vect(); | |
623 | mX4 -= v.t(); | |
624 | return *this; | |
625 | } | |
626 | ||
627 | template<class T> | |
628 | AliFemtoLorentzVector<T>& | |
629 | AliFemtoLorentzVector<T>::operator-= (const AliFemtoLorentzVector<double>& v) | |
630 | { | |
631 | mThreeVector -= v.vect(); | |
632 | mX4 -= v.t(); | |
633 | return *this; | |
634 | } | |
635 | ||
636 | #endif // ST_NO_MEMBER_TEMPLATES | |
637 | #endif /* ! __CINT__ */ | |
638 | #ifdef __CINT__ | |
639 | template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
640 | template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
641 | template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
642 | template<> AliFemtoLorentzVector<float> operator+ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
643 | template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
644 | template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
645 | template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
646 | template<> AliFemtoLorentzVector<float> operator- (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
647 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
648 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
649 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
650 | template<> AliFemtoLorentzVector<float> operator* (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
651 | template<> AliFemtoLorentzVector<double> operator* (const double v1, const AliFemtoLorentzVector<double>& v2); | |
652 | template<> AliFemtoLorentzVector<double> operator* (const double v1, const AliFemtoLorentzVector<float>& v2); | |
653 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const double v2); | |
654 | template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<float>& v1, const double v2); | |
655 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2); | |
656 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2); | |
657 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2); | |
658 | template<> AliFemtoLorentzVector<float> operator/ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2); | |
659 | template<> AliFemtoLorentzVector<double> operator/ (const double v1, const AliFemtoLorentzVector<double>& v2); | |
660 | template<> AliFemtoLorentzVector<double> operator/ (const double v1, const AliFemtoLorentzVector<float>& v2); | |
661 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const double v2); | |
662 | template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<float>& v1, const double v2); | |
663 | template<> istream& operator>> (istream& is, const AliFemtoLorentzVector<double>& v); | |
664 | template<> ostream& operator<< (ostream& os, const AliFemtoLorentzVector<double>& v); | |
665 | template<> istream& operator>> (istream& is, const AliFemtoLorentzVector<float>& v); | |
666 | template<> ostream& operator<< (ostream& os, const AliFemtoLorentzVector<float>& v); | |
667 | template<> double abs(const AliFemtoLorentzVector<double>& v); | |
668 | template<> float abs(const AliFemtoLorentzVector<float>& v); | |
669 | #else | |
670 | // | |
671 | // Non-member operators | |
672 | // | |
673 | template<class T, class X> | |
674 | AliFemtoLorentzVector<T> | |
675 | operator+ (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2) | |
676 | { | |
677 | return AliFemtoLorentzVector<T>(v1) += v2; | |
678 | } | |
679 | ||
680 | template<class T, class X> | |
681 | AliFemtoLorentzVector<T> | |
682 | operator- (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2) | |
683 | { | |
684 | return AliFemtoLorentzVector<T>(v1) -= v2; | |
685 | } | |
686 | ||
687 | template<class T, class X> | |
688 | T | |
689 | operator* (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2) | |
690 | { | |
691 | return v1.t()*v2.t() - v1.vect()*v2.vect(); | |
692 | } | |
693 | ||
694 | template<class T> | |
695 | AliFemtoLorentzVector<T> | |
696 | operator* (const AliFemtoLorentzVector<T>& v, double c) | |
697 | { | |
698 | return AliFemtoLorentzVector<T>(v) *= c; | |
699 | } | |
700 | ||
701 | template<class T> | |
702 | AliFemtoLorentzVector<T> operator* (double c, const AliFemtoLorentzVector<T>& v) | |
703 | { | |
704 | return AliFemtoLorentzVector<T>(v) *= c; | |
705 | } | |
706 | ||
707 | template<class T, class X> | |
708 | AliFemtoLorentzVector<T> operator/ (const AliFemtoLorentzVector<T>& v, X c) | |
709 | { | |
710 | return AliFemtoLorentzVector<T>(v) /= c; | |
711 | } | |
712 | ||
713 | template<class T> | |
714 | ostream& operator<< (ostream& os, const AliFemtoLorentzVector<T>& v) | |
715 | { | |
716 | return os << v.vect() << "\t\t" << v.t(); | |
717 | } | |
718 | ||
719 | template<class T> | |
720 | istream& operator>>(istream& is, AliFemtoLorentzVector<T>& v) | |
721 | { | |
722 | T x, y, z, t; | |
723 | is >> x >> y >> z >> t; | |
724 | v.setX(x); | |
725 | v.setY(y); | |
726 | v.setZ(z); | |
727 | v.setT(t); | |
728 | return is; | |
729 | } | |
730 | ||
731 | // | |
732 | // Non-member functions | |
733 | // | |
734 | template<class T> | |
735 | T abs(const AliFemtoLorentzVector<T>& v) {return v.m();} | |
736 | ||
737 | #endif /* __CINT__ */ | |
738 | #endif |