]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliTrackPoints.cxx
Use MSTU(16) = 2 for heavy flavor. HF Hadrons point to the
[u/mrichter/AliRoot.git] / ANALYSIS / AliTrackPoints.cxx
index 4249d50259b21e9038abde6b42d3f6cc33ecfceb..000709f0cb4523753d05e09c870840774b2cb1cb 100644 (file)
@@ -1,5 +1,20 @@
-#include "AliTrackPoints.h"
-//_________________________________
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
 ////////////////////////////////////////////////////////////
 //                                                        //
 // class AliTrackPoints                                //
@@ -13,6 +28,9 @@
 //                                                        //
 ////////////////////////////////////////////////////////////
 
+#include "AliTrackPoints.h"
+#include "AliLog.h"
+
 #include <TClonesArray.h>
 #include <TFile.h>
 #include <TMath.h>
 #include "AliTrackReference.h"
 #include "AliITStrackV2.h"
 
+#include "AliRun.h"
+#include "AliMagF.h"
+#include "AliTracker.h"
+#include "AliESD.h"
+#include "AliRunLoader.h"
+#include "AliTPCtrack.h"
+#include "TTree.h"
+#include "TBranch.h"
+#include "TH2D.h"
+
 ClassImp(AliTrackPoints)
 
 Int_t AliTrackPoints::fgDebug = 0;
@@ -34,19 +62,21 @@ AliTrackPoints::AliTrackPoints():
 {
   //constructor
 }
+
 /***************************************************************/
 
-AliTrackPoints::AliTrackPoints(AliTrackPoints::ETypes type, AliESDtrack* track):
+AliTrackPoints::AliTrackPoints(AliTrackPoints::ETypes type, AliESDtrack* track, Float_t mf):
  fN(0),
  fX(0x0),
  fY(0x0),
  fZ(0x0)
 {
-  //constructor
+  //constructor 
+  //tupe -  what kind of track points should be calculated
+  //mf - magnetic field in [kG] = [T]*10.0
   switch (type)
    {
      case kITS:
-       //Used only in non-id analysis
        fN = 6;
        fX = new Float_t[fN];
        fY = new Float_t[fN];
@@ -54,11 +84,20 @@ AliTrackPoints::AliTrackPoints(AliTrackPoints::ETypes type, AliESDtrack* track):
        MakeITSPoints(track);
        break;
 
+     case kITSInnerFromVertexOuterFromTPC:
+       fN = 6;
+       fX = new Float_t[fN];
+       fY = new Float_t[fN];
+       fZ = new Float_t[fN];
+       MakeITSPointsInnerFromVertexOuterFromTPC(track,mf);
+       break;
+
      default:
        Info("AliTrackPoints","Not recognized type");
    }
    
 }
+
 /***************************************************************/
 
 AliTrackPoints::AliTrackPoints(Int_t n, AliESDtrack* track, Float_t mf, Float_t dr, Float_t r0):
@@ -68,7 +107,7 @@ AliTrackPoints::AliTrackPoints(Int_t n, AliESDtrack* track, Float_t mf, Float_t
  fZ(new Float_t[fN])
 {
   //constructor
-  //mf - magnetic field in kG - needed to calculated curvature out of Pt
+  //mf - magnetic field in kG - needed to calculate curvature out of Pt
   //r0 - starting radius
   //dr - calculate points every dr cm, default every 30cm
   if (track == 0x0)
@@ -86,8 +125,7 @@ AliTrackPoints::AliTrackPoints(Int_t n, AliESDtrack* track, Float_t mf, Float_t
        ((track->GetStatus() & AliESDtrack::kTPCin) == kFALSE)  )
    {
      //could happend: its stand alone tracking
-     if (GetDebug() > 3) 
-       Warning("AliTrackPoints","This ESD track does not contain TPC information");
+     AliDebug(3,"This ESD track does not contain TPC information");
        
      fN = 0;
      delete [] fX;
@@ -98,9 +136,9 @@ AliTrackPoints::AliTrackPoints(Int_t n, AliESDtrack* track, Float_t mf, Float_t
      return;
    }
   
-  Double_t x;
+  Double_t alpha,x;
   Double_t par[5];
-  track->GetInnerExternalParameters(x,par);     //get properties of the track
+  track->GetInnerExternalParameters(alpha,x,par);//get properties of the track
   if (par[4] == 0)
    {
      Error("AliTrackPoints","This ESD track seem not to contain TPC information (curv is 0)");
@@ -113,13 +151,14 @@ AliTrackPoints::AliTrackPoints(Int_t n, AliESDtrack* track, Float_t mf, Float_t
      return;
    }
    
-  Double_t alpha = track->GetInnerAlpha();
+  //Double_t alpha = track->GetInnerAlpha();
   Double_t cc = 1000./0.299792458/mf;//conversion constant
   Double_t c=par[4]/cc;
   
   MakePoints(dr,r0,x,par,c,alpha);
   
 }
+
 /***************************************************************/
 
 AliTrackPoints::AliTrackPoints(Int_t n, AliTPCtrack* track, Float_t dr, Float_t r0):
@@ -157,7 +196,8 @@ AliTrackPoints::AliTrackPoints(Int_t n, AliTPCtrack* track, Float_t dr, Float_t
   Double_t alpha = track->GetAlpha();
   Double_t c=track->GetC();
   MakePoints(dr,r0,x,par,c,alpha);
-}  
+}
+
 /***************************************************************/
 
 AliTrackPoints::~AliTrackPoints()
@@ -167,6 +207,7 @@ AliTrackPoints::~AliTrackPoints()
   delete [] fY;
   delete [] fZ;
 }
+
 /***************************************************************/
 
 void AliTrackPoints::MakePoints( Float_t dr, Float_t r0, Double_t x, Double_t* par, Double_t c, Double_t alpha)
@@ -194,11 +235,9 @@ void AliTrackPoints::MakePoints( Float_t dr, Float_t r0, Double_t x, Double_t* p
   Double_t r = TMath::Hypot(x,y);
   
 
-  if (GetDebug() > 9) 
-    Info("AliTrackPoints","Radius0 %f, Real Radius %f",r0,r); 
+  AliDebug(9,Form("Radius0 %f, Real Radius %f",r0,r)); 
   
-  if (GetDebug() > 5) 
-    Info("AliTrackPoints","Phi Global at first padraw %f, Phi locat %f",phi0global,phi0local);
+  AliDebug(5,Form("Phi Global at first padraw %f, Phi locat %f",phi0global,phi0local));
     
   Double_t eta = x*c - par[2] ;//par[2] = fX*C - eta; eta==fP2 ; C==fP4
   
@@ -223,14 +262,12 @@ void AliTrackPoints::MakePoints( Float_t dr, Float_t r0, Double_t x, Double_t* p
      Double_t ftmp = (c2*rc + cst1/rc)/cst2;
      if (ftmp > 1.0) 
       {
-        if (GetDebug() > 1) 
-          Warning("AliTrackPoints","ASin argument > 1 %f:",ftmp);
+        AliDebug(1,Form("ASin argument > 1 %f:",ftmp));
         ftmp=1.0;
       }
      else if (ftmp < -1.0) 
       {
-        if (GetDebug() > 1) 
-          Warning("AliTrackPoints","ASin argument < -1 %f:",ftmp);
+        AliDebug(1,Form("ASin argument < -1 %f:",ftmp));
         ftmp=-1.0;
       }
       
@@ -240,22 +277,19 @@ void AliTrackPoints::MakePoints( Float_t dr, Float_t r0, Double_t x, Double_t* p
      ftmp = (rc*rc-dcasq)/cst2;
      if (ftmp < 0.0) 
       {
-        if (GetDebug() > 1) 
-          Warning("AliTrackPoints","Sqrt argument < 0: %f",ftmp);
+        AliDebug(1,Form("Sqrt argument < 0: %f",ftmp));
         ftmp=0.0;
       }
      
      ftmp = c2*TMath::Sqrt(ftmp);
      if (ftmp > 1.0) 
       {
-        if (GetDebug() > 1) 
-          Warning("AliTrackPoints","ASin argument > 1: %f",ftmp);
+        AliDebug(1,Form("ASin argument > 1: %f",ftmp));
         ftmp=1.0;
       }
      else if (ftmp < -1.0) 
       {
-        if (GetDebug() > 1) 
-          Warning("AliTrackPoints","ASin argument < -1: %f",ftmp);
+        AliDebug(2,Form("ASin argument < -1: %f",ftmp));
         ftmp=-1.0;
       }
      Double_t factorZ = TMath::ASin(ftmp)*par[3]/c2;
@@ -263,13 +297,11 @@ void AliTrackPoints::MakePoints( Float_t dr, Float_t r0, Double_t x, Double_t* p
      fX[i] = rc*TMath::Cos(phi);
      fY[i] = rc*TMath::Sin(phi);
      
-     if ( GetDebug() > 2 )
-      {
-        Info("AliTrackPoints","X %f Y %f Z %f R asked %f R obtained %f",
-             fX[i],fY[i],fZ[i],rc,TMath::Hypot(fX[i],fY[i]));
-      }
+     AliDebug(3,Form("AliTrackPoints","X %f Y %f Z %f R asked %f R obtained %f",
+             fX[i],fY[i],fZ[i],rc,TMath::Hypot(fX[i],fY[i])));
    }
 }
+
 /***************************************************************/
 
 void AliTrackPoints::MakeITSPoints(AliESDtrack* track)
@@ -278,10 +310,10 @@ void AliTrackPoints::MakeITSPoints(AliESDtrack* track)
 // z=R*Pz/Pt
  AliITStrackV2 itstrack(*track,kTRUE);
  Double_t x,y,z;
- static const Double_t r[6] = {4.0, 7.0, 14.9, 23.8, 39.1, 43.6};
+ static const Double_t kR[6] = {4.0, 7.0, 14.9, 23.8, 39.1, 43.6};
  for (Int_t i = 0; i < 6; i++)
   {
-    itstrack.GetGlobalXYZat(r[i],x,y,z);
+    itstrack.GetGlobalXYZat(kR[i],x,y,z);
     fX[i] = x;
     fY[i] = y;
     fZ[i] = z;
@@ -292,10 +324,46 @@ void AliTrackPoints::MakeITSPoints(AliESDtrack* track)
 }
 
 /***************************************************************/
+
+void AliTrackPoints::MakeITSPointsInnerFromVertexOuterFromTPC(AliESDtrack* track, Float_t mf)
+{
+//makes trackpoints for ITS  
+//for 3 inner layers calculates out of the vector at vertex
+//for 3 outer ---------------//------------------ at inner TPC  
+
+ static const Double_t kR[6] = {4.0, 7.0, 14.9, 23.8, 39.1, 43.6};
+ AliITStrackV2 itstrack(*track,kTRUE);
+ Double_t x,y,z;
+ for (Int_t i = 0; i < 3; i++)
+  {
+    itstrack.GetGlobalXYZat(kR[i],x,y,z);
+    fX[i] = x;
+    fY[i] = y;
+    fZ[i] = z;
+    AliDebug(3,Form("X %f Y %f Z %f R asked %f R obtained %f",
+                fX[i],fY[i],fZ[i],kR[i],TMath::Hypot(fX[i],fY[i])));
+  }   
+ for (Int_t i = 3; i < 6; i++)
+  {
+    Float_t ax,ay,az;
+    AliTrackPoints tmptp(1,track,mf,0,kR[i]);
+    tmptp.PositionAt(0,ax,ay,az);
+    fX[i] = ax;
+    fY[i] = ay;
+    fZ[i] = az;
+    AliDebug(3,Form("X %f Y %f Z %f R asked %f R obtained %f",
+                fX[i],fY[i],fZ[i],kR[i],TMath::Hypot(fX[i],fY[i])));
+  }
+}
+    
+/***************************************************************/
+
 void AliTrackPoints::PositionAt(Int_t n, Float_t &x,Float_t &y,Float_t &z)
 {
   //returns position at point n
-  if ((n<0) || (n>fN))
+  if ((n<0) || (n>=fN))
    {
      Error("PositionAt","Point %d out of range",n);
      return;
@@ -304,11 +372,10 @@ void AliTrackPoints::PositionAt(Int_t n, Float_t &x,Float_t &y,Float_t &z)
   x = fX[n];
   y = fY[n];
   z = fZ[n];
-  if ( GetDebug() > 1 )
-    {
-      Info("AliTrackPoints","n %d; X %f; Y %f; Z %f",n,x,y,z);
-    }
+  AliDebug(2,Form("n %d; X %f; Y %f; Z %f",n,x,y,z));
+
 }
+
 /***************************************************************/
 
 void AliTrackPoints::Move(Float_t x, Float_t y, Float_t z)
@@ -321,6 +388,7 @@ void AliTrackPoints::Move(Float_t x, Float_t y, Float_t z)
      fZ[i]+=z;
    }   
 }
+
 /***************************************************************/
 
 Double_t AliTrackPoints::AvarageDistance(const AliTrackPoints& tr)
@@ -329,7 +397,7 @@ Double_t AliTrackPoints::AvarageDistance(const AliTrackPoints& tr)
 //  Info("AvarageDistance","Entered");
   if ( (fN <= 0) || (tr.fN <=0) )
    {
-     if (GetDebug()) Warning("AvarageDistance","One of tracks is empty");
+     AliDebug(1,"One of tracks is empty");
      return -1;
    }
 
@@ -342,14 +410,9 @@ Double_t AliTrackPoints::AvarageDistance(const AliTrackPoints& tr)
   Double_t sum = 0;
   for (Int_t i = 0; i<fN; i++)
    {
-     if (GetDebug()>9)
-      {
+     AliDebug(10,Form("radii: %f %f",TMath::Hypot(fX[i],fY[i]),TMath::Hypot(tr.fX[i],tr.fY[i])));
 //       Float_t r1sq = fX[i]*fX[i]+fY[i]*fY[i];
 //       Float_t r2sq = tr.fX[i]*tr.fX[i]+tr.fY[i]*tr.fY[i];
-       Float_t r1sq = TMath::Hypot(fX[i],fY[i]);
-       Float_t r2sq = TMath::Hypot(tr.fX[i],tr.fY[i]);
-       Info("AvarageDistance","radii: %f %f",r1sq,r2sq);
-      } 
 
       
      Double_t dx = fX[i]-tr.fX[i];
@@ -357,43 +420,36 @@ Double_t AliTrackPoints::AvarageDistance(const AliTrackPoints& tr)
      Double_t dz = fZ[i]-tr.fZ[i];
      sum+=TMath::Sqrt(dx*dx + dy*dy + dz*dz);
      
-     if (GetDebug()>1)
-      {
-       Info("AvarageDistance","Diff: x ,y z: %f , %f, %f",dx,dy,dz);
-       Info("AvarageDistance","xxyyzz %f %f %f %f %f %f",
-            fX[i],tr.fX[i],fY[i],tr.fY[i],fZ[i],tr.fZ[i]);
-      } 
+     AliDebug(2,Form("Diff: x ,y z: %f , %f, %f",dx,dy,dz));
+     AliDebug(2,Form("xxyyzz %f %f %f %f %f %f",
+            fX[i],tr.fX[i],fY[i],tr.fY[i],fZ[i],tr.fZ[i]));
    }
    
   Double_t retval = sum/((Double_t)fN);
-  if ( GetDebug() )
-    {
-      Info("AvarageDistance","Avarage distance is %f.",retval);
-    }
+  AliDebug(1,Form("Avarage distance is %f.",retval));
+
   return retval;
 }
-/***************************************************************/
-/***************************************************************/
-/***************************************************************/
-/***************************************************************/
-/***************************************************************/
-/***************************************************************/
 
-#include "AliRun.h"
-#include "AliESD.h"
-#include "AliRunLoader.h"
-#include "AliTPCtrack.h"
-#include "TTree.h"
-#include "TBranch.h"
-#include "TH2D.h"
-#include "TCanvas.h"
-#include "AliMagF.h"
+/***************************************************************/
 
+void AliTrackPoints::Print(Option_t* /*option*/) const
+{
+  // Prints the coordinates of the track points
+  Info("Print","There is %d points",fN);
+  for(Int_t i = 0; i < fN; i++)
+   {
+     Info("Print","%d: %f %f %f",i,fX[i],fY[i],fZ[i]);
+   }
 
+}
 
+/***************************************************************/
 
 void AliTrackPoints::Testesd(Int_t entr,const char* fname )
 {
+  // This is a former macro converted to member function.
+  // It is used to test the functionality of the class using ESD tracks
   delete gAlice;
   gAlice = 0x0;
   AliRunLoader* rl = AliRunLoader::Open();
@@ -418,8 +474,8 @@ void AliTrackPoints::Testesd(Int_t entr,const char* fname )
    }
 
   
-  Int_t N = 170;
-  AliTrackPoints* tp = new AliTrackPoints(N,t,mf,1.);
+  Int_t nTrackPoints = 170;
+  AliTrackPoints* tp = new AliTrackPoints(nTrackPoints,t,mf,1.);
   
   Float_t xmin = -250;
   Float_t xmax =  250;
@@ -448,7 +504,7 @@ void AliTrackPoints::Testesd(Int_t entr,const char* fname )
 
   Float_t x,y,z;
    
-  for (Int_t i = 0;i<N;i++)
+  for (Int_t i = 0;i<nTrackPoints;i++)
    {  
       Double_t r = 84.1+i;
       tp->PositionAt(i,x,y,z);
@@ -514,25 +570,25 @@ void AliTrackPoints::Testesd(Int_t entr,const char* fname )
   delete rl;
 }
 
-/***************************************************************/
-/***************************************************************/
 /***************************************************************/
 
 void AliTrackPoints::Testtpc(Int_t entr)
 {
+  // This is a former macro converted to member function.
+  // It is used to test the functionality of the class using TPC tracks
   delete gAlice;
   gAlice = 0x0;
   AliRunLoader* rl = AliRunLoader::Open();
   AliLoader* l = rl->GetLoader("TPCLoader");
   rl->LoadgAlice();
-  AliKalmanTrack::SetConvConst(100/0.299792458/0.2/rl->GetAliRun()->Field()->Factor());
+  AliTracker::SetFieldMap(rl->GetAliRun()->Field(),kTRUE);
   l->LoadTracks();
   AliTPCtrack* t = new AliTPCtrack();
   TBranch* b=l->TreeT()->GetBranch("tracks");
   b->SetAddress(&t);
   l->TreeT()->GetEntry(entr);  
-  Int_t N = 160;
-  AliTrackPoints* tp = new AliTrackPoints(N,t,1.);
+  Int_t nTrackPoints = 160;
+  AliTrackPoints* tp = new AliTrackPoints(nTrackPoints,t,1.);
   
   Float_t xmin = -250;
   Float_t xmax =  250;
@@ -561,7 +617,7 @@ void AliTrackPoints::Testtpc(Int_t entr)
 
   Float_t x,y,z;
    
-  for (Int_t i = 0;i<N;i++)
+  for (Int_t i = 0;i<nTrackPoints;i++)
    {  
       Double_t r = 84.1+i;
       tp->PositionAt(i,x,y,z);
@@ -569,7 +625,7 @@ void AliTrackPoints::Testtpc(Int_t entr)
       hxz->Fill(x,z);
       printf("Rdemanded %f\n",r);
       printf("tpx %f tpy %f tpz %f Rt =%f\n", x,y,z,TMath::Hypot(x,y));
-      
+
       //BUT they are local!!!!
       t->PropagateTo(r);
 //      Double_t phi = t->Phi();