1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // Handling of Lorentz 4-vectors in various reference frames.
22 // This class is meant to serve as a base class for ALICE objects
23 // that have Lorentz 4-vector characteristics.
24 // Error propagation is performed automatically.
26 // All 4-vectors are treated in the contravariant form and the convention
27 // for the metric and the 4-vector components is according to the one
28 // used in the book "Classical Electrodynamics" by J.D. Jackson.
30 // A 4-vector is said to have a scalar part and a 3-vector part,
31 // which is indicated by the notation
33 // x^i = (x^0,x^1,x^2,x^3)
35 // The scalar part = x^0
36 // The 3-vector part = (x^1,x^2,x^3)
38 // In view of accuracy and the fact that e.g. particle identity (mass)
39 // is preserved in many physics processes, the Lorentz invariant
40 // (x^i*x_i) is internally saved together with the scalar part.
42 // This allows the following two modes of functionality :
44 // Scalar mode : The scalar part and the 3-vector part are considered
45 // as basic quantities and the invariant with its error
46 // is derived from these.
47 // Invariant mode : The invariant and the 3-vector part are considered
48 // as basic quantities and the scalar with its error
49 // is derived from these.
51 // The philosophy followed here is the following :
52 // ===============================================
54 // 1) Invokation of SetVector() sets the scalar and 3-vector parts
55 // and the invariant is calculated from these.
56 // Automatically the scalar mode is selected and invokation of
57 // SetErrors() will calculate the error on the invariant.
59 // 2) In case the scalar part is modified via SetScalar(), scalar mode is
60 // automatically selected and the Lorentz invariant (x^i*x_i) and its
61 // error are updated accordingly.
62 // The 3-vector part is NOT modified.
63 // This situation arises when one e.g. precisely determines the time
66 // 3) In case the Lorentz invariant (x^i*x_i) is modified via SetInvariant(),
67 // invariant mode is selected automatically and the scalar part and its
68 // error are updated accordingly.
69 // The 3-vector part is NOT modified.
70 // This situation arises when one e.g. precisely determines the mass.
72 // 4) In case the vector part is modified via Set3Vector(), then the
73 // current mode determines whether the scalar or the invariant is updated.
74 // Scalar mode : The Lorentz invariant (x^i*x_i) and its error are updated;
75 // the scalar part and its error are NOT modified.
76 // This situation arises when one e.g. improves the 3-position
77 // vector for a particle with a very precise timing.
78 // Invariant mode : The scalar part and its error are updated;
79 // the Lorentz invariant (x^i*x_i) and its error are NOT modified.
80 // This situation arises when one e.g. improves the 3-momentum
81 // vector for a particle with known mass.
83 // The dotproduct is defined such that p.Dot(p) yields the Lorentz invariant
84 // scalar of the 4-vector p (i.e. m**2 in case p is a 4-momentum).
88 // Vectors (v), Errors (e), reference frames (f) and angular units (u)
90 // SetVector(Float_t* v,TString f,TString u)
91 // SetErrors(Float_t* e,TString f,TString u)
92 // under the following conventions :
94 // f="car" ==> v in Cartesian coordinates (x,y,z)
95 // f="sph" ==> v in Spherical coordinates (r,theta,phi)
96 // f="cyl" ==> v in Cylindrical coordinates (rho,phi,z)
98 // u="rad" ==> angles in radians
99 // u="deg" ==> angles in degrees
101 // The "f" and "u" facilities only serve as a convenient user interface.
102 // Internally the actual storage of the various components is performed
103 // in a unique way. This allows setting/retrieval of vector components in a
104 // user selected frame/unit convention at any time.
111 // Float_t v[4]={25,-1,3,7};
112 // a.SetVector(v,"car");
115 // a.GetVector(vec,"sph","deg");
118 // Float_t v2[4]={33,6,-18,2};
119 // b.SetVector(v2,"car");
121 // Float_t dotpro=a.Dot(b);
125 // Float_t vec2[3]={1,2,3};
126 // x.SetVector(vec2,"car");
129 // c.SetVector(x0,x);
130 // c.GetVector(vec,"car");
136 //--- Author: Nick van Eijndhoven 01-apr-1999 UU-SAP Utrecht
137 //- Modified: NvE $Date$ UU-SAP Utrecht
138 ///////////////////////////////////////////////////////////////////////////
140 #include "Ali4Vector.h"
141 #include "Riostream.h"
143 ClassImp(Ali4Vector) // Class implementation to enable ROOT I/O
145 Ali4Vector::Ali4Vector()
147 // Creation of a contravariant 4-vector and initialisation of parameters.
148 // All values are initialised to 0.
149 // Scalar mode is initially selected.
153 ///////////////////////////////////////////////////////////////////////////
154 Ali4Vector::~Ali4Vector()
156 // Destructor to delete dynamically allocated memory
158 ///////////////////////////////////////////////////////////////////////////
159 Ali4Vector::Ali4Vector(const Ali4Vector& v)
170 ///////////////////////////////////////////////////////////////////////////
171 void Ali4Vector::Load(Ali4Vector& q)
173 // Load all attributes of the input Ali4Vector into this Ali4Vector object.
174 Int_t temp1=q.GetScalarFlag();
175 Double_t temp2=q.GetResultError();
177 q.GetVector(a,"sph");
179 q.GetErrors(a,"car");
184 ///////////////////////////////////////////////////////////////////////////
185 void Ali4Vector::SetZero()
187 // (Re)set all attributes to zero.
188 // Note : The (de)selection of the scalar mode is not modified.
196 ///////////////////////////////////////////////////////////////////////////
197 void Ali4Vector::SetVector(Double_t v0,Ali3Vector& v)
199 // Store contravariant vector.
200 // The error on the scalar part is initialised to 0.
201 // The errors on the vector part are taken from the input Ali3Vector.
202 // Scalar mode is automatically selected.
203 // The error on scalar result operations is reset to 0.
207 fV2=pow(v0,2)-fV.Dot(fV);
210 ///////////////////////////////////////////////////////////////////////////
211 void Ali4Vector::SetVector(Double_t* v,TString f,TString u)
213 // Store vector according to reference frame f.
215 // The string argument "u" allows to choose between different angular units
216 // in case e.g. a spherical frame is selected.
217 // u = "rad" : angles provided in radians
218 // "deg" : angles provided in degrees
220 // The default is u="rad".
222 // All errors are initialised to 0.
224 // Scalar mode is automatically selected.
225 // The error on scalar result operations is reset to 0.
229 for (Int_t i=0; i<3; i++)
235 fV2=pow(fV0,2)-fV.Dot(fV);
240 ///////////////////////////////////////////////////////////////////////////
241 void Ali4Vector::GetVector(Double_t* v,TString f,TString u)
243 // Provide 4-vector components according to reference frame f
244 // and according to the current mode.
245 // Scalar mode : The scalar part is directly returned via v[0].
246 // Invariant mode : The scalar part is re-calculated via the value
247 // of the Lorentz invariant and then returned via v[0].
249 // The string argument "u" allows to choose between different angular units
250 // in case e.g. a spherical frame is selected.
251 // u = "rad" : angles provided in radians
252 // "deg" : angles provided in degrees
254 // The default is u="rad".
262 v[0]=sqrt(fV.Dot(fV)+fV2);
266 for (Int_t i=0; i<3; i++)
271 ///////////////////////////////////////////////////////////////////////////
272 void Ali4Vector::SetVector(Float_t* v,TString f,TString u)
274 // Store vector according to reference frame f.
276 // The string argument "u" allows to choose between different angular units
277 // in case e.g. a spherical frame is selected.
278 // u = "rad" : angles provided in radians
279 // "deg" : angles provided in degrees
281 // The default is u="rad".
283 // All errors are initialised to 0.
285 // Scalar mode is automatically selected.
286 // The error on scalar result operations is reset to 0.
289 for (Int_t i=0; i<4; i++)
295 ///////////////////////////////////////////////////////////////////////////
296 void Ali4Vector::GetVector(Float_t* v,TString f,TString u)
298 // Provide 4-vector components according to reference frame f
299 // and according to the current mode.
300 // Scalar mode : The scalar part is directly returned via v[0].
301 // Invariant mode : The scalar part is re-calculated via the value
302 // of the Lorentz invariant and then returned via v[0].
304 // The string argument "u" allows to choose between different angular units
305 // in case e.g. a spherical frame is selected.
306 // u = "rad" : angles provided in radians
307 // "deg" : angles provided in degrees
309 // The default is u="rad".
313 for (Int_t i=0; i<4; i++)
318 ///////////////////////////////////////////////////////////////////////////
319 Double_t Ali4Vector::GetScalar()
321 // Provide the scalar part.
322 // The error on the scalar value is available via GetResultError()
323 // after invokation of GetScalar().
331 Double_t dot=fV.Dot(fV);
332 Double_t ddot=fV.GetResultError();
333 Double_t v02=dot+fV2;
334 Double_t dv02=sqrt(pow(ddot,2)+pow(fDv2,2));
335 Double_t v0=sqrt(fabs(v02));
337 if (v0) dv0=dv02/(2.*v0);
342 ///////////////////////////////////////////////////////////////////////////
343 Double_t Ali4Vector::GetResultError() const
345 // Provide the error on the result of an operation yielding a scalar
346 // E.g. GetScalar(), GetInvariant() or Dot()
349 ///////////////////////////////////////////////////////////////////////////
350 void Ali4Vector::SetScalar(Double_t v0,Double_t dv0)
352 // Modify the scalar part (v0) and its error (dv0).
353 // The default value for dv0 is 0.
354 // The vector part is not modified.
355 // Scalar mode is automatically selected
356 // ==> Lorentz invariant and its error are updated.
357 // The error on scalar result operations is reset to 0.
360 fV2=pow(v0,2)-fV.Dot(fV);
363 ///////////////////////////////////////////////////////////////////////////
364 void Ali4Vector::SetScalarError(Double_t dv0)
366 // Set the error on the scalar part.
367 // If in scalar mode, update error on the invariant accordingly.
368 // The error on scalar result operations is reset to 0.
372 Double_t norm=fV.GetNorm();
373 Double_t dnorm=fV.GetResultError();
374 fDv2=sqrt(pow(2.*fV0*fDv0,2)+pow(2.*norm*dnorm,2));
378 ///////////////////////////////////////////////////////////////////////////
379 void Ali4Vector::Set3Vector(Ali3Vector& v)
381 // Set the 3-vector part, the errors are taken from the input Ali3Vector
382 // Scalar mode : The scalar part and its error are not modified,
383 // the Lorentz invariantand its error are re-calculated.
384 // Invariant mode : The Lorentz invariant and its error are not modified,
385 // the scalar part and its error are re-calculated.
386 // The error on scalar result operations is reset to 0.
394 SetInvariant(fV2,fDv2);
397 ///////////////////////////////////////////////////////////////////////////
398 void Ali4Vector::Set3Vector(Double_t* v,TString f,TString u)
400 // Set the 3-vector part according to reference frame f
402 // The string argument "u" allows to choose between different angular units
403 // in case e.g. a spherical frame is selected.
404 // u = "rad" : angles provided in radians
405 // "deg" : angles provided in degrees
407 // The default is u="rad".
409 // The errors on the vector part are initialised to 0
411 // Scalar mode : The scalar part and its error are not modified,
412 // the Lorentz invariantand its error are re-calculated.
413 // Invariant mode : The Lorentz invariant and its error are not modified,
414 // the scalar part and its error are re-calculated.
415 // The error on scalar result operations is reset to 0.
418 for (Int_t i=0; i<3; i++)
430 SetInvariant(fV2,fDv2);
433 ///////////////////////////////////////////////////////////////////////////
434 void Ali4Vector::Set3Vector(Float_t* v,TString f,TString u)
436 // Set the 3-vector part according to reference frame f
438 // The string argument "u" allows to choose between different angular units
439 // in case e.g. a spherical frame is selected.
440 // u = "rad" : angles provided in radians
441 // "deg" : angles provided in degrees
443 // The default is u="rad".
445 // The errors on the vector part are initialised to 0
446 // The Lorentz invariant is not modified
447 // The error on scalar result operations is reset to 0.
450 for (Int_t i=0; i<3; i++)
456 ///////////////////////////////////////////////////////////////////////////
457 void Ali4Vector::SetInvariant(Double_t v2,Double_t dv2)
459 // Modify the Lorentz invariant (v2) quantity v^i*v_i and its error (dv2).
460 // The default value for the error dv2 is 0.
461 // The vector part is not modified.
462 // Invariant mode is automatically selected
463 // ==> the scalar part and its error are updated.
464 // The error on scalar result operations is reset to 0.
470 fDv0=GetResultError();
473 ///////////////////////////////////////////////////////////////////////////
474 void Ali4Vector::SetInvariantError(Double_t dv2)
476 // Set the error on the Lorentz invariant.
477 // If in invariant mode, update error on the scalar part accordingly.
478 // The error on scalar result operations is reset to 0.
482 fDv0=GetResultError();
486 ///////////////////////////////////////////////////////////////////////////
487 Double_t Ali4Vector::GetInvariant()
489 // Provide the Lorentz invariant v^i*v_i.
490 // The error on the Lorentz invariant is available via GetResultError()
491 // after invokation of GetInvariant().
499 Double_t inv=Dot(*this);
503 ///////////////////////////////////////////////////////////////////////////
504 Ali3Vector Ali4Vector::Get3Vector() const
506 // Provide the 3-vector part
509 ///////////////////////////////////////////////////////////////////////////
510 void Ali4Vector::SetErrors(Double_t* e,TString f,TString u)
512 // Store errors for vector v^i according to reference frame f
514 // The string argument "u" allows to choose between different angular units
515 // in case e.g. a spherical frame is selected.
516 // u = "rad" : angles provided in radians
517 // "deg" : angles provided in degrees
519 // The default is u="rad".
521 // If in scalar mode, update error on the invariant accordingly.
522 // The error on scalar result operations is reset to 0.
525 for (Int_t i=0; i<3; i++)
529 SetScalarError(e[0]);
532 ///////////////////////////////////////////////////////////////////////////
533 void Ali4Vector::SetErrors(Float_t* e,TString f,TString u)
535 // Store errors for vector v^i according to reference frame f
537 // The string argument "u" allows to choose between different angular units
538 // in case e.g. a spherical frame is selected.
539 // u = "rad" : angles provided in radians
540 // "deg" : angles provided in degrees
542 // The default is u="rad".
544 // If in scalar mode, update error on the invariant accordingly.
545 // The error on scalar result operations is reset to 0.
548 for (Int_t i=0; i<4; i++)
554 ///////////////////////////////////////////////////////////////////////////
555 void Ali4Vector::GetErrors(Double_t* e,TString f,TString u)
557 // Provide errors for vector v^i according to reference frame f
558 // and according to the current mode.
559 // Scalar mode : The error on the scalar part is directly returned via e[0].
560 // Invariant mode : The error on the scalar part is re-calculated via the error
561 // value on the Lorentz invariant and then returned via e[0].
563 // The string argument "u" allows to choose between different angular units
564 // in case e.g. a spherical frame is selected.
565 // u = "rad" : angles provided in radians
566 // "deg" : angles provided in degrees
568 // The default is u="rad".
573 // Dummy invokation of GetScalar to obtain automatic proper error determination
576 e[0]=GetResultError();
578 for (Int_t i=0; i<3; i++)
583 ///////////////////////////////////////////////////////////////////////////
584 void Ali4Vector::GetErrors(Float_t* e,TString f,TString u)
586 // Provide errors for vector v^i according to reference frame f
587 // and according to the current mode.
588 // Scalar mode : The error on the scalar part is directly returned via e[0].
589 // Invariant mode : The error on the scalar part is re-calculated via the error
590 // value on the Lorentz invariant and then returned via e[0].
592 // The string argument "u" allows to choose between different angular units
593 // in case e.g. a spherical frame is selected.
594 // u = "rad" : angles provided in radians
595 // "deg" : angles provided in degrees
597 // The default is u="rad".
601 for (Int_t i=0; i<4; i++)
606 ///////////////////////////////////////////////////////////////////////////
607 void Ali4Vector::Data(TString f,TString u)
609 // Print contravariant vector components and errors according to
610 // reference frame f and according to the current mode.
611 // Scalar mode : The scalar part and its error are directly returned.
612 // Invariant mode : The scalar part and its error are re-calculated via the
613 // value (and error) of the Lorentz invariant.
615 // The string argument "u" allows to choose between different angular units
616 // in case e.g. a spherical frame is selected.
617 // u = "rad" : angles provided in radians
618 // "deg" : angles provided in degrees
620 // The defaults are f="car" and u="rad".
622 if (f=="car" || f=="sph" || f=="cyl")
624 Double_t vec[4],err[4];
627 Double_t inv=GetInvariant();
628 Double_t dinv=GetResultError();
629 cout << " Contravariant vector in " << f.Data() << " (" << u.Data() << ") coordinates : "
630 << vec[0] << " " << vec[1] << " " << vec[2] << " " << vec[3] << endl;
631 cout << " ------------- Errors in " << f.Data() << " (" << u.Data() << ") coordinates : "
632 << err[0] << " " << err[1] << " " << err[2] << " " << err[3] << endl;
633 cout << " --- Lorentz invariant (v^i*v_i) : " << inv << " error : " << dinv << endl;
637 cout << " *Ali4Vector::Data* Unsupported frame : " << f.Data() << endl
638 << " Possible frames are 'car', 'sph' and 'cyl'." << endl;
641 ///////////////////////////////////////////////////////////////////////////
642 Double_t Ali4Vector::Dot(Ali4Vector& q)
644 // Provide the dot product of the current vector with vector q
646 Double_t a0=GetScalar();
647 Double_t da0=GetResultError();
648 if ((this) == &q) // Check for special case v.Dot(v)
650 Double_t norm=fV.GetNorm();
651 Double_t dnorm=fV.GetResultError();
652 dotpro=pow(a0,2)-pow(norm,2);
653 fDresult=sqrt(pow(2.*a0*da0,2)+pow(2.*norm*dnorm,2));
657 Double_t b0=q.GetScalar();
658 Double_t db0=q.GetResultError();
659 Ali3Vector b=q.Get3Vector();
661 Double_t dot=fV.Dot(b);
662 Double_t ddot=fV.GetResultError();
666 fDresult=sqrt(pow(b0*da0,2)+pow(a0*db0,2)+pow(ddot,2));
671 ///////////////////////////////////////////////////////////////////////////
672 Ali4Vector Ali4Vector::operator+(Ali4Vector& q)
674 // Add 4-vector q to the current 4-vector
675 // Error propagation is performed automatically
676 Double_t a0=GetScalar();
677 Double_t da0=GetResultError();
678 Ali3Vector a=Get3Vector();
679 Double_t b0=q.GetScalar();
680 Double_t db0=q.GetResultError();
681 Ali3Vector b=q.Get3Vector();
685 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
689 v.SetScalarError(dc0);
692 ///////////////////////////////////////////////////////////////////////////
693 Ali4Vector Ali4Vector::operator-(Ali4Vector& q)
695 // Subtract 4-vector q from the current 4-vector
696 // Error propagation is performed automatically
697 Double_t a0=GetScalar();
698 Double_t da0=GetResultError();
699 Ali3Vector a=Get3Vector();
700 Double_t b0=q.GetScalar();
701 Double_t db0=q.GetResultError();
702 Ali3Vector b=q.Get3Vector();
706 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
710 v.SetScalarError(dc0);
713 ///////////////////////////////////////////////////////////////////////////
714 Ali4Vector Ali4Vector::operator*(Double_t s)
716 // Multiply the current 4-vector with a scalar s
717 // Error propagation is performed automatically
718 Double_t a0=GetScalar();
719 Double_t da0=GetResultError();
720 Ali3Vector a=Get3Vector();
728 v.SetScalarError(da0);
732 ///////////////////////////////////////////////////////////////////////////
733 Ali4Vector Ali4Vector::operator/(Double_t s)
735 // Divide the current vector by a scalar s
736 // Error propagation is performed automatically
738 if (fabs(s)<1.e-20) // Protect against division by 0
740 cout << " *Ali4Vector::/* Division by 0 detected. No action taken." << endl;
745 Double_t a0=GetScalar();
746 Double_t da0=GetResultError();
747 Ali3Vector a=Get3Vector();
755 v.SetScalarError(da0);
760 ///////////////////////////////////////////////////////////////////////////
761 Ali4Vector& Ali4Vector::operator+=(Ali4Vector& q)
763 // Add 4-vector q to the current 4-vector
764 // Error propagation is performed automatically
765 Double_t a0=GetScalar();
766 Double_t da0=GetResultError();
767 Ali3Vector a=Get3Vector();
768 Double_t b0=q.GetScalar();
769 Double_t db0=q.GetResultError();
770 Ali3Vector b=q.Get3Vector();
774 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
781 ///////////////////////////////////////////////////////////////////////////
782 Ali4Vector& Ali4Vector::operator-=(Ali4Vector& q)
784 // Subtract 4-vector q from the current 4-vector
785 // Error propagation is performed automatically
786 Double_t a0=GetScalar();
787 Double_t da0=GetResultError();
788 Ali3Vector a=Get3Vector();
789 Double_t b0=q.GetScalar();
790 Double_t db0=q.GetResultError();
791 Ali3Vector b=q.Get3Vector();
795 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
802 ///////////////////////////////////////////////////////////////////////////
803 Ali4Vector& Ali4Vector::operator*=(Double_t s)
805 // Multiply the current 4-vector with a scalar s
806 // Error propagation is performed automatically
807 Double_t a0=GetScalar();
808 Double_t da0=GetResultError();
809 Ali3Vector a=Get3Vector();
820 ///////////////////////////////////////////////////////////////////////////
821 Ali4Vector& Ali4Vector::operator/=(Double_t s)
823 // Divide the current vector by a scalar s
824 // Error propagation is performed automatically
826 if (fabs(s)<1.e-20) // Protect against division by 0
828 cout << " *Ali4Vector::/* Division by 0 detected. No action taken." << endl;
833 Double_t a0=GetScalar();
834 Double_t da0=GetResultError();
835 Ali3Vector a=Get3Vector();
847 ///////////////////////////////////////////////////////////////////////////
848 Int_t Ali4Vector::GetScalarFlag() const
850 // Provide the value of the fScalar flag (for internal use only).
853 ///////////////////////////////////////////////////////////////////////////
854 Ali3Vector Ali4Vector::GetVecTrans() const
856 // Provide the transverse vector part w.r.t. z-axis.
857 // Error propagation is performed automatically
859 return fV.GetVecTrans();
861 ///////////////////////////////////////////////////////////////////////////
862 Ali3Vector Ali4Vector::GetVecLong() const
864 // Provide the longitudinal vector part w.r.t. z-axis.
865 // Error propagation is performed automatically
867 return fV.GetVecLong();
869 ///////////////////////////////////////////////////////////////////////////
870 Double_t Ali4Vector::GetScaTrans()
872 // Provide the "transverse value" of the scalar part w.r.t. z-axis.
873 // This provides a basis for e.g. E_trans calculation.
874 // Note : the returned value is always positive or zero.
875 // The error on the value is available via GetResultError()
876 // after invokation of GetScaTrans().
879 fV.GetVector(a,"sph");
880 fV.GetErrors(ea,"sph");
882 Double_t s=GetScalar();
883 Double_t ds=GetResultError();
887 dst2=pow((sin(a[1])*ds),2)+pow((s*cos(a[1])*ea[1]),2);
892 ///////////////////////////////////////////////////////////////////////////
893 Double_t Ali4Vector::GetScaLong()
895 // Provide the "longitudinal value" of the scalar part w.r.t. z-axis.
896 // This provides a basis for e.g. E_long calculation.
897 // Note : the returned value can also be negative.
898 // The error on the value is available via GetResultError()
899 // after invokation of GetScaLong().
902 fV.GetVector(a,"sph");
903 fV.GetErrors(ea,"sph");
905 Double_t s=GetScalar();
906 Double_t ds=GetResultError();
910 dsl2=pow((cos(a[1])*ds),2)+pow((s*sin(a[1])*ea[1]),2);
915 ///////////////////////////////////////////////////////////////////////////
916 Double_t Ali4Vector::GetPseudoRapidity()
918 // Provide the pseudorapidity value of the vector part w.r.t. z-axis.
919 // The error on the value is available via GetResultError()
920 // after invokation of GetPseudoRapidity().
921 Double_t eta=fV.GetPseudoRapidity();
922 fDresult=fV.GetResultError();
925 ///////////////////////////////////////////////////////////////////////////
926 Ali3Vector Ali4Vector::GetBetaVector() const
928 // Provide the beta 3-vector corresponding to this 4-vector.
930 if (fabs(fV0)>0.) beta=fV/fV0;
933 Double_t vecv[3],errv[3],errb[3];
935 fV.GetVector(vecv,"car");
936 fV.GetErrors(errv,"car");
937 for (Int_t i=0; i<3; i++)
939 sqerr=pow((errv[i]/fV0),2)+pow((vecv[i]*fDv0/(fV0*fV0)),2);
942 beta.SetErrors(errb,"car");
946 ///////////////////////////////////////////////////////////////////////////
947 Double_t Ali4Vector::GetBeta()
949 // Provide the beta value (i.e. v/c) corresponding to this 4-vector.
950 Ali3Vector beta=GetBetaVector();
951 Double_t val=beta.GetNorm();
952 fDresult=beta.GetResultError();
955 ///////////////////////////////////////////////////////////////////////////
956 Double_t Ali4Vector::GetGamma()
958 // Provide the Lorentz gamma factor corresponding to this 4-vector.
959 // In case the gamma factor is infinite a value of -1 is returned.
962 Double_t inv=sqrt(fabs(fV2));
965 Double_t dinv=fDv2/(2.*inv);
967 Double_t sqerr=pow((fDv0/inv),2)+pow((fV0*dinv/fV2),2);
968 fDresult=sqrt(sqerr);
972 ///////////////////////////////////////////////////////////////////////////
973 Double_t Ali4Vector::GetX(Int_t i,TString f,TString u)
975 // Provide i-th vector component according to reference frame f.
977 // The string argument "u" allows to choose between different angular units
978 // in case e.g. a spherical frame is selected.
979 // u = "rad" : angles provided in radians
980 // "deg" : angles provided in degrees
982 // The default is u="rad".
984 // The vector components are addressed via the generic x0,x1,x2,x3 notation.
985 // So, i=0 denotes the scalar component and i=1 denotes the first 3-vector component.
986 // The error on the selected component can be obtained via the
987 // usual GetResultError() facility.
991 if (i<0 || i>3) return 0;
1002 fDresult=fV.GetResultError();
1007 ///////////////////////////////////////////////////////////////////////////
1008 Double_t Ali4Vector::GetOpeningAngle(Ali4Vector& q,TString u)
1010 // Provide the opening angle between 3-vector parts with 4-vector q.
1011 // The string argument "u" allows to choose between different output units.
1012 // u = "rad" : opening angle provided in radians
1013 // "deg" : opening angle provided in degrees
1015 // The default is u="rad".
1018 Ali3Vector v2=q.Get3Vector();
1020 Double_t ang=v1.GetOpeningAngle(v2,u);
1021 fDresult=v1.GetResultError();
1025 ///////////////////////////////////////////////////////////////////////////
1026 Double_t Ali4Vector::GetOpeningAngle(Ali3Vector& q,TString u)
1028 // Provide the opening angle between the 3-vector part and 3-vector q.
1029 // The string argument "u" allows to choose between different output units.
1030 // u = "rad" : opening angle provided in radians
1031 // "deg" : opening angle provided in degrees
1033 // The default is u="rad".
1037 Double_t ang=v1.GetOpeningAngle(q,u);
1038 fDresult=v1.GetResultError();
1042 ///////////////////////////////////////////////////////////////////////////