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 ///////////////////////////////////////////////////////////////////////////
96 #include "Riostream.h"
97 #include "TObjArray.h"
100 #include "AliPositionObj.h"
101 #include "AliSignal.h"
102 #include "AliTimestamp.h"
103 #include "AliTrack.h"
105 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
107 AliTrack::AliTrack() : TNamed(),Ali4Vector()
109 // Default constructor
110 // All variables initialised to 0
114 ///////////////////////////////////////////////////////////////////////////
115 void AliTrack::Init()
117 // Initialisation of pointers etc...
133 ///////////////////////////////////////////////////////////////////////////
134 AliTrack::~AliTrack()
136 // Destructor to delete memory allocated for decay tracks array.
137 // This destructor automatically cleares all references to this AliTrack
138 // from all the related AliSignal objects.
139 Int_t nsig=GetNsignals();
140 for (Int_t i=1; i<=nsig; i++)
142 AliSignal* s=GetSignal(i);
143 if (s) s->RemoveTrack(*this,0);
207 ///////////////////////////////////////////////////////////////////////////
208 AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
215 if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin));
216 if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd));
217 if (t.fRef) fRef=new AliPositionObj(*(t.fRef));
218 if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY));
219 if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ));
220 if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ));
221 if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest));
222 if (t.fFit) fFit=t.fFit->Clone();
223 if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp));
229 Int_t ndec=t.GetNdecay();
232 fDecays=new TObjArray(ndec);
234 for (Int_t it=1; it<=ndec; it++)
236 AliTrack* tx=t.GetDecayTrack(it);
237 fDecays->Add(new AliTrack(*tx));
241 Int_t nsig=t.GetNsignals();
244 fSignals=new TObjArray(nsig);
245 for (Int_t is=1; is<=nsig; is++)
247 AliSignal* sx=t.GetSignal(is);
252 Int_t nhyp=t.GetNhypotheses();
255 fHypotheses=new TObjArray(nhyp);
256 fHypotheses->SetOwner();
257 for (Int_t ih=1; ih<=nhyp; ih++)
259 AliTrack* tx=t.GetTrackHypothesis(ih);
260 fHypotheses->Add(new AliTrack(*tx));
264 ///////////////////////////////////////////////////////////////////////////
265 void AliTrack::Reset()
267 // Reset all variables to 0 and delete all auto-generated decay tracks.
268 // Note : The scale for the energy/momentum units will not be changed.
273 Double_t a[4]={0,0,0,0};
337 ///////////////////////////////////////////////////////////////////////////
338 void AliTrack::Set3Momentum(Ali3Vector& p)
340 // Set the track parameters according to the 3-momentum p.
341 // In case the mass was not yet set, the energy is set to correspond to m=0.
343 Double_t inv=GetInvariant();
344 if (inv<0) SetMass(0.);
346 ///////////////////////////////////////////////////////////////////////////
347 void AliTrack::Set4Momentum(Ali4Vector& p)
349 // Set the track parameters according to the 4-momentum p
350 Double_t eE=p.GetScalar();
351 Double_t dE=p.GetResultError();
352 Ali3Vector pv=p.Get3Vector();
356 ///////////////////////////////////////////////////////////////////////////
357 void AliTrack::SetMass(Double_t m,Double_t dm)
359 // Set the particle mass
360 // The default value for the error dm is 0.
361 Double_t inv=pow(m,2);
362 Double_t dinv=fabs(2.*m*dm);
363 SetInvariant(inv,dinv);
365 ///////////////////////////////////////////////////////////////////////////
366 void AliTrack::SetCharge(Float_t q)
368 // Set the particle charge
371 ///////////////////////////////////////////////////////////////////////////
372 void AliTrack::Data(TString f,TString u)
374 // Provide track information within the coordinate frame f
376 // The string argument "u" allows to choose between different angular units
377 // in case e.g. a spherical frame is selected.
378 // u = "rad" : angles provided in radians
379 // "deg" : angles provided in degrees
381 // The defaults are f="car" and u="rad".
383 Double_t m=GetMass();
384 Double_t dm=GetResultError();
385 const char* name=GetName();
386 const char* title=GetTitle();
388 cout << " *" << ClassName() << "::Data*";
389 if (strlen(name)) cout << " Name : " << name;
390 if (strlen(title)) cout << " Title : " << title;
392 if (fTstamp) fTstamp->Date(1);
393 cout << " Id : " << fUserId << " Code : " << fCode
394 << " m : " << m << " dm : " << dm << " Charge : " << fQ
395 << " p : " << GetMomentum() << endl;
396 cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
397 << " Nsignals : " << GetNsignals() << " Energy scale : " << fEscale << " GeV" << endl;
400 cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode()
401 << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge()
402 << " p : " << fParent->GetMomentum();
403 const char* pname=fParent->GetName();
404 const char* ptitle=fParent->GetTitle();
405 if (strlen(pname)) cout << " Name : " << pname;
406 if (strlen(ptitle)) cout << " Title : " << ptitle;
411 cout << " Fit details present in object of class " << fFit->ClassName() << endl;
412 if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1);
414 Ali4Vector::Data(f,u);
416 ///////////////////////////////////////////////////////////////////////////
417 void AliTrack::List(TString f,TString u)
419 // Provide current track and decay level 1 information within coordinate frame f
421 // The string argument "u" allows to choose between different angular units
422 // in case e.g. a spherical frame is selected.
423 // u = "rad" : angles provided in radians
424 // "deg" : angles provided in degrees
426 // The defaults are f="car" and u="rad".
428 Data(f,u); // Information of the current track
429 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
430 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
431 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
433 // Decay products of this track
435 for (Int_t id=1; id<=GetNdecay(); id++)
437 td=GetDecayTrack(id);
440 cout << " ---Level 1 sec. track no. " << id << endl;
445 cout << " *AliTrack::List* Error : Empty decay track slot." << endl;
449 ///////////////////////////////////////////////////////////////////////////
450 void AliTrack::ListAll(TString f,TString u)
452 // Provide complete track and decay information within the coordinate frame f
454 // The string argument "u" allows to choose between different angular units
455 // in case e.g. a spherical frame is selected.
456 // u = "rad" : angles provided in radians
457 // "deg" : angles provided in degrees
459 // The defaults are f="car" and u="rad".
461 Data(f,u); // Information of the current track
462 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
463 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
464 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
466 Int_t nhyp=GetNhypotheses();
469 cout << " List of the " << nhyp << " track hypotheses : " << endl;
470 for (Int_t ih=1; ih<=nhyp; ih++)
472 AliTrack* tx=GetTrackHypothesis(ih);
473 if (tx) tx->Data(f,u);
477 Int_t nsig=GetNsignals();
480 cout << " List of the corresponding slots for the " << nsig
481 << " related signals : " << endl;
485 for (Int_t is=1; is<=nsig; is++)
487 AliSignal* sx=GetSignal(is);
490 nrefs=sx->GetIndices(this,slotarr,0);
491 for (Int_t jref=0; jref<nrefs; jref++)
493 jslot=slotarr.At(jref);
504 Dumps(t,1,f,u); // Information of all decay products
506 //////////////////////////////////////////////////////////////////////////
507 void AliTrack::Dumps(const AliTrack* t,Int_t n,TString f,TString u)
509 // Recursively provide the info of all decay levels of this track
511 for (Int_t id=1; id<=t->GetNdecay(); id++)
513 td=t->GetDecayTrack(id);
516 cout << " ---Level " << n << " sec. track no. " << id << endl;
519 Int_t nhyp=td->GetNhypotheses();
522 cout << " List of the " << nhyp << " track hypotheses : " << endl;
523 for (Int_t ih=1; ih<=nhyp; ih++)
525 AliTrack* tx=td->GetTrackHypothesis(ih);
526 if (tx) tx->Data(f,u);
530 Int_t nsig=td->GetNsignals();
533 cout << " List of the " << nsig << " related signals : " << endl;
534 for (Int_t is=1; is<=nsig; is++)
536 AliSignal* sx=td->GetSignal(is);
537 if (sx) sx->Data(f,u);
541 // Go for next decay level of this decay track recursively
546 cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl;
550 //////////////////////////////////////////////////////////////////////////
551 Double_t AliTrack::GetMomentum(Float_t scale)
553 // Provide the value of the track 3-momentum.
554 // By default the momentum is returned in the units as it was stored in the track
555 // structure. However, the user can select a different momentum unit scale by
556 // specification of the scale parameter.
557 // The convention is that scale=1 corresponds to GeV/c, so specification
558 // of scale=0.001 will provide the momentum in MeV/c.
559 // The error can be obtained by invoking GetResultError() after
560 // invokation of GetMomentum().
562 Double_t norm=fV.GetNorm();
563 fDresult=fV.GetResultError();
567 fDresult*=fEscale/scale;
571 ///////////////////////////////////////////////////////////////////////////
572 Ali3Vector AliTrack::Get3Momentum(Float_t scale) const
574 // Provide the track 3-momentum.
575 // By default the components of the 3-momentum are returned in the units
576 // as they were stored in the track structure.
577 // However, the user can select a different momentum unit scale for the
578 // components by specification of the scale parameter.
579 // The convention is that scale=1 corresponds to GeV/c, so specification
580 // of scale=0.001 will provide the 3-momentum in MeV/c.
582 Ali3Vector p=Get3Vector();
583 if (scale>0) p*=fEscale/scale;
586 ///////////////////////////////////////////////////////////////////////////
587 Double_t AliTrack::GetMass(Float_t scale)
589 // Provide the particle mass.
590 // By default the mass is returned in the units as it was stored in the track
591 // structure. However, the user can select a different mass unit scale by
592 // specification of the scale parameter.
593 // The convention is that scale=1 corresponds to GeV/c**2, so specification
594 // of scale=0.001 will provide the mass in MeV/c**2.
595 // The error can be obtained by invoking GetResultError() after
596 // invokation of GetMass().
598 Double_t inv=GetInvariant();
599 Double_t dinv=GetResultError();
603 Double_t m=sqrt(inv);
604 if (m) dm=dinv/(2.*m);
615 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
616 cout << " Value 0 will be returned." << endl;
621 ///////////////////////////////////////////////////////////////////////////
622 Float_t AliTrack::GetCharge() const
624 // Provide the particle charge
627 ///////////////////////////////////////////////////////////////////////////
628 Double_t AliTrack::GetEnergy(Float_t scale)
630 // Provide the particle's energy.
631 // By default the energy is returned in the units as it was stored in the track
632 // structure. However, the user can select a different energy unit scale by
633 // specification of the scale parameter.
634 // The convention is that scale=1 corresponds to GeV, so specification
635 // of scale=0.001 will provide the energy in MeV.
636 // The error can be obtained by invoking GetResultError() after
637 // invokation of GetEnergy().
638 Double_t eE=GetScalar();
644 fDresult*=fEscale/scale;
650 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << eE << endl;
651 cout << " Value 0 will be returned." << endl;
655 ///////////////////////////////////////////////////////////////////////////
656 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
658 // Perform 2-body decay of current track
659 // m1 : mass of decay product 1
660 // m2 : mass of decay product 2
661 // thcms : cms theta decay angle (in rad.) of m1
662 // phicms : cms phi decay angle (in rad.) of m1
664 Double_t mM=GetMass();
666 // Compute the 4-momenta of the decay products in the cms
667 // Note : p2=p1=pnorm for a 2-body decay
669 if (mM) e1=((mM*mM)+(m1*m1)-(m2*m2))/(2.*mM);
671 if (mM) e2=((mM*mM)+(m2*m2)-(m1*m1))/(2.*mM);
672 Double_t pnorm=(e1*e1)-(m1*m1);
687 p.SetVector(a,"sph");
690 pprim1.SetVector(e1,p);
691 pprim1.SetInvariant(m1*m1);
695 pprim2.SetVector(e2,p);
696 pprim2.SetInvariant(m2*m2);
698 // Determine boost parameters from the parent particle
699 Double_t eE=GetEnergy();
707 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
708 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
710 // Enter the boosted data into the decay tracks array
716 fDecays=new TObjArray(2);
719 fDecays->Add(new AliTrack);
720 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
721 ((AliTrack*)fDecays->At(0))->SetMass(m1);
722 fDecays->Add(new AliTrack);
723 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
724 ((AliTrack*)fDecays->At(1))->SetMass(m2);
726 ///////////////////////////////////////////////////////////////////////////
727 Int_t AliTrack::GetNdecay() const
729 // Provide the number of decay produced tracks
731 if (fDecays) ndec=fDecays->GetEntries();
734 ///////////////////////////////////////////////////////////////////////////
735 AliTrack* AliTrack::GetDecayTrack(Int_t j) const
737 // Provide decay produced track number j
738 // Note : j=1 denotes the first decay track
741 cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
746 if ((j >= 1) && (j <= GetNdecay()))
748 return (AliTrack*)fDecays->At(j-1);
752 cout << " *AliTrack* decay track number : " << j << " out of range."
753 << " Ndec = " << GetNdecay() << endl;
758 ///////////////////////////////////////////////////////////////////////////
759 void AliTrack::RemoveDecays()
761 // Remove all decay tracks from this track.
768 ///////////////////////////////////////////////////////////////////////////
769 void AliTrack::AddSignal(AliSignal& s,Int_t mode)
771 // Relate an AliSignal object to this track.
773 // mode = 0 : Only the reference to the specified signal is stored in
774 // the current track, without storing the (backward) reference
775 // to this track into the AliSignal structure.
776 // 1 : The (backward) reference to the current track is also automatically
777 // stored into the AliSignal (or derived) object specified in the
780 // The default is mode=0.
782 if (!fSignals) fSignals=new TObjArray(1);
784 // Check if this signal is already stored for this track
785 Int_t nsig=GetNsignals();
786 for (Int_t i=0; i<nsig; i++)
788 if (&s==fSignals->At(i)) return;
792 if (mode==1) s.AddTrack(*this,0);
794 ///////////////////////////////////////////////////////////////////////////
795 void AliTrack::RemoveSignal(AliSignal& s,Int_t mode)
797 // Remove related AliSignal object from this track.
799 // mode = 0 : Only the reference to the specified signal is removed from
800 // the current track, without removing the (backward) reference(s)
801 // to this track from the AliSignal structure.
802 // 1 : The (backward) reference(s) to the current track are also automatically
803 // removed from the AliSignal (or derived) object specified in the
806 // The default is mode=1.
810 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
811 if (test) fSignals->Compress();
813 if (mode==1) s.RemoveTrack(*this,0);
815 ///////////////////////////////////////////////////////////////////////////
816 void AliTrack::RemoveSignals(Int_t mode)
818 // Remove all related AliSignal objects from this track.
820 // mode = 0 : All signal references are removed from the current track,
821 // without removing the (backward) references to this track from
822 // the corresponding AliSignal objects.
823 // 1 : The (backward) references to the current track are also automatically
824 // removed from the corresponding AliSignal (or derived) objects.
826 // The default is mode=1.
828 if (!fSignals) return;
830 Int_t ns=GetNsignals();
831 for (Int_t i=0; i<ns; i++)
833 AliSignal* sx=(AliSignal*)fSignals->At(i);
834 if (sx && mode==1) sx->RemoveTrack(*this,0);
840 ///////////////////////////////////////////////////////////////////////////
841 Int_t AliTrack::GetNsignals() const
843 // Provide the number of related AliSignals.
845 if (fSignals) nsig=fSignals->GetEntries();
848 ///////////////////////////////////////////////////////////////////////////
849 Int_t AliTrack::GetNsignals(const char* classname) const
851 // Provide the number of stored signals of the specified class.
854 for (Int_t isig=1; isig<=GetNsignals(); isig++)
856 TObject* obj=GetSignal(isig);
859 if (obj->InheritsFrom(classname)) nsigs++;
863 ///////////////////////////////////////////////////////////////////////////
864 AliSignal* AliTrack::GetSignal(Int_t j) const
866 // Provide the related AliSignal number j.
867 // Note : j=1 denotes the first signal.
870 cout << " *AliTrack::GetSignal* No signals present." << endl;
875 if ((j >= 1) && (j <= GetNsignals()))
877 return (AliSignal*)fSignals->At(j-1);
881 cout << " *AliTrack* signal number : " << j << " out of range."
882 << " Nsig = " << GetNsignals() << endl;
887 ///////////////////////////////////////////////////////////////////////////
888 void AliTrack::AddTrackHypothesis(AliTrack& t)
890 // Relate a track hypothesis to this track.
891 // Note : a private copy of the input track will be made via the Clone()
895 fHypotheses=new TObjArray(1);
896 fHypotheses->SetOwner();
898 fHypotheses->Add(t.Clone());
900 ///////////////////////////////////////////////////////////////////////////
901 void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
903 // Add a track hypothesis by explicitly setting the mass and probability.
904 // This will affect e.g. the hypothesis track's energy, since the momentum
905 // and all other attributes will be copied from the current track.
909 // prob=probalility m=mass value dm=error on the mass value.
910 // The default value for the mass error dm is 0.
914 t.RemoveTrackHypotheses();
916 t.SetTitle("Mass hypothesis");
919 AddTrackHypothesis(t);
921 ///////////////////////////////////////////////////////////////////////////
922 void AliTrack::RemoveTrackHypothesis(AliTrack& t)
924 // Remove the specified track hypothesis from this track.
927 AliTrack* test=(AliTrack*)fHypotheses->Remove(&t);
928 if (test) fHypotheses->Compress();
931 ///////////////////////////////////////////////////////////////////////////
932 void AliTrack::RemoveTrackHypotheses()
934 // Remove all track hypotheses from this track.
941 ///////////////////////////////////////////////////////////////////////////
942 Int_t AliTrack::GetNhypotheses() const
944 // Provide the number of track hypotheses.
946 if (fHypotheses) nhyp=fHypotheses->GetEntries();
949 ///////////////////////////////////////////////////////////////////////////
950 AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const
952 // Provide the j-th track hypothesis.
953 // Note : j=1 denotes the first hypothesis.
954 // Default : j=0 ==> Hypothesis with highest probability.
956 if (!fHypotheses) return 0;
958 Int_t nhyp=GetNhypotheses();
960 // Check validity of index j
963 cout << " *AliTrack* hypothesis number : " << j << " out of range."
964 << " Nhyp = " << nhyp << endl;
970 if (j==0) // Provide track hypothesis with highest probability
973 t=(AliTrack*)fHypotheses->At(0);
974 if (t) prob=t->GetProb();
976 for (Int_t ih=1; ih<nhyp; ih++)
978 AliTrack* tx=(AliTrack*)fHypotheses->At(ih);
982 if (probx > prob) t=tx;
987 else // Provide requested j-th track hypothesis
989 return (AliTrack*)fHypotheses->At(j-1);
992 ///////////////////////////////////////////////////////////////////////////
993 void AliTrack::SetBeginPoint(AliPosition& p)
995 // Store the position of the track begin-point.
996 if (fBegin) delete fBegin;
997 fBegin=new AliPositionObj(p);
999 ///////////////////////////////////////////////////////////////////////////
1000 AliPosition* AliTrack::GetBeginPoint() const
1002 // Provide the position of the track begin-point.
1005 ///////////////////////////////////////////////////////////////////////////
1006 void AliTrack::SetEndPoint(AliPosition& p)
1008 // Store the position of the track end-point.
1009 if (fEnd) delete fEnd;
1010 fEnd=new AliPositionObj(p);
1012 ///////////////////////////////////////////////////////////////////////////
1013 AliPosition* AliTrack::GetEndPoint() const
1015 // Provide the position of the track end-point.
1018 ///////////////////////////////////////////////////////////////////////////
1019 void AliTrack::SetReferencePoint(AliPosition& p)
1021 // Store the position of the track reference-point.
1022 // The reference-point is the point on the track in which the
1023 // 3-momentum vector components have been defined.
1024 // This reference point is the preferable point to start track extrapolations
1025 // etc... which are sensitive to the components of the 3-momentum vector.
1026 if (fRef) delete fRef;
1027 fRef=new AliPositionObj(p);
1029 ///////////////////////////////////////////////////////////////////////////
1030 AliPosition* AliTrack::GetReferencePoint() const
1032 // Provide the position of the track reference-point.
1033 // The reference-point is the point on the track in which the
1034 // 3-momentum vector components have been defined.
1035 // This reference point is the preferable point to start track extrapolations
1036 // etc... which are sensitive to the components of the 3-momentum vector.
1039 ///////////////////////////////////////////////////////////////////////////
1040 void AliTrack::SetMass()
1042 // Set the mass and error to the value of the hypothesis with highest prob.
1046 // Select mass hypothesis with highest probability
1047 AliTrack* t=GetTrackHypothesis(0);
1051 dm=t->GetResultError();
1056 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
1059 ///////////////////////////////////////////////////////////////////////////
1060 Double_t AliTrack::GetPt(Float_t scale)
1062 // Provide the transverse momentum value w.r.t. z-axis.
1063 // By default the value is returned in the units as it was stored in the track
1064 // structure. However, the user can select a different momentum unit scale by
1065 // specification of the scale parameter.
1066 // The convention is that scale=1 corresponds to GeV/c, so specification
1067 // of scale=0.001 will provide the transverse momentum in MeV/c.
1068 // The error on the value can be obtained by GetResultError()
1069 // after invokation of GetPt().
1072 Double_t norm=v.GetNorm();
1073 fDresult=v.GetResultError();
1076 norm*=fEscale/scale;
1077 fDresult*=fEscale/scale;
1082 ///////////////////////////////////////////////////////////////////////////
1083 Double_t AliTrack::GetPl(Float_t scale)
1085 // Provide the longitudinal momentum value w.r.t. z-axis.
1086 // By default the value is returned in the units as it was stored in the track
1087 // structure. However, the user can select a different momentum unit scale by
1088 // specification of the scale parameter.
1089 // The convention is that scale=1 corresponds to GeV/c, so specification
1090 // of scale=0.001 will provide the longitudinal momentum in MeV/c.
1091 // Note : the returned value can also be negative.
1092 // The error on the value can be obtained by GetResultError()
1093 // after invokation of GetPl().
1098 Double_t pl=v.GetNorm();
1099 fDresult=v.GetResultError();
1102 v.GetVector(a,"sph");
1103 if (cos(a[1])<0) pl=-pl;
1107 fDresult*=fEscale/scale;
1112 ///////////////////////////////////////////////////////////////////////////
1113 Double_t AliTrack::GetEt(Float_t scale)
1115 // Provide transverse 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 transverse energy in MeV.
1121 // The error on the value can be obtained by GetResultError()
1122 // after invokation of GetEt().
1124 Double_t et=GetScaTrans();
1128 fDresult*=fEscale/scale;
1133 ///////////////////////////////////////////////////////////////////////////
1134 Double_t AliTrack::GetEl(Float_t scale)
1136 // Provide longitudinal energy value w.r.t. z-axis.
1137 // By default the value is returned in the units as it was stored in the track
1138 // structure. However, the user can select a different energy unit scale by
1139 // specification of the scale parameter.
1140 // The convention is that scale=1 corresponds to GeV, so specification
1141 // of scale=0.001 will provide the longitudinal energy in MeV.
1142 // Note : the returned value can also be negative.
1143 // The error on the value can be obtained by GetResultError()
1144 // after invokation of GetEl().
1146 Double_t el=GetScaLong();
1150 fDresult*=fEscale/scale;
1155 ///////////////////////////////////////////////////////////////////////////
1156 Double_t AliTrack::GetMt(Float_t scale)
1158 // Provide transverse mass value w.r.t. z-axis.
1159 // By default the value is returned in the units as it was stored in the track
1160 // structure. However, the user can select a different energy unit scale by
1161 // specification of the scale parameter.
1162 // The convention is that scale=1 corresponds to GeV, so specification
1163 // of scale=0.001 will provide the transverse mass in MeV.
1164 // The error on the value can be obtained by GetResultError()
1165 // after invokation of GetMt().
1166 Double_t pt=GetPt();
1167 Double_t dpt=GetResultError();
1168 Double_t m=GetMass();
1169 Double_t dm=GetResultError();
1171 Double_t mt=sqrt(pt*pt+m*m);
1173 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
1175 fDresult=sqrt(dmt2);
1179 fDresult*=fEscale/scale;
1183 ///////////////////////////////////////////////////////////////////////////
1184 Double_t AliTrack::GetRapidity()
1186 // Provide rapidity value w.r.t. z-axis.
1187 // The error on the value can be obtained by GetResultError()
1188 // after invokation of GetRapidity().
1189 // Note : Also GetPseudoRapidity() is available since this class is
1190 // derived from Ali4Vector.
1191 Double_t e=GetEnergy();
1192 Double_t de=GetResultError();
1193 Double_t pl=GetPl();
1194 Double_t dpl=GetResultError();
1198 Double_t y=9999,dy2=0;
1199 if (sum && dif) y=0.5*log(sum/dif);
1201 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
1206 ///////////////////////////////////////////////////////////////////////////
1207 void AliTrack::SetImpactPoint(AliPosition& p,TString q)
1209 // Store the position of the impact-point in the plane "q=0".
1210 // Here q denotes one of the axes X, Y or Z.
1211 // Note : The character to denote the axis may be entered in lower or
1214 if (q=="x" || q=="X") axis=1;
1215 if (q=="y" || q=="Y") axis=2;
1216 if (q=="z" || q=="Z") axis=3;
1220 case 1: // Impact-point in the plane X=0
1221 if (fImpactYZ) delete fImpactYZ;
1222 fImpactYZ=new AliPositionObj(p);
1225 case 2: // Impact-point in the plane Y=0
1226 if (fImpactXZ) delete fImpactXZ;
1227 fImpactXZ=new AliPositionObj(p);
1230 case 3: // Impact-point in the plane Z=0
1231 if (fImpactXY) delete fImpactXY;
1232 fImpactXY=new AliPositionObj(p);
1235 default: // Unsupported axis
1236 cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
1237 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1241 ///////////////////////////////////////////////////////////////////////////
1242 AliPosition* AliTrack::GetImpactPoint(TString q) const
1244 // Provide the position of the impact-point in the plane "q=0".
1245 // Here q denotes one of the axes X, Y or Z.
1246 // Note : The character to denote the axis may be entered in lower or
1249 if (q=="x" || q=="X") axis=1;
1250 if (q=="y" || q=="Y") axis=2;
1251 if (q=="z" || q=="Z") axis=3;
1255 case 1: // Impact-point in the plane X=0
1258 case 2: // Impact-point in the plane Y=0
1261 case 3: // Impact-point in the plane Z=0
1264 default: // Unsupported axis
1265 cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
1266 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1270 ///////////////////////////////////////////////////////////////////////////
1271 void AliTrack::SetId(Int_t id)
1273 // Set a user defined unique identifier for this track.
1276 ///////////////////////////////////////////////////////////////////////////
1277 Int_t AliTrack::GetId() const
1279 // Provide the user defined unique identifier of this track.
1282 ///////////////////////////////////////////////////////////////////////////
1283 void AliTrack::SetClosestPoint(AliPosition& p)
1285 // Set position p as the point of closest approach w.r.t. some reference
1286 if (fClosest) delete fClosest;
1287 fClosest=new AliPositionObj(p);
1289 ///////////////////////////////////////////////////////////////////////////
1290 AliPosition* AliTrack::GetClosestPoint() const
1292 // Provide the point of closest approach w.r.t. some reference
1295 ///////////////////////////////////////////////////////////////////////////
1296 void AliTrack::SetEscale(Float_t scale)
1298 // Indicate the energy/momentum scale as used by the user.
1299 // The convention is that scale=1 indicates values in units
1300 // of GeV, GeV/c or GeV/c**2.
1301 // So, in case one decides to store values in units of MeV, MeV/c or MeV/c**2
1302 // the scale indicator should be set to scale=0.001.
1304 // By default scale=1 is set in the constructor.
1312 cout << " *AliTrack::SetEscale* Invalid scale value : " << scale << endl;
1315 ///////////////////////////////////////////////////////////////////////////
1316 Float_t AliTrack::GetEscale() const
1318 // Provide the energy/momentum scale as used by the user.
1319 // The convention is that scale=1 indicates values in units
1320 // of GeV, GeV/c or GeV/c**2.
1321 // So, a value of scale=0.001 indicates that energy/momentum values are
1322 // stored in units of MeV, MeV/c or MeV/c**2.
1325 ///////////////////////////////////////////////////////////////////////////
1326 void AliTrack::SetParticleCode(Int_t code)
1328 // Set the user defined particle id code (e.g. the PDF convention).
1331 ///////////////////////////////////////////////////////////////////////////
1332 Int_t AliTrack::GetParticleCode() const
1334 // Provide the user defined particle id code.
1337 ///////////////////////////////////////////////////////////////////////////
1338 void AliTrack::SetParentTrack(AliTrack * const t)
1340 // Set pointer to the parent track.
1343 ///////////////////////////////////////////////////////////////////////////
1344 AliTrack* AliTrack::GetParentTrack() const
1346 // Provide pointer to the parent track.
1349 ///////////////////////////////////////////////////////////////////////////
1350 void AliTrack::SetProb(Double_t prob)
1352 // Set hypothesis probability for this track.
1355 ///////////////////////////////////////////////////////////////////////////
1356 Float_t AliTrack::GetProb() const
1358 // Provide the hypothesis probability for this track.
1361 ///////////////////////////////////////////////////////////////////////////
1362 void AliTrack::SetFitDetails(const TObject* obj)
1364 // Enter the object containing the fit details.
1365 // In case an object to hold fit details was already present, this
1366 // will be deleted first before the new one is stored.
1367 // This means that SetFitDetails(0) can be used to just remove the
1368 // existing object with the fit details.
1369 // All objects derived from TObject can be entered in this way.
1370 // Obvious candidates for objects containing detailed fit information
1371 // are functions (e.g. TF1) and histograms (e.g. TH1F).
1372 // However, using an AliDevice object provides a very versatile facility
1373 // to store the parameters of various fit procedures.
1374 // In such a case the AliDevice can be used to provide the various fit
1375 // definitions and the corresponding fit parameters can be entered as
1376 // separate AliSignal objects which are stored as hits to the AliDevice.
1377 // In addition various functions and histograms can be linked to the
1378 // various AliSignal instances
1379 // The latter procedure is based on the original idea of Adam Bouchta.
1381 // Note : The entered object is owned by this AliTrack instance.
1382 // As such, a private copy of obj will be stored using the Clone()
1384 // In case the entered object contains pointers to other objects,
1385 // the user has to provide the appropriate Clone() memberfunction
1386 // for the class to which the entered object belongs.
1387 // An example can be seen from AliTrack::Clone().
1395 if (obj) fFit=obj->Clone();
1397 ///////////////////////////////////////////////////////////////////////////
1398 TObject* AliTrack::GetFitDetails() const
1400 // Provide the pointer to the object containing the fit details.
1403 ///////////////////////////////////////////////////////////////////////////
1404 void AliTrack::SetTimestamp(AliTimestamp& t)
1406 // Store the timestamp for this track.
1407 if (fTstamp) delete fTstamp;
1408 fTstamp=new AliTimestamp(t);
1410 ///////////////////////////////////////////////////////////////////////////
1411 AliTimestamp* AliTrack::GetTimestamp() const
1413 // Provide the timestamp of this track.
1416 ///////////////////////////////////////////////////////////////////////////
1417 void AliTrack::RemoveTimestamp()
1419 // Remove the timestamp from this track.
1426 ///////////////////////////////////////////////////////////////////////////
1427 Double_t AliTrack::GetDistance(AliPosition* const p,Float_t scale)
1429 // Provide distance of the current track to the position p.
1430 // The error on the result can be obtained as usual by invoking
1431 // GetResultError() afterwards.
1433 // By default the distance will be provided in the metric unit scale of
1434 // the AliPosition p.
1435 // However, the user can select a different metric unit scale by
1436 // specification of the scale parameter.
1437 // The convention is that scale=1 corresponds to meter, so specification
1438 // of scale=0.01 will provide the distance in cm.
1439 // As such it is possible to obtain a correctly computed distance even in case
1440 // the track parameters have a different unit scale.
1441 // However, it is recommended to work always with one single unit scale.
1443 // Note : In case of incomplete information, a distance value of -1 is
1449 if (!p) return dist;
1451 // Obtain a defined position on this track
1452 AliPosition* rx=fRef;
1456 if (!rx) return dist;
1458 Ali3Vector p1=Get3Momentum();
1460 if (p1.GetNorm() <= 0.) return dist;
1462 Ali3Vector r0=(Ali3Vector)(*rx);
1464 Float_t tscale=rx->GetUnitScale();
1465 Float_t pscale=p->GetUnitScale();
1466 if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale);
1468 // Obtain the direction unit vector of this track
1471 p1.GetVector(vec,"sph");
1472 p1.GetErrors(err,"sph");
1475 p1.SetVector(vec,"sph");
1476 p1.SetErrors(err,"sph");
1478 Ali3Vector q=(Ali3Vector)(*p);
1480 Ali3Vector d=r.Cross(p1);
1482 fDresult=d.GetResultError();
1486 fDresult*=pscale/scale;
1490 ///////////////////////////////////////////////////////////////////////////
1491 Double_t AliTrack::GetDistance(AliTrack* const t,Float_t scale)
1493 // Provide distance of the current track to the track t.
1494 // The error on the result can be obtained as usual by invoking
1495 // GetResultError() afterwards.
1497 // By default the distance will be provided in the metric unit scale of
1498 // the current track.
1499 // This implies that the results of t1.GetDistance(t2) and t2.GetDistance(t1)
1500 // may be numerically different in case t1 and t2 have different metric units.
1501 // However, the user can specify a required metric unit scale by specification
1502 // of the scale parameter.
1503 // The convention is that scale=1 corresponds to meter, so specification
1504 // of scale=0.01 will provide the distance in cm.
1505 // As such it is possible to obtain a correctly computed distance even in case
1506 // the track parameters have a different unit scale.
1507 // However, it is recommended to work always with one single unit scale.
1509 // Note : In case of incomplete information, a distance value of -1 is
1515 if (!t) return dist;
1517 // Obtain a defined position on this track
1518 AliPosition* rx=fRef;
1522 if (!rx) return dist;
1524 // Obtain a defined position on track t
1525 AliPosition* ry=t->GetReferencePoint();
1526 if (!ry) ry=t->GetBeginPoint();
1527 if (!ry) ry=t->GetEndPoint();
1529 if (!ry) return dist;
1531 Ali3Vector p1=Get3Momentum();
1532 Ali3Vector p2=t->Get3Momentum();
1534 if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist;
1536 // The vector normal to both track directions
1537 Ali3Vector n=p1.Cross(p2);
1539 Float_t scalex=rx->GetUnitScale();
1540 Float_t scaley=ry->GetUnitScale();
1542 if (n.GetNorm() > 1.e-10)
1544 // Normalise n to a unit vector
1547 n.GetVector(vec,"sph");
1548 n.GetErrors(err,"sph");
1551 n.SetVector(vec,"sph");
1552 n.SetErrors(err,"sph");
1553 Ali3Vector r1=(Ali3Vector)(*rx);
1554 Ali3Vector r2=(Ali3Vector)(*ry);
1555 // Correct components of r2 in case of different unit scales
1556 if ((scaley/scalex > 1.1) || (scalex/scaley > 1.1)) r2=r2*(scaley/scalex);
1558 dist=fabs(r.Dot(n));
1559 fDresult=r.GetResultError();
1561 else // Parallel tracks
1563 dist=t->GetDistance(rx);
1564 fDresult=t->GetResultError();
1570 fDresult*=scalex/scale;
1574 ///////////////////////////////////////////////////////////////////////////
1575 TObject* AliTrack::Clone(const char* name) const
1577 // Make a deep copy of the current object and provide the pointer to the copy.
1578 // This memberfunction enables automatic creation of new objects of the
1579 // correct type depending on the object type, a feature which may be very useful
1580 // for containers when adding objects in case the container owns the objects.
1581 // This feature allows e.g. AliJet to store either AliTrack objects or
1582 // objects derived from AliTrack via the AddTrack memberfunction, provided
1583 // these derived classes also have a proper Clone memberfunction.
1585 AliTrack* trk=new AliTrack(*this);
1588 if (strlen(name)) trk->SetName(name);
1592 ///////////////////////////////////////////////////////////////////////////