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 : By default all quantities are in GeV, GeV/c or GeV/c**2
87 // but the user can indicate the usage of a different scale
88 // for the energy-momentum units via the SetEscale() memberfunction.
89 // The actual energy-momentum unit scale can be obtained via the
90 // GetEscale() memberfunction.
92 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
93 //- Modified: NvE $Date$ UU-SAP Utrecht
94 ///////////////////////////////////////////////////////////////////////////
97 #include "Riostream.h"
99 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
101 AliTrack::AliTrack() : TNamed(),Ali4Vector()
103 // Default constructor
104 // All variables initialised to 0
108 ///////////////////////////////////////////////////////////////////////////
109 void AliTrack::Init()
111 // Initialisation of pointers etc...
127 ///////////////////////////////////////////////////////////////////////////
128 AliTrack::~AliTrack()
130 // Destructor to delete memory allocated for decay tracks array.
131 // This destructor automatically cleares all references to this AliTrack
132 // from all the related AliSignal objects.
133 Int_t nsig=GetNsignals();
134 for (Int_t i=1; i<=nsig; i++)
136 AliSignal* s=GetSignal(i);
137 if (s) s->RemoveTrack(*this,0);
201 ///////////////////////////////////////////////////////////////////////////
202 AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
209 if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin));
210 if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd));
211 if (t.fRef) fRef=new AliPositionObj(*(t.fRef));
212 if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY));
213 if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ));
214 if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ));
215 if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest));
216 if (t.fFit) fFit=t.fFit->Clone();
217 if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp));
223 Int_t ndec=t.GetNdecay();
226 fDecays=new TObjArray(ndec);
228 for (Int_t it=1; it<=ndec; it++)
230 AliTrack* tx=t.GetDecayTrack(it);
231 fDecays->Add(new AliTrack(*tx));
235 Int_t nsig=t.GetNsignals();
238 fSignals=new TObjArray(nsig);
239 for (Int_t is=1; is<=nsig; is++)
241 AliSignal* sx=t.GetSignal(is);
246 Int_t nhyp=t.GetNhypotheses();
249 fHypotheses=new TObjArray(nhyp);
250 fHypotheses->SetOwner();
251 for (Int_t ih=1; ih<=nhyp; ih++)
253 AliTrack* tx=t.GetTrackHypothesis(ih);
254 fHypotheses->Add(new AliTrack(*tx));
258 ///////////////////////////////////////////////////////////////////////////
259 void AliTrack::Reset()
261 // Reset all variables to 0 and delete all auto-generated decay tracks.
262 // Note : The scale for the energy/momentum units will not be changed.
267 Double_t a[4]={0,0,0,0};
331 ///////////////////////////////////////////////////////////////////////////
332 void AliTrack::Set3Momentum(Ali3Vector& p)
334 // Set the track parameters according to the 3-momentum p.
335 // In case the mass was not yet set, the energy is set to correspond to m=0.
337 Double_t inv=GetInvariant();
338 if (inv<0) SetMass(0.);
340 ///////////////////////////////////////////////////////////////////////////
341 void AliTrack::Set4Momentum(Ali4Vector& p)
343 // Set the track parameters according to the 4-momentum p
344 Double_t E=p.GetScalar();
345 Double_t dE=p.GetResultError();
346 Ali3Vector pv=p.Get3Vector();
350 ///////////////////////////////////////////////////////////////////////////
351 void AliTrack::SetMass(Double_t m,Double_t dm)
353 // Set the particle mass
354 // The default value for the error dm is 0.
355 Double_t inv=pow(m,2);
356 Double_t dinv=fabs(2.*m*dm);
357 SetInvariant(inv,dinv);
359 ///////////////////////////////////////////////////////////////////////////
360 void AliTrack::SetCharge(Float_t q)
362 // Set the particle charge
365 ///////////////////////////////////////////////////////////////////////////
366 void AliTrack::Data(TString f,TString u)
368 // Provide track information within the coordinate frame f
370 // The string argument "u" allows to choose between different angular units
371 // in case e.g. a spherical frame is selected.
372 // u = "rad" : angles provided in radians
373 // "deg" : angles provided in degrees
375 // The defaults are f="car" and u="rad".
377 Double_t m=GetMass();
378 Double_t dm=GetResultError();
379 const char* name=GetName();
380 const char* title=GetTitle();
382 cout << " *" << ClassName() << "::Data*";
383 if (strlen(name)) cout << " Name : " << name;
384 if (strlen(title)) cout << " Title : " << title;
386 if (fTstamp) fTstamp->Date(1);
387 cout << " Id : " << fUserId << " Code : " << fCode
388 << " m : " << m << " dm : " << dm << " Charge : " << fQ
389 << " p : " << GetMomentum() << endl;
390 cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
391 << " Nsignals : " << GetNsignals() << " Energy scale : " << fEscale << " GeV" << endl;
394 cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode()
395 << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge()
396 << " p : " << fParent->GetMomentum();
397 const char* pname=fParent->GetName();
398 const char* ptitle=fParent->GetTitle();
399 if (strlen(pname)) cout << " Name : " << pname;
400 if (strlen(ptitle)) cout << " Title : " << ptitle;
405 cout << " Fit details present in object of class " << fFit->ClassName() << endl;
406 if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1);
408 Ali4Vector::Data(f,u);
410 ///////////////////////////////////////////////////////////////////////////
411 void AliTrack::List(TString f,TString u)
413 // Provide current track and decay level 1 information within coordinate frame f
415 // The string argument "u" allows to choose between different angular units
416 // in case e.g. a spherical frame is selected.
417 // u = "rad" : angles provided in radians
418 // "deg" : angles provided in degrees
420 // The defaults are f="car" and u="rad".
422 Data(f,u); // Information of the current track
423 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
424 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
425 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
427 // Decay products of this track
429 for (Int_t id=1; id<=GetNdecay(); id++)
431 td=GetDecayTrack(id);
434 cout << " ---Level 1 sec. track no. " << id << endl;
439 cout << " *AliTrack::List* Error : Empty decay track slot." << endl;
443 ///////////////////////////////////////////////////////////////////////////
444 void AliTrack::ListAll(TString f,TString u)
446 // Provide complete track and decay information within the coordinate frame f
448 // The string argument "u" allows to choose between different angular units
449 // in case e.g. a spherical frame is selected.
450 // u = "rad" : angles provided in radians
451 // "deg" : angles provided in degrees
453 // The defaults are f="car" and u="rad".
455 Data(f,u); // Information of the current track
456 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
457 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
458 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
460 Int_t nhyp=GetNhypotheses();
463 cout << " List of the " << nhyp << " track hypotheses : " << endl;
464 for (Int_t ih=1; ih<=nhyp; ih++)
466 AliTrack* tx=GetTrackHypothesis(ih);
467 if (tx) tx->Data(f,u);
471 Int_t nsig=GetNsignals();
474 cout << " List of the corresponding slots for the " << nsig
475 << " related signals : " << endl;
479 for (Int_t is=1; is<=nsig; is++)
481 AliSignal* sx=GetSignal(is);
484 nrefs=sx->GetIndices(this,slotarr,0);
485 for (Int_t jref=0; jref<nrefs; jref++)
487 jslot=slotarr.At(jref);
498 Dumps(t,1,f,u); // Information of all decay products
500 //////////////////////////////////////////////////////////////////////////
501 void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u)
503 // Recursively provide the info of all decay levels of this track
505 for (Int_t id=1; id<=t->GetNdecay(); id++)
507 td=t->GetDecayTrack(id);
510 cout << " ---Level " << n << " sec. track no. " << id << endl;
513 Int_t nhyp=td->GetNhypotheses();
516 cout << " List of the " << nhyp << " track hypotheses : " << endl;
517 for (Int_t ih=1; ih<=nhyp; ih++)
519 AliTrack* tx=td->GetTrackHypothesis(ih);
520 if (tx) tx->Data(f,u);
524 Int_t nsig=td->GetNsignals();
527 cout << " List of the " << nsig << " related signals : " << endl;
528 for (Int_t is=1; is<=nsig; is++)
530 AliSignal* sx=td->GetSignal(is);
531 if (sx) sx->Data(f,u);
535 // Go for next decay level of this decay track recursively
540 cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl;
544 //////////////////////////////////////////////////////////////////////////
545 Double_t AliTrack::GetMomentum(Float_t scale)
547 // Provide the value of the track 3-momentum.
548 // By default the momentum is returned in the units as it was stored in the track
549 // structure. However, the user can select a different momentum unit scale by
550 // specification of the scale parameter.
551 // The convention is that scale=1 corresponds to GeV/c, so specification
552 // of scale=0.001 will provide the momentum in MeV/c.
553 // The error can be obtained by invoking GetResultError() after
554 // invokation of GetMomentum().
556 Double_t norm=fV.GetNorm();
557 fDresult=fV.GetResultError();
561 fDresult*=fEscale/scale;
565 ///////////////////////////////////////////////////////////////////////////
566 Ali3Vector AliTrack::Get3Momentum(Float_t scale) const
568 // Provide the track 3-momentum.
569 // By default the components of the 3-momentum are returned in the units
570 // as they were stored in the track structure.
571 // However, the user can select a different momentum unit scale for the
572 // components by specification of the scale parameter.
573 // The convention is that scale=1 corresponds to GeV/c, so specification
574 // of scale=0.001 will provide the 3-momentum in MeV/c.
576 Ali3Vector p=Get3Vector();
577 if (scale>0) p*=fEscale/scale;
580 ///////////////////////////////////////////////////////////////////////////
581 Double_t AliTrack::GetMass(Float_t scale)
583 // Provide the particle mass.
584 // By default the mass is returned in the units as it was stored in the track
585 // structure. However, the user can select a different mass unit scale by
586 // specification of the scale parameter.
587 // The convention is that scale=1 corresponds to GeV/c**2, so specification
588 // of scale=0.001 will provide the mass in MeV/c**2.
589 // The error can be obtained by invoking GetResultError() after
590 // invokation of GetMass().
592 Double_t inv=GetInvariant();
593 Double_t dinv=GetResultError();
597 Double_t m=sqrt(inv);
598 if (m) dm=dinv/(2.*m);
609 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
610 cout << " Value 0 will be returned." << endl;
615 ///////////////////////////////////////////////////////////////////////////
616 Float_t AliTrack::GetCharge() const
618 // Provide the particle charge
621 ///////////////////////////////////////////////////////////////////////////
622 Double_t AliTrack::GetEnergy(Float_t scale)
624 // Provide the particle's energy.
625 // By default the energy is returned in the units as it was stored in the track
626 // structure. However, the user can select a different energy unit scale by
627 // specification of the scale parameter.
628 // The convention is that scale=1 corresponds to GeV, so specification
629 // of scale=0.001 will provide the energy in MeV.
630 // The error can be obtained by invoking GetResultError() after
631 // invokation of GetEnergy().
632 Double_t E=GetScalar();
638 fDresult*=fEscale/scale;
644 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
645 cout << " Value 0 will be returned." << endl;
649 ///////////////////////////////////////////////////////////////////////////
650 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
652 // Perform 2-body decay of current track
653 // m1 : mass of decay product 1
654 // m2 : mass of decay product 2
655 // thcms : cms theta decay angle (in rad.) of m1
656 // phicms : cms phi decay angle (in rad.) of m1
658 Double_t M=GetMass();
660 // Compute the 4-momenta of the decay products in the cms
661 // Note : p2=p1=pnorm for a 2-body decay
663 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
665 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
666 Double_t pnorm=(e1*e1)-(m1*m1);
681 p.SetVector(a,"sph");
684 pprim1.SetVector(e1,p);
685 pprim1.SetInvariant(m1*m1);
689 pprim2.SetVector(e2,p);
690 pprim2.SetInvariant(m2*m2);
692 // Determine boost parameters from the parent particle
693 Double_t E=GetEnergy();
701 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
702 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
704 // Enter the boosted data into the decay tracks array
710 fDecays=new TObjArray(2);
713 fDecays->Add(new AliTrack);
714 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
715 ((AliTrack*)fDecays->At(0))->SetMass(m1);
716 fDecays->Add(new AliTrack);
717 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
718 ((AliTrack*)fDecays->At(1))->SetMass(m2);
720 ///////////////////////////////////////////////////////////////////////////
721 Int_t AliTrack::GetNdecay() const
723 // Provide the number of decay produced tracks
725 if (fDecays) ndec=fDecays->GetEntries();
728 ///////////////////////////////////////////////////////////////////////////
729 AliTrack* AliTrack::GetDecayTrack(Int_t j) const
731 // Provide decay produced track number j
732 // Note : j=1 denotes the first decay track
735 cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
740 if ((j >= 1) && (j <= GetNdecay()))
742 return (AliTrack*)fDecays->At(j-1);
746 cout << " *AliTrack* decay track number : " << j << " out of range."
747 << " Ndec = " << GetNdecay() << endl;
752 ///////////////////////////////////////////////////////////////////////////
753 void AliTrack::RemoveDecays()
755 // Remove all decay tracks from this track.
762 ///////////////////////////////////////////////////////////////////////////
763 void AliTrack::AddSignal(AliSignal& s,Int_t mode)
765 // Relate an AliSignal object to this track.
767 // mode = 0 : Only the reference to the specified signal is stored in
768 // the current track, without storing the (backward) reference
769 // to this track into the AliSignal structure.
770 // 1 : The (backward) reference to the current track is also automatically
771 // stored into the AliSignal (or derived) object specified in the
774 // The default is mode=0.
776 if (!fSignals) fSignals=new TObjArray(1);
778 // Check if this signal is already stored for this track
779 Int_t nsig=GetNsignals();
780 for (Int_t i=0; i<nsig; i++)
782 if (&s==fSignals->At(i)) return;
786 if (mode==1) s.AddTrack(*this,0);
788 ///////////////////////////////////////////////////////////////////////////
789 void AliTrack::RemoveSignal(AliSignal& s,Int_t mode)
791 // Remove related AliSignal object from this track.
793 // mode = 0 : Only the reference to the specified signal is removed from
794 // the current track, without removing the (backward) reference(s)
795 // to this track from the AliSignal structure.
796 // 1 : The (backward) reference(s) to the current track are also automatically
797 // removed from the AliSignal (or derived) object specified in the
800 // The default is mode=1.
804 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
805 if (test) fSignals->Compress();
807 if (mode==1) s.RemoveTrack(*this,0);
809 ///////////////////////////////////////////////////////////////////////////
810 void AliTrack::RemoveSignals(Int_t mode)
812 // Remove all related AliSignal objects from this track.
814 // mode = 0 : All signal references are removed from the current track,
815 // without removing the (backward) references to this track from
816 // the corresponding AliSignal objects.
817 // 1 : The (backward) references to the current track are also automatically
818 // removed from the corresponding AliSignal (or derived) objects.
820 // The default is mode=1.
822 if (!fSignals) return;
824 Int_t ns=GetNsignals();
825 for (Int_t i=0; i<ns; i++)
827 AliSignal* sx=(AliSignal*)fSignals->At(i);
828 if (sx && mode==1) sx->RemoveTrack(*this,0);
834 ///////////////////////////////////////////////////////////////////////////
835 Int_t AliTrack::GetNsignals() const
837 // Provide the number of related AliSignals.
839 if (fSignals) nsig=fSignals->GetEntries();
842 ///////////////////////////////////////////////////////////////////////////
843 AliSignal* AliTrack::GetSignal(Int_t j) const
845 // Provide the related AliSignal number j.
846 // Note : j=1 denotes the first signal.
849 cout << " *AliTrack::GetSignal* No signals present." << endl;
854 if ((j >= 1) && (j <= GetNsignals()))
856 return (AliSignal*)fSignals->At(j-1);
860 cout << " *AliTrack* signal number : " << j << " out of range."
861 << " Nsig = " << GetNsignals() << endl;
866 ///////////////////////////////////////////////////////////////////////////
867 void AliTrack::AddTrackHypothesis(AliTrack& t)
869 // Relate a track hypothesis to this track.
870 // Note : a private copy of the input track will be made via the Clone()
874 fHypotheses=new TObjArray(1);
875 fHypotheses->SetOwner();
877 fHypotheses->Add(t.Clone());
879 ///////////////////////////////////////////////////////////////////////////
880 void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
882 // Add a track hypothesis by explicitly setting the mass and probability.
883 // This will affect e.g. the hypothesis track's energy, since the momentum
884 // and all other attributes will be copied from the current track.
888 // prob=probalility m=mass value dm=error on the mass value.
889 // The default value for the mass error dm is 0.
893 t.RemoveTrackHypotheses();
895 t.SetTitle("Mass hypothesis");
898 AddTrackHypothesis(t);
900 ///////////////////////////////////////////////////////////////////////////
901 void AliTrack::RemoveTrackHypothesis(AliTrack& t)
903 // Remove the specified track hypothesis from this track.
906 AliTrack* test=(AliTrack*)fHypotheses->Remove(&t);
907 if (test) fHypotheses->Compress();
910 ///////////////////////////////////////////////////////////////////////////
911 void AliTrack::RemoveTrackHypotheses()
913 // Remove all track hypotheses from this track.
920 ///////////////////////////////////////////////////////////////////////////
921 Int_t AliTrack::GetNhypotheses() const
923 // Provide the number of track hypotheses.
925 if (fHypotheses) nhyp=fHypotheses->GetEntries();
928 ///////////////////////////////////////////////////////////////////////////
929 AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const
931 // Provide the j-th track hypothesis.
932 // Note : j=1 denotes the first hypothesis.
933 // Default : j=0 ==> Hypothesis with highest probability.
935 if (!fHypotheses) return 0;
937 Int_t nhyp=GetNhypotheses();
939 // Check validity of index j
942 cout << " *AliTrack* hypothesis number : " << j << " out of range."
943 << " Nhyp = " << nhyp << endl;
949 if (j==0) // Provide track hypothesis with highest probability
952 t=(AliTrack*)fHypotheses->At(0);
953 if (t) prob=t->GetProb();
955 for (Int_t ih=1; ih<nhyp; ih++)
957 AliTrack* tx=(AliTrack*)fHypotheses->At(ih);
961 if (probx > prob) t=tx;
966 else // Provide requested j-th track hypothesis
968 return (AliTrack*)fHypotheses->At(j-1);
971 ///////////////////////////////////////////////////////////////////////////
972 void AliTrack::SetBeginPoint(AliPosition& p)
974 // Store the position of the track begin-point.
975 if (fBegin) delete fBegin;
976 fBegin=new AliPositionObj(p);
978 ///////////////////////////////////////////////////////////////////////////
979 AliPosition* AliTrack::GetBeginPoint()
981 // Provide the position of the track begin-point.
984 ///////////////////////////////////////////////////////////////////////////
985 void AliTrack::SetEndPoint(AliPosition& p)
987 // Store the position of the track end-point.
988 if (fEnd) delete fEnd;
989 fEnd=new AliPositionObj(p);
991 ///////////////////////////////////////////////////////////////////////////
992 AliPosition* AliTrack::GetEndPoint()
994 // Provide the position of the track end-point.
997 ///////////////////////////////////////////////////////////////////////////
998 void AliTrack::SetReferencePoint(AliPosition& p)
1000 // Store the position of the track reference-point.
1001 // The reference-point is the point on the track in which the
1002 // 3-momentum vector components have been defined.
1003 // This reference point is the preferable point to start track extrapolations
1004 // etc... which are sensitive to the components of the 3-momentum vector.
1005 if (fRef) delete fRef;
1006 fRef=new AliPositionObj(p);
1008 ///////////////////////////////////////////////////////////////////////////
1009 AliPosition* AliTrack::GetReferencePoint()
1011 // Provide the position of the track reference-point.
1012 // The reference-point is the point on the track in which the
1013 // 3-momentum vector components have been defined.
1014 // This reference point is the preferable point to start track extrapolations
1015 // etc... which are sensitive to the components of the 3-momentum vector.
1018 ///////////////////////////////////////////////////////////////////////////
1019 void AliTrack::SetMass()
1021 // Set the mass and error to the value of the hypothesis with highest prob.
1025 // Select mass hypothesis with highest probability
1026 AliTrack* t=GetTrackHypothesis(0);
1030 dm=t->GetResultError();
1035 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
1038 ///////////////////////////////////////////////////////////////////////////
1039 Double_t AliTrack::GetPt(Float_t scale)
1041 // Provide the transverse momentum value w.r.t. z-axis.
1042 // By default the value is returned in the units as it was stored in the track
1043 // structure. However, the user can select a different momentum unit scale by
1044 // specification of the scale parameter.
1045 // The convention is that scale=1 corresponds to GeV/c, so specification
1046 // of scale=0.001 will provide the transverse momentum in MeV/c.
1047 // The error on the value can be obtained by GetResultError()
1048 // after invokation of GetPt().
1051 Double_t norm=v.GetNorm();
1052 fDresult=v.GetResultError();
1055 norm*=fEscale/scale;
1056 fDresult*=fEscale/scale;
1061 ///////////////////////////////////////////////////////////////////////////
1062 Double_t AliTrack::GetPl(Float_t scale)
1064 // Provide the longitudinal momentum value w.r.t. z-axis.
1065 // By default the value is returned in the units as it was stored in the track
1066 // structure. However, the user can select a different momentum unit scale by
1067 // specification of the scale parameter.
1068 // The convention is that scale=1 corresponds to GeV/c, so specification
1069 // of scale=0.001 will provide the longitudinal momentum in MeV/c.
1070 // Note : the returned value can also be negative.
1071 // The error on the value can be obtained by GetResultError()
1072 // after invokation of GetPl().
1077 Double_t pl=v.GetNorm();
1078 fDresult=v.GetResultError();
1081 v.GetVector(a,"sph");
1082 if (cos(a[1])<0) pl=-pl;
1086 fDresult*=fEscale/scale;
1091 ///////////////////////////////////////////////////////////////////////////
1092 Double_t AliTrack::GetEt(Float_t scale)
1094 // Provide transverse energy value w.r.t. z-axis.
1095 // By default the value is returned in the units as it was stored in the track
1096 // structure. However, the user can select a different energy unit scale by
1097 // specification of the scale parameter.
1098 // The convention is that scale=1 corresponds to GeV, so specification
1099 // of scale=0.001 will provide the transverse energy in MeV.
1100 // The error on the value can be obtained by GetResultError()
1101 // after invokation of GetEt().
1103 Double_t et=GetScaTrans();
1107 fDresult*=fEscale/scale;
1112 ///////////////////////////////////////////////////////////////////////////
1113 Double_t AliTrack::GetEl(Float_t scale)
1115 // Provide longitudinal energy value w.r.t. z-axis.
1116 // By default the value is returned in the units as it was stored in the track
1117 // structure. However, the user can select a different energy unit scale by
1118 // specification of the scale parameter.
1119 // The convention is that scale=1 corresponds to GeV, so specification
1120 // of scale=0.001 will provide the longitudinal energy in MeV.
1121 // Note : the returned value can also be negative.
1122 // The error on the value can be obtained by GetResultError()
1123 // after invokation of GetEl().
1125 Double_t el=GetScaLong();
1129 fDresult*=fEscale/scale;
1134 ///////////////////////////////////////////////////////////////////////////
1135 Double_t AliTrack::GetMt(Float_t scale)
1137 // Provide transverse mass value w.r.t. z-axis.
1138 // By default the value is returned in the units as it was stored in the track
1139 // structure. However, the user can select a different energy unit scale by
1140 // specification of the scale parameter.
1141 // The convention is that scale=1 corresponds to GeV, so specification
1142 // of scale=0.001 will provide the transverse mass in MeV.
1143 // The error on the value can be obtained by GetResultError()
1144 // after invokation of GetMt().
1145 Double_t pt=GetPt();
1146 Double_t dpt=GetResultError();
1147 Double_t m=GetMass();
1148 Double_t dm=GetResultError();
1150 Double_t mt=sqrt(pt*pt+m*m);
1152 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
1154 fDresult=sqrt(dmt2);
1158 fDresult*=fEscale/scale;
1162 ///////////////////////////////////////////////////////////////////////////
1163 Double_t AliTrack::GetRapidity()
1165 // Provide rapidity value w.r.t. z-axis.
1166 // The error on the value can be obtained by GetResultError()
1167 // after invokation of GetRapidity().
1168 // Note : Also GetPseudoRapidity() is available since this class is
1169 // derived from Ali4Vector.
1170 Double_t e=GetEnergy();
1171 Double_t de=GetResultError();
1172 Double_t pl=GetPl();
1173 Double_t dpl=GetResultError();
1177 Double_t y=9999,dy2=0;
1178 if (sum && dif) y=0.5*log(sum/dif);
1180 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
1185 ///////////////////////////////////////////////////////////////////////////
1186 void AliTrack::SetImpactPoint(AliPosition& p,TString q)
1188 // Store the position of the impact-point in the plane "q=0".
1189 // Here q denotes one of the axes X, Y or Z.
1190 // Note : The character to denote the axis may be entered in lower or
1193 if (q=="x" || q=="X") axis=1;
1194 if (q=="y" || q=="Y") axis=2;
1195 if (q=="z" || q=="Z") axis=3;
1199 case 1: // Impact-point in the plane X=0
1200 if (fImpactYZ) delete fImpactYZ;
1201 fImpactYZ=new AliPositionObj(p);
1204 case 2: // Impact-point in the plane Y=0
1205 if (fImpactXZ) delete fImpactXZ;
1206 fImpactXZ=new AliPositionObj(p);
1209 case 3: // Impact-point in the plane Z=0
1210 if (fImpactXY) delete fImpactXY;
1211 fImpactXY=new AliPositionObj(p);
1214 default: // Unsupported axis
1215 cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
1216 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1220 ///////////////////////////////////////////////////////////////////////////
1221 AliPosition* AliTrack::GetImpactPoint(TString q)
1223 // Provide the position of the impact-point in the plane "q=0".
1224 // Here q denotes one of the axes X, Y or Z.
1225 // Note : The character to denote the axis may be entered in lower or
1228 if (q=="x" || q=="X") axis=1;
1229 if (q=="y" || q=="Y") axis=2;
1230 if (q=="z" || q=="Z") axis=3;
1234 case 1: // Impact-point in the plane X=0
1237 case 2: // Impact-point in the plane Y=0
1240 case 3: // Impact-point in the plane Z=0
1243 default: // Unsupported axis
1244 cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
1245 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1249 ///////////////////////////////////////////////////////////////////////////
1250 void AliTrack::SetId(Int_t id)
1252 // Set a user defined unique identifier for this track.
1255 ///////////////////////////////////////////////////////////////////////////
1256 Int_t AliTrack::GetId() const
1258 // Provide the user defined unique identifier of this track.
1261 ///////////////////////////////////////////////////////////////////////////
1262 void AliTrack::SetClosestPoint(AliPosition& p)
1264 // Set position p as the point of closest approach w.r.t. some reference
1265 if (fClosest) delete fClosest;
1266 fClosest=new AliPositionObj(p);
1268 ///////////////////////////////////////////////////////////////////////////
1269 AliPosition* AliTrack::GetClosestPoint()
1271 // Provide the point of closest approach w.r.t. some reference
1274 ///////////////////////////////////////////////////////////////////////////
1275 void AliTrack::SetEscale(Float_t scale)
1277 // Indicate the energy/momentum scale as used by the user.
1278 // The convention is that scale=1 indicates values in units
1279 // of GeV, GeV/c or GeV/c**2.
1280 // So, in case one decides to store values in units of MeV, MeV/c or MeV/c**2
1281 // the scale indicator should be set to scale=0.001.
1283 // By default scale=1 is set in the constructor.
1291 cout << " *AliTrack::SetEscale* Invalid scale value : " << scale << endl;
1294 ///////////////////////////////////////////////////////////////////////////
1295 Float_t AliTrack::GetEscale() const
1297 // Provide the energy/momentum scale as used by the user.
1298 // The convention is that scale=1 indicates values in units
1299 // of GeV, GeV/c or GeV/c**2.
1300 // So, a value of scale=0.001 indicates that energy/momentum values are
1301 // stored in units of MeV, MeV/c or MeV/c**2.
1304 ///////////////////////////////////////////////////////////////////////////
1305 void AliTrack::SetParticleCode(Int_t code)
1307 // Set the user defined particle id code (e.g. the PDF convention).
1310 ///////////////////////////////////////////////////////////////////////////
1311 Int_t AliTrack::GetParticleCode() const
1313 // Provide the user defined particle id code.
1316 ///////////////////////////////////////////////////////////////////////////
1317 void AliTrack::SetParentTrack(AliTrack* t)
1319 // Set pointer to the parent track.
1322 ///////////////////////////////////////////////////////////////////////////
1323 AliTrack* AliTrack::GetParentTrack()
1325 // Provide pointer to the parent track.
1328 ///////////////////////////////////////////////////////////////////////////
1329 void AliTrack::SetProb(Double_t prob)
1331 // Set hypothesis probability for this track.
1334 ///////////////////////////////////////////////////////////////////////////
1335 Float_t AliTrack::GetProb() const
1337 // Provide the hypothesis probability for this track.
1340 ///////////////////////////////////////////////////////////////////////////
1341 void AliTrack::SetFitDetails(TObject* obj)
1343 // Enter the object containing the fit details.
1344 // In case an object to hold fit details was already present, this
1345 // will be deleted first before the new one is stored.
1346 // This means that SetFitDetails(0) can be used to just remove the
1347 // existing object with the fit details.
1348 // All objects derived from TObject can be entered in this way.
1349 // Obvious candidates for objects containing detailed fit information
1350 // are functions (e.g. TF1) and histograms (e.g. TH1F).
1351 // However, using an AliDevice object provides a very versatile facility
1352 // to store the parameters of various fit procedures.
1353 // In such a case the AliDevice can be used to provide the various fit
1354 // definitions and the corresponding fit parameters can be entered as
1355 // separate AliSignal objects which are stored as hits to the AliDevice.
1356 // In addition various functions and histograms can be linked to the
1357 // various AliSignal instances
1358 // The latter procedure is based on the original idea of Adam Bouchta.
1360 // Note : The entered object is owned by this AliTrack instance.
1361 // As such, a private copy of obj will be stored using the Clone()
1363 // In case the entered object contains pointers to other objects,
1364 // the user has to provide the appropriate Clone() memberfunction
1365 // for the class to which the entered object belongs.
1366 // An example can be seen from AliTrack::Clone().
1374 if (obj) fFit=obj->Clone();
1376 ///////////////////////////////////////////////////////////////////////////
1377 TObject* AliTrack::GetFitDetails()
1379 // Provide the pointer to the object containing the fit details.
1382 ///////////////////////////////////////////////////////////////////////////
1383 void AliTrack::SetTimestamp(AliTimestamp& t)
1385 // Store the timestamp for this track.
1386 if (fTstamp) delete fTstamp;
1387 fTstamp=new AliTimestamp(t);
1389 ///////////////////////////////////////////////////////////////////////////
1390 AliTimestamp* AliTrack::GetTimestamp()
1392 // Provide the timestamp of this track.
1395 ///////////////////////////////////////////////////////////////////////////
1396 void AliTrack::RemoveTimestamp()
1398 // Remove the timestamp from this track.
1405 ///////////////////////////////////////////////////////////////////////////
1406 Double_t AliTrack::GetDistance(AliPosition* p,Float_t scale)
1408 // Provide distance of the current track to the position p.
1409 // The error on the result can be obtained as usual by invoking
1410 // GetResultError() afterwards.
1412 // By default the distance will be provided in the metric unit scale of
1413 // the AliPosition p.
1414 // However, the user can select a different metric unit scale by
1415 // specification of the scale parameter.
1416 // The convention is that scale=1 corresponds to meter, so specification
1417 // of scale=0.01 will provide the distance in cm.
1418 // As such it is possible to obtain a correctly computed distance even in case
1419 // the track parameters have a different unit scale.
1420 // However, it is recommended to work always with one single unit scale.
1422 // Note : In case of incomplete information, a distance value of -1 is
1428 if (!p) return dist;
1430 // Obtain a defined position on this track
1431 AliPosition* rx=fRef;
1435 if (!rx) return dist;
1437 Ali3Vector p1=Get3Momentum();
1439 if (p1.GetNorm() <= 0.) return dist;
1441 Ali3Vector r0=(Ali3Vector)(*rx);
1443 Float_t tscale=rx->GetUnitScale();
1444 Float_t pscale=p->GetUnitScale();
1445 if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale);
1447 // Obtain the direction unit vector of this track
1450 p1.GetVector(vec,"sph");
1451 p1.GetErrors(err,"sph");
1454 p1.SetVector(vec,"sph");
1455 p1.SetErrors(err,"sph");
1457 Ali3Vector q=(Ali3Vector)(*p);
1459 Ali3Vector d=r.Cross(p1);
1461 fDresult=d.GetResultError();
1465 fDresult*=pscale/scale;
1469 ///////////////////////////////////////////////////////////////////////////
1470 Double_t AliTrack::GetDistance(AliTrack* t,Float_t scale)
1472 // Provide distance of the current track to the track t.
1473 // The error on the result can be obtained as usual by invoking
1474 // GetResultError() afterwards.
1476 // By default the distance will be provided in the metric unit scale of
1477 // the current track.
1478 // This implies that the results of t1.GetDistance(t2) and t2.GetDistance(t1)
1479 // may be numerically different in case t1 and t2 have different metric units.
1480 // However, the user can specify a required metric unit scale by specification
1481 // of the scale parameter.
1482 // The convention is that scale=1 corresponds to meter, so specification
1483 // of scale=0.01 will provide the distance in cm.
1484 // As such it is possible to obtain a correctly computed distance even in case
1485 // the track parameters have a different unit scale.
1486 // However, it is recommended to work always with one single unit scale.
1488 // Note : In case of incomplete information, a distance value of -1 is
1494 if (!t) return dist;
1496 // Obtain a defined position on this track
1497 AliPosition* rx=fRef;
1501 if (!rx) return dist;
1503 // Obtain a defined position on track t
1504 AliPosition* ry=t->GetReferencePoint();
1505 if (!ry) ry=t->GetBeginPoint();
1506 if (!ry) ry=t->GetEndPoint();
1508 if (!ry) return dist;
1510 Ali3Vector p1=Get3Momentum();
1511 Ali3Vector p2=t->Get3Momentum();
1513 if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist;
1515 // The vector normal to both track directions
1516 Ali3Vector n=p1.Cross(p2);
1518 Float_t scalex=rx->GetUnitScale();
1519 Float_t scaley=ry->GetUnitScale();
1521 if (n.GetNorm() > 1.e-10)
1523 // Normalise n to a unit vector
1526 n.GetVector(vec,"sph");
1527 n.GetErrors(err,"sph");
1530 n.SetVector(vec,"sph");
1531 n.SetErrors(err,"sph");
1532 Ali3Vector r1=(Ali3Vector)(*rx);
1533 Ali3Vector r2=(Ali3Vector)(*ry);
1534 // Correct components of r2 in case of different unit scales
1535 if ((scaley/scalex > 1.1) || (scalex/scaley > 1.1)) r2=r2*(scaley/scalex);
1537 dist=fabs(r.Dot(n));
1538 fDresult=r.GetResultError();
1540 else // Parallel tracks
1542 dist=t->GetDistance(rx);
1543 fDresult=t->GetResultError();
1549 fDresult*=scalex/scale;
1553 ///////////////////////////////////////////////////////////////////////////
1554 TObject* AliTrack::Clone(const char* name) const
1556 // Make a deep copy of the current object and provide the pointer to the copy.
1557 // This memberfunction enables automatic creation of new objects of the
1558 // correct type depending on the object type, a feature which may be very useful
1559 // for containers when adding objects in case the container owns the objects.
1560 // This feature allows e.g. AliJet to store either AliTrack objects or
1561 // objects derived from AliTrack via the AddTrack memberfunction, provided
1562 // these derived classes also have a proper Clone memberfunction.
1564 AliTrack* trk=new AliTrack(*this);
1567 if (strlen(name)) trk->SetName(name);
1571 ///////////////////////////////////////////////////////////////////////////