New version of RALICE introduced
[u/mrichter/AliRoot.git] / RALICE / Ali4Vector.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
959fbac5 18Revision 1.2 1999/09/29 09:24:28 fca
19Introduction of the Copyright and cvs Log
20
4c039060 21*/
22
959fbac5 23///////////////////////////////////////////////////////////////////////////
24// Class Ali4Vector
25// Handling of Lorentz 4-vectors in various reference frames.
26//
27// This class is meant to serve as a base class for ALICE objects
28// that have Lorentz 4-vector characteristics.
29// Error propagation is performed automatically.
30//
31// All 4-vectors are treated in the contravariant form and the convention
32// for the metric and the 4-vector components is according to the one
33// used in the book "Classical Electrodynamics" by J.D. Jackson.
34//
35// A 4-vector is said to have a scalar part and a 3-vector part,
36// which is indicated by the notation
37//
38// x^i = (x^0,x^1,x^2,x^3)
39//
40// The scalar part = x^0
41// The 3-vector part = (x^1,x^2,x^3)
42//
43// In view of accuracy and the fact that e.g. particle identity (mass)
44// is preserved in many physics processes, the Lorentz invariant
45// (x^i*x_i) is internally saved together with the scalar part.
46//
47// This allows the following two modes of functionality :
48//
49// Scalar mode : The scalar part and the 3-vector part are considered
50// as basic quantities and the invariant with its error
51// is derived from these.
52// Invariant mode : The invariant and the 3-vector part are considered
53// as basic quantities and the scalar with its error
54// is derived from these.
55//
56// The philosophy followed here is the following :
57// ===============================================
58//
59// 1) Invokation of SetVector() sets the scalar and 3-vector parts
60// and the invariant is calculated from these.
61// Automatically the scalar mode is selected and invokation of
62// SetErrors() will calculate the error on the invariant.
63//
64// 2) In case the scalar part is modified via SetScalar(), scalar mode is
65// automatically selected and the Lorentz invariant (x^i*x_i) and its
66// error are updated accordingly.
67// The 3-vector part is NOT modified.
68// This situation arises when one e.g. precisely determines the time
69// or energy (x^0).
70//
71// 3) In case the Lorentz invariant (x^i*x_i) is modified via SetInvariant(),
72// invariant mode is selected automatically and the scalar part and its
73// error are updated accordingly.
74// The 3-vector part is NOT modified.
75// This situation arises when one e.g. precisely determines the mass.
76//
77// 4) In case the vector part is modified via Set3Vector(), then the
78// current mode determines whether the scalar or the invariant is updated.
79// Scalar mode : The Lorentz invariant (x^i*x_i) and its error are updated;
80// the scalar part and its error are NOT modified.
81// This situation arises when one e.g. improves the 3-position
82// vector for a particle with a very precise timing.
83// Invariant mode : The scalar part and its error are updated;
84// the Lorentz invariant (x^i*x_i) and its error are NOT modified.
85// This situation arises when one e.g. improves the 3-momentum
86// vector for a particle with known mass.
87//
88// The dotproduct is defined such that p.Dot(p) yields the Lorentz invariant
89// scalar of the 4-vector p (i.e. m**2 in case p is a 4-momentum).
90//
91// Note :
92// ------
93// Vectors (v), Errors (e) and reference frames (f) are specified via
94// SetVector(Float_t* v,TString f)
95// SetErrors(Float_t* e,TString f)
96// under the following conventions :
97//
98// f="car" ==> 3-vector part of v in Cartesian coordinates (x,y,z)
99// f="sph" ==> 3-vector part of v in Spherical coordinates (r,theta,phi)
100// f="cyl" ==> 3-vector part of v in Cylindrical coordinates (rho,phi,z)
101//
102// All angles are in radians.
103//
104// Example :
105// ---------
106//
107// Ali4Vector a;
108//
109// Float_t v[4]={25,-1,3,7};
110// a.SetVector(v,"car");
111//
112// Float_t vec[4];
113// a.GetVector(vec,"sph");
114//
115// Ali4Vector b;
116// Float_t v2[4]={33,6,-18,2};
117// b.SetVector(v2,"car");
118//
119// Float_t dotpro=a.Dot(b);
120//
121// Float_t x0=16;
122// Ali3Vector x;
123// Float_t vec2[3]={1,2,3};
124// x.SetVector(vec2,"car");
125//
126// Ali4Vector c;
127// c.SetVector(x0,x);
128// c.GetVector(vec,"car");
129// c.Info("cyl");
130// c=a+b;
131// c=a-b;
132// c=a*5;
133//
134//--- Author: Nick van Eijndhoven 01-apr-1999 UU-SAP Utrecht
135//- Modified: NvE 15-oct-1999 UU-SAP Utrecht
136///////////////////////////////////////////////////////////////////////////
137
d88f97cc 138#include "Ali4Vector.h"
139
140ClassImp(Ali4Vector) // Class implementation to enable ROOT I/O
141
142Ali4Vector::Ali4Vector()
143{
959fbac5 144// Creation of a contravariant 4-vector and initialisation of parameters.
145// All values are initialised to 0.
146// Scalar mode is initially selected.
147 fScalar=1;
148 fV2=0;
149 fDv2=0;
d88f97cc 150 fV0=0;
959fbac5 151 fDv0=0;
152 fDresult=0;
d88f97cc 153 Double_t a[3]={0,0,0};
154 fV.SetVector(a,"sph");
155}
156///////////////////////////////////////////////////////////////////////////
157Ali4Vector::~Ali4Vector()
158{
159// Destructor to delete dynamically allocated memory
160}
161///////////////////////////////////////////////////////////////////////////
162void Ali4Vector::SetVector(Double_t v0,Ali3Vector v)
163{
959fbac5 164// Store contravariant vector.
165// The error on the scalar part is initialised to 0.
166// The errors on the vector part are taken from the input Ali3Vector.
167// Scalar mode is automatically selected.
168// The error on scalar result operations is reset to 0.
169 fScalar=1;
d88f97cc 170 fV0=v0;
171 fV=v;
959fbac5 172 fV2=pow(v0,2)-fV.Dot(fV);
173 SetScalarError(0);
d88f97cc 174}
175///////////////////////////////////////////////////////////////////////////
176void Ali4Vector::SetVector(Double_t* v,TString f)
177{
959fbac5 178// Store vector according to reference frame f.
179// All errors are initialised to 0.
180// Scalar mode is automatically selected.
181// The error on scalar result operations is reset to 0.
182 fScalar=1;
d88f97cc 183 Double_t a[3];
184 for (Int_t i=0; i<3; i++)
185 {
186 a[i]=v[i+1];
187 }
959fbac5 188 fV0=v[0];
d88f97cc 189 fV.SetVector(a,f);
959fbac5 190 fV2=pow(fV0,2)-fV.Dot(fV);
191 fDv2=0;
192 fDv0=0;
193 fDresult=0;
d88f97cc 194}
195///////////////////////////////////////////////////////////////////////////
196void Ali4Vector::GetVector(Double_t* v,TString f)
197{
959fbac5 198// Provide 4-vector components according to reference frame f
199// and according to the current mode.
200// Scalar mode : The scalar part is directly returned via v[0].
201// Invariant mode : The scalar part is re-calculated via the value
202// of the Lorentz invariant and then returned via v[0].
203 if (fScalar)
204 {
205 v[0]=fV0;
206 }
207 else
208 {
209 v[0]=sqrt(fV.Dot(fV)+fV2);
210 }
d88f97cc 211 Double_t a[3];
212 fV.GetVector(a,f);
213 for (Int_t i=0; i<3; i++)
214 {
215 v[i+1]=a[i];
216 }
217}
218///////////////////////////////////////////////////////////////////////////
219void Ali4Vector::SetVector(Float_t* v,TString f)
220{
959fbac5 221// Store vector according to reference frame f.
222// All errors are initialised to 0.
223// Scalar mode is automatically selected.
224// The error on scalar result operations is reset to 0.
d88f97cc 225 Double_t vec[4];
226 for (Int_t i=0; i<4; i++)
227 {
228 vec[i]=v[i];
229 }
230 SetVector(vec,f);
231}
232///////////////////////////////////////////////////////////////////////////
233void Ali4Vector::GetVector(Float_t* v,TString f)
234{
959fbac5 235// Provide 4-vector components according to reference frame f
236// and according to the current mode.
237// Scalar mode : The scalar part is directly returned via v[0].
238// Invariant mode : The scalar part is re-calculated via the value
239// of the Lorentz invariant and then returned via v[0].
d88f97cc 240 Double_t vec[4];
241 GetVector(vec,f);
242 for (Int_t i=0; i<4; i++)
243 {
244 v[i]=vec[i];
245 }
246}
247///////////////////////////////////////////////////////////////////////////
248Double_t Ali4Vector::GetScalar()
249{
959fbac5 250// Provide the scalar part.
251// The error on the scalar value is available via GetResultError()
252// after invokation of GetScalar().
253 if (fScalar)
254 {
255 fDresult=fDv0;
256 return fV0;
257 }
258 else
259 {
260 Double_t dot=fV.Dot(fV);
261 Double_t ddot=fV.GetResultError();
262 Double_t v02=dot+fV2;
263 Double_t dv02=sqrt(pow(ddot,2)+pow(fDv2,2));
264 Double_t v0=sqrt(fabs(v02));
265 Double_t dv0=0;
266 if (v0) dv0=dv02/(2.*v0);
267 fDresult=dv0;
268 return v0;
269 }
270}
271///////////////////////////////////////////////////////////////////////////
272Double_t Ali4Vector::GetResultError()
273{
274// Provide the error on the result of an operation yielding a scalar
275// E.g. GetScalar(), GetInvariant() or Dot()
276 return fDresult;
277}
278///////////////////////////////////////////////////////////////////////////
279void Ali4Vector::SetScalar(Double_t v0,Double_t dv0)
280{
281// Modify the scalar part (v0) and its error (dv0).
282// The default value for dv0 is 0.
283// The vector part is not modified.
284// Scalar mode is automatically selected
285// ==> Lorentz invariant and its error are updated.
286// The error on scalar result operations is reset to 0.
287 fScalar=1;
288 fV0=v0;
289 fV2=pow(v0,2)-fV.Dot(fV);
290 SetScalarError(dv0);
291}
292///////////////////////////////////////////////////////////////////////////
293void Ali4Vector::SetScalarError(Double_t dv0)
294{
295// Set the error on the scalar part.
296// If in scalar mode, update error on the invariant accordingly.
297// The error on scalar result operations is reset to 0.
298 fDv0=dv0;
299 if (fScalar)
300 {
301 Double_t norm=fV.GetNorm();
302 Double_t dnorm=fV.GetResultError();
303 fDv2=sqrt(pow(2.*fV0*fDv0,2)+pow(2.*norm*dnorm,2));
304 }
305 fDresult=0;
306}
307///////////////////////////////////////////////////////////////////////////
308void Ali4Vector::Set3Vector(Ali3Vector v)
309{
310// Set the 3-vector part, the errors are taken from the input Ali3Vector
311// Scalar mode : The scalar part and its error are not modified,
312// the Lorentz invariantand its error are re-calculated.
313// Invariant mode : The Lorentz invariant and its error are not modified,
314// the scalar part and its error are re-calculated.
315// The error on scalar result operations is reset to 0.
316 fV=v;
317 if (fScalar)
318 {
319 SetScalar(fV0,fDv0);
320 }
321 else
322 {
323 SetInvariant(fV2,fDv2);
324 }
325}
326///////////////////////////////////////////////////////////////////////////
327void Ali4Vector::Set3Vector(Double_t* v,TString f)
328{
329// Set the 3-vector part according to reference frame f
330// The errors on the vector part are initialised to 0
331// Scalar mode : The scalar part and its error are not modified,
332// the Lorentz invariantand its error are re-calculated.
333// Invariant mode : The Lorentz invariant and its error are not modified,
334// the scalar part and its error are re-calculated.
335// The error on scalar result operations is reset to 0.
336 Double_t a[3];
337 for (Int_t i=0; i<3; i++)
338 {
339 a[i]=v[i];
340 }
341 fV.SetVector(a,f);
342
343 if (fScalar)
344 {
345 SetScalar(fV0,fDv0);
346 }
347 else
348 {
349 SetInvariant(fV2,fDv2);
350 }
351}
352///////////////////////////////////////////////////////////////////////////
353void Ali4Vector::Set3Vector(Float_t* v,TString f)
354{
355// Set the 3-vector part according to reference frame f
356// The errors on the vector part are initialised to 0
357// The Lorentz invariant is not modified
358// The error on scalar result operations is reset to 0.
359 Double_t vec[3];
360 for (Int_t i=0; i<3; i++)
361 {
362 vec[i]=v[i];
363 }
364 Set3Vector(vec,f);
365}
366///////////////////////////////////////////////////////////////////////////
367void Ali4Vector::SetInvariant(Double_t v2,Double_t dv2)
368{
369// Modify the Lorentz invariant (v2) quantity v^i*v_i and its error (dv2).
370// The default value for the error dv2 is 0.
371// The vector part is not modified.
372// Invariant mode is automatically selected
373// ==> the scalar part and its error are updated.
374// The error on scalar result operations is reset to 0.
375//
376 fScalar=0;
377 fV2=v2;
378 fDv2=dv2;
379 fV0=GetScalar();
380 fDv0=GetResultError();
381 fDresult=0;
382}
383///////////////////////////////////////////////////////////////////////////
384void Ali4Vector::SetInvariantError(Double_t dv2)
385{
386// Set the error on the Lorentz invariant.
387// If in invariant mode, update error on the scalar part accordingly.
388// The error on scalar result operations is reset to 0.
389 fDv2=dv2;
390 if (!fScalar)
391 {
392 fDv0=GetResultError();
393 }
394 fDresult=0;
395}
396///////////////////////////////////////////////////////////////////////////
397Double_t Ali4Vector::GetInvariant()
398{
399// Provide the Lorentz invariant v^i*v_i.
400// The error on the Lorentz invariant is available via GetResultError()
401// after invokation of GetInvariant().
402 if (!fScalar)
403 {
404 fDresult=fDv2;
405 return fV2;
406 }
407 else
408 {
409 Double_t inv=Dot(*this);
410 return inv;
411 }
d88f97cc 412}
413///////////////////////////////////////////////////////////////////////////
414Ali3Vector Ali4Vector::Get3Vector()
415{
416// Provide the 3-vector part
417 return fV;
418}
419///////////////////////////////////////////////////////////////////////////
959fbac5 420void Ali4Vector::SetErrors(Double_t* e,TString f)
421{
422// Store errors for vector v^i according to reference frame f
423// If in scalar mode, update error on the invariant accordingly.
424// The error on scalar result operations is reset to 0.
425 Double_t a[3];
426 for (Int_t i=0; i<3; i++)
427 {
428 a[i]=e[i+1];
429 }
430 SetScalarError(e[0]);
431 fV.SetErrors(a,f);
432}
433///////////////////////////////////////////////////////////////////////////
434void Ali4Vector::SetErrors(Float_t* e,TString f)
435{
436// Store errors for vector v^i according to reference frame f
437// If in scalar mode, update error on the invariant accordingly.
438// The error on scalar result operations is reset to 0.
439 Double_t a[4];
440 for (Int_t i=0; i<4; i++)
441 {
442 a[i]=e[i];
443 }
444 SetErrors(a,f);
445}
446///////////////////////////////////////////////////////////////////////////
447void Ali4Vector::GetErrors(Double_t* e,TString f)
448{
449// Provide errors for vector v^i according to reference frame f
450// and according to the current mode.
451// Scalar mode : The error on the scalar part is directly returned via e[0].
452// Invariant mode : The error on the scalar part is re-calculated via the error
453// value on the Lorentz invariant and then returned via e[0].
454 Double_t a[3];
455 fV.GetErrors(a,f);
456
457 e[0]=GetResultError();
458 for (Int_t i=0; i<3; i++)
459 {
460 e[i+1]=a[i];
461 }
462}
463///////////////////////////////////////////////////////////////////////////
464void Ali4Vector::GetErrors(Float_t* e,TString f)
465{
466// Provide errors for vector v^i according to reference frame f
467// and according to the current mode.
468// Scalar mode : The error on the scalar part is directly returned via e[0].
469// Invariant mode : The error on the scalar part is re-calculated via the error
470// value on the Lorentz invariant and then returned via e[0].
471 Double_t a[4];
472 GetErrors(a,f);
473 for (Int_t i=0; i<4; i++)
474 {
475 e[i]=a[i];
476 }
477}
478///////////////////////////////////////////////////////////////////////////
d88f97cc 479void Ali4Vector::Info(TString f)
480{
959fbac5 481// Print contravariant vector components and errors according to
482// reference frame f and according to the current mode.
483// Scalar mode : The scalar part and its error are directly returned.
484// Invariant mode : The scalar part and its error are re-calculated via the
485// value (and error) of the Lorentz invariant.
486
d88f97cc 487 if (f=="car" || f=="sph" || f=="cyl")
488 {
959fbac5 489 Double_t vec[4],err[4];
d88f97cc 490 GetVector(vec,f);
959fbac5 491 GetErrors(err,f);
492 Double_t inv=GetInvariant();
493 Double_t dinv=GetResultError();
d88f97cc 494 cout << " Contravariant vector in " << f << " coordinates : "
495 << vec[0] << " " << vec[1] << " " << vec[2] << " " << vec[3] << endl;
959fbac5 496 cout << " ------------- Errors in " << f << " coordinates : "
497 << err[0] << " " << err[1] << " " << err[2] << " " << err[3] << endl;
498 cout << " --- Lorentz invariant (v^i*v_i) : " << inv << " error : " << dinv << endl;
d88f97cc 499 }
500 else
501 {
502 cout << " *Ali4Vector::Info* Unsupported frame : " << f << endl
503 << " Possible frames are 'car', 'sph' and 'cyl'." << endl;
504 }
505}
506///////////////////////////////////////////////////////////////////////////
507Double_t Ali4Vector::Dot(Ali4Vector& q)
508{
509// Provide the dot product of the current vector with vector q
959fbac5 510 Double_t dotpro=0;
511 Double_t a0=GetScalar();
512 Double_t da0=GetResultError();
513 if ((this) == &q) // Check for special case v.Dot(v)
514 {
515 Double_t norm=fV.GetNorm();
516 Double_t dnorm=fV.GetResultError();
517 dotpro=pow(a0,2)-pow(norm,2);
518 fDresult=sqrt(pow(2.*a0*da0,2)+pow(2.*norm*dnorm,2));
519 }
520 else
521 {
522 Double_t b0=q.GetScalar();
523 Double_t db0=q.GetResultError();
524 Ali3Vector b=q.Get3Vector();
d88f97cc 525
959fbac5 526 Double_t dot=fV.Dot(b);
527 Double_t ddot=fV.GetResultError();
d88f97cc 528
959fbac5 529 dotpro=a0*b0-dot;
530
531 fDresult=sqrt(pow(b0*da0,2)+pow(a0*db0,2)+pow(ddot,2));
d88f97cc 532 }
959fbac5 533
d88f97cc 534 return dotpro;
535}
536///////////////////////////////////////////////////////////////////////////
537Ali4Vector Ali4Vector::operator+(Ali4Vector& q)
538{
959fbac5 539// Add 4-vector q to the current 4-vector
540// Error propagation is performed automatically
541 Double_t a0=GetScalar();
542 Double_t da0=GetResultError();
543 Ali3Vector a=Get3Vector();
544 Double_t b0=q.GetScalar();
545 Double_t db0=q.GetResultError();
546 Ali3Vector b=q.Get3Vector();
d88f97cc 547
959fbac5 548 Double_t c0=a0+b0;
549 Ali3Vector c=a+b;
550 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
d88f97cc 551
552 Ali4Vector v;
959fbac5 553 v.SetVector(c0,c);
554 v.SetScalarError(dc0);
d88f97cc 555 return v;
556}
557///////////////////////////////////////////////////////////////////////////
558Ali4Vector Ali4Vector::operator-(Ali4Vector& q)
559{
959fbac5 560// Subtract 4-vector q from the current 4-vector
561// Error propagation is performed automatically
562 Double_t a0=GetScalar();
563 Double_t da0=GetResultError();
564 Ali3Vector a=Get3Vector();
565 Double_t b0=q.GetScalar();
566 Double_t db0=q.GetResultError();
567 Ali3Vector b=q.Get3Vector();
d88f97cc 568
959fbac5 569 Double_t c0=a0-b0;
570 Ali3Vector c=a-b;
571 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
d88f97cc 572
573 Ali4Vector v;
959fbac5 574 v.SetVector(c0,c);
575 v.SetScalarError(dc0);
d88f97cc 576 return v;
577}
578///////////////////////////////////////////////////////////////////////////
579Ali4Vector Ali4Vector::operator*(Double_t s)
580{
959fbac5 581// Multiply the current 4-vector with a scalar s
582// Error propagation is performed automatically
583 Double_t a0=GetScalar();
584 Double_t da0=GetResultError();
585 Ali3Vector a=Get3Vector();
d88f97cc 586
959fbac5 587 a0*=s;
588 a*=s;
589 da0*=s;
d88f97cc 590
591 Ali4Vector v;
959fbac5 592 v.SetVector(a0,a);
593 v.SetScalarError(da0);
d88f97cc 594
595 return v;
596}
597///////////////////////////////////////////////////////////////////////////
598Ali4Vector Ali4Vector::operator/(Double_t s)
599{
600// Divide the current vector by a scalar s
959fbac5 601// Error propagation is performed automatically
d88f97cc 602
603 if (fabs(s)<1.e-20) // Protect against division by 0
604 {
605 cout << " *Ali4Vector::/* Division by 0 detected. No action taken." << endl;
606 return *this;
607 }
608 else
609 {
959fbac5 610 Double_t a0=GetScalar();
611 Double_t da0=GetResultError();
612 Ali3Vector a=Get3Vector();
d88f97cc 613
959fbac5 614 a0/=s;
615 a/=s;
616 da0/=s;
d88f97cc 617
618 Ali4Vector v;
959fbac5 619 v.SetVector(a0,a);
620 v.SetScalarError(da0);
d88f97cc 621
622 return v;
623 }
624}
625///////////////////////////////////////////////////////////////////////////
626Ali4Vector& Ali4Vector::operator+=(Ali4Vector& q)
627{
959fbac5 628// Add 4-vector q to the current 4-vector
629// Error propagation is performed automatically
630 Double_t a0=GetScalar();
631 Double_t da0=GetResultError();
632 Ali3Vector a=Get3Vector();
633 Double_t b0=q.GetScalar();
634 Double_t db0=q.GetResultError();
635 Ali3Vector b=q.Get3Vector();
d88f97cc 636
959fbac5 637 Double_t c0=a0+b0;
638 Ali3Vector c=a+b;
639 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
d88f97cc 640
959fbac5 641 SetVector(c0,c);
642 SetScalarError(dc0);
d88f97cc 643
644 return *this;
645}
646///////////////////////////////////////////////////////////////////////////
647Ali4Vector& Ali4Vector::operator-=(Ali4Vector& q)
648{
959fbac5 649// Subtract 4-vector q from the current 4-vector
650// Error propagation is performed automatically
651 Double_t a0=GetScalar();
652 Double_t da0=GetResultError();
653 Ali3Vector a=Get3Vector();
654 Double_t b0=q.GetScalar();
655 Double_t db0=q.GetResultError();
656 Ali3Vector b=q.Get3Vector();
d88f97cc 657
959fbac5 658 Double_t c0=a0-b0;
659 Ali3Vector c=a-b;
660 Double_t dc0=sqrt(pow(da0,2)+pow(db0,2));
d88f97cc 661
959fbac5 662 SetVector(c0,c);
663 SetScalarError(dc0);
d88f97cc 664
d88f97cc 665 return *this;
666}
667///////////////////////////////////////////////////////////////////////////
668Ali4Vector& Ali4Vector::operator*=(Double_t s)
669{
959fbac5 670// Multiply the current 4-vector with a scalar s
671// Error propagation is performed automatically
672 Double_t a0=GetScalar();
673 Double_t da0=GetResultError();
674 Ali3Vector a=Get3Vector();
d88f97cc 675
959fbac5 676 a0*=s;
677 a*=s;
678 da0*=s;
d88f97cc 679
959fbac5 680 SetVector(a0,a);
681 SetScalarError(da0);
d88f97cc 682
d88f97cc 683 return *this;
684}
685///////////////////////////////////////////////////////////////////////////
686Ali4Vector& Ali4Vector::operator/=(Double_t s)
687{
688// Divide the current vector by a scalar s
959fbac5 689// Error propagation is performed automatically
d88f97cc 690
691 if (fabs(s)<1.e-20) // Protect against division by 0
692 {
959fbac5 693 cout << " *Ali4Vector::/* Division by 0 detected. No action taken." << endl;
d88f97cc 694 return *this;
695 }
696 else
697 {
959fbac5 698 Double_t a0=GetScalar();
699 Double_t da0=GetResultError();
700 Ali3Vector a=Get3Vector();
d88f97cc 701
959fbac5 702 a0/=s;
703 a/=s;
704 da0/=s;
d88f97cc 705
959fbac5 706 SetVector(a0,a);
707 SetScalarError(da0);
d88f97cc 708
709 return *this;
710 }
711}
712///////////////////////////////////////////////////////////////////////////
959fbac5 713Int_t Ali4Vector::GetScalarFlag()
714{
715// Provide the value of the fScalar flag (for internal use only).
716 return fScalar;
717}
718///////////////////////////////////////////////////////////////////////////