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 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++)
131 AliSignal* s=GetSignal(i);
132 if (s) s->RemoveTrack(*this,0);
196 ///////////////////////////////////////////////////////////////////////////
197 AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
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));
219 Int_t ndec=t.GetNdecay();
222 fDecays=new TObjArray(ndec);
224 for (Int_t it=1; it<=ndec; it++)
226 AliTrack* tx=t.GetDecayTrack(it);
227 fDecays->Add(new AliTrack(*tx));
231 Int_t nsig=t.GetNsignals();
234 fSignals=new TObjArray(nsig);
235 for (Int_t is=1; is<=nsig; is++)
237 AliSignal* sx=t.GetSignal(is);
242 Int_t nhyp=t.GetNhypotheses();
245 fHypotheses=new TObjArray(nhyp);
246 fHypotheses->SetOwner();
247 for (Int_t ih=1; ih<=nhyp; ih++)
249 AliTrack* tx=t.GetTrackHypothesis(ih);
250 fHypotheses->Add(new AliTrack(*tx));
254 ///////////////////////////////////////////////////////////////////////////
255 void AliTrack::Reset()
257 // Reset all variables to 0 and delete all auto-generated decay tracks.
264 Double_t a[4]={0,0,0,0};
328 ///////////////////////////////////////////////////////////////////////////
329 void AliTrack::Set3Momentum(Ali3Vector& p)
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.
334 Double_t inv=GetInvariant();
335 if (inv<0) SetMass(0.);
337 ///////////////////////////////////////////////////////////////////////////
338 void AliTrack::Set4Momentum(Ali4Vector& p)
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();
347 ///////////////////////////////////////////////////////////////////////////
348 void AliTrack::SetMass(Double_t m,Double_t dm)
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);
356 ///////////////////////////////////////////////////////////////////////////
357 void AliTrack::SetCharge(Float_t q)
359 // Set the particle charge
362 ///////////////////////////////////////////////////////////////////////////
363 void AliTrack::Data(TString f,TString u)
365 // Provide track information within the coordinate frame f
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
372 // The defaults are f="car" and u="rad".
374 Double_t m=GetMass();
375 Double_t dm=GetResultError();
376 const char* name=GetName();
377 const char* title=GetTitle();
379 cout << " *" << ClassName() << "::Data*";
380 if (strlen(name)) cout << " Name : " << name;
381 if (strlen(title)) cout << " Title : " << title;
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;
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;
402 cout << " Fit details present in object of class " << fFit->ClassName() << endl;
403 if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1);
405 Ali4Vector::Data(f,u);
407 ///////////////////////////////////////////////////////////////////////////
408 void AliTrack::List(TString f,TString u)
410 // Provide current track and decay level 1 information within coordinate frame f
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
417 // The defaults are f="car" and u="rad".
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); }
424 // Decay products of this track
426 for (Int_t id=1; id<=GetNdecay(); id++)
428 td=GetDecayTrack(id);
431 cout << " ---Level 1 sec. track no. " << id << endl;
436 cout << " *AliTrack::List* Error : Empty decay track slot." << endl;
440 ///////////////////////////////////////////////////////////////////////////
441 void AliTrack::ListAll(TString f,TString u)
443 // Provide complete track and decay information within the coordinate frame f
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
450 // The defaults are f="car" and u="rad".
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); }
457 Int_t nhyp=GetNhypotheses();
460 cout << " List of the " << nhyp << " track hypotheses : " << endl;
461 for (Int_t ih=1; ih<=nhyp; ih++)
463 AliTrack* tx=GetTrackHypothesis(ih);
464 if (tx) tx->Data(f,u);
468 Int_t nsig=GetNsignals();
471 cout << " List of the corresponding slots for the " << nsig
472 << " related signals : " << endl;
476 for (Int_t is=1; is<=nsig; is++)
478 AliSignal* sx=GetSignal(is);
481 nrefs=sx->GetIndices(this,slotarr,0);
482 for (Int_t jref=0; jref<nrefs; jref++)
484 jslot=slotarr.At(jref);
495 Dumps(t,1,f,u); // Information of all decay products
497 //////////////////////////////////////////////////////////////////////////
498 void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u)
500 // Recursively provide the info of all decay levels of this track
502 for (Int_t id=1; id<=t->GetNdecay(); id++)
504 td=t->GetDecayTrack(id);
507 cout << " ---Level " << n << " sec. track no. " << id << endl;
510 Int_t nhyp=td->GetNhypotheses();
513 cout << " List of the " << nhyp << " track hypotheses : " << endl;
514 for (Int_t ih=1; ih<=nhyp; ih++)
516 AliTrack* tx=td->GetTrackHypothesis(ih);
517 if (tx) tx->Data(f,u);
521 Int_t nsig=td->GetNsignals();
524 cout << " List of the " << nsig << " related signals : " << endl;
525 for (Int_t is=1; is<=nsig; is++)
527 AliSignal* sx=td->GetSignal(is);
528 if (sx) sx->Data(f,u);
532 // Go for next decay level of this decay track recursively
537 cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl;
541 //////////////////////////////////////////////////////////////////////////
542 Double_t AliTrack::GetMomentum()
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();
551 ///////////////////////////////////////////////////////////////////////////
552 Ali3Vector AliTrack::Get3Momentum() const
554 // Provide the track 3-momentum
555 return (Ali3Vector)Get3Vector();
557 ///////////////////////////////////////////////////////////////////////////
558 Double_t AliTrack::GetMass()
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();
568 Double_t m=sqrt(inv);
569 if (m) dm=dinv/(2.*m);
575 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
576 cout << " Value 0 will be returned." << endl;
581 ///////////////////////////////////////////////////////////////////////////
582 Float_t AliTrack::GetCharge() const
584 // Provide the particle charge
587 ///////////////////////////////////////////////////////////////////////////
588 Double_t AliTrack::GetEnergy()
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();
600 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
601 cout << " Value 0 will be returned." << endl;
605 ///////////////////////////////////////////////////////////////////////////
606 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
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
614 Double_t M=GetMass();
616 // Compute the 4-momenta of the decay products in the cms
617 // Note : p2=p1=pnorm for a 2-body decay
619 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
621 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
622 Double_t pnorm=(e1*e1)-(m1*m1);
637 p.SetVector(a,"sph");
640 pprim1.SetVector(e1,p);
641 pprim1.SetInvariant(m1*m1);
645 pprim2.SetVector(e2,p);
646 pprim2.SetInvariant(m2*m2);
648 // Determine boost parameters from the parent particle
649 Double_t E=GetEnergy();
657 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
658 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
660 // Enter the boosted data into the decay tracks array
666 fDecays=new TObjArray(2);
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);
676 ///////////////////////////////////////////////////////////////////////////
677 Int_t AliTrack::GetNdecay() const
679 // Provide the number of decay produced tracks
681 if (fDecays) ndec=fDecays->GetEntries();
684 ///////////////////////////////////////////////////////////////////////////
685 AliTrack* AliTrack::GetDecayTrack(Int_t j) const
687 // Provide decay produced track number j
688 // Note : j=1 denotes the first decay track
691 cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
696 if ((j >= 1) && (j <= GetNdecay()))
698 return (AliTrack*)fDecays->At(j-1);
702 cout << " *AliTrack* decay track number : " << j << " out of range."
703 << " Ndec = " << GetNdecay() << endl;
708 ///////////////////////////////////////////////////////////////////////////
709 void AliTrack::RemoveDecays()
711 // Remove all decay tracks from this track.
718 ///////////////////////////////////////////////////////////////////////////
719 void AliTrack::AddSignal(AliSignal& s,Int_t mode)
721 // Relate an AliSignal object to this track.
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
730 // The default is mode=0.
732 if (!fSignals) fSignals=new TObjArray(1);
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++)
738 if (&s==fSignals->At(i)) return;
742 if (mode==1) s.AddTrack(*this,0);
744 ///////////////////////////////////////////////////////////////////////////
745 void AliTrack::RemoveSignal(AliSignal& s,Int_t mode)
747 // Remove related AliSignal object from this track.
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
756 // The default is mode=1.
760 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
761 if (test) fSignals->Compress();
763 if (mode==1) s.RemoveTrack(*this,0);
765 ///////////////////////////////////////////////////////////////////////////
766 void AliTrack::RemoveSignals(Int_t mode)
768 // Remove all related AliSignal objects from this track.
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.
776 // The default is mode=1.
778 if (!fSignals) return;
780 Int_t ns=GetNsignals();
781 for (Int_t i=0; i<ns; i++)
783 AliSignal* sx=(AliSignal*)fSignals->At(i);
784 if (sx && mode==1) sx->RemoveTrack(*this,0);
790 ///////////////////////////////////////////////////////////////////////////
791 Int_t AliTrack::GetNsignals() const
793 // Provide the number of related AliSignals.
795 if (fSignals) nsig=fSignals->GetEntries();
798 ///////////////////////////////////////////////////////////////////////////
799 AliSignal* AliTrack::GetSignal(Int_t j) const
801 // Provide the related AliSignal number j.
802 // Note : j=1 denotes the first signal.
805 cout << " *AliTrack::GetSignal* No signals present." << endl;
810 if ((j >= 1) && (j <= GetNsignals()))
812 return (AliSignal*)fSignals->At(j-1);
816 cout << " *AliTrack* signal number : " << j << " out of range."
817 << " Nsig = " << GetNsignals() << endl;
822 ///////////////////////////////////////////////////////////////////////////
823 void AliTrack::AddTrackHypothesis(AliTrack& t)
825 // Relate a track hypothesis to this track.
826 // Note : a private copy of the input track will be made via the Clone()
830 fHypotheses=new TObjArray(1);
831 fHypotheses->SetOwner();
833 fHypotheses->Add(t.Clone());
835 ///////////////////////////////////////////////////////////////////////////
836 void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
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.
844 // prob=probalility m=mass value dm=error on the mass value.
845 // The default value for the mass error dm is 0.
849 t.RemoveTrackHypotheses();
851 t.SetTitle("Mass hypothesis");
854 AddTrackHypothesis(t);
856 ///////////////////////////////////////////////////////////////////////////
857 void AliTrack::RemoveTrackHypothesis(AliTrack& t)
859 // Remove the specified track hypothesis from this track.
862 AliTrack* test=(AliTrack*)fHypotheses->Remove(&t);
863 if (test) fHypotheses->Compress();
866 ///////////////////////////////////////////////////////////////////////////
867 void AliTrack::RemoveTrackHypotheses()
869 // Remove all track hypotheses from this track.
876 ///////////////////////////////////////////////////////////////////////////
877 Int_t AliTrack::GetNhypotheses() const
879 // Provide the number of track hypotheses.
881 if (fHypotheses) nhyp=fHypotheses->GetEntries();
884 ///////////////////////////////////////////////////////////////////////////
885 AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const
887 // Provide the j-th track hypothesis.
888 // Note : j=1 denotes the first hypothesis.
889 // Default : j=0 ==> Hypothesis with highest probability.
891 if (!fHypotheses) return 0;
893 Int_t nhyp=GetNhypotheses();
895 // Check validity of index j
898 cout << " *AliTrack* hypothesis number : " << j << " out of range."
899 << " Nhyp = " << nhyp << endl;
905 if (j==0) // Provide track hypothesis with highest probability
908 t=(AliTrack*)fHypotheses->At(0);
909 if (t) prob=t->GetProb();
911 for (Int_t ih=1; ih<nhyp; ih++)
913 AliTrack* tx=(AliTrack*)fHypotheses->At(ih);
917 if (probx > prob) t=tx;
922 else // Provide requested j-th track hypothesis
924 return (AliTrack*)fHypotheses->At(j-1);
927 ///////////////////////////////////////////////////////////////////////////
928 void AliTrack::SetBeginPoint(AliPosition& p)
930 // Store the position of the track begin-point.
931 if (fBegin) delete fBegin;
932 fBegin=new AliPositionObj(p);
934 ///////////////////////////////////////////////////////////////////////////
935 AliPosition* AliTrack::GetBeginPoint()
937 // Provide the position of the track begin-point.
940 ///////////////////////////////////////////////////////////////////////////
941 void AliTrack::SetEndPoint(AliPosition& p)
943 // Store the position of the track end-point.
944 if (fEnd) delete fEnd;
945 fEnd=new AliPositionObj(p);
947 ///////////////////////////////////////////////////////////////////////////
948 AliPosition* AliTrack::GetEndPoint()
950 // Provide the position of the track end-point.
953 ///////////////////////////////////////////////////////////////////////////
954 void AliTrack::SetReferencePoint(AliPosition& p)
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);
964 ///////////////////////////////////////////////////////////////////////////
965 AliPosition* AliTrack::GetReferencePoint()
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.
974 ///////////////////////////////////////////////////////////////////////////
975 void AliTrack::SetMass()
977 // Set the mass and error to the value of the hypothesis with highest prob.
981 // Select mass hypothesis with highest probability
982 AliTrack* t=GetTrackHypothesis(0);
986 dm=t->GetResultError();
991 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
994 ///////////////////////////////////////////////////////////////////////////
995 Double_t AliTrack::GetPt()
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().
1002 Double_t norm=v.GetNorm();
1003 fDresult=v.GetResultError();
1007 ///////////////////////////////////////////////////////////////////////////
1008 Double_t AliTrack::GetPl()
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().
1017 Double_t pl=v.GetNorm();
1018 fDresult=v.GetResultError();
1021 v.GetVector(a,"sph");
1022 if (cos(a[1])<0) pl=-pl;
1026 ///////////////////////////////////////////////////////////////////////////
1027 Double_t AliTrack::GetEt()
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();
1036 ///////////////////////////////////////////////////////////////////////////
1037 Double_t AliTrack::GetEl()
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();
1047 ///////////////////////////////////////////////////////////////////////////
1048 Double_t AliTrack::GetMt()
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();
1058 Double_t mt=sqrt(pt*pt+m*m);
1060 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
1062 fDresult=sqrt(dmt2);
1065 ///////////////////////////////////////////////////////////////////////////
1066 Double_t AliTrack::GetRapidity()
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();
1080 Double_t y=9999,dy2=0;
1081 if (sum && dif) y=0.5*log(sum/dif);
1083 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
1088 ///////////////////////////////////////////////////////////////////////////
1089 void AliTrack::SetImpactPoint(AliPosition& p,TString q)
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
1096 if (q=="x" || q=="X") axis=1;
1097 if (q=="y" || q=="Y") axis=2;
1098 if (q=="z" || q=="Z") axis=3;
1102 case 1: // Impact-point in the plane X=0
1103 if (fImpactYZ) delete fImpactYZ;
1104 fImpactYZ=new AliPositionObj(p);
1107 case 2: // Impact-point in the plane Y=0
1108 if (fImpactXZ) delete fImpactXZ;
1109 fImpactXZ=new AliPositionObj(p);
1112 case 3: // Impact-point in the plane Z=0
1113 if (fImpactXY) delete fImpactXY;
1114 fImpactXY=new AliPositionObj(p);
1117 default: // Unsupported axis
1118 cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
1119 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1123 ///////////////////////////////////////////////////////////////////////////
1124 AliPosition* AliTrack::GetImpactPoint(TString q)
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
1131 if (q=="x" || q=="X") axis=1;
1132 if (q=="y" || q=="Y") axis=2;
1133 if (q=="z" || q=="Z") axis=3;
1137 case 1: // Impact-point in the plane X=0
1140 case 2: // Impact-point in the plane Y=0
1143 case 3: // Impact-point in the plane Z=0
1146 default: // Unsupported axis
1147 cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
1148 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1152 ///////////////////////////////////////////////////////////////////////////
1153 void AliTrack::SetId(Int_t id)
1155 // Set a user defined unique identifier for this track.
1158 ///////////////////////////////////////////////////////////////////////////
1159 Int_t AliTrack::GetId() const
1161 // Provide the user defined unique identifier of this track.
1164 ///////////////////////////////////////////////////////////////////////////
1165 void AliTrack::SetClosestPoint(AliPosition& p)
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);
1171 ///////////////////////////////////////////////////////////////////////////
1172 AliPosition* AliTrack::GetClosestPoint()
1174 // Provide the point of closest approach w.r.t. some reference
1177 ///////////////////////////////////////////////////////////////////////////
1178 void AliTrack::SetChi2(Float_t chi2)
1180 // Set the chi-squared value of the track fit.
1183 cout << " *AliTrack::SetChi2* Invalid chi2 value : " << chi2 << endl;
1190 ///////////////////////////////////////////////////////////////////////////
1191 void AliTrack::SetNdf(Int_t ndf)
1193 // Set the number of degrees of freedom for the track fit.
1196 cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl;
1203 ///////////////////////////////////////////////////////////////////////////
1204 Float_t AliTrack::GetChi2() const
1206 // Provide the chi-squared value of the track fit.
1209 ///////////////////////////////////////////////////////////////////////////
1210 Int_t AliTrack::GetNdf() const
1212 // Provide the number of degrees of freedom for the track fit.
1215 ///////////////////////////////////////////////////////////////////////////
1216 void AliTrack::SetParticleCode(Int_t code)
1218 // Set the user defined particle id code (e.g. the PDF convention).
1221 ///////////////////////////////////////////////////////////////////////////
1222 Int_t AliTrack::GetParticleCode() const
1224 // Provide the user defined particle id code.
1227 ///////////////////////////////////////////////////////////////////////////
1228 void AliTrack::SetParentTrack(AliTrack* t)
1230 // Set pointer to the parent track.
1233 ///////////////////////////////////////////////////////////////////////////
1234 AliTrack* AliTrack::GetParentTrack()
1236 // Provide pointer to the parent track.
1239 ///////////////////////////////////////////////////////////////////////////
1240 void AliTrack::SetProb(Double_t prob)
1242 // Set hypothesis probability for this track.
1245 ///////////////////////////////////////////////////////////////////////////
1246 Float_t AliTrack::GetProb() const
1248 // Provide the hypothesis probability for this track.
1251 ///////////////////////////////////////////////////////////////////////////
1252 void AliTrack::SetFitDetails(TObject* obj)
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.
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()
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().
1285 if (obj) fFit=obj->Clone();
1287 ///////////////////////////////////////////////////////////////////////////
1288 TObject* AliTrack::GetFitDetails()
1290 // Provide the pointer to the object containing the fit details.
1293 ///////////////////////////////////////////////////////////////////////////
1294 void AliTrack::SetTimestamp(AliTimestamp& t)
1296 // Store the timestamp for this track.
1297 if (fTstamp) delete fTstamp;
1298 fTstamp=new AliTimestamp(t);
1300 ///////////////////////////////////////////////////////////////////////////
1301 AliTimestamp* AliTrack::GetTimestamp()
1303 // Provide the timestamp of this track.
1306 ///////////////////////////////////////////////////////////////////////////
1307 void AliTrack::RemoveTimestamp()
1309 // Remove the timestamp from this track.
1316 ///////////////////////////////////////////////////////////////////////////
1317 Double_t AliTrack::GetDistance(AliPosition* p)
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.
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.
1328 // Note : In case of incomplete information, a distance value of -1 is
1334 if (!p) return dist;
1336 // Obtain a defined position on this track
1337 AliPosition* rx=fRef;
1341 if (!rx) return dist;
1343 Ali3Vector p1=Get3Momentum();
1345 if (p1.GetNorm() <= 0.) return dist;
1347 Ali3Vector r0=(Ali3Vector)(*rx);
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);
1353 // Obtain the direction unit vector of this track
1356 p1.GetVector(vec,"sph");
1357 p1.GetErrors(err,"sph");
1360 p1.SetVector(vec,"sph");
1361 p1.SetErrors(err,"sph");
1363 Ali3Vector q=(Ali3Vector)(*p);
1365 Ali3Vector d=r.Cross(p1);
1367 fDresult=d.GetResultError();
1370 ///////////////////////////////////////////////////////////////////////////
1371 Double_t AliTrack::GetDistance(AliTrack* t)
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.
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.
1384 // Note : In case of incomplete information, a distance value of -1 is
1390 if (!t) return dist;
1392 // Obtain a defined position on this track
1393 AliPosition* rx=fRef;
1397 if (!rx) return dist;
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();
1404 if (!ry) return dist;
1406 Ali3Vector p1=Get3Momentum();
1407 Ali3Vector p2=t->Get3Momentum();
1409 if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist;
1411 // The vector normal to both track directions
1412 Ali3Vector n=p1.Cross(p2);
1414 if (n.GetNorm() > 1.e-10)
1416 // Normalise n to a unit vector
1419 n.GetVector(vec,"sph");
1420 n.GetErrors(err,"sph");
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);
1432 dist=fabs(r.Dot(n));
1433 fDresult=r.GetResultError();
1435 else // Parallel tracks
1437 dist=t->GetDistance(rx);
1438 fDresult=t->GetResultError();
1442 ///////////////////////////////////////////////////////////////////////////
1443 TObject* AliTrack::Clone(const char* name) const
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.
1453 AliTrack* trk=new AliTrack(*this);
1456 if (strlen(name)) trk->SetName(name);
1460 ///////////////////////////////////////////////////////////////////////////