]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FEMTOSCOPY/AliFemto/AliFemtoLorentzVector.h
Improving rule conformance
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemto / AliFemtoLorentzVector.h
CommitLineData
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"
71template<class T> class AliFemtoLorentzVector {
72public:
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
a19edcc9 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);
67427ff7 121
122#ifndef ST_NO_MEMBER_TEMPLATES
a19edcc9 123 template <class X> void SetVect(const AliFemtoThreeVector<X>&);
67427ff7 124#else
a19edcc9 125 void SetVect(const AliFemtoThreeVector<float>&);
126 void SetVect(const AliFemtoThreeVector<double>&);
67427ff7 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
174protected:
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//
185template<class T>
186AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T x, T y, T z, T t)
187 : mThreeVector(x, y, z), mX4(t) { /* nop */ }
188
189template<class T>
190AliFemtoLorentzVector<T>::~AliFemtoLorentzVector() { /* nopt */ }
191
192template<class T>
193const AliFemtoThreeVector<T>& AliFemtoLorentzVector<T>::vect() const
194{
195 return mThreeVector;
196}
197
198template<class T>
199T AliFemtoLorentzVector<T>::m2() const
200{
201 return (mX4*mX4 - mThreeVector*mThreeVector);
202}
203
204template<class T>
205T AliFemtoLorentzVector<T>::plus() const { return (e() + pz()); }
206
207template<class T>
208T AliFemtoLorentzVector<T>::minus() const { return (e() - pz()); }
209
210template<class T>
211T 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
220template<class T>
221T AliFemtoLorentzVector<T>::mt2() const
222{
223 return this->perp2() + m2();
224}
225
226template<class T>
227T 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
239template<class T>
a19edcc9 240void AliFemtoLorentzVector<T>::SetPx(T x) {mThreeVector.SetX(x);}
67427ff7 241
242template<class T>
a19edcc9 243void AliFemtoLorentzVector<T>::SetPy(T y) {mThreeVector.SetY(y);}
67427ff7 244
245template<class T>
a19edcc9 246void AliFemtoLorentzVector<T>::SetPz(T z) {mThreeVector.SetZ(z);}
67427ff7 247
248template<class T>
a19edcc9 249void AliFemtoLorentzVector<T>::SetX(T x) {mThreeVector.SetX(x);}
67427ff7 250
251template<class T>
a19edcc9 252void AliFemtoLorentzVector<T>::SetY(T y) {mThreeVector.SetY(y);}
67427ff7 253
254template<class T>
a19edcc9 255void AliFemtoLorentzVector<T>::SetZ(T z) {mThreeVector.SetZ(z);}
67427ff7 256
257template<class T>
a19edcc9 258void AliFemtoLorentzVector<T>::SetT(T t) {mX4 = t;}
67427ff7 259
260template<class T>
a19edcc9 261void AliFemtoLorentzVector<T>::SetE(T e) {mX4 = e;}
67427ff7 262
263template<class T>
264T AliFemtoLorentzVector<T>::x() const {return mThreeVector.x();}
265
266template<class T>
267T AliFemtoLorentzVector<T>::y() const {return mThreeVector.y();}
268
269template<class T>
270T AliFemtoLorentzVector<T>::z() const {return mThreeVector.z();}
271
272template<class T>
273T AliFemtoLorentzVector<T>::px() const {return mThreeVector.x();}
274
275template<class T>
276T AliFemtoLorentzVector<T>::py() const {return mThreeVector.y();}
277
278template<class T>
279T AliFemtoLorentzVector<T>::pz() const {return mThreeVector.z();}
280
281template<class T>
282T AliFemtoLorentzVector<T>::e() const {return mX4;}
283
284template<class T>
285T AliFemtoLorentzVector<T>::t() const {return mX4;}
286
287template<class T>
288T AliFemtoLorentzVector<T>::perp() const {return mThreeVector.perp();}
289
290template<class T>
291T AliFemtoLorentzVector<T>::perp2() const {return mThreeVector.perp2();}
292
293template<class T>
294T AliFemtoLorentzVector<T>::pseudoRapidity() const {return mThreeVector.pseudoRapidity();}
295
296template<class T>
297T AliFemtoLorentzVector<T>::phi() const {return mThreeVector.phi();}
298
299template<class T>
300T AliFemtoLorentzVector<T>::theta() const {return mThreeVector.theta();}
301
302template<class T>
303T AliFemtoLorentzVector<T>::cosTheta() const {return mThreeVector.cosTheta();}
304
305template<class T>
306T 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
322template<class T>
323T& 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
339template<class T>
340T 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
356template<class T>
357T& 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
373template<class T>
374T AliFemtoLorentzVector<T>::rapidity() const
375{
376 return 0.5*::log((mX4+mThreeVector.z())/(mX4-mThreeVector.z())+1e-20);
377}
378
379template<class T>
380AliFemtoLorentzVector<T> AliFemtoLorentzVector<T>::operator- ()
381{
382 return AliFemtoLorentzVector<T>(-mX4,-mThreeVector);
383}
384
385template<class T>
386AliFemtoLorentzVector<T> AliFemtoLorentzVector<T>::operator+ ()
387{
388 return *this;
389}
390
391template<class T>
392AliFemtoLorentzVector<T>& AliFemtoLorentzVector<T>::operator*= (double c)
393{
394 mThreeVector *= c;
395 mX4 *= c;
396 return *this;
397}
398
399template<class T>
400AliFemtoLorentzVector<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
410template<class T>
411template<class X>
412AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<X> &vec, T t)
413 : mThreeVector(vec), mX4(t) { /* nop */ }
414
415template<class T>
416template<class X>
417AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<X> &vec)
418 : mThreeVector(vec), mX4(t) { /* nop */ }
419
420template<class T>
421template<class X>
422AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<X> &vec)
423 : mThreeVector(vec.vect()), mX4(vec.t()) { /* nop */ }
424
425template<class T>
426template<class X>
427AliFemtoLorentzVector<T>
428AliFemtoLorentzVector<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
438template<class T>
439template<class X>
a19edcc9 440void AliFemtoLorentzVector<T>::SetVect(const AliFemtoThreeVector<X>& v)
67427ff7 441{
442 mThreeVector = v;
443}
444
445template<class T>
446template<class X>
447AliFemtoLorentzVector<T>&
448AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<X>& vec)
449{
450 mThreeVector = vec.vect();
451 mX4 = vec.t();
452 return *this;
453}
454
455template<class T>
456template<class X>
457bool
458AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<X>& v) const
459{
460 return (mThreeVector == v.vect()) && (mX4 == v.t());
461}
462
463template<class T>
464template<class X>
465bool
466AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<X>& v) const
467{
468 return !(*this == v);
469}
470
471template<class T>
472template<class X>
473AliFemtoLorentzVector<T>&
474AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<X>& v)
475{
476 mThreeVector += v.vect();
477 mX4 += v.t();
478 return *this;
479}
480
481template<class T>
482template<class X>
483AliFemtoLorentzVector<T>&
484AliFemtoLorentzVector<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
494template<class T>
495AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<float> &vec, T t)
496 : mThreeVector(vec), mX4(t) { /* nop */ }
497
498template<class T>
499AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoThreeVector<double> &vec, T t)
500 : mThreeVector(vec), mX4(t) { /* nop */ }
501
502template<class T>
503AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<float> &vec)
504 : mThreeVector(vec), mX4(t) { /* nop */ }
505
506template<class T>
507AliFemtoLorentzVector<T>::AliFemtoLorentzVector(T t, const AliFemtoThreeVector<double> &vec)
508 : mThreeVector(vec), mX4(t) { /* nop */ }
509
510template<class T>
511AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<float> &vec)
512 : mThreeVector(vec.vect()), mX4(vec.t()) { /* nop */ }
513
514template<class T>
515AliFemtoLorentzVector<T>::AliFemtoLorentzVector(const AliFemtoLorentzVector<double> &vec)
516 : mThreeVector(vec.vect()), mX4(vec.t()) { /* nop */ }
517
518template<class T>
519AliFemtoLorentzVector<T>
520AliFemtoLorentzVector<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
530template<class T>
531AliFemtoLorentzVector<T>
532AliFemtoLorentzVector<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
542template<class T>
a19edcc9 543void AliFemtoLorentzVector<T>::SetVect(const AliFemtoThreeVector<float>& v)
67427ff7 544{
545 mThreeVector = v;
546}
547
548template<class T>
a19edcc9 549void AliFemtoLorentzVector<T>::SetVect(const AliFemtoThreeVector<double>& v)
67427ff7 550{
551 mThreeVector = v;
552}
553
554template<class T>
555AliFemtoLorentzVector<T>&
556AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<float>& vec)
557{
558 mThreeVector = vec.vect();
559 mX4 = vec.t();
560 return *this;
561}
562
563template<class T>
564AliFemtoLorentzVector<T>&
565AliFemtoLorentzVector<T>::operator=(const AliFemtoLorentzVector<double>& vec)
566{
567 mThreeVector = vec.vect();
568 mX4 = vec.t();
569 return *this;
570}
571
572template<class T>
573bool
574AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<float>& v) const
575{
576 return (this->vect() == v.vect()) && (mX4 == v.t());
577}
578
579template<class T>
580bool
581AliFemtoLorentzVector<T>::operator== (const AliFemtoLorentzVector<double>& v) const
582{
583 return (mThreeVector == v.vect()) && (mX4 == v.t());
584}
585
586template<class T>
587bool
588AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<float>& v) const
589{
590 return !(*this == v);
591}
592
593template<class T>
594bool
595AliFemtoLorentzVector<T>::operator!= (const AliFemtoLorentzVector<double>& v) const
596{
597 return !(*this == v);
598}
599
600template<class T>
601AliFemtoLorentzVector<T>&
602AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<float>& v)
603{
604 mThreeVector += v.vect();
605 mX4 += v.t();
606 return *this;
607}
608
609template<class T>
610AliFemtoLorentzVector<T>&
611AliFemtoLorentzVector<T>::operator+= (const AliFemtoLorentzVector<double>& v)
612{
613 mThreeVector += v.vect();
614 mX4 += v.t();
615 return *this;
616}
617
618template<class T>
619AliFemtoLorentzVector<T>&
620AliFemtoLorentzVector<T>::operator-= (const AliFemtoLorentzVector<float>& v)
621{
622 mThreeVector -= v.vect();
623 mX4 -= v.t();
624 return *this;
625}
626
627template<class T>
628AliFemtoLorentzVector<T>&
629AliFemtoLorentzVector<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__
639template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2);
640template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2);
641template<> AliFemtoLorentzVector<double> operator+ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2);
642template<> AliFemtoLorentzVector<float> operator+ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2);
643template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2);
644template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2);
645template<> AliFemtoLorentzVector<double> operator- (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2);
646template<> AliFemtoLorentzVector<float> operator- (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2);
647template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2);
648template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2);
649template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2);
650template<> AliFemtoLorentzVector<float> operator* (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2);
651template<> AliFemtoLorentzVector<double> operator* (const double v1, const AliFemtoLorentzVector<double>& v2);
652template<> AliFemtoLorentzVector<double> operator* (const double v1, const AliFemtoLorentzVector<float>& v2);
653template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<double>& v1, const double v2);
654template<> AliFemtoLorentzVector<double> operator* (const AliFemtoLorentzVector<float>& v1, const double v2);
655template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<double>& v2);
656template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const AliFemtoLorentzVector<float>& v2);
657template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<double>& v2);
658template<> AliFemtoLorentzVector<float> operator/ (const AliFemtoLorentzVector<float>& v1, const AliFemtoLorentzVector<float>& v2);
659template<> AliFemtoLorentzVector<double> operator/ (const double v1, const AliFemtoLorentzVector<double>& v2);
660template<> AliFemtoLorentzVector<double> operator/ (const double v1, const AliFemtoLorentzVector<float>& v2);
661template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<double>& v1, const double v2);
662template<> AliFemtoLorentzVector<double> operator/ (const AliFemtoLorentzVector<float>& v1, const double v2);
663template<> istream& operator>> (istream& is, const AliFemtoLorentzVector<double>& v);
664template<> ostream& operator<< (ostream& os, const AliFemtoLorentzVector<double>& v);
665template<> istream& operator>> (istream& is, const AliFemtoLorentzVector<float>& v);
666template<> ostream& operator<< (ostream& os, const AliFemtoLorentzVector<float>& v);
667template<> double abs(const AliFemtoLorentzVector<double>& v);
668template<> float abs(const AliFemtoLorentzVector<float>& v);
669#else
670//
671// Non-member operators
672//
673template<class T, class X>
674AliFemtoLorentzVector<T>
675operator+ (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2)
676{
677 return AliFemtoLorentzVector<T>(v1) += v2;
678}
679
680template<class T, class X>
681AliFemtoLorentzVector<T>
682operator- (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2)
683{
684 return AliFemtoLorentzVector<T>(v1) -= v2;
685}
686
687template<class T, class X>
688T
689operator* (const AliFemtoLorentzVector<T>& v1, const AliFemtoLorentzVector<X>& v2)
690{
691 return v1.t()*v2.t() - v1.vect()*v2.vect();
692}
693
694template<class T>
695AliFemtoLorentzVector<T>
696operator* (const AliFemtoLorentzVector<T>& v, double c)
697{
698 return AliFemtoLorentzVector<T>(v) *= c;
699}
700
701template<class T>
702AliFemtoLorentzVector<T> operator* (double c, const AliFemtoLorentzVector<T>& v)
703{
704 return AliFemtoLorentzVector<T>(v) *= c;
705}
706
707template<class T, class X>
708AliFemtoLorentzVector<T> operator/ (const AliFemtoLorentzVector<T>& v, X c)
709{
710 return AliFemtoLorentzVector<T>(v) /= c;
711}
712
713template<class T>
714ostream& operator<< (ostream& os, const AliFemtoLorentzVector<T>& v)
715{
716 return os << v.vect() << "\t\t" << v.t();
717}
718
719template<class T>
720istream& operator>>(istream& is, AliFemtoLorentzVector<T>& v)
721{
722 T x, y, z, t;
723 is >> x >> y >> z >> t;
a19edcc9 724 v.SetX(x);
725 v.SetY(y);
726 v.SetZ(z);
727 v.SetT(t);
67427ff7 728 return is;
729}
730
731//
732// Non-member functions
733//
734template<class T>
735T abs(const AliFemtoLorentzVector<T>& v) {return v.m();}
736
737#endif /* __CINT__ */
738#endif