]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliTrack.cxx
Updates on golden D hadronic decay channel by
[u/mrichter/AliRoot.git] / RALICE / AliTrack.cxx
index 80c75d5323c69ec691d0ec589df50e9e50606789..8287e1b766bd6bc25d92886de29a2c301fc3aab6 100644 (file)
@@ -110,11 +110,14 @@ void AliTrack::Init()
  fHypotheses=0;
  fBegin=0;
  fEnd=0;
+ fRef=0;
  fImpactXY=0;
  fImpactXZ=0;
  fImpactYZ=0;
  fClosest=0;
  fParent=0;
+ fFit=0;
+ fTstamp=0;
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTrack::~AliTrack()
@@ -122,7 +125,6 @@ AliTrack::~AliTrack()
 // 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++)
  {
@@ -156,6 +158,11 @@ AliTrack::~AliTrack()
   delete fEnd;
   fEnd=0;
  }
+ if (fRef)
+ {
+  delete fRef;
+  fRef=0;
+ }
  if (fImpactXY)
  {
   delete fImpactXY;
@@ -176,9 +183,19 @@ AliTrack::~AliTrack()
   delete fClosest;
   fClosest=0;
  }
+ if (fFit)
+ {
+  delete fFit;
+  fFit=0;
+ }
+ if (fTstamp)
+ {
+  delete fTstamp;
+  fTstamp=0;
+ }
 }
 ///////////////////////////////////////////////////////////////////////////
-AliTrack::AliTrack(AliTrack& t) : TNamed(t),Ali4Vector(t)
+AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
 {
 // Copy constructor
  Init();
@@ -187,10 +204,13 @@ AliTrack::AliTrack(AliTrack& t) : TNamed(t),Ali4Vector(t)
  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;
@@ -271,6 +291,11 @@ void AliTrack::Reset()
   delete fEnd;
   fEnd=0;
  }
+ if (fRef)
+ {
+  delete fRef;
+  fRef=0;
+ }
  if (fImpactXY)
  {
   delete fImpactXY;
@@ -291,12 +316,25 @@ void AliTrack::Reset()
   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)
@@ -324,31 +362,66 @@ 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();
  const char* name=GetName();
  const char* title=GetTitle();
 
  cout << " *" << ClassName() << "::Data*";
- if (strlen(name))  cout << " Name : " << GetName();
- if (strlen(title)) cout << " Title : " << GetTitle();
+ if (strlen(name))  cout << " Name : " << name;
+ if (strlen(title)) cout << " Title : " << title;
  cout << endl;
+ if (fTstamp) fTstamp->Date(1);
  cout << " Id : " << fUserId << " Code : " << fCode
       << " m : " << m << " dm : " << dm << " Charge : " << fQ
       << " p : " << GetMomentum() << endl;
  cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
       << " Nsignals : " << GetNsignals() << endl;
- Ali4Vector::Data(f); 
+ if (fParent)
+ {
+  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;
+ }
+ 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; 
@@ -358,7 +431,7 @@ void AliTrack::List(TString f)
   if (td)
   {
    cout << "  ---Level 1 sec. track no. " << id << endl;
-   td->Data(f); 
+   td->Data(f,u); 
   }
   else
   {
@@ -367,13 +440,21 @@ void AliTrack::List(TString f)
  }
 } 
 ///////////////////////////////////////////////////////////////////////////
-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
- if (fBegin) { cout << " Begin-point :"; fBegin->Data(f); }
- if (fEnd)   { cout << " End-point   :"; fEnd->Data(f); }
+ 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)
@@ -382,7 +463,7 @@ void AliTrack::ListAll(TString f)
   for (Int_t ih=1; ih<=nhyp; ih++)
   {
    AliTrack* tx=GetTrackHypothesis(ih);
-   if (tx) tx->Data(f);
+   if (tx) tx->Data(f,u);
   }
  }
 
@@ -407,16 +488,16 @@ void AliTrack::ListAll(TString f)
     }
     r=sx->GetPosition();
     cout << "   Position";
-    r.Data(f);
+    r.Data(f,u);
    }
   }
  }
 
  AliTrack* t=this;
- Dumps(t,1,f); // Information of all decay products
+ Dumps(t,1,f,u); // Information of all decay products
 }
 //////////////////////////////////////////////////////////////////////////
-void AliTrack::Dumps(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; 
@@ -426,7 +507,7 @@ void AliTrack::Dumps(AliTrack* t,Int_t n,TString f)
   if (td)
   {
    cout << "  ---Level " << n << " sec. track no. " << id << endl;
-   td->Data(f); 
+   td->Data(f,u); 
 
    Int_t nhyp=td->GetNhypotheses();
    if (nhyp)
@@ -435,7 +516,7 @@ void AliTrack::Dumps(AliTrack* t,Int_t n,TString f)
     for (Int_t ih=1; ih<=nhyp; ih++)
     {
      AliTrack* tx=td->GetTrackHypothesis(ih);
-     if (tx) tx->Data(f);
+     if (tx) tx->Data(f,u);
     }
    }
 
@@ -446,12 +527,12 @@ void AliTrack::Dumps(AliTrack* t,Int_t n,TString f)
     for (Int_t is=1; is<=nsig; is++)
     {
      AliSignal* sx=td->GetSignal(is);
-     if (sx) sx->Data(f);
+     if (sx) sx->Data(f,u);
     }
    }
 
    // Go for next decay level of this decay track recursively
-   Dumps(td,n+1,f);
+   Dumps(td,n+1,f,u);
   }
   else
   {
@@ -470,7 +551,7 @@ Double_t AliTrack::GetMomentum()
  return norm;
 }
 ///////////////////////////////////////////////////////////////////////////
-Ali3Vector AliTrack::Get3Momentum()
+Ali3Vector AliTrack::Get3Momentum() const
 {
 // Provide the track 3-momentum
  return (Ali3Vector)Get3Vector();
@@ -500,7 +581,7 @@ Double_t AliTrack::GetMass()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Float_t AliTrack::GetCharge()
+Float_t AliTrack::GetCharge() const
 {
 // Provide the particle charge
  return fQ;
@@ -595,7 +676,7 @@ 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
  Int_t ndec=0;
@@ -603,7 +684,7 @@ Int_t AliTrack::GetNdecay()
  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
@@ -673,7 +754,7 @@ void AliTrack::RemoveSignals()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliTrack::GetNsignals()
+Int_t AliTrack::GetNsignals() const
 {
 // Provide the number of related AliSignals.
  Int_t nsig=0;
@@ -681,7 +762,7 @@ Int_t AliTrack::GetNsignals()
  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.
@@ -759,7 +840,7 @@ void AliTrack::RemoveTrackHypotheses()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliTrack::GetNhypotheses()
+Int_t AliTrack::GetNhypotheses() const
 {
 // Provide the number of track hypotheses.
  Int_t nhyp=0;
@@ -767,7 +848,7 @@ Int_t AliTrack::GetNhypotheses()
  return nhyp;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliTrack* AliTrack::GetTrackHypothesis(Int_t j)
+AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const
 {
 // Provide the j-th track hypothesis.
 // Note : j=1 denotes the first hypothesis.
@@ -813,14 +894,8 @@ AliTrack* AliTrack::GetTrackHypothesis(Int_t j)
 void AliTrack::SetBeginPoint(AliPosition& p)
 {
 // Store the position of the track begin-point.
- if (!fBegin)
- {
-  fBegin=new AliPositionObj(p);
- }
- else
- {
-  fBegin->Load(p);
- }
+ if (fBegin) delete fBegin;
+ fBegin=new AliPositionObj(p);
 }
 ///////////////////////////////////////////////////////////////////////////
 AliPosition* AliTrack::GetBeginPoint()
@@ -832,14 +907,8 @@ AliPosition* AliTrack::GetBeginPoint()
 void AliTrack::SetEndPoint(AliPosition& p)
 {
 // Store the position of the track end-point.
- if (!fEnd)
- {
-  fEnd=new AliPositionObj(p);
- }
- else
- {
-  fEnd->Load(p);
- }
+ if (fEnd) delete fEnd;
+ fEnd=new AliPositionObj(p);
 }
 ///////////////////////////////////////////////////////////////////////////
 AliPosition* AliTrack::GetEndPoint()
@@ -848,6 +917,27 @@ AliPosition* AliTrack::GetEndPoint()
  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.
@@ -976,36 +1066,18 @@ void AliTrack::SetImpactPoint(AliPosition& p,TString q)
  switch (axis)
  {
   case 1: // Impact-point in the plane X=0
-   if (!fImpactYZ)
-   {
-    fImpactYZ=new AliPositionObj(p);
-   }
-   else
-   {
-    fImpactYZ->Load(p);
-   }
+   if (fImpactYZ) delete fImpactYZ;
+   fImpactYZ=new AliPositionObj(p);
    break;
 
   case 2: // Impact-point in the plane Y=0
-   if (!fImpactXZ)
-   {
-    fImpactXZ=new AliPositionObj(p);
-   }
-   else
-   {
-    fImpactXZ->Load(p);
-   }
+   if (fImpactXZ) delete fImpactXZ;
+   fImpactXZ=new AliPositionObj(p);
    break;
 
   case 3: // Impact-point in the plane Z=0
-   if (!fImpactXY)
-   {
-    fImpactXY=new AliPositionObj(p);
-   }
-   else
-   {
-    fImpactXY->Load(p);
-   }
+   if (fImpactXY) delete fImpactXY;
+   fImpactXY=new AliPositionObj(p);
    break;
 
   default: // Unsupported axis
@@ -1050,7 +1122,7 @@ 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;
@@ -1059,14 +1131,8 @@ Int_t AliTrack::GetId()
 void AliTrack::SetClosestPoint(AliPosition& p)
 {
 // Set position p as the point of closest approach w.r.t. some reference
- if (!fClosest)
- {
-  fClosest=new AliPositionObj(p);
- }
- else
- {
-  fClosest->Load(p);
- }
+ if (fClosest) delete fClosest;
+ fClosest=new AliPositionObj(p);
 }
 ///////////////////////////////////////////////////////////////////////////
 AliPosition* AliTrack::GetClosestPoint()
@@ -1101,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;
@@ -1119,7 +1185,7 @@ 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;
@@ -1143,13 +1209,129 @@ void AliTrack::SetProb(Double_t prob)
  fProb=prob;
 }
 ///////////////////////////////////////////////////////////////////////////
-Float_t AliTrack::GetProb()
+Float_t AliTrack::GetProb() const
 {
 // Provide the hypothesis probability for this track.
  return fProb;
 }
 ///////////////////////////////////////////////////////////////////////////
-TObject* AliTrack::Clone(const char* name)
+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