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 the attributes of a reconstructed particle track.
25 // Float_t a[4]={195.,1.2,-0.04,8.5};
27 // pmu.SetVector(a,"car");
29 // t1.Set4Momentum(pmu);
31 // Float_t b[3]={1.2,-0.04,8.5};
33 // p.SetVector(b,"car");
35 // t2.Set3Momentum(p);
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
47 // t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion
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
55 // AliSignal s1,s2,s3,s4;
57 // .... // Code (e.g. detector readout) to fill AliSignal data
59 // AliTrack trec; // Track which will be reconstructed from signals
60 // trec.AddSignal(s1);
61 // trec.AddSignal(s3);
62 // trec.AddSignal(s4);
67 // ... // Code which accesses signals from trec and reconstructs
68 // 3-momentum P, charge Q, mass M etc...
70 // trec.Set3Momentum(P);
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);
86 // Note : All quantities are in GeV, GeV/c or GeV/c**2
88 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
89 //- Modified: NvE $Date$ UU-SAP Utrecht
90 ///////////////////////////////////////////////////////////////////////////
93 #include "Riostream.h"
95 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
97 AliTrack::AliTrack() : TNamed(),Ali4Vector()
99 // Default constructor
100 // All variables initialised to 0
104 ///////////////////////////////////////////////////////////////////////////
105 void AliTrack::Init()
107 // Initialisation of pointers etc...
122 ///////////////////////////////////////////////////////////////////////////
123 AliTrack::~AliTrack()
125 // Destructor to delete memory allocated for decay tracks array.
126 // This destructor automatically cleares the pointer of this AliTrack
127 // from all the link slots of the related AliSignal objects.
128 Int_t nsig=GetNsignals();
129 for (Int_t i=1; i<=nsig; i++)
131 AliSignal* s=GetSignal(i);
132 if (s) s->ResetLinks(this);
197 ///////////////////////////////////////////////////////////////////////////
198 AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
205 if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin));
206 if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd));
207 if (t.fRef) fRef=new AliPositionObj(*(t.fRef));
208 if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY));
209 if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ));
210 if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ));
211 if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest));
212 if (t.fFit) fFit=t.fFit->Clone();
213 if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp));
220 Int_t ndec=t.GetNdecay();
223 fDecays=new TObjArray(ndec);
225 for (Int_t it=1; it<=ndec; it++)
227 AliTrack* tx=t.GetDecayTrack(it);
228 fDecays->Add(new AliTrack(*tx));
232 Int_t nsig=t.GetNsignals();
235 fSignals=new TObjArray(nsig);
236 for (Int_t is=1; is<=nsig; is++)
238 AliSignal* sx=t.GetSignal(is);
243 Int_t nhyp=t.GetNhypotheses();
246 fHypotheses=new TObjArray(nhyp);
247 fHypotheses->SetOwner();
248 for (Int_t ih=1; ih<=nhyp; ih++)
250 AliTrack* tx=t.GetTrackHypothesis(ih);
251 fHypotheses->Add(new AliTrack(*tx));
255 ///////////////////////////////////////////////////////////////////////////
256 void AliTrack::Reset()
258 // Reset all variables to 0 and delete all auto-generated decay tracks.
265 Double_t a[4]={0,0,0,0};
330 ///////////////////////////////////////////////////////////////////////////
331 void AliTrack::Set3Momentum(Ali3Vector& p)
333 // Set the track parameters according to the 3-momentum p.
334 // In case the mass was not yet set, the energy is set to correspond to m=0.
336 Double_t inv=GetInvariant();
337 if (inv<0) SetMass(0.);
339 ///////////////////////////////////////////////////////////////////////////
340 void AliTrack::Set4Momentum(Ali4Vector& p)
342 // Set the track parameters according to the 4-momentum p
343 Double_t E=p.GetScalar();
344 Double_t dE=p.GetResultError();
345 Ali3Vector pv=p.Get3Vector();
349 ///////////////////////////////////////////////////////////////////////////
350 void AliTrack::SetMass(Double_t m,Double_t dm)
352 // Set the particle mass
353 // The default value for the error dm is 0.
354 Double_t inv=pow(m,2);
355 Double_t dinv=fabs(2.*m*dm);
356 SetInvariant(inv,dinv);
358 ///////////////////////////////////////////////////////////////////////////
359 void AliTrack::SetCharge(Float_t q)
361 // Set the particle charge
364 ///////////////////////////////////////////////////////////////////////////
365 void AliTrack::Data(TString f,TString u)
367 // Provide track information within the coordinate frame f
369 // The string argument "u" allows to choose between different angular units
370 // in case e.g. a spherical frame is selected.
371 // u = "rad" : angles provided in radians
372 // "deg" : angles provided in degrees
374 // The defaults are f="car" and u="rad".
376 Double_t m=GetMass();
377 Double_t dm=GetResultError();
378 const char* name=GetName();
379 const char* title=GetTitle();
381 cout << " *" << ClassName() << "::Data*";
382 if (strlen(name)) cout << " Name : " << name;
383 if (strlen(title)) cout << " Title : " << title;
385 if (fTstamp) fTstamp->Date(1);
386 cout << " Id : " << fUserId << " Code : " << fCode
387 << " m : " << m << " dm : " << dm << " Charge : " << fQ
388 << " p : " << GetMomentum() << endl;
389 cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
390 << " Nsignals : " << GetNsignals() << endl;
393 cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode()
394 << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge()
395 << " p : " << fParent->GetMomentum();
396 const char* pname=fParent->GetName();
397 const char* ptitle=fParent->GetTitle();
398 if (strlen(pname)) cout << " Name : " << pname;
399 if (strlen(ptitle)) cout << " Title : " << ptitle;
404 cout << " Fit details present in object of class " << fFit->ClassName() << endl;
405 if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1);
407 Ali4Vector::Data(f,u);
409 ///////////////////////////////////////////////////////////////////////////
410 void AliTrack::List(TString f,TString u)
412 // Provide current track and decay level 1 information within coordinate frame f
414 // The string argument "u" allows to choose between different angular units
415 // in case e.g. a spherical frame is selected.
416 // u = "rad" : angles provided in radians
417 // "deg" : angles provided in degrees
419 // The defaults are f="car" and u="rad".
421 Data(f,u); // Information of the current track
422 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
423 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
424 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
426 // Decay products of this track
428 for (Int_t id=1; id<=GetNdecay(); id++)
430 td=GetDecayTrack(id);
433 cout << " ---Level 1 sec. track no. " << id << endl;
438 cout << " *AliTrack::List* Error : Empty decay track slot." << endl;
442 ///////////////////////////////////////////////////////////////////////////
443 void AliTrack::ListAll(TString f,TString u)
445 // Provide complete track and decay information within the coordinate frame f
447 // The string argument "u" allows to choose between different angular units
448 // in case e.g. a spherical frame is selected.
449 // u = "rad" : angles provided in radians
450 // "deg" : angles provided in degrees
452 // The defaults are f="car" and u="rad".
454 Data(f,u); // Information of the current track
455 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
456 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
457 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
459 Int_t nhyp=GetNhypotheses();
462 cout << " List of the " << nhyp << " track hypotheses : " << endl;
463 for (Int_t ih=1; ih<=nhyp; ih++)
465 AliTrack* tx=GetTrackHypothesis(ih);
466 if (tx) tx->Data(f,u);
470 Int_t nsig=GetNsignals();
473 cout << " List of the corresponding slots for the " << nsig
474 << " related signals : " << endl;
478 for (Int_t is=1; is<=nsig; is++)
480 AliSignal* sx=GetSignal(is);
483 nrefs=sx->GetIndices(this,slotarr,0);
484 for (Int_t jref=0; jref<nrefs; jref++)
486 jslot=slotarr.At(jref);
497 Dumps(t,1,f,u); // Information of all decay products
499 //////////////////////////////////////////////////////////////////////////
500 void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u)
502 // Recursively provide the info of all decay levels of this track
504 for (Int_t id=1; id<=t->GetNdecay(); id++)
506 td=t->GetDecayTrack(id);
509 cout << " ---Level " << n << " sec. track no. " << id << endl;
512 Int_t nhyp=td->GetNhypotheses();
515 cout << " List of the " << nhyp << " track hypotheses : " << endl;
516 for (Int_t ih=1; ih<=nhyp; ih++)
518 AliTrack* tx=td->GetTrackHypothesis(ih);
519 if (tx) tx->Data(f,u);
523 Int_t nsig=td->GetNsignals();
526 cout << " List of the " << nsig << " related signals : " << endl;
527 for (Int_t is=1; is<=nsig; is++)
529 AliSignal* sx=td->GetSignal(is);
530 if (sx) sx->Data(f,u);
534 // Go for next decay level of this decay track recursively
539 cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl;
543 //////////////////////////////////////////////////////////////////////////
544 Double_t AliTrack::GetMomentum()
546 // Provide the value of the track 3-momentum.
547 // The error can be obtained by invoking GetResultError() after
548 // invokation of GetMomentum().
549 Double_t norm=fV.GetNorm();
550 fDresult=fV.GetResultError();
553 ///////////////////////////////////////////////////////////////////////////
554 Ali3Vector AliTrack::Get3Momentum() const
556 // Provide the track 3-momentum
557 return (Ali3Vector)Get3Vector();
559 ///////////////////////////////////////////////////////////////////////////
560 Double_t AliTrack::GetMass()
562 // Provide the particle mass.
563 // The error can be obtained by invoking GetResultError() after
564 // invokation of GetMass().
565 Double_t inv=GetInvariant();
566 Double_t dinv=GetResultError();
570 Double_t m=sqrt(inv);
571 if (m) dm=dinv/(2.*m);
577 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
578 cout << " Value 0 will be returned." << endl;
583 ///////////////////////////////////////////////////////////////////////////
584 Float_t AliTrack::GetCharge() const
586 // Provide the particle charge
589 ///////////////////////////////////////////////////////////////////////////
590 Double_t AliTrack::GetEnergy()
592 // Provide the particle's energy.
593 // The error can be obtained by invoking GetResultError() after
594 // invokation of GetEnergy().
595 Double_t E=GetScalar();
602 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
603 cout << " Value 0 will be returned." << endl;
607 ///////////////////////////////////////////////////////////////////////////
608 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
610 // Perform 2-body decay of current track
611 // m1 : mass of decay product 1
612 // m2 : mass of decay product 2
613 // thcms : cms theta decay angle (in rad.) of m1
614 // phicms : cms phi decay angle (in rad.) of m1
616 Double_t M=GetMass();
618 // Compute the 4-momenta of the decay products in the cms
619 // Note : p2=p1=pnorm for a 2-body decay
621 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
623 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
624 Double_t pnorm=(e1*e1)-(m1*m1);
639 p.SetVector(a,"sph");
642 pprim1.SetVector(e1,p);
643 pprim1.SetInvariant(m1*m1);
647 pprim2.SetVector(e2,p);
648 pprim2.SetInvariant(m2*m2);
650 // Determine boost parameters from the parent particle
651 Double_t E=GetEnergy();
659 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
660 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
662 // Enter the boosted data into the decay tracks array
668 fDecays=new TObjArray(2);
671 fDecays->Add(new AliTrack);
672 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
673 ((AliTrack*)fDecays->At(0))->SetMass(m1);
674 fDecays->Add(new AliTrack);
675 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
676 ((AliTrack*)fDecays->At(1))->SetMass(m2);
678 ///////////////////////////////////////////////////////////////////////////
679 Int_t AliTrack::GetNdecay() const
681 // Provide the number of decay produced tracks
683 if (fDecays) ndec=fDecays->GetEntries();
686 ///////////////////////////////////////////////////////////////////////////
687 AliTrack* AliTrack::GetDecayTrack(Int_t j) const
689 // Provide decay produced track number j
690 // Note : j=1 denotes the first decay track
693 cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
698 if ((j >= 1) && (j <= GetNdecay()))
700 return (AliTrack*)fDecays->At(j-1);
704 cout << " *AliTrack* decay track number : " << j << " out of range."
705 << " Ndec = " << GetNdecay() << endl;
710 ///////////////////////////////////////////////////////////////////////////
711 void AliTrack::RemoveDecays()
713 // Remove all decay tracks from this track.
720 ///////////////////////////////////////////////////////////////////////////
721 void AliTrack::AddSignal(AliSignal& s)
723 // Relate an AliSignal object to this track.
724 if (!fSignals) fSignals=new TObjArray(1);
726 // Check if this signal is already stored for this track
727 Int_t nsig=GetNsignals();
728 for (Int_t i=0; i<nsig; i++)
730 if (&s==fSignals->At(i)) return;
735 ///////////////////////////////////////////////////////////////////////////
736 void AliTrack::RemoveSignal(AliSignal& s)
738 // Remove related AliSignal object from this track.
741 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
742 if (test) fSignals->Compress();
745 ///////////////////////////////////////////////////////////////////////////
746 void AliTrack::RemoveSignals()
748 // Remove all related AliSignal objects from this track.
756 ///////////////////////////////////////////////////////////////////////////
757 Int_t AliTrack::GetNsignals() const
759 // Provide the number of related AliSignals.
761 if (fSignals) nsig=fSignals->GetEntries();
764 ///////////////////////////////////////////////////////////////////////////
765 AliSignal* AliTrack::GetSignal(Int_t j) const
767 // Provide the related AliSignal number j.
768 // Note : j=1 denotes the first signal.
771 cout << " *AliTrack::GetSignal* No signals present." << endl;
776 if ((j >= 1) && (j <= GetNsignals()))
778 return (AliSignal*)fSignals->At(j-1);
782 cout << " *AliTrack* signal number : " << j << " out of range."
783 << " Nsig = " << GetNsignals() << endl;
788 ///////////////////////////////////////////////////////////////////////////
789 void AliTrack::AddTrackHypothesis(AliTrack& t)
791 // Relate a track hypothesis to this track.
792 // Note : a private copy of the input track will be made via the Clone()
796 fHypotheses=new TObjArray(1);
797 fHypotheses->SetOwner();
799 fHypotheses->Add(t.Clone());
801 ///////////////////////////////////////////////////////////////////////////
802 void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
804 // Add a track hypothesis by explicitly setting the mass and probability.
805 // This will affect e.g. the hypothesis track's energy, since the momentum
806 // and all other attributes will be copied from the current track.
810 // prob=probalility m=mass value dm=error on the mass value.
811 // The default value for the mass error dm is 0.
815 t.RemoveTrackHypotheses();
817 t.SetTitle("Mass hypothesis");
820 AddTrackHypothesis(t);
822 ///////////////////////////////////////////////////////////////////////////
823 void AliTrack::RemoveTrackHypothesis(AliTrack& t)
825 // Remove the specified track hypothesis from this track.
828 AliTrack* test=(AliTrack*)fHypotheses->Remove(&t);
829 if (test) fHypotheses->Compress();
832 ///////////////////////////////////////////////////////////////////////////
833 void AliTrack::RemoveTrackHypotheses()
835 // Remove all track hypotheses from this track.
842 ///////////////////////////////////////////////////////////////////////////
843 Int_t AliTrack::GetNhypotheses() const
845 // Provide the number of track hypotheses.
847 if (fHypotheses) nhyp=fHypotheses->GetEntries();
850 ///////////////////////////////////////////////////////////////////////////
851 AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const
853 // Provide the j-th track hypothesis.
854 // Note : j=1 denotes the first hypothesis.
855 // Default : j=0 ==> Hypothesis with highest probability.
857 if (!fHypotheses) return 0;
859 Int_t nhyp=GetNhypotheses();
861 // Check validity of index j
864 cout << " *AliTrack* hypothesis number : " << j << " out of range."
865 << " Nhyp = " << nhyp << endl;
871 if (j==0) // Provide track hypothesis with highest probability
874 t=(AliTrack*)fHypotheses->At(0);
875 if (t) prob=t->GetProb();
877 for (Int_t ih=1; ih<nhyp; ih++)
879 AliTrack* tx=(AliTrack*)fHypotheses->At(ih);
883 if (probx > prob) t=tx;
888 else // Provide requested j-th track hypothesis
890 return (AliTrack*)fHypotheses->At(j-1);
893 ///////////////////////////////////////////////////////////////////////////
894 void AliTrack::SetBeginPoint(AliPosition& p)
896 // Store the position of the track begin-point.
897 if (fBegin) delete fBegin;
898 fBegin=new AliPositionObj(p);
900 ///////////////////////////////////////////////////////////////////////////
901 AliPosition* AliTrack::GetBeginPoint()
903 // Provide the position of the track begin-point.
906 ///////////////////////////////////////////////////////////////////////////
907 void AliTrack::SetEndPoint(AliPosition& p)
909 // Store the position of the track end-point.
910 if (fEnd) delete fEnd;
911 fEnd=new AliPositionObj(p);
913 ///////////////////////////////////////////////////////////////////////////
914 AliPosition* AliTrack::GetEndPoint()
916 // Provide the position of the track end-point.
919 ///////////////////////////////////////////////////////////////////////////
920 void AliTrack::SetReferencePoint(AliPosition& p)
922 // Store the position of the track reference-point.
923 // The reference-point is the point on the track in which the
924 // 3-momentum vector components have been defined.
925 // This reference point is the preferable point to start track extrapolations
926 // etc... which are sensitive to the components of the 3-momentum vector.
927 if (fRef) delete fRef;
928 fRef=new AliPositionObj(p);
930 ///////////////////////////////////////////////////////////////////////////
931 AliPosition* AliTrack::GetReferencePoint()
933 // Provide the position of the track reference-point.
934 // The reference-point is the point on the track in which the
935 // 3-momentum vector components have been defined.
936 // This reference point is the preferable point to start track extrapolations
937 // etc... which are sensitive to the components of the 3-momentum vector.
940 ///////////////////////////////////////////////////////////////////////////
941 void AliTrack::SetMass()
943 // Set the mass and error to the value of the hypothesis with highest prob.
947 // Select mass hypothesis with highest probability
948 AliTrack* t=GetTrackHypothesis(0);
952 dm=t->GetResultError();
957 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
960 ///////////////////////////////////////////////////////////////////////////
961 Double_t AliTrack::GetPt()
963 // Provide trans. momentum value w.r.t. z-axis.
964 // The error on the value can be obtained by GetResultError()
965 // after invokation of GetPt().
968 Double_t norm=v.GetNorm();
969 fDresult=v.GetResultError();
973 ///////////////////////////////////////////////////////////////////////////
974 Double_t AliTrack::GetPl()
976 // Provide long. momentum value w.r.t. z-axis.
977 // Note : the returned value can also be negative.
978 // The error on the value can be obtained by GetResultError()
979 // after invokation of GetPl().
983 Double_t pl=v.GetNorm();
984 fDresult=v.GetResultError();
987 v.GetVector(a,"sph");
988 if (cos(a[1])<0) pl=-pl;
992 ///////////////////////////////////////////////////////////////////////////
993 Double_t AliTrack::GetEt()
995 // Provide trans. energy value w.r.t. z-axis.
996 // The error on the value can be obtained by GetResultError()
997 // after invokation of GetEt().
998 Double_t et=GetScaTrans();
1002 ///////////////////////////////////////////////////////////////////////////
1003 Double_t AliTrack::GetEl()
1005 // Provide long. energy value w.r.t. z-axis.
1006 // Note : the returned value can also be negative.
1007 // The error on the value can be obtained by GetResultError()
1008 // after invokation of GetEl().
1009 Double_t el=GetScaLong();
1013 ///////////////////////////////////////////////////////////////////////////
1014 Double_t AliTrack::GetMt()
1016 // Provide transverse mass value w.r.t. z-axis.
1017 // The error on the value can be obtained by GetResultError()
1018 // after invokation of GetMt().
1019 Double_t pt=GetPt();
1020 Double_t dpt=GetResultError();
1021 Double_t m=GetMass();
1022 Double_t dm=GetResultError();
1024 Double_t mt=sqrt(pt*pt+m*m);
1026 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
1028 fDresult=sqrt(dmt2);
1031 ///////////////////////////////////////////////////////////////////////////
1032 Double_t AliTrack::GetRapidity()
1034 // Provide rapidity value w.r.t. z-axis.
1035 // The error on the value can be obtained by GetResultError()
1036 // after invokation of GetRapidity().
1037 // Note : Also GetPseudoRapidity() is available since this class is
1038 // derived from Ali4Vector.
1039 Double_t e=GetEnergy();
1040 Double_t de=GetResultError();
1041 Double_t pl=GetPl();
1042 Double_t dpl=GetResultError();
1046 Double_t y=9999,dy2=0;
1047 if (sum && dif) y=0.5*log(sum/dif);
1049 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
1054 ///////////////////////////////////////////////////////////////////////////
1055 void AliTrack::SetImpactPoint(AliPosition& p,TString q)
1057 // Store the position of the impact-point in the plane "q=0".
1058 // Here q denotes one of the axes X, Y or Z.
1059 // Note : The character to denote the axis may be entered in lower or
1062 if (q=="x" || q=="X") axis=1;
1063 if (q=="y" || q=="Y") axis=2;
1064 if (q=="z" || q=="Z") axis=3;
1068 case 1: // Impact-point in the plane X=0
1069 if (fImpactYZ) delete fImpactYZ;
1070 fImpactYZ=new AliPositionObj(p);
1073 case 2: // Impact-point in the plane Y=0
1074 if (fImpactXZ) delete fImpactXZ;
1075 fImpactXZ=new AliPositionObj(p);
1078 case 3: // Impact-point in the plane Z=0
1079 if (fImpactXY) delete fImpactXY;
1080 fImpactXY=new AliPositionObj(p);
1083 default: // Unsupported axis
1084 cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
1085 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1089 ///////////////////////////////////////////////////////////////////////////
1090 AliPosition* AliTrack::GetImpactPoint(TString q)
1092 // Provide the position of the impact-point in the plane "q=0".
1093 // Here q denotes one of the axes X, Y or Z.
1094 // Note : The character to denote the axis may be entered in lower or
1097 if (q=="x" || q=="X") axis=1;
1098 if (q=="y" || q=="Y") axis=2;
1099 if (q=="z" || q=="Z") axis=3;
1103 case 1: // Impact-point in the plane X=0
1106 case 2: // Impact-point in the plane Y=0
1109 case 3: // Impact-point in the plane Z=0
1112 default: // Unsupported axis
1113 cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
1114 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1118 ///////////////////////////////////////////////////////////////////////////
1119 void AliTrack::SetId(Int_t id)
1121 // Set a user defined unique identifier for this track.
1124 ///////////////////////////////////////////////////////////////////////////
1125 Int_t AliTrack::GetId() const
1127 // Provide the user defined unique identifier of this track.
1130 ///////////////////////////////////////////////////////////////////////////
1131 void AliTrack::SetClosestPoint(AliPosition& p)
1133 // Set position p as the point of closest approach w.r.t. some reference
1134 if (fClosest) delete fClosest;
1135 fClosest=new AliPositionObj(p);
1137 ///////////////////////////////////////////////////////////////////////////
1138 AliPosition* AliTrack::GetClosestPoint()
1140 // Provide the point of closest approach w.r.t. some reference
1143 ///////////////////////////////////////////////////////////////////////////
1144 void AliTrack::SetChi2(Float_t chi2)
1146 // Set the chi-squared value of the track fit.
1149 cout << " *AliTrack::SetChi2* Invalid chi2 value : " << chi2 << endl;
1156 ///////////////////////////////////////////////////////////////////////////
1157 void AliTrack::SetNdf(Int_t ndf)
1159 // Set the number of degrees of freedom for the track fit.
1162 cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl;
1169 ///////////////////////////////////////////////////////////////////////////
1170 Float_t AliTrack::GetChi2() const
1172 // Provide the chi-squared value of the track fit.
1175 ///////////////////////////////////////////////////////////////////////////
1176 Int_t AliTrack::GetNdf() const
1178 // Provide the number of degrees of freedom for the track fit.
1181 ///////////////////////////////////////////////////////////////////////////
1182 void AliTrack::SetParticleCode(Int_t code)
1184 // Set the user defined particle id code (e.g. the PDF convention).
1187 ///////////////////////////////////////////////////////////////////////////
1188 Int_t AliTrack::GetParticleCode() const
1190 // Provide the user defined particle id code.
1193 ///////////////////////////////////////////////////////////////////////////
1194 void AliTrack::SetParentTrack(AliTrack* t)
1196 // Set pointer to the parent track.
1199 ///////////////////////////////////////////////////////////////////////////
1200 AliTrack* AliTrack::GetParentTrack()
1202 // Provide pointer to the parent track.
1205 ///////////////////////////////////////////////////////////////////////////
1206 void AliTrack::SetProb(Double_t prob)
1208 // Set hypothesis probability for this track.
1211 ///////////////////////////////////////////////////////////////////////////
1212 Float_t AliTrack::GetProb() const
1214 // Provide the hypothesis probability for this track.
1217 ///////////////////////////////////////////////////////////////////////////
1218 void AliTrack::SetFitDetails(TObject* obj)
1220 // Enter the object containing the fit details.
1221 // In case an object to hold fit details was already present, this
1222 // will be deleted first before the new one is stored.
1223 // This means that SetFitDetails(0) can be used to just remove the
1224 // existing object with the fit details.
1225 // All objects derived from TObject can be entered in this way.
1226 // Obvious candidates for objects containing detailed fit information
1227 // are functions (e.g. TF1) and histograms (e.g. TH1F).
1228 // However, using an AliDevice object provides a very versatile facility
1229 // to store the parameters of various fit procedures.
1230 // In such a case the AliDevice can be used to provide the various fit
1231 // definitions and the corresponding fit parameters can be entered as
1232 // separate AliSignal objects which are stored as hits to the AliDevice.
1233 // In addition various functions and histograms can be linked to the
1234 // various AliSignal instances
1235 // The latter procedure is based on the original idea of Adam Bouchta.
1237 // Note : The entered object is owned by this AliTrack instance.
1238 // As such, a private copy of obj will be stored using the Clone()
1240 // In case the entered object contains pointers to other objects,
1241 // the user has to provide the appropriate Clone() memberfunction
1242 // for the class to which the entered object belongs.
1243 // An example can be seen from AliTrack::Clone().
1251 if (obj) fFit=obj->Clone();
1253 ///////////////////////////////////////////////////////////////////////////
1254 TObject* AliTrack::GetFitDetails()
1256 // Provide the pointer to the object containing the fit details.
1259 ///////////////////////////////////////////////////////////////////////////
1260 void AliTrack::SetTimestamp(AliTimestamp& t)
1262 // Store the timestamp for this track.
1263 if (fTstamp) delete fTstamp;
1264 fTstamp=new AliTimestamp(t);
1266 ///////////////////////////////////////////////////////////////////////////
1267 AliTimestamp* AliTrack::GetTimestamp()
1269 // Provide the timestamp of this track.
1272 ///////////////////////////////////////////////////////////////////////////
1273 void AliTrack::RemoveTimestamp()
1275 // Remove the timestamp from this track.
1282 ///////////////////////////////////////////////////////////////////////////
1283 Double_t AliTrack::GetDistance(AliPosition* p)
1285 // Provide distance of the current track to the position p.
1286 // The error on the result can be obtained as usual by invoking
1287 // GetResultError() afterwards.
1289 // The distance will be provided in the unit scale of the AliPosition p.
1290 // As such it is possible to obtain a correctly computed distance even in case
1291 // the track parameters have a different unit scale.
1292 // However, it is recommended to work always with one single unit scale.
1294 // Note : In case of incomplete information, a distance value of -1 is
1300 if (!p) return dist;
1302 // Obtain a defined position on this track
1303 AliPosition* rx=fRef;
1307 if (!rx) return dist;
1309 Ali3Vector r0=(Ali3Vector)(*rx);
1311 Float_t tscale=rx->GetUnitScale();
1312 Float_t pscale=p->GetUnitScale();
1313 if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale);
1315 // Obtain the direction unit vector of this track
1318 Ali3Vector p1=Get3Momentum();
1319 p1.GetVector(vec,"sph");
1320 p1.GetErrors(err,"sph");
1323 p1.SetVector(vec,"sph");
1324 p1.SetErrors(err,"sph");
1326 Ali3Vector q=(Ali3Vector)(*p);
1328 Ali3Vector d=r.Cross(p1);
1330 fDresult=d.GetResultError();
1333 ///////////////////////////////////////////////////////////////////////////
1334 TObject* AliTrack::Clone(const char* name) const
1336 // Make a deep copy of the current object and provide the pointer to the copy.
1337 // This memberfunction enables automatic creation of new objects of the
1338 // correct type depending on the object type, a feature which may be very useful
1339 // for containers when adding objects in case the container owns the objects.
1340 // This feature allows e.g. AliJet to store either AliTrack objects or
1341 // objects derived from AliTrack via the AddTrack memberfunction, provided
1342 // these derived classes also have a proper Clone memberfunction.
1344 AliTrack* trk=new AliTrack(*this);
1347 if (strlen(name)) trk->SetName(name);
1351 ///////////////////////////////////////////////////////////////////////////