]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliTrack.cxx
22-jun-2006 NvE Linear track storage facility introduced in AliSignal to enable
[u/mrichter/AliRoot.git] / RALICE / AliTrack.cxx
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 // $Id$
17
18 ///////////////////////////////////////////////////////////////////////////
19 // Class AliTrack
20 // Handling of the attributes of a reconstructed particle track.
21 //
22 // Coding example :
23 // ----------------
24 //
25 // Float_t a[4]={195.,1.2,-0.04,8.5};
26 // Ali4Vector pmu;
27 // pmu.SetVector(a,"car");
28 // AliTrack t1;
29 // t1.Set4Momentum(pmu);
30 //
31 // Float_t b[3]={1.2,-0.04,8.5};
32 // Ali3Vector p;
33 // p.SetVector(b,"car");
34 // AliTrack t2;
35 // t2.Set3Momentum(p);
36 // t2.SetCharge(0);
37 // t2.SetMass(1.115);
38 //
39 // t1.Data();
40 // t2.Data();
41 //
42 // Float_t pi=acos(-1.);
43 // Float_t thcms=0.2*pi; // decay theta angle in cms
44 // Float_t phicms=pi/4.; // decay theta angle in cms
45 // Float_t m1=0.938;
46 // Float_t m2=0.140;
47 // t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion
48 //
49 // t2.List();
50 //
51 // Int_t ndec=t2.GetNdecay();
52 // AliTrack* d1=t2.GetDecayTrack(1); // Access to decay track number 1
53 // AliTrack* d2=t2.GetDecayTrack(2); // Access to decay track number 2
54 //
55 // AliSignal s1,s2,s3,s4;
56 //
57 // .... // Code (e.g. detector readout) to fill AliSignal data
58 //
59 // AliTrack trec; // Track which will be reconstructed from signals
60 // trec.AddSignal(s1);
61 // trec.AddSignal(s3);
62 // trec.AddSignal(s4);
63 //
64 // Ali3Vector P;
65 // Float_t Q,M;
66 //
67 // ... // Code which accesses signals from trec and reconstructs
68 //        3-momentum P, charge Q, mass M etc...
69 //
70 // trec.Set3Momentum(P);
71 // trec.SetCharge(Q);
72 // trec.SetMass(M);
73 //
74 // Float_t r1[3]={1.6,-3.8,25.7};
75 // Float_t er1[3]={0.2,0.5,1.8};
76 // Float_t r2[3]={8.6,23.8,-6.7};
77 // Float_t er2[3]={0.93,1.78,0.8};
78 // AliPosition begin,end;
79 // begin.SetPosition(r1,"car");
80 // begin.SetPositionErrors(er1,"car");
81 // end.SetPosition(r2,"car");
82 // end.SetPositionErrors(er2,"car");
83 // trec.SetBeginPoint(begin);
84 // trec.SetEndPoint(end);
85 // 
86 // Note : All quantities are in GeV, GeV/c or GeV/c**2
87 //
88 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
89 //- Modified: NvE $Date$ UU-SAP Utrecht
90 ///////////////////////////////////////////////////////////////////////////
91
92 #include "AliTrack.h"
93 #include "Riostream.h"
94  
95 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
96  
97 AliTrack::AliTrack() : TNamed(),Ali4Vector()
98 {
99 // Default constructor
100 // All variables initialised to 0
101  Init();
102  Reset();
103 }
104 ///////////////////////////////////////////////////////////////////////////
105 void AliTrack::Init()
106 {
107 // Initialisation of pointers etc...
108  fDecays=0;
109  fSignals=0;
110  fHypotheses=0;
111  fBegin=0;
112  fEnd=0;
113  fRef=0;
114  fImpactXY=0;
115  fImpactXZ=0;
116  fImpactYZ=0;
117  fClosest=0;
118  fParent=0;
119  fFit=0;
120  fTstamp=0;
121 }
122 ///////////////////////////////////////////////////////////////////////////
123 AliTrack::~AliTrack()
124 {
125 // Destructor to delete memory allocated for decay tracks array.
126 // This destructor automatically cleares all references to this AliTrack
127 // from all the related AliSignal objects.
128  Int_t nsig=GetNsignals();
129  for (Int_t i=1; i<=nsig; i++)
130  {
131   AliSignal* s=GetSignal(i);
132   if (s) s->RemoveTrack(*this,0);
133  }
134  
135  if (fDecays)
136  {
137   delete fDecays;
138   fDecays=0;
139  }
140  if (fSignals)
141  {
142   delete fSignals;
143   fSignals=0;
144  }
145  if (fHypotheses)
146  {
147   delete fHypotheses;
148   fHypotheses=0;
149  }
150  if (fBegin)
151  {
152   delete fBegin;
153   fBegin=0;
154  }
155  if (fEnd)
156  {
157   delete fEnd;
158   fEnd=0;
159  }
160  if (fRef)
161  {
162   delete fRef;
163   fRef=0;
164  }
165  if (fImpactXY)
166  {
167   delete fImpactXY;
168   fImpactXY=0;
169  }
170  if (fImpactXZ)
171  {
172   delete fImpactXZ;
173   fImpactXZ=0;
174  }
175  if (fImpactYZ)
176  {
177   delete fImpactYZ;
178   fImpactYZ=0;
179  }
180  if (fClosest)
181  {
182   delete fClosest;
183   fClosest=0;
184  }
185  if (fFit)
186  {
187   delete fFit;
188   fFit=0;
189  }
190  if (fTstamp)
191  {
192   delete fTstamp;
193   fTstamp=0;
194  }
195 }
196 ///////////////////////////////////////////////////////////////////////////
197 AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
198 {
199 // Copy constructor
200  Init();
201
202  fQ=t.fQ;
203  fProb=t.fProb;
204  if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin));
205  if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd));
206  if (t.fRef) fRef=new AliPositionObj(*(t.fRef));
207  if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY));
208  if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ));
209  if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ));
210  if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest));
211  if (t.fFit) fFit=t.fFit->Clone();
212  if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp));
213  fUserId=t.fUserId;
214  fChi2=t.fChi2;
215  fNdf=t.fNdf;
216  fCode=t.fCode;
217  fParent=t.fParent;
218
219  Int_t ndec=t.GetNdecay();
220  if (ndec)
221  {
222   fDecays=new TObjArray(ndec);
223   fDecays->SetOwner();
224   for (Int_t it=1; it<=ndec; it++)
225   {
226    AliTrack* tx=t.GetDecayTrack(it);
227    fDecays->Add(new AliTrack(*tx));
228   }
229  }
230
231  Int_t nsig=t.GetNsignals();
232  if (nsig)
233  {
234   fSignals=new TObjArray(nsig);
235   for (Int_t is=1; is<=nsig; is++)
236   {
237    AliSignal* sx=t.GetSignal(is);
238    fSignals->Add(sx);
239   }
240  }
241
242  Int_t nhyp=t.GetNhypotheses();
243  if (nhyp)
244  {
245   fHypotheses=new TObjArray(nhyp);
246   fHypotheses->SetOwner();
247   for (Int_t ih=1; ih<=nhyp; ih++)
248   {
249    AliTrack* tx=t.GetTrackHypothesis(ih);
250    fHypotheses->Add(new AliTrack(*tx));
251   }
252  }
253 }
254 ///////////////////////////////////////////////////////////////////////////
255 void AliTrack::Reset()
256 {
257 // Reset all variables to 0 and delete all auto-generated decay tracks.
258  fQ=0;
259  fChi2=0;
260  fNdf=0;
261  fUserId=0;
262  fCode=0;
263  fProb=0;
264  Double_t a[4]={0,0,0,0};
265  SetVector(a,"sph");
266  fParent=0;
267  if (fDecays)
268  {
269   delete fDecays;
270   fDecays=0;
271  }
272  if (fSignals)
273  {
274   delete fSignals;
275   fSignals=0;
276  }
277  if (fHypotheses)
278  {
279   delete fHypotheses;
280   fHypotheses=0;
281  }
282  if (fBegin)
283  {
284   delete fBegin;
285   fBegin=0;
286  }
287  if (fEnd)
288  {
289   delete fEnd;
290   fEnd=0;
291  }
292  if (fRef)
293  {
294   delete fRef;
295   fRef=0;
296  }
297  if (fImpactXY)
298  {
299   delete fImpactXY;
300   fImpactXY=0;
301  }
302  if (fImpactXZ)
303  {
304   delete fImpactXZ;
305   fImpactXZ=0;
306  }
307  if (fImpactYZ)
308  {
309   delete fImpactYZ;
310   fImpactYZ=0;
311  }
312  if (fClosest)
313  {
314   delete fClosest;
315   fClosest=0;
316  }
317  if (fFit)
318  {
319   delete fFit;
320   fFit=0;
321  }
322  if (fTstamp)
323  {
324   delete fTstamp;
325   fTstamp=0;
326  }
327 }
328 ///////////////////////////////////////////////////////////////////////////
329 void AliTrack::Set3Momentum(Ali3Vector& p)
330 {
331 // Set the track parameters according to the 3-momentum p.
332 // In case the mass was not yet set, the energy is set to correspond to m=0. 
333  Set3Vector(p);
334  Double_t inv=GetInvariant();
335  if (inv<0) SetMass(0.);
336 }
337 ///////////////////////////////////////////////////////////////////////////
338 void AliTrack::Set4Momentum(Ali4Vector& p)
339 {
340 // Set the track parameters according to the 4-momentum p
341  Double_t E=p.GetScalar();
342  Double_t dE=p.GetResultError();
343  Ali3Vector pv=p.Get3Vector();
344  SetVector(E,pv);
345  SetScalarError(dE);
346 }
347 ///////////////////////////////////////////////////////////////////////////
348 void AliTrack::SetMass(Double_t m,Double_t dm)
349 {
350 // Set the particle mass
351 // The default value for the error dm is 0.
352  Double_t inv=pow(m,2);
353  Double_t dinv=fabs(2.*m*dm);
354  SetInvariant(inv,dinv);
355 }
356 ///////////////////////////////////////////////////////////////////////////
357 void AliTrack::SetCharge(Float_t q)
358 {
359 // Set the particle charge
360  fQ=q;
361 }
362 ///////////////////////////////////////////////////////////////////////////
363 void AliTrack::Data(TString f,TString u)
364 {
365 // Provide track information within the coordinate frame f
366 //
367 // The string argument "u" allows to choose between different angular units
368 // in case e.g. a spherical frame is selected.
369 // u = "rad" : angles provided in radians
370 //     "deg" : angles provided in degrees
371 //
372 // The defaults are f="car" and u="rad".
373
374  Double_t m=GetMass();
375  Double_t dm=GetResultError();
376  const char* name=GetName();
377  const char* title=GetTitle();
378
379  cout << " *" << ClassName() << "::Data*";
380  if (strlen(name))  cout << " Name : " << name;
381  if (strlen(title)) cout << " Title : " << title;
382  cout << endl;
383  if (fTstamp) fTstamp->Date(1);
384  cout << " Id : " << fUserId << " Code : " << fCode
385       << " m : " << m << " dm : " << dm << " Charge : " << fQ
386       << " p : " << GetMomentum() << endl;
387  cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
388       << " Nsignals : " << GetNsignals() << endl;
389  if (fParent)
390  {
391   cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode()
392        << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge()
393        << " p : " << fParent->GetMomentum();
394   const char* pname=fParent->GetName();
395   const char* ptitle=fParent->GetTitle();
396   if (strlen(pname))  cout << " Name : " << pname;
397   if (strlen(ptitle)) cout << " Title : " << ptitle;
398   cout << endl;
399  }
400  if (fFit)
401  {
402   cout << " Fit details present in object of class " << fFit->ClassName() << endl; 
403   if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1);
404  }
405  Ali4Vector::Data(f,u); 
406
407 ///////////////////////////////////////////////////////////////////////////
408 void AliTrack::List(TString f,TString u)
409 {
410 // Provide current track and decay level 1 information within coordinate frame f
411 //
412 // The string argument "u" allows to choose between different angular units
413 // in case e.g. a spherical frame is selected.
414 // u = "rad" : angles provided in radians
415 //     "deg" : angles provided in degrees
416 //
417 // The defaults are f="car" and u="rad".
418
419  Data(f,u); // Information of the current track
420  if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
421  if (fEnd)   { cout << " End-point   :"; fEnd->Data(f,u); }
422  if (fRef)   { cout << " Ref-point   :"; fRef->Data(f,u); }
423
424  // Decay products of this track
425  AliTrack* td; 
426  for (Int_t id=1; id<=GetNdecay(); id++)
427  {
428   td=GetDecayTrack(id);
429   if (td)
430   {
431    cout << "  ---Level 1 sec. track no. " << id << endl;
432    td->Data(f,u); 
433   }
434   else
435   {
436    cout << " *AliTrack::List* Error : Empty decay track slot." << endl; 
437   }
438  }
439
440 ///////////////////////////////////////////////////////////////////////////
441 void AliTrack::ListAll(TString f,TString u)
442 {
443 // Provide complete track and decay information within the coordinate frame f
444 //
445 // The string argument "u" allows to choose between different angular units
446 // in case e.g. a spherical frame is selected.
447 // u = "rad" : angles provided in radians
448 //     "deg" : angles provided in degrees
449 //
450 // The defaults are f="car" and u="rad".
451
452  Data(f,u); // Information of the current track
453  if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
454  if (fEnd)   { cout << " End-point   :"; fEnd->Data(f,u); }
455  if (fRef)   { cout << " Ref-point   :"; fRef->Data(f,u); }
456
457  Int_t nhyp=GetNhypotheses();
458  if (nhyp)
459  {
460   cout << " List of the " << nhyp << " track hypotheses : " << endl;
461   for (Int_t ih=1; ih<=nhyp; ih++)
462   {
463    AliTrack* tx=GetTrackHypothesis(ih);
464    if (tx) tx->Data(f,u);
465   }
466  }
467
468  Int_t nsig=GetNsignals();
469  if (nsig)
470  {
471   cout << " List of the corresponding slots for the " << nsig
472        << " related signals : " << endl;
473   AliPosition r;
474   Int_t nrefs,jslot;
475   TArrayI slotarr;
476   for (Int_t is=1; is<=nsig; is++)
477   {
478    AliSignal* sx=GetSignal(is);
479    if (sx)
480    {
481     nrefs=sx->GetIndices(this,slotarr,0);
482     for (Int_t jref=0; jref<nrefs; jref++)
483     {
484      jslot=slotarr.At(jref);
485      sx->List(jslot);
486     }
487     r=sx->GetPosition();
488     cout << "   Position";
489     r.Data(f,u);
490    }
491   }
492  }
493
494  AliTrack* t=this;
495  Dumps(t,1,f,u); // Information of all decay products
496 }
497 //////////////////////////////////////////////////////////////////////////
498 void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u)
499 {
500 // Recursively provide the info of all decay levels of this track
501  AliTrack* td; 
502  for (Int_t id=1; id<=t->GetNdecay(); id++)
503  {
504   td=t->GetDecayTrack(id);
505   if (td)
506   {
507    cout << "  ---Level " << n << " sec. track no. " << id << endl;
508    td->Data(f,u); 
509
510    Int_t nhyp=td->GetNhypotheses();
511    if (nhyp)
512    {
513     cout << " List of the " << nhyp << " track hypotheses : " << endl;
514     for (Int_t ih=1; ih<=nhyp; ih++)
515     {
516      AliTrack* tx=td->GetTrackHypothesis(ih);
517      if (tx) tx->Data(f,u);
518     }
519    }
520
521    Int_t nsig=td->GetNsignals();
522    if (nsig)
523    {
524     cout << " List of the " << nsig << " related signals : " << endl;
525     for (Int_t is=1; is<=nsig; is++)
526     {
527      AliSignal* sx=td->GetSignal(is);
528      if (sx) sx->Data(f,u);
529     }
530    }
531
532    // Go for next decay level of this decay track recursively
533    Dumps(td,n+1,f,u);
534   }
535   else
536   {
537    cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl; 
538   }
539  }
540
541 //////////////////////////////////////////////////////////////////////////
542 Double_t AliTrack::GetMomentum()
543 {
544 // Provide the value of the track 3-momentum.
545 // The error can be obtained by invoking GetResultError() after
546 // invokation of GetMomentum().
547  Double_t norm=fV.GetNorm();
548  fDresult=fV.GetResultError();
549  return norm;
550 }
551 ///////////////////////////////////////////////////////////////////////////
552 Ali3Vector AliTrack::Get3Momentum() const
553 {
554 // Provide the track 3-momentum
555  return (Ali3Vector)Get3Vector();
556 }
557 ///////////////////////////////////////////////////////////////////////////
558 Double_t AliTrack::GetMass()
559 {
560 // Provide the particle mass.
561 // The error can be obtained by invoking GetResultError() after
562 // invokation of GetMass().
563  Double_t inv=GetInvariant();
564  Double_t dinv=GetResultError();
565  Double_t dm=0;
566  if (inv >= 0)
567  {
568  Double_t m=sqrt(inv);
569  if (m) dm=dinv/(2.*m);
570  fDresult=dm;
571  return m;
572  }
573  else
574  {
575   cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
576   cout << " Value 0 will be returned." << endl;
577   fDresult=dm;
578   return 0;
579  }
580 }
581 ///////////////////////////////////////////////////////////////////////////
582 Float_t AliTrack::GetCharge() const
583 {
584 // Provide the particle charge
585  return fQ;
586 }
587 ///////////////////////////////////////////////////////////////////////////
588 Double_t AliTrack::GetEnergy()
589 {
590 // Provide the particle's energy.
591 // The error can be obtained by invoking GetResultError() after
592 // invokation of GetEnergy().
593  Double_t E=GetScalar();
594  if (E>0)
595  {
596   return E;
597  }
598  else
599  {
600   cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
601   cout << " Value 0 will be returned." << endl;
602   return 0;
603  }
604 }
605 ///////////////////////////////////////////////////////////////////////////
606 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
607 {
608 // Perform 2-body decay of current track
609 // m1     : mass of decay product 1
610 // m2     : mass of decay product 2
611 // thcms  : cms theta decay angle (in rad.) of m1
612 // phicms : cms phi decay angle (in rad.) of m1
613  
614  Double_t M=GetMass();
615  
616 // Compute the 4-momenta of the decay products in the cms
617 // Note : p2=p1=pnorm for a 2-body decay
618  Double_t e1=0;
619  if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
620  Double_t e2=0;
621  if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
622  Double_t pnorm=(e1*e1)-(m1*m1);
623  if (pnorm>0.)
624  {
625   pnorm=sqrt(pnorm);
626  }
627  else
628  {
629   pnorm=0;
630  }
631  
632  Double_t a[3];
633  a[0]=pnorm;
634  a[1]=thcms;
635  a[2]=phicms;
636  Ali3Vector p;
637  p.SetVector(a,"sph");
638
639  Ali4Vector pprim1;
640  pprim1.SetVector(e1,p);
641  pprim1.SetInvariant(m1*m1);
642
643  Ali4Vector pprim2;
644  p*=-1;
645  pprim2.SetVector(e2,p);
646  pprim2.SetInvariant(m2*m2);
647
648  // Determine boost parameters from the parent particle
649  Double_t E=GetEnergy();
650  p=Get3Vector();
651  Ali4Vector pmu;
652  pmu.SetVector(E,p);
653
654  AliBoost q;
655  q.Set4Momentum(pmu);
656  
657  Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
658  Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
659  
660  // Enter the boosted data into the decay tracks array
661  if (fDecays)
662  {
663   delete fDecays;
664   fDecays=0;
665  }
666  fDecays=new TObjArray(2);
667  fDecays->SetOwner();
668
669  fDecays->Add(new AliTrack);
670  ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
671  ((AliTrack*)fDecays->At(0))->SetMass(m1);
672  fDecays->Add(new AliTrack);
673  ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
674  ((AliTrack*)fDecays->At(1))->SetMass(m2);
675 }
676 ///////////////////////////////////////////////////////////////////////////
677 Int_t AliTrack::GetNdecay() const
678 {
679 // Provide the number of decay produced tracks
680  Int_t ndec=0;
681  if (fDecays) ndec=fDecays->GetEntries();
682  return ndec;
683 }
684 ///////////////////////////////////////////////////////////////////////////
685 AliTrack* AliTrack::GetDecayTrack(Int_t j) const
686 {
687 // Provide decay produced track number j
688 // Note : j=1 denotes the first decay track
689  if (!fDecays)
690  {
691   cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
692   return 0;
693  }
694  else
695  {
696   if ((j >= 1) && (j <= GetNdecay()))
697   {
698    return (AliTrack*)fDecays->At(j-1);
699   }
700   else
701   {
702    cout << " *AliTrack* decay track number : " << j << " out of range."
703         << " Ndec = " << GetNdecay() << endl;
704    return 0;  
705   }
706  }
707 }
708 ///////////////////////////////////////////////////////////////////////////
709 void AliTrack::RemoveDecays()
710 {
711 // Remove all decay tracks from this track.
712  if (fDecays)
713  {
714   delete fDecays;
715   fDecays=0;
716  }
717 }
718 ///////////////////////////////////////////////////////////////////////////
719 void AliTrack::AddSignal(AliSignal& s,Int_t mode)
720 {
721 // Relate an AliSignal object to this track.
722 //
723 // mode = 0 : Only the reference to the specified signal is stored in
724 //            the current track, without storing the (backward) reference
725 //            to this track into the AliSignal structure. 
726 //        1 : The (backward) reference to the current track is also automatically
727 //            stored into the AliSignal (or derived) object specified in the
728 //            input argument.
729 //
730 // The default is mode=0.
731
732  if (!fSignals) fSignals=new TObjArray(1);
733
734  // Check if this signal is already stored for this track
735  Int_t nsig=GetNsignals();
736  for (Int_t i=0; i<nsig; i++)
737  {
738   if (&s==fSignals->At(i)) return; 
739  }
740
741  fSignals->Add(&s);
742  if (mode==1) s.AddTrack(*this,0);
743 }
744 ///////////////////////////////////////////////////////////////////////////
745 void AliTrack::RemoveSignal(AliSignal& s,Int_t mode)
746 {
747 // Remove related AliSignal object from this track.
748 //
749 // mode = 0 : Only the reference to the specified signal is removed from
750 //            the current track, without removing the (backward) reference(s)
751 //            to this track from the AliSignal structure. 
752 //        1 : The (backward) reference(s) to the current track are also automatically
753 //            removed from the AliSignal (or derived) object specified in the
754 //            input argument.
755 //
756 // The default is mode=1.
757
758  if (fSignals)
759  {
760   AliSignal* test=(AliSignal*)fSignals->Remove(&s);
761   if (test) fSignals->Compress();
762  }
763  if (mode==1) s.RemoveTrack(*this,0);
764 }
765 ///////////////////////////////////////////////////////////////////////////
766 void AliTrack::RemoveSignals(Int_t mode)
767 {
768 // Remove all related AliSignal objects from this track.
769 //
770 // mode = 0 : All signal references are removed from the current track,
771 //            without removing the (backward) references to this track from
772 //            the corresponding AliSignal objects.
773 //        1 : The (backward) references to the current track are also automatically
774 //            removed from the corresponding AliSignal (or derived) objects.
775 //
776 // The default is mode=1.
777
778  if (!fSignals) return;
779
780  Int_t ns=GetNsignals();
781  for (Int_t i=0; i<ns; i++)
782  {
783   AliSignal* sx=(AliSignal*)fSignals->At(i);
784   if (sx && mode==1) sx->RemoveTrack(*this,0);
785  }
786
787  delete fSignals;
788  fSignals=0;
789 }
790 ///////////////////////////////////////////////////////////////////////////
791 Int_t AliTrack::GetNsignals() const
792 {
793 // Provide the number of related AliSignals.
794  Int_t nsig=0;
795  if (fSignals) nsig=fSignals->GetEntries();
796  return nsig;
797 }
798 ///////////////////////////////////////////////////////////////////////////
799 AliSignal* AliTrack::GetSignal(Int_t j) const
800 {
801 // Provide the related AliSignal number j.
802 // Note : j=1 denotes the first signal.
803  if (!fSignals)
804  {
805   cout << " *AliTrack::GetSignal* No signals present." << endl;
806   return 0;
807  }
808  else
809  {
810   if ((j >= 1) && (j <= GetNsignals()))
811   {
812    return (AliSignal*)fSignals->At(j-1);
813   }
814   else
815   {
816    cout << " *AliTrack* signal number : " << j << " out of range."
817         << " Nsig = " << GetNsignals() << endl;
818    return 0;
819   }
820  }
821 }
822 ///////////////////////////////////////////////////////////////////////////
823 void AliTrack::AddTrackHypothesis(AliTrack& t)
824 {
825 // Relate a track hypothesis to this track.
826 // Note : a private copy of the input track will be made via the Clone()
827 //        facility.
828  if (!fHypotheses)
829  {
830   fHypotheses=new TObjArray(1);
831   fHypotheses->SetOwner();
832  }
833  fHypotheses->Add(t.Clone());
834 }
835 ///////////////////////////////////////////////////////////////////////////
836 void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
837 {
838 // Add a track hypothesis by explicitly setting the mass and probability.
839 // This will affect e.g. the hypothesis track's energy, since the momentum
840 // and all other attributes will be copied from the current track.
841 //
842 // Input arguments :
843 // ----------------- 
844 // prob=probalility  m=mass value  dm=error on the mass value.
845 // The default value for the mass error dm is 0.
846
847  AliTrack t(*this);
848  t.RemoveDecays();
849  t.RemoveTrackHypotheses();
850  t.RemoveSignals();
851  t.SetTitle("Mass hypothesis");
852  t.SetMass(m,dm);
853  t.SetProb(prob);
854  AddTrackHypothesis(t);
855 }
856 ///////////////////////////////////////////////////////////////////////////
857 void AliTrack::RemoveTrackHypothesis(AliTrack& t)
858 {
859 // Remove the specified track hypothesis from this track.
860  if (fHypotheses)
861  {
862   AliTrack* test=(AliTrack*)fHypotheses->Remove(&t);
863   if (test) fHypotheses->Compress();
864  }
865 }
866 ///////////////////////////////////////////////////////////////////////////
867 void AliTrack::RemoveTrackHypotheses()
868 {
869 // Remove all track hypotheses from this track.
870  if (fHypotheses)
871  {
872   delete fHypotheses;
873   fHypotheses=0;
874  }
875 }
876 ///////////////////////////////////////////////////////////////////////////
877 Int_t AliTrack::GetNhypotheses() const
878 {
879 // Provide the number of track hypotheses.
880  Int_t nhyp=0;
881  if (fHypotheses) nhyp=fHypotheses->GetEntries();
882  return nhyp;
883 }
884 ///////////////////////////////////////////////////////////////////////////
885 AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const
886 {
887 // Provide the j-th track hypothesis.
888 // Note : j=1 denotes the first hypothesis.
889 // Default : j=0 ==> Hypothesis with highest probability.
890
891  if (!fHypotheses) return 0;
892
893  Int_t nhyp=GetNhypotheses();
894
895  // Check validity of index j
896  if (j<0 || j>nhyp)
897  {
898    cout << " *AliTrack* hypothesis number : " << j << " out of range."
899         << " Nhyp = " << nhyp << endl;
900    return 0;
901  } 
902
903  AliTrack* t=0;
904
905  if (j==0) // Provide track hypothesis with highest probability
906  {
907   Float_t prob=0;   
908   t=(AliTrack*)fHypotheses->At(0);
909   if (t) prob=t->GetProb();
910   Float_t probx=0;
911   for (Int_t ih=1; ih<nhyp; ih++)
912   {
913    AliTrack* tx=(AliTrack*)fHypotheses->At(ih);
914    if (tx)
915    {
916     probx=tx->GetProb();
917     if (probx > prob) t=tx; 
918    }
919   }
920   return t;
921  }
922  else // Provide requested j-th track hypothesis
923  {
924   return (AliTrack*)fHypotheses->At(j-1);
925  }
926 }
927 ///////////////////////////////////////////////////////////////////////////
928 void AliTrack::SetBeginPoint(AliPosition& p)
929 {
930 // Store the position of the track begin-point.
931  if (fBegin) delete fBegin;
932  fBegin=new AliPositionObj(p);
933 }
934 ///////////////////////////////////////////////////////////////////////////
935 AliPosition* AliTrack::GetBeginPoint()
936 {
937 // Provide the position of the track begin-point.
938  return fBegin;
939 }
940 ///////////////////////////////////////////////////////////////////////////
941 void AliTrack::SetEndPoint(AliPosition& p)
942 {
943 // Store the position of the track end-point.
944  if (fEnd) delete fEnd;
945  fEnd=new AliPositionObj(p);
946 }
947 ///////////////////////////////////////////////////////////////////////////
948 AliPosition* AliTrack::GetEndPoint()
949 {
950 // Provide the position of the track end-point.
951  return fEnd;
952 }
953 ///////////////////////////////////////////////////////////////////////////
954 void AliTrack::SetReferencePoint(AliPosition& p)
955 {
956 // Store the position of the track reference-point.
957 // The reference-point is the point on the track in which the 
958 // 3-momentum vector components have been defined.
959 // This reference point is the preferable point to start track extrapolations
960 // etc... which are sensitive to the components of the 3-momentum vector.
961  if (fRef) delete fRef;
962  fRef=new AliPositionObj(p);
963 }
964 ///////////////////////////////////////////////////////////////////////////
965 AliPosition* AliTrack::GetReferencePoint()
966 {
967 // Provide the position of the track reference-point.
968 // The reference-point is the point on the track in which the 
969 // 3-momentum vector components have been defined.
970 // This reference point is the preferable point to start track extrapolations
971 // etc... which are sensitive to the components of the 3-momentum vector.
972  return fRef;
973 }
974 ///////////////////////////////////////////////////////////////////////////
975 void AliTrack::SetMass()
976 {
977 // Set the mass and error to the value of the hypothesis with highest prob.
978
979  Double_t m=0,dm=0;
980
981  // Select mass hypothesis with highest probability
982  AliTrack* t=GetTrackHypothesis(0);
983  if (t) 
984  {
985   m=t->GetMass();
986   dm=t->GetResultError();
987   SetMass(m,dm);
988  }
989  else
990  {
991   cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
992  }
993 }
994 ///////////////////////////////////////////////////////////////////////////
995 Double_t AliTrack::GetPt()
996 {
997 // Provide trans. momentum value w.r.t. z-axis.
998 // The error on the value can be obtained by GetResultError()
999 // after invokation of GetPt().
1000  Ali3Vector v;
1001  v=GetVecTrans();
1002  Double_t norm=v.GetNorm();
1003  fDresult=v.GetResultError();
1004
1005  return norm;
1006 }
1007 ///////////////////////////////////////////////////////////////////////////
1008 Double_t AliTrack::GetPl()
1009 {
1010 // Provide long. momentum value w.r.t. z-axis.
1011 // Note : the returned value can also be negative.
1012 // The error on the value can be obtained by GetResultError()
1013 // after invokation of GetPl().
1014  Ali3Vector v;
1015  v=GetVecLong();
1016
1017  Double_t pl=v.GetNorm();
1018  fDresult=v.GetResultError();
1019
1020  Double_t a[3];
1021  v.GetVector(a,"sph");
1022  if (cos(a[1])<0) pl=-pl;
1023
1024  return pl;
1025 }
1026 ///////////////////////////////////////////////////////////////////////////
1027 Double_t AliTrack::GetEt()
1028 {
1029 // Provide trans. energy value w.r.t. z-axis.
1030 // The error on the value can be obtained by GetResultError()
1031 // after invokation of GetEt().
1032  Double_t et=GetScaTrans();
1033
1034  return et;
1035 }
1036 ///////////////////////////////////////////////////////////////////////////
1037 Double_t AliTrack::GetEl()
1038 {
1039 // Provide long. energy value w.r.t. z-axis.
1040 // Note : the returned value can also be negative.
1041 // The error on the value can be obtained by GetResultError()
1042 // after invokation of GetEl().
1043  Double_t el=GetScaLong();
1044
1045  return el;
1046 }
1047 ///////////////////////////////////////////////////////////////////////////
1048 Double_t AliTrack::GetMt()
1049 {
1050 // Provide transverse mass value w.r.t. z-axis.
1051 // The error on the value can be obtained by GetResultError()
1052 // after invokation of GetMt().
1053  Double_t pt=GetPt();
1054  Double_t dpt=GetResultError();
1055  Double_t m=GetMass();
1056  Double_t dm=GetResultError();
1057
1058  Double_t mt=sqrt(pt*pt+m*m);
1059  Double_t dmt2=0;
1060  if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
1061
1062  fDresult=sqrt(dmt2);
1063  return mt;
1064 }
1065 ///////////////////////////////////////////////////////////////////////////
1066 Double_t AliTrack::GetRapidity()
1067 {
1068 // Provide rapidity value w.r.t. z-axis.
1069 // The error on the value can be obtained by GetResultError()
1070 // after invokation of GetRapidity().
1071 // Note : Also GetPseudoRapidity() is available since this class is
1072 //        derived from Ali4Vector.
1073  Double_t e=GetEnergy();
1074  Double_t de=GetResultError();
1075  Double_t pl=GetPl();
1076  Double_t dpl=GetResultError();
1077  Double_t sum=e+pl;
1078  Double_t dif=e-pl;
1079
1080  Double_t y=9999,dy2=0;
1081  if (sum && dif) y=0.5*log(sum/dif);
1082
1083  if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
1084
1085  fDresult=sqrt(dy2);
1086  return y;
1087 }
1088 ///////////////////////////////////////////////////////////////////////////
1089 void AliTrack::SetImpactPoint(AliPosition& p,TString q)
1090 {
1091 // Store the position of the impact-point in the plane "q=0".
1092 // Here q denotes one of the axes X, Y or Z.
1093 // Note : The character to denote the axis may be entered in lower or
1094 //        in uppercase.
1095  Int_t axis=0;
1096  if (q=="x" || q=="X") axis=1;
1097  if (q=="y" || q=="Y") axis=2;
1098  if (q=="z" || q=="Z") axis=3;
1099
1100  switch (axis)
1101  {
1102   case 1: // Impact-point in the plane X=0
1103    if (fImpactYZ) delete fImpactYZ;
1104    fImpactYZ=new AliPositionObj(p);
1105    break;
1106
1107   case 2: // Impact-point in the plane Y=0
1108    if (fImpactXZ) delete fImpactXZ;
1109    fImpactXZ=new AliPositionObj(p);
1110    break;
1111
1112   case 3: // Impact-point in the plane Z=0
1113    if (fImpactXY) delete fImpactXY;
1114    fImpactXY=new AliPositionObj(p);
1115    break;
1116
1117   default: // Unsupported axis
1118    cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
1119         << " Possible axes are 'X', 'Y' and 'Z'." << endl; 
1120    break;
1121  }
1122 }
1123 ///////////////////////////////////////////////////////////////////////////
1124 AliPosition* AliTrack::GetImpactPoint(TString q)
1125 {
1126 // Provide the position of the impact-point in the plane "q=0".
1127 // Here q denotes one of the axes X, Y or Z.
1128 // Note : The character to denote the axis may be entered in lower or
1129 //        in uppercase.
1130  Int_t axis=0;
1131  if (q=="x" || q=="X") axis=1;
1132  if (q=="y" || q=="Y") axis=2;
1133  if (q=="z" || q=="Z") axis=3;
1134
1135  switch (axis)
1136  {
1137   case 1: // Impact-point in the plane X=0
1138    return fImpactYZ;
1139
1140   case 2: // Impact-point in the plane Y=0
1141    return fImpactXZ;
1142
1143   case 3: // Impact-point in the plane Z=0
1144    return fImpactXY;
1145
1146   default: // Unsupported axis
1147    cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
1148         << " Possible axes are 'X', 'Y' and 'Z'." << endl; 
1149    return 0;
1150  }
1151 }
1152 ///////////////////////////////////////////////////////////////////////////
1153 void AliTrack::SetId(Int_t id)
1154 {
1155 // Set a user defined unique identifier for this track.
1156  fUserId=id;
1157 }
1158 ///////////////////////////////////////////////////////////////////////////
1159 Int_t AliTrack::GetId() const
1160 {
1161 // Provide the user defined unique identifier of this track.
1162  return fUserId;
1163 }
1164 ///////////////////////////////////////////////////////////////////////////
1165 void AliTrack::SetClosestPoint(AliPosition& p)
1166 {
1167 // Set position p as the point of closest approach w.r.t. some reference
1168  if (fClosest) delete fClosest;
1169  fClosest=new AliPositionObj(p);
1170 }
1171 ///////////////////////////////////////////////////////////////////////////
1172 AliPosition* AliTrack::GetClosestPoint()
1173 {
1174 // Provide the point of closest approach w.r.t. some reference
1175  return fClosest;
1176 }
1177 ///////////////////////////////////////////////////////////////////////////
1178 void AliTrack::SetChi2(Float_t chi2)
1179 {
1180 // Set the chi-squared value of the track fit.
1181  if (chi2<0)
1182  {
1183   cout << " *AliTrack::SetChi2* Invalid chi2 value : " << chi2 << endl;
1184  }
1185  else
1186  {
1187   fChi2=chi2;
1188  }
1189 }
1190 ///////////////////////////////////////////////////////////////////////////
1191 void AliTrack::SetNdf(Int_t ndf)
1192 {
1193 // Set the number of degrees of freedom for the track fit.
1194  if (ndf<0)
1195  {
1196   cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl;
1197  }
1198  else
1199  {
1200   fNdf=ndf;
1201  }
1202 }
1203 ///////////////////////////////////////////////////////////////////////////
1204 Float_t AliTrack::GetChi2() const
1205 {
1206 // Provide the chi-squared value of the track fit.
1207  return fChi2;
1208 }
1209 ///////////////////////////////////////////////////////////////////////////
1210 Int_t AliTrack::GetNdf() const
1211 {
1212 // Provide the number of degrees of freedom for the track fit.
1213  return fNdf;
1214 }
1215 ///////////////////////////////////////////////////////////////////////////
1216 void AliTrack::SetParticleCode(Int_t code)
1217 {
1218 // Set the user defined particle id code (e.g. the PDF convention).
1219  fCode=code;
1220 }
1221 ///////////////////////////////////////////////////////////////////////////
1222 Int_t AliTrack::GetParticleCode() const
1223 {
1224 // Provide the user defined particle id code.
1225  return fCode;
1226 }
1227 ///////////////////////////////////////////////////////////////////////////
1228 void AliTrack::SetParentTrack(AliTrack* t)
1229 {
1230 // Set pointer to the parent track.
1231  fParent=t;
1232 }
1233 ///////////////////////////////////////////////////////////////////////////
1234 AliTrack* AliTrack::GetParentTrack()
1235 {
1236 // Provide pointer to the parent track.
1237  return fParent;
1238 }
1239 ///////////////////////////////////////////////////////////////////////////
1240 void AliTrack::SetProb(Double_t prob)
1241 {
1242 // Set hypothesis probability for this track.
1243  fProb=prob;
1244 }
1245 ///////////////////////////////////////////////////////////////////////////
1246 Float_t AliTrack::GetProb() const
1247 {
1248 // Provide the hypothesis probability for this track.
1249  return fProb;
1250 }
1251 ///////////////////////////////////////////////////////////////////////////
1252 void AliTrack::SetFitDetails(TObject* obj)
1253 {
1254 // Enter the object containing the fit details.
1255 // In case an object to hold fit details was already present, this
1256 // will be deleted first before the new one is stored.
1257 // This means that SetFitDetails(0) can be used to just remove the
1258 // existing object with the fit details.
1259 // All objects derived from TObject can be entered in this way.
1260 // Obvious candidates for objects containing detailed fit information
1261 // are functions (e.g. TF1) and histograms (e.g. TH1F).
1262 // However, using an AliDevice object provides a very versatile facility
1263 // to store the parameters of various fit procedures.
1264 // In such a case the AliDevice can be used to provide the various fit
1265 // definitions and the corresponding fit parameters can be entered as
1266 // separate AliSignal objects which are stored as hits to the AliDevice.
1267 // In addition various functions and histograms can be linked to the
1268 // various AliSignal instances
1269 // The latter procedure is based on the original idea of Adam Bouchta.
1270 //
1271 // Note : The entered object is owned by this AliTrack instance.
1272 //        As such, a private copy of obj will be stored using the Clone()
1273 //        memberfunction.
1274 //        In case the entered object contains pointers to other objects,
1275 //        the user has to provide the appropriate Clone() memberfunction
1276 //        for the class to which the entered object belongs.
1277 //        An example can be seen from AliTrack::Clone().   
1278 //
1279  if (fFit)
1280  {
1281   delete fFit;
1282   fFit=0;
1283  }
1284
1285  if (obj) fFit=obj->Clone();
1286 }
1287 ///////////////////////////////////////////////////////////////////////////
1288 TObject* AliTrack::GetFitDetails()
1289 {
1290 // Provide the pointer to the object containing the fit details.
1291  return fFit;
1292 }
1293 ///////////////////////////////////////////////////////////////////////////
1294 void AliTrack::SetTimestamp(AliTimestamp& t)
1295 {
1296 // Store the timestamp for this track.
1297  if (fTstamp) delete fTstamp;
1298  fTstamp=new AliTimestamp(t);
1299 }
1300 ///////////////////////////////////////////////////////////////////////////
1301 AliTimestamp* AliTrack::GetTimestamp()
1302 {
1303 // Provide the timestamp of this track.
1304  return fTstamp;
1305 }
1306 ///////////////////////////////////////////////////////////////////////////
1307 void AliTrack::RemoveTimestamp()
1308 {
1309 // Remove the timestamp from this track.
1310  if (fTstamp)
1311  {
1312   delete fTstamp;
1313   fTstamp=0;
1314  }
1315 }
1316 ///////////////////////////////////////////////////////////////////////////
1317 Double_t AliTrack::GetDistance(AliPosition* p)
1318 {
1319 // Provide distance of the current track to the position p.
1320 // The error on the result can be obtained as usual by invoking
1321 // GetResultError() afterwards. 
1322 //
1323 // The distance will be provided in the unit scale of the AliPosition p.
1324 // As such it is possible to obtain a correctly computed distance even in case
1325 // the track parameters have a different unit scale.
1326 // However, it is recommended to work always with one single unit scale.
1327 //
1328 // Note : In case of incomplete information, a distance value of -1 is
1329 //        returned.
1330  
1331  Double_t dist=-1.;
1332  fDresult=0.;
1333
1334  if (!p) return dist;
1335
1336  // Obtain a defined position on this track
1337  AliPosition* rx=fRef;
1338  if (!rx) rx=fBegin;
1339  if (!rx) rx=fEnd;
1340
1341  if (!rx) return dist;
1342
1343  Ali3Vector p1=Get3Momentum();
1344
1345  if (p1.GetNorm() <= 0.) return dist;
1346
1347  Ali3Vector r0=(Ali3Vector)(*rx);
1348
1349  Float_t tscale=rx->GetUnitScale();
1350  Float_t pscale=p->GetUnitScale();
1351  if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale);
1352  
1353  // Obtain the direction unit vector of this track
1354  Double_t vec[3];
1355  Double_t err[3];
1356  p1.GetVector(vec,"sph");
1357  p1.GetErrors(err,"sph");
1358  vec[0]=1.;
1359  err[0]=0.;
1360  p1.SetVector(vec,"sph");
1361  p1.SetErrors(err,"sph");
1362
1363  Ali3Vector q=(Ali3Vector)(*p);
1364  Ali3Vector r=q-r0;
1365  Ali3Vector d=r.Cross(p1);
1366  dist=d.GetNorm();
1367  fDresult=d.GetResultError();
1368  return dist;
1369 }
1370 ///////////////////////////////////////////////////////////////////////////
1371 Double_t AliTrack::GetDistance(AliTrack* t)
1372 {
1373 // Provide distance of the current track to the track t.
1374 // The error on the result can be obtained as usual by invoking
1375 // GetResultError() afterwards. 
1376 //
1377 // The distance will be provided in the unit scale of the current track.
1378 // As such it is possible to obtain a correctly computed distance even in case
1379 // the track parameters have a different unit scale.
1380 // This implies that in such cases the results of t1.GetDistance(t2) and
1381 // t2.GetDistance(t1) will be numerically different.
1382 // However, it is recommended to work always with one single unit scale.
1383 //
1384 // Note : In case of incomplete information, a distance value of -1 is
1385 //        returned.
1386  
1387  Double_t dist=-1.;
1388  fDresult=0.;
1389
1390  if (!t) return dist;
1391
1392  // Obtain a defined position on this track
1393  AliPosition* rx=fRef;
1394  if (!rx) rx=fBegin;
1395  if (!rx) rx=fEnd;
1396
1397  if (!rx) return dist;
1398
1399  // Obtain a defined position on track t
1400  AliPosition* ry=t->GetReferencePoint();
1401  if (!ry) ry=t->GetBeginPoint();
1402  if (!ry) ry=t->GetEndPoint();
1403
1404  if (!ry) return dist;
1405  
1406  Ali3Vector p1=Get3Momentum();
1407  Ali3Vector p2=t->Get3Momentum();
1408
1409  if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist;
1410
1411  // The vector normal to both track directions
1412  Ali3Vector n=p1.Cross(p2);
1413
1414  if (n.GetNorm() > 1.e-10)
1415  {
1416   // Normalise n to a unit vector
1417   Double_t vec[3];
1418   Double_t err[3];
1419   n.GetVector(vec,"sph");
1420   n.GetErrors(err,"sph");
1421   vec[0]=1.;
1422   err[0]=0.;
1423   n.SetVector(vec,"sph");
1424   n.SetErrors(err,"sph");
1425   Ali3Vector r1=(Ali3Vector)(*rx);
1426   Ali3Vector r2=(Ali3Vector)(*ry);
1427   // Correct components of r2 in case of different unit scales
1428   Float_t scale=rx->GetUnitScale();
1429   Float_t tscale=ry->GetUnitScale();
1430   if ((tscale/scale > 1.1) || (scale/tscale > 1.1)) r2=r2*(tscale/scale);
1431   Ali3Vector r=r1-r2;
1432   dist=fabs(r.Dot(n));
1433   fDresult=r.GetResultError();
1434  }
1435  else // Parallel tracks
1436  {
1437   dist=t->GetDistance(rx);
1438   fDresult=t->GetResultError();
1439  }
1440  return dist;
1441 }
1442 ///////////////////////////////////////////////////////////////////////////
1443 TObject* AliTrack::Clone(const char* name) const
1444 {
1445 // Make a deep copy of the current object and provide the pointer to the copy.
1446 // This memberfunction enables automatic creation of new objects of the
1447 // correct type depending on the object type, a feature which may be very useful
1448 // for containers when adding objects in case the container owns the objects.
1449 // This feature allows e.g. AliJet to store either AliTrack objects or
1450 // objects derived from AliTrack via the AddTrack memberfunction, provided
1451 // these derived classes also have a proper Clone memberfunction. 
1452
1453  AliTrack* trk=new AliTrack(*this);
1454  if (name)
1455  {
1456   if (strlen(name)) trk->SetName(name);
1457  }
1458  return trk;
1459 }
1460 ///////////////////////////////////////////////////////////////////////////