X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=RALICE%2FAliTrack.cxx;h=8287e1b766bd6bc25d92886de29a2c301fc3aab6;hb=bb2a935f25323db112bb00c6af27c6b971cd50ea;hp=f520ceb2acd6f6f662b227b87ff461ed3383856e;hpb=84bb7c662a1f4f63efcc0ee92f7c9f7dfac1f196;p=u%2Fmrichter%2FAliRoot.git diff --git a/RALICE/AliTrack.cxx b/RALICE/AliTrack.cxx index f520ceb2acd..8287e1b766b 100644 --- a/RALICE/AliTrack.cxx +++ b/RALICE/AliTrack.cxx @@ -90,10 +90,11 @@ /////////////////////////////////////////////////////////////////////////// #include "AliTrack.h" +#include "Riostream.h" ClassImp(AliTrack) // Class implementation to enable ROOT I/O -AliTrack::AliTrack() +AliTrack::AliTrack() : TNamed(),Ali4Vector() { // Default constructor // All variables initialised to 0 @@ -106,14 +107,31 @@ void AliTrack::Init() // Initialisation of pointers etc... fDecays=0; fSignals=0; - fMasses=0; - fDmasses=0; - fPmasses=0; + fHypotheses=0; + fBegin=0; + fEnd=0; + fRef=0; + fImpactXY=0; + fImpactXZ=0; + fImpactYZ=0; + fClosest=0; + fParent=0; + fFit=0; + fTstamp=0; } /////////////////////////////////////////////////////////////////////////// AliTrack::~AliTrack() { -// Destructor to delete memory allocated for decay tracks array +// Destructor to delete memory allocated for decay tracks array. +// This destructor automatically cleares the pointer of this AliTrack +// from all the link slots of the related AliSignal objects. + Int_t nsig=GetNsignals(); + for (Int_t i=1; i<=nsig; i++) + { + AliSignal* s=GetSignal(i); + if (s) s->ResetLinks(this); + } + if (fDecays) { delete fDecays; @@ -125,66 +143,112 @@ AliTrack::~AliTrack() delete fSignals; fSignals=0; } + if (fHypotheses) + { + delete fHypotheses; + fHypotheses=0; + } + if (fBegin) + { + delete fBegin; + fBegin=0; + } + if (fEnd) + { + delete fEnd; + fEnd=0; + } + if (fRef) + { + delete fRef; + fRef=0; + } + if (fImpactXY) + { + delete fImpactXY; + fImpactXY=0; + } + if (fImpactXZ) + { + delete fImpactXZ; + fImpactXZ=0; + } + if (fImpactYZ) + { + delete fImpactYZ; + fImpactYZ=0; + } + if (fClosest) + { + delete fClosest; + fClosest=0; + } + if (fFit) + { + delete fFit; + fFit=0; + } + if (fTstamp) + { + delete fTstamp; + fTstamp=0; + } } /////////////////////////////////////////////////////////////////////////// -AliTrack::AliTrack(AliTrack& t) +AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t) { // Copy constructor Init(); - fQ=t.GetCharge(); - fChi2=t.GetChi2(); - fNdf=t.GetNdf(); - fUserId=t.GetId(); - fCode=t.GetParticleCode(); - fNdec=t.GetNdecay(); - fNsig=t.GetNsignals(); - fNmasses=t.GetNMassHypotheses(); - Set4Momentum((Ali4Vector&)t); - fBegin=t.GetBeginPoint(); - fEnd=t.GetEndPoint(); - fImpactXY=t.GetImpactPoint("z"); - fImpactXZ=t.GetImpactPoint("y"); - fImpactYZ=t.GetImpactPoint("x"); - fClosest=t.GetClosestPoint(); - - AliTrack* tx; - if (fNdec) - { - fDecays=new TObjArray(fNdec); + fQ=t.fQ; + fProb=t.fProb; + if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin)); + if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd)); + if (t.fRef) fRef=new AliPositionObj(*(t.fRef)); + if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY)); + if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ)); + if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ)); + if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest)); + if (t.fFit) fFit=t.fFit->Clone(); + if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp)); + fUserId=t.fUserId; + fChi2=t.fChi2; + fNdf=t.fNdf; + fCode=t.fCode; + fParent=t.fParent; + + Int_t ndec=t.GetNdecay(); + if (ndec) + { + fDecays=new TObjArray(ndec); fDecays->SetOwner(); - for (Int_t it=1; it<=fNdec; it++) + for (Int_t it=1; it<=ndec; it++) { - tx=t.GetDecayTrack(it); + AliTrack* tx=t.GetDecayTrack(it); fDecays->Add(new AliTrack(*tx)); } } - AliSignal* sx; - if (fNsig) + Int_t nsig=t.GetNsignals(); + if (nsig) { - fSignals=new TObjArray(fNsig); - for (Int_t is=1; is<=fNsig; is++) + fSignals=new TObjArray(nsig); + for (Int_t is=1; is<=nsig; is++) { - sx=t.GetSignal(is); + AliSignal* sx=t.GetSignal(is); fSignals->Add(sx); } } - Double_t prob,m,dm; - if (fNmasses) + Int_t nhyp=t.GetNhypotheses(); + if (nhyp) { - fMasses=new TArrayD(fNmasses); - fDmasses=new TArrayD(fNmasses); - fPmasses=new TArrayD(fNmasses); - for (Int_t ih=1; ih<=fNmasses; ih++) + fHypotheses=new TObjArray(nhyp); + fHypotheses->SetOwner(); + for (Int_t ih=1; ih<=nhyp; ih++) { - prob=t.GetMassHypothesisProb(ih); - m=t.GetMassHypothesis(ih); - dm=t.GetResultError(); - fMasses->AddAt(m,ih-1); - fDmasses->AddAt(dm,ih-1); - fPmasses->AddAt(prob,ih-1); + AliTrack* tx=t.GetTrackHypothesis(ih); + fHypotheses->Add(new AliTrack(*tx)); } } } @@ -197,11 +261,10 @@ void AliTrack::Reset() fNdf=0; fUserId=0; fCode=0; - fNdec=0; - fNsig=0; - fNmasses=0; + fProb=0; Double_t a[4]={0,0,0,0}; SetVector(a,"sph"); + fParent=0; if (fDecays) { delete fDecays; @@ -213,34 +276,65 @@ void AliTrack::Reset() delete fSignals; fSignals=0; } - Double_t b[3]={0,0,0}; - fBegin.SetPosition(b,"sph"); - fEnd.SetPosition(b,"sph"); - fImpactXY.SetPosition(b,"sph"); - fImpactXZ.SetPosition(b,"sph"); - fImpactYZ.SetPosition(b,"sph"); - fClosest.SetPosition(b,"sph"); - if (fMasses) + if (fHypotheses) + { + delete fHypotheses; + fHypotheses=0; + } + if (fBegin) + { + delete fBegin; + fBegin=0; + } + if (fEnd) + { + delete fEnd; + fEnd=0; + } + if (fRef) { - delete fMasses; - fMasses=0; + delete fRef; + fRef=0; } - if (fDmasses) + if (fImpactXY) { - delete fDmasses; - fDmasses=0; + delete fImpactXY; + fImpactXY=0; } - if (fPmasses) + if (fImpactXZ) { - delete fPmasses; - fPmasses=0; + delete fImpactXZ; + fImpactXZ=0; + } + if (fImpactYZ) + { + delete fImpactYZ; + fImpactYZ=0; + } + if (fClosest) + { + delete fClosest; + fClosest=0; + } + if (fFit) + { + delete fFit; + fFit=0; + } + if (fTstamp) + { + delete fTstamp; + fTstamp=0; } } /////////////////////////////////////////////////////////////////////////// void AliTrack::Set3Momentum(Ali3Vector& p) { -// Set the track parameters according to the 3-momentum p +// Set the track parameters according to the 3-momentum p. +// In case the mass was not yet set, the energy is set to correspond to m=0. Set3Vector(p); + Double_t inv=GetInvariant(); + if (inv<0) SetMass(0.); } /////////////////////////////////////////////////////////////////////////// void AliTrack::Set4Momentum(Ali4Vector& p) @@ -268,64 +362,142 @@ void AliTrack::SetCharge(Float_t q) fQ=q; } /////////////////////////////////////////////////////////////////////////// -void AliTrack::Data(TString f) +void AliTrack::Data(TString f,TString u) { // Provide track information within the coordinate frame f +// +// The string argument "u" allows to choose between different angular units +// in case e.g. a spherical frame is selected. +// u = "rad" : angles provided in radians +// "deg" : angles provided in degrees +// +// The defaults are f="car" and u="rad". + Double_t m=GetMass(); Double_t dm=GetResultError(); - cout << " *AliTrack::Data* Id : " << fUserId << " Code : " << fCode - << " Mass : " << m << " error : " << dm << " Charge : " << fQ - << " Momentum : " << GetMomentum() << " Nmass hyp. : " << fNmasses - << " Ntracks : " << fNdec << " Nsignals : " << fNsig << endl; - for (Int_t i=0; iDate(1); + cout << " Id : " << fUserId << " Code : " << fCode + << " m : " << m << " dm : " << dm << " Charge : " << fQ + << " p : " << GetMomentum() << endl; + cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay() + << " Nsignals : " << GetNsignals() << endl; + if (fParent) { - cout << " Mass hypothesis " << (i+1) << " Mass : " << fMasses->At(i) - << " error : " << fDmasses->At(i) << " prob. : " << fPmasses->At(i) - << endl; + cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode() + << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge() + << " p : " << fParent->GetMomentum(); + const char* pname=fParent->GetName(); + const char* ptitle=fParent->GetTitle(); + if (strlen(pname)) cout << " Name : " << pname; + if (strlen(ptitle)) cout << " Title : " << ptitle; + cout << endl; } - Ali4Vector::Data(f); + if (fFit) + { + cout << " Fit details present in object of class " << fFit->ClassName() << endl; + if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1); + } + Ali4Vector::Data(f,u); } /////////////////////////////////////////////////////////////////////////// -void AliTrack::List(TString f) +void AliTrack::List(TString f,TString u) { // Provide current track and decay level 1 information within coordinate frame f +// +// The string argument "u" allows to choose between different angular units +// in case e.g. a spherical frame is selected. +// u = "rad" : angles provided in radians +// "deg" : angles provided in degrees +// +// The defaults are f="car" and u="rad". - Data(f); // Information of the current track + Data(f,u); // Information of the current track + if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); } + if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); } + if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); } // Decay products of this track AliTrack* td; - for (Int_t id=1; id<=fNdec; id++) + for (Int_t id=1; id<=GetNdecay(); id++) { td=GetDecayTrack(id); if (td) { cout << " ---Level 1 sec. track no. " << id << endl; - td->Data(f); + td->Data(f,u); } else { - cout << " *AliTrack::List* Error : No decay track present." << endl; + cout << " *AliTrack::List* Error : Empty decay track slot." << endl; } } } /////////////////////////////////////////////////////////////////////////// -void AliTrack::ListAll(TString f) +void AliTrack::ListAll(TString f,TString u) { // Provide complete track and decay information within the coordinate frame f +// +// The string argument "u" allows to choose between different angular units +// in case e.g. a spherical frame is selected. +// u = "rad" : angles provided in radians +// "deg" : angles provided in degrees +// +// The defaults are f="car" and u="rad". - Data(f); // Information of the current track - cout << " Begin-point :"; fBegin.Data(f); - cout << " End-point :"; fEnd.Data(f); - for (Int_t is=1; is<=GetNsignals(); is++) + Data(f,u); // Information of the current track + if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); } + if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); } + if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); } + + Int_t nhyp=GetNhypotheses(); + if (nhyp) { - ((AliSignal*)GetSignal(is))->Data(f); + cout << " List of the " << nhyp << " track hypotheses : " << endl; + for (Int_t ih=1; ih<=nhyp; ih++) + { + AliTrack* tx=GetTrackHypothesis(ih); + if (tx) tx->Data(f,u); + } + } + + Int_t nsig=GetNsignals(); + if (nsig) + { + cout << " List of the corresponding slots for the " << nsig + << " related signals : " << endl; + AliPosition r; + Int_t nrefs,jslot; + TArrayI slotarr; + for (Int_t is=1; is<=nsig; is++) + { + AliSignal* sx=GetSignal(is); + if (sx) + { + nrefs=sx->GetIndices(this,slotarr,0); + for (Int_t jref=0; jrefList(jslot); + } + r=sx->GetPosition(); + cout << " Position"; + r.Data(f,u); + } + } } AliTrack* t=this; - Dump(t,1,f); // Information of all decay products + Dumps(t,1,f,u); // Information of all decay products } ////////////////////////////////////////////////////////////////////////// -void AliTrack::Dump(AliTrack* t,Int_t n,TString f) +void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u) { // Recursively provide the info of all decay levels of this track AliTrack* td; @@ -335,18 +507,36 @@ void AliTrack::Dump(AliTrack* t,Int_t n,TString f) if (td) { cout << " ---Level " << n << " sec. track no. " << id << endl; - td->Data(f); - for (Int_t is=1; is<=td->GetNsignals(); is++) + td->Data(f,u); + + Int_t nhyp=td->GetNhypotheses(); + if (nhyp) { - ((AliSignal*)td->GetSignal(is))->Data(f); + cout << " List of the " << nhyp << " track hypotheses : " << endl; + for (Int_t ih=1; ih<=nhyp; ih++) + { + AliTrack* tx=td->GetTrackHypothesis(ih); + if (tx) tx->Data(f,u); + } + } + + Int_t nsig=td->GetNsignals(); + if (nsig) + { + cout << " List of the " << nsig << " related signals : " << endl; + for (Int_t is=1; is<=nsig; is++) + { + AliSignal* sx=td->GetSignal(is); + if (sx) sx->Data(f,u); + } } // Go for next decay level of this decay track recursively - Dump(td,n+1,f); + Dumps(td,n+1,f,u); } else { - cout << " *AliTrack::Dump* Error : No decay track present." << endl; + cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl; } } } @@ -361,7 +551,7 @@ Double_t AliTrack::GetMomentum() return norm; } /////////////////////////////////////////////////////////////////////////// -Ali3Vector AliTrack::Get3Momentum() +Ali3Vector AliTrack::Get3Momentum() const { // Provide the track 3-momentum return (Ali3Vector)Get3Vector(); @@ -391,7 +581,7 @@ Double_t AliTrack::GetMass() } } /////////////////////////////////////////////////////////////////////////// -Float_t AliTrack::GetCharge() +Float_t AliTrack::GetCharge() const { // Provide the particle charge return fQ; @@ -423,8 +613,6 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) // thcms : cms theta decay angle (in rad.) of m1 // phicms : cms phi decay angle (in rad.) of m1 - fNdec=2; // it's a 2-body decay - Double_t M=GetMass(); // Compute the 4-momenta of the decay products in the cms @@ -477,7 +665,7 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) delete fDecays; fDecays=0; } - fDecays=new TObjArray(); + fDecays=new TObjArray(2); fDecays->SetOwner(); fDecays->Add(new AliTrack); @@ -488,13 +676,15 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) ((AliTrack*)fDecays->At(1))->SetMass(m2); } /////////////////////////////////////////////////////////////////////////// -Int_t AliTrack::GetNdecay() +Int_t AliTrack::GetNdecay() const { // Provide the number of decay produced tracks - return fNdec; + Int_t ndec=0; + if (fDecays) ndec=fDecays->GetEntries(); + return ndec; } /////////////////////////////////////////////////////////////////////////// -AliTrack* AliTrack::GetDecayTrack(Int_t j) +AliTrack* AliTrack::GetDecayTrack(Int_t j) const { // Provide decay produced track number j // Note : j=1 denotes the first decay track @@ -505,48 +695,74 @@ AliTrack* AliTrack::GetDecayTrack(Int_t j) } else { - if ((j >= 1) && (j <= fNdec)) + if ((j >= 1) && (j <= GetNdecay())) { return (AliTrack*)fDecays->At(j-1); } else { cout << " *AliTrack* decay track number : " << j << " out of range." - << " Ndec = " << fNdec << endl; + << " Ndec = " << GetNdecay() << endl; return 0; } } } /////////////////////////////////////////////////////////////////////////// +void AliTrack::RemoveDecays() +{ +// Remove all decay tracks from this track. + if (fDecays) + { + delete fDecays; + fDecays=0; + } +} +/////////////////////////////////////////////////////////////////////////// void AliTrack::AddSignal(AliSignal& s) { // Relate an AliSignal object to this track. - if (!fSignals) fSignals=new TObjArray(); - fNsig++; + if (!fSignals) fSignals=new TObjArray(1); + + // Check if this signal is already stored for this track + Int_t nsig=GetNsignals(); + for (Int_t i=0; iAt(i)) return; + } + fSignals->Add(&s); } /////////////////////////////////////////////////////////////////////////// void AliTrack::RemoveSignal(AliSignal& s) { -// Remove related AliSignal object to this track. +// Remove related AliSignal object from this track. if (fSignals) { AliSignal* test=(AliSignal*)fSignals->Remove(&s); - if (test) - { - fNsig--; - fSignals->Compress(); - } + if (test) fSignals->Compress(); + } +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::RemoveSignals() +{ +// Remove all related AliSignal objects from this track. + if (fSignals) + { + fSignals->Clear(); + delete fSignals; + fSignals=0; } } /////////////////////////////////////////////////////////////////////////// -Int_t AliTrack::GetNsignals() +Int_t AliTrack::GetNsignals() const { // Provide the number of related AliSignals. - return fNsig; + Int_t nsig=0; + if (fSignals) nsig=fSignals->GetEntries(); + return nsig; } /////////////////////////////////////////////////////////////////////////// -AliSignal* AliTrack::GetSignal(Int_t j) +AliSignal* AliTrack::GetSignal(Int_t j) const { // Provide the related AliSignal number j. // Note : j=1 denotes the first signal. @@ -557,169 +773,183 @@ AliSignal* AliTrack::GetSignal(Int_t j) } else { - if ((j >= 1) && (j <= fNsig)) + if ((j >= 1) && (j <= GetNsignals())) { return (AliSignal*)fSignals->At(j-1); } else { cout << " *AliTrack* signal number : " << j << " out of range." - << " Nsig = " << fNsig << endl; + << " Nsig = " << GetNsignals() << endl; return 0; } } } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetBeginPoint(AliPosition p) +void AliTrack::AddTrackHypothesis(AliTrack& t) { -// Store the position of the track begin-point. - fBegin=p; -} -/////////////////////////////////////////////////////////////////////////// -AliPosition AliTrack::GetBeginPoint() -{ -// Provide the position of the track begin-point. - return fBegin; +// Relate a track hypothesis to this track. +// Note : a private copy of the input track will be made via the Clone() +// facility. + if (!fHypotheses) + { + fHypotheses=new TObjArray(1); + fHypotheses->SetOwner(); + } + fHypotheses->Add(t.Clone()); } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetEndPoint(AliPosition p) +void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm) { -// Store the position of the track end-point. - fEnd=p; +// Add a track hypothesis by explicitly setting the mass and probability. +// This will affect e.g. the hypothesis track's energy, since the momentum +// and all other attributes will be copied from the current track. +// +// Input arguments : +// ----------------- +// prob=probalility m=mass value dm=error on the mass value. +// The default value for the mass error dm is 0. + + AliTrack t(*this); + t.RemoveDecays(); + t.RemoveTrackHypotheses(); + t.RemoveSignals(); + t.SetTitle("Mass hypothesis"); + t.SetMass(m,dm); + t.SetProb(prob); + AddTrackHypothesis(t); } /////////////////////////////////////////////////////////////////////////// -AliPosition AliTrack::GetEndPoint() +void AliTrack::RemoveTrackHypothesis(AliTrack& t) { -// Provide the position of the track end-point. - return fEnd; +// Remove the specified track hypothesis from this track. + if (fHypotheses) + { + AliTrack* test=(AliTrack*)fHypotheses->Remove(&t); + if (test) fHypotheses->Compress(); + } } /////////////////////////////////////////////////////////////////////////// -void AliTrack::AddMassHypothesis(Double_t prob,Double_t m,Double_t dm) +void AliTrack::RemoveTrackHypotheses() { -// Add a mass hypothesis for this current track. -// prob=probalility m=mass value dm=error on the mass value. -// The default value for the mass error dm is 0. - if (!fMasses) fMasses=new TArrayD(); - if (!fDmasses) fDmasses=new TArrayD(); - if (!fPmasses) fPmasses=new TArrayD(); - - fNmasses++; - fMasses->Set(fNmasses); - fDmasses->Set(fNmasses); - fPmasses->Set(fNmasses); - - fMasses->AddAt(m,fNmasses-1); - fDmasses->AddAt(dm,fNmasses-1); - fPmasses->AddAt(prob,fNmasses-1); +// Remove all track hypotheses from this track. + if (fHypotheses) + { + delete fHypotheses; + fHypotheses=0; + } } /////////////////////////////////////////////////////////////////////////// -Int_t AliTrack::GetNMassHypotheses() +Int_t AliTrack::GetNhypotheses() const { -// Provide the number of mass hypotheses for this track. - return fNmasses; +// Provide the number of track hypotheses. + Int_t nhyp=0; + if (fHypotheses) nhyp=fHypotheses->GetEntries(); + return nhyp; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetMassHypothesis(Int_t j) +AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const { -// Provide the mass of the jth hypothesis for this track. -// Note : the first hypothesis is indicated by j=1. +// Provide the j-th track hypothesis. +// Note : j=1 denotes the first hypothesis. // Default : j=0 ==> Hypothesis with highest probability. -// The error on the mass can be obtained by invoking GetResultError() -// after invokation of GetMassHypothesis(j). - Double_t m=0,dm=0,prob=0; + if (!fHypotheses) return 0; + + Int_t nhyp=GetNhypotheses(); // Check validity of index j - if (j<0 || j>fNmasses) + if (j<0 || j>nhyp) { - cout << " *AliTrack::GetMassHypothesis* Invalid index j : " << j - << " Number of mass hypotheses : " << fNmasses << endl; - fDresult=0; - return 0; - } + cout << " *AliTrack* hypothesis number : " << j << " out of range." + << " Nhyp = " << nhyp << endl; + return 0; + } - // Select mass hypothesis with highest probability - if (j==0) + AliTrack* t=0; + + if (j==0) // Provide track hypothesis with highest probability { - if (fNmasses) + Float_t prob=0; + t=(AliTrack*)fHypotheses->At(0); + if (t) prob=t->GetProb(); + Float_t probx=0; + for (Int_t ih=1; ihAt(0); - dm=fDmasses->At(0); - prob=fPmasses->At(0); - for (Int_t i=1; iAt(ih); + if (tx) { - if (fPmasses->At(i)>prob) - { - m=fMasses->At(i); - dm=fDmasses->At(i); - } + probx=tx->GetProb(); + if (probx > prob) t=tx; } } - fDresult=dm; - return m; + return t; + } + else // Provide requested j-th track hypothesis + { + return (AliTrack*)fHypotheses->At(j-1); } - - // Provide data of requested mass hypothesis - m=fMasses->At(j-1); - fDresult=fDmasses->At(j-1); - return m; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetMassHypothesisProb(Int_t j) +void AliTrack::SetBeginPoint(AliPosition& p) { -// Provide the probability of the jth hypothesis for this track. -// Note : the first hypothesis is indicated by j=1. -// Default : j=0 ==> Hypothesis with highest probability. - - Double_t prob=0; - - // Check validity of index j - if (j<0 || j>fNmasses) - { - cout << " *AliTrack::GetMassHypothesisProb* Invalid index j : " << j - << " Number of mass hypotheses : " << fNmasses << endl; - return 0; - } - - // Select mass hypothesis with highest probability - if (j==0) - { - if (fNmasses) - { - prob=fPmasses->At(0); - for (Int_t i=1; iAt(i)>prob) prob=fPmasses->At(i); - } - } - return prob; - } - - // Provide probability of requested mass hypothesis - prob=fPmasses->At(j-1); - return prob; +// Store the position of the track begin-point. + if (fBegin) delete fBegin; + fBegin=new AliPositionObj(p); +} +/////////////////////////////////////////////////////////////////////////// +AliPosition* AliTrack::GetBeginPoint() +{ +// Provide the position of the track begin-point. + return fBegin; +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::SetEndPoint(AliPosition& p) +{ +// Store the position of the track end-point. + if (fEnd) delete fEnd; + fEnd=new AliPositionObj(p); +} +/////////////////////////////////////////////////////////////////////////// +AliPosition* AliTrack::GetEndPoint() +{ +// Provide the position of the track end-point. + return fEnd; +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::SetReferencePoint(AliPosition& p) +{ +// Store the position of the track reference-point. +// The reference-point is the point on the track in which the +// 3-momentum vector components have been defined. +// This reference point is the preferable point to start track extrapolations +// etc... which are sensitive to the components of the 3-momentum vector. + if (fRef) delete fRef; + fRef=new AliPositionObj(p); +} +/////////////////////////////////////////////////////////////////////////// +AliPosition* AliTrack::GetReferencePoint() +{ +// Provide the position of the track reference-point. +// The reference-point is the point on the track in which the +// 3-momentum vector components have been defined. +// This reference point is the preferable point to start track extrapolations +// etc... which are sensitive to the components of the 3-momentum vector. + return fRef; } /////////////////////////////////////////////////////////////////////////// void AliTrack::SetMass() { // Set the mass and error to the value of the hypothesis with highest prob. - Double_t m=0,dm=0,prob=0; + Double_t m=0,dm=0; // Select mass hypothesis with highest probability - if (fNmasses) + AliTrack* t=GetTrackHypothesis(0); + if (t) { - m=fMasses->At(0); - dm=fDmasses->At(0); - prob=fPmasses->At(0); - for (Int_t i=1; iAt(i)>prob) - { - m=fMasses->At(i); - dm=fDmasses->At(i); - } - } + m=t->GetMass(); + dm=t->GetResultError(); SetMass(m,dm); } else @@ -728,34 +958,6 @@ void AliTrack::SetMass() } } /////////////////////////////////////////////////////////////////////////// -void AliTrack::RemoveMassHypothesis(Int_t j) -{ -// Remove the jth mass hypothesis for this track. -// Note : the first hypothesis is indicated by j=1. - - if (j<=0 || j>fNmasses) // Check validity of index j - { - cout << " *AliTrack::RemoveMassHypothesis* Invalid index j : " << j - << " Number of mass hypotheses : " << fNmasses << endl; - } - else - { - if (j != fNmasses) - { - fMasses->AddAt(fMasses->At(fNmasses-1),j-1); - fDmasses->AddAt(fDmasses->At(fNmasses-1),j-1); - fPmasses->AddAt(fPmasses->At(fNmasses-1),j-1); - } - fMasses->AddAt(0,fNmasses-1); - fDmasses->AddAt(0,fNmasses-1); - fPmasses->AddAt(0,fNmasses-1); - fNmasses--; - fMasses->Set(fNmasses); - fDmasses->Set(fNmasses); - fPmasses->Set(fNmasses); - } -} -/////////////////////////////////////////////////////////////////////////// Double_t AliTrack::GetPt() { // Provide trans. momentum value w.r.t. z-axis. @@ -827,26 +1029,6 @@ Double_t AliTrack::GetMt() return mt; } /////////////////////////////////////////////////////////////////////////// -Double_t AliTrack::GetMt(Int_t j) -{ -// Provide transverse mass value w.r.t. z-axis and jth mass hypothesis. -// Note : the first hypothesis is indicated by j=1. -// j=0 ==> Hypothesis with highest probability. -// The error on the value can be obtained by GetResultError() -// after invokation of GetMt(j). - Double_t pt=GetPt(); - Double_t dpt=GetResultError(); - Double_t m=GetMassHypothesis(j); - Double_t dm=GetResultError(); - - Double_t mt=sqrt(pt*pt+m*m); - Double_t dmt2=0; - if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt); - - fDresult=sqrt(dmt2); - return mt; -} -/////////////////////////////////////////////////////////////////////////// Double_t AliTrack::GetRapidity() { // Provide rapidity value w.r.t. z-axis. @@ -870,7 +1052,7 @@ Double_t AliTrack::GetRapidity() return y; } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetImpactPoint(AliPosition p,TString q) +void AliTrack::SetImpactPoint(AliPosition& p,TString q) { // Store the position of the impact-point in the plane "q=0". // Here q denotes one of the axes X, Y or Z. @@ -884,15 +1066,18 @@ void AliTrack::SetImpactPoint(AliPosition p,TString q) switch (axis) { case 1: // Impact-point in the plane X=0 - fImpactYZ=p; + if (fImpactYZ) delete fImpactYZ; + fImpactYZ=new AliPositionObj(p); break; case 2: // Impact-point in the plane Y=0 - fImpactXZ=p; + if (fImpactXZ) delete fImpactXZ; + fImpactXZ=new AliPositionObj(p); break; case 3: // Impact-point in the plane Z=0 - fImpactXY=p; + if (fImpactXY) delete fImpactXY; + fImpactXY=new AliPositionObj(p); break; default: // Unsupported axis @@ -902,13 +1087,12 @@ void AliTrack::SetImpactPoint(AliPosition p,TString q) } } /////////////////////////////////////////////////////////////////////////// -AliPosition AliTrack::GetImpactPoint(TString q) +AliPosition* AliTrack::GetImpactPoint(TString q) { // Provide the position of the impact-point in the plane "q=0". // Here q denotes one of the axes X, Y or Z. // Note : The character to denote the axis may be entered in lower or // in uppercase. - AliPosition dummy; Int_t axis=0; if (q=="x" || q=="X") axis=1; if (q=="y" || q=="Y") axis=2; @@ -928,7 +1112,7 @@ AliPosition AliTrack::GetImpactPoint(TString q) default: // Unsupported axis cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl << " Possible axes are 'X', 'Y' and 'Z'." << endl; - return dummy; + return 0; } } /////////////////////////////////////////////////////////////////////////// @@ -938,19 +1122,20 @@ void AliTrack::SetId(Int_t id) fUserId=id; } /////////////////////////////////////////////////////////////////////////// -Int_t AliTrack::GetId() +Int_t AliTrack::GetId() const { // Provide the user defined unique identifier of this track. return fUserId; } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetClosestPoint(AliPosition p) +void AliTrack::SetClosestPoint(AliPosition& p) { // Set position p as the point of closest approach w.r.t. some reference - fClosest=p; + if (fClosest) delete fClosest; + fClosest=new AliPositionObj(p); } /////////////////////////////////////////////////////////////////////////// -AliPosition AliTrack::GetClosestPoint() +AliPosition* AliTrack::GetClosestPoint() { // Provide the point of closest approach w.r.t. some reference return fClosest; @@ -982,13 +1167,13 @@ void AliTrack::SetNdf(Int_t ndf) } } /////////////////////////////////////////////////////////////////////////// -Float_t AliTrack::GetChi2() +Float_t AliTrack::GetChi2() const { // Provide the chi-squared value of the track fit. return fChi2; } /////////////////////////////////////////////////////////////////////////// -Int_t AliTrack::GetNdf() +Int_t AliTrack::GetNdf() const { // Provide the number of degrees of freedom for the track fit. return fNdf; @@ -1000,9 +1185,167 @@ void AliTrack::SetParticleCode(Int_t code) fCode=code; } /////////////////////////////////////////////////////////////////////////// -Int_t AliTrack::GetParticleCode() +Int_t AliTrack::GetParticleCode() const { // Provide the user defined particle id code. return fCode; } /////////////////////////////////////////////////////////////////////////// +void AliTrack::SetParentTrack(AliTrack* t) +{ +// Set pointer to the parent track. + fParent=t; +} +/////////////////////////////////////////////////////////////////////////// +AliTrack* AliTrack::GetParentTrack() +{ +// Provide pointer to the parent track. + return fParent; +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::SetProb(Double_t prob) +{ +// Set hypothesis probability for this track. + fProb=prob; +} +/////////////////////////////////////////////////////////////////////////// +Float_t AliTrack::GetProb() const +{ +// Provide the hypothesis probability for this track. + return fProb; +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::SetFitDetails(TObject* obj) +{ +// Enter the object containing the fit details. +// In case an object to hold fit details was already present, this +// will be deleted first before the new one is stored. +// This means that SetFitDetails(0) can be used to just remove the +// existing object with the fit details. +// All objects derived from TObject can be entered in this way. +// Obvious candidates for objects containing detailed fit information +// are functions (e.g. TF1) and histograms (e.g. TH1F). +// However, using an AliDevice object provides a very versatile facility +// to store the parameters of various fit procedures. +// In such a case the AliDevice can be used to provide the various fit +// definitions and the corresponding fit parameters can be entered as +// separate AliSignal objects which are stored as hits to the AliDevice. +// In addition various functions and histograms can be linked to the +// various AliSignal instances +// The latter procedure is based on the original idea of Adam Bouchta. +// +// Note : The entered object is owned by this AliTrack instance. +// As such, a private copy of obj will be stored using the Clone() +// memberfunction. +// In case the entered object contains pointers to other objects, +// the user has to provide the appropriate Clone() memberfunction +// for the class to which the entered object belongs. +// An example can be seen from AliTrack::Clone(). +// + if (fFit) + { + delete fFit; + fFit=0; + } + + if (obj) fFit=obj->Clone(); +} +/////////////////////////////////////////////////////////////////////////// +TObject* AliTrack::GetFitDetails() +{ +// Provide the pointer to the object containing the fit details. + return fFit; +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::SetTimestamp(AliTimestamp& t) +{ +// Store the timestamp for this track. + if (fTstamp) delete fTstamp; + fTstamp=new AliTimestamp(t); +} +/////////////////////////////////////////////////////////////////////////// +AliTimestamp* AliTrack::GetTimestamp() +{ +// Provide the timestamp of this track. + return fTstamp; +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::RemoveTimestamp() +{ +// Remove the timestamp from this track. + if (fTstamp) + { + delete fTstamp; + fTstamp=0; + } +} +/////////////////////////////////////////////////////////////////////////// +Double_t AliTrack::GetDistance(AliPosition* p) +{ +// Provide distance of the current track to the position p. +// The error on the result can be obtained as usual by invoking +// GetResultError() afterwards. +// +// The distance will be provided in the unit scale of the AliPosition p. +// As such it is possible to obtain a correctly computed distance even in case +// the track parameters have a different unit scale. +// However, it is recommended to work always with one single unit scale. +// +// Note : In case of incomplete information, a distance value of -1 is +// returned. + + Double_t dist=-1.; + fDresult=0.; + + if (!p) return dist; + + // Obtain a defined position on this track + AliPosition* rx=fRef; + if (!rx) rx=fBegin; + if (!rx) rx=fEnd; + + if (!rx) return dist; + + Ali3Vector r0=(Ali3Vector)(*rx); + + Float_t tscale=rx->GetUnitScale(); + Float_t pscale=p->GetUnitScale(); + if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale); + + // Obtain the direction unit vector of this track + Double_t vec[3]; + Double_t err[3]; + Ali3Vector p1=Get3Momentum(); + p1.GetVector(vec,"sph"); + p1.GetErrors(err,"sph"); + vec[0]=1.; + err[0]=0.; + p1.SetVector(vec,"sph"); + p1.SetErrors(err,"sph"); + + Ali3Vector q=(Ali3Vector)(*p); + Ali3Vector r=q-r0; + Ali3Vector d=r.Cross(p1); + dist=d.GetNorm(); + fDresult=d.GetResultError(); + return dist; +} +/////////////////////////////////////////////////////////////////////////// +TObject* AliTrack::Clone(const char* name) const +{ +// Make a deep copy of the current object and provide the pointer to the copy. +// This memberfunction enables automatic creation of new objects of the +// correct type depending on the object type, a feature which may be very useful +// for containers when adding objects in case the container owns the objects. +// This feature allows e.g. AliJet to store either AliTrack objects or +// objects derived from AliTrack via the AddTrack memberfunction, provided +// these derived classes also have a proper Clone memberfunction. + + AliTrack* trk=new AliTrack(*this); + if (name) + { + if (strlen(name)) trk->SetName(name); + } + return trk; +} +///////////////////////////////////////////////////////////////////////////