]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliTrack.cxx
Merging the VirtualMC branch to the main development branch (HEAD)
[u/mrichter/AliRoot.git] / RALICE / AliTrack.cxx
index 191300dec6338725ed1327b3c350365557df4e69..4a64ec553fda46e23c0ca3b08589991f7a263eeb 100644 (file)
@@ -97,12 +97,18 @@ AliTrack::AliTrack()
 {
 // Default constructor
 // All variables initialised to 0
+ Init();
+ Reset();
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::Init()
+{
+// Initialisation of pointers etc...
  fDecays=0;
  fSignals=0;
  fMasses=0;
  fDmasses=0;
  fPmasses=0;
- Reset();
 }
 ///////////////////////////////////////////////////////////////////////////
 AliTrack::~AliTrack()
@@ -110,7 +116,6 @@ AliTrack::~AliTrack()
 // Destructor to delete memory allocated for decay tracks array
  if (fDecays)
  {
-  fDecays->Delete();
   delete fDecays;
   fDecays=0;
  }
@@ -122,10 +127,74 @@ AliTrack::~AliTrack()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
+AliTrack::AliTrack(AliTrack& t)
+{
+// Copy constructor
+ Init();
+
+ fQ=t.GetCharge();
+ fChi2=t.GetChi2();
+ fNdf=t.GetNdf();
+ fUserId=t.GetId();
+ 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);
+  fDecays->SetOwner();
+  for (Int_t it=1; it<=fNdec; it++)
+  {
+   tx=t.GetDecayTrack(it);
+   fDecays->Add(new AliTrack(*tx));
+  }
+ }
+
+ AliSignal* sx;
+ if (fNsig)
+ {
+  fSignals=new TObjArray(fNsig);
+  for (Int_t is=1; is<=fNsig; is++)
+  {
+   sx=t.GetSignal(is);
+   fSignals->Add(sx);
+  }
+ }
+
+ Double_t prob,m,dm;
+ if (fNmasses)
+ {
+  fMasses=new TArrayD(fNmasses);
+  fDmasses=new TArrayD(fNmasses);
+  fPmasses=new TArrayD(fNmasses);
+  for (Int_t ih=1; ih<=fNmasses; 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);
+  }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
 void AliTrack::Reset()
 {
-// Reset all variables to 0
+// Reset all variables to 0 and delete all auto-generated decay tracks.
  fQ=0;
+ fChi2=0;
+ fNdf=0;
+ fUserId=0;
  fNdec=0;
  fNsig=0;
  fNmasses=0;
@@ -133,7 +202,6 @@ void AliTrack::Reset()
  SetVector(a,"sph");
  if (fDecays)
  {
-  fDecays->Delete();
   delete fDecays;
   fDecays=0;
  }
@@ -146,6 +214,10 @@ void AliTrack::Reset()
  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)
  {
   delete fMasses;
@@ -199,7 +271,7 @@ void AliTrack::Info(TString f)
 // Provide track information within the coordinate frame f
  Double_t m=GetMass();
  Double_t dm=GetResultError();
- cout << " *AliTrack::Info* Mass : " << m
+ cout << " *AliTrack::Info* Id : " << fUserId << " Mass : " << m
       << " error : " << dm << " Charge : " << fQ
       << " Momentum : " << GetMomentum() << " Nmass hyp. : " << fNmasses
       << " Ntracks : " << fNdec << " Nsignals : " << fNsig << endl;
@@ -400,10 +472,11 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
  // Enter the boosted data into the decay tracks array
  if (fDecays)
  {
-  fDecays->Delete();
   delete fDecays;
+  fDecays=0;
  }
  fDecays=new TObjArray();
+ fDecays->SetOwner();
 
  fDecays->Add(new AliTrack);
  ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
@@ -423,15 +496,23 @@ AliTrack* AliTrack::GetDecayTrack(Int_t j)
 {
 // Provide decay produced track number j
 // Note : j=1 denotes the first decay track
- if ((j >= 1) && (j <= fNdec))
+ if (!fDecays)
  {
-  return (AliTrack*)fDecays->At(j-1);
+  cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
+  return 0;
  }
  else
  {
-  cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
-  cout << " -- Decay track number 1 (if any) returned." << endl;
-  return (AliTrack*)fDecays->At(0);
+  if ((j >= 1) && (j <= fNdec))
+  {
+   return (AliTrack*)fDecays->At(j-1);
+  }
+  else
+  {
+   cout << " *AliTrack* decay track number : " << j << " out of range."
+        << " Ndec = " << fNdec << endl;
+   return 0;  
+  }
  }
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -467,15 +548,23 @@ AliSignal* AliTrack::GetSignal(Int_t j)
 {
 // Provide the related AliSignal number j.
 // Note : j=1 denotes the first signal.
- if ((j >= 1) && (j <= fNsig))
+ if (!fSignals)
  {
-  return (AliSignal*)fSignals->At(j-1);
+  cout << " *AliTrack::GetSignal* No signals present." << endl;
+  return 0;
  }
  else
  {
-  cout << " *AliTrack* signal number : " << j << " out of range." << endl;
-  cout << " -- Signal number 1 (if any) returned." << endl;
-  return (AliSignal*)fDecays->At(0);
+  if ((j >= 1) && (j <= fNsig))
+  {
+   return (AliSignal*)fSignals->At(j-1);
+  }
+  else
+  {
+   cout << " *AliTrack* signal number : " << j << " out of range."
+        << " Nsig = " << fNsig << endl;
+   return 0;
+  }
  }
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -779,3 +868,127 @@ Double_t AliTrack::GetRapidity()
  return y;
 }
 ///////////////////////////////////////////////////////////////////////////
+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.
+// Note : The character to denote the axis may be entered in lower or
+//        in uppercase.
+ Int_t axis=0;
+ if (q=="x" || q=="X") axis=1;
+ if (q=="y" || q=="Y") axis=2;
+ if (q=="z" || q=="Z") axis=3;
+
+ switch (axis)
+ {
+  case 1: // Impact-point in the plane X=0
+   fImpactYZ=p;
+   break;
+
+  case 2: // Impact-point in the plane Y=0
+   fImpactXZ=p;
+   break;
+
+  case 3: // Impact-point in the plane Z=0
+   fImpactXY=p;
+   break;
+
+  default: // Unsupported axis
+   cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
+        << " Possible axes are 'X', 'Y' and 'Z'." << endl; 
+   break;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+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;
+ if (q=="z" || q=="Z") axis=3;
+
+ switch (axis)
+ {
+  case 1: // Impact-point in the plane X=0
+   return fImpactYZ;
+
+  case 2: // Impact-point in the plane Y=0
+   return fImpactXZ;
+
+  case 3: // Impact-point in the plane Z=0
+   return fImpactXY;
+
+  default: // Unsupported axis
+   cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
+        << " Possible axes are 'X', 'Y' and 'Z'." << endl; 
+   return dummy;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetId(Int_t id)
+{
+// Set a user defined identifier for this track.
+ fUserId=id;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliTrack::GetId()
+{
+// Provide the user defined identifier of this track.
+ return fUserId;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetClosestPoint(AliPosition p)
+{
+// Set position p as the point of closest approach w.r.t. some reference
+ fClosest=p;
+}
+///////////////////////////////////////////////////////////////////////////
+AliPosition AliTrack::GetClosestPoint()
+{
+// Provide the point of closest approach w.r.t. some reference
+ return fClosest;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetChi2(Float_t chi2)
+{
+// Set the chi-squared value of the track fit.
+ if (chi2<0)
+ {
+  cout << " *AliTrack::SetChi2* Invalid chi2 value : " << chi2 << endl;
+ }
+ else
+ {
+  fChi2=chi2;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliTrack::SetNdf(Int_t ndf)
+{
+// Set the number of degrees of freedom for the track fit.
+ if (ndf<0)
+ {
+  cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl;
+ }
+ else
+ {
+  fNdf=ndf;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Float_t AliTrack::GetChi2()
+{
+// Provide the chi-squared value of the track fit.
+ return fChi2;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliTrack::GetNdf()
+{
+// Provide the number of degrees of freedom for the track fit.
+ return fNdf;
+}
+///////////////////////////////////////////////////////////////////////////