]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCtracker.cxx
Corrected UInt_t <-> Int_t conversion
[u/mrichter/AliRoot.git] / TPC / AliTPCtracker.cxx
index 26f968ca5da9f1978fd8cc59df831c44f1621638..8a4d8ad91dccbc29b15cd8d9dc2b132888b63b18 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.39  2003/11/06 07:40:05  kowal2
-Removed dependencies
-
-Revision 1.38  2003/10/17 12:01:16  kowal2
-Removed compiler warning.
-
-Revision 1.37  2003/07/22 15:56:14  hristov
-Implementing ESD functionality in the NewIO (Yu.Belikov)
-
-Revision 1.35.2.3  2003/07/15 09:58:03  hristov
-Corrected back-propagation (Yu.Belikov)
-
-Revision 1.35.2.2  2003/07/14 09:19:33  hristov
-TOF included in the combined PID (Yu.Belikov)
-
-Revision 1.35.2.1  2003/07/11 10:53:01  hristov
-Inward refit for TPC and TRD in the ESD schema (T.Kuhr)
-
-Revision 1.35  2003/05/23 10:08:51  hristov
-SetLabel replaced by SetNumber (Yu.Belikov)
-
-Revision 1.34  2003/05/22 13:57:48  hristov
-First implementation of ESD classes (Yu.Belikov)
-
-Revision 1.32  2003/04/10 10:36:54  hristov
-Code for unified TPC/TRD tracking (S.Radomski)
-
-Revision 1.31  2003/03/19 17:14:11  hristov
-Load/UnloadClusters added to the base class and the derived classes changed correspondingly. Possibility to give 2 input files for ITS and TPC tracks in PropagateBack. TRD tracker uses fEventN from the base class (T.Kuhr)
-
-Revision 1.30  2003/02/28 16:13:32  hristov
-Typos corrected
-
-Revision 1.29  2003/02/28 15:18:16  hristov
-Corrections suggested by J.Chudoba
-
-Revision 1.28  2003/02/27 16:15:52  hristov
-Code for inward refitting (S.Radomski)
-
-Revision 1.27  2003/02/25 16:47:58  hristov
-allow back propagation for more than 1 event (J.Chudoba)
-
-Revision 1.26  2003/02/19 08:49:46  hristov
-Track time measurement (S.Radomski)
-
-Revision 1.25  2003/01/28 16:43:35  hristov
-Additional protection: to be discussed with the Root team (M.Ivanov)
-
-Revision 1.24  2002/11/19 16:13:24  hristov
-stdlib.h included to declare exit() on HP
-
-Revision 1.23  2002/11/19 11:50:08  hristov
-Removing CONTAINERS (Yu.Belikov)
-
-Revision 1.19  2002/07/19 07:31:40  kowal2
-Improvement in tracking by J. Belikov
-
-Revision 1.18  2002/05/13 07:33:52  kowal2
-Added protection in Int_t AliTPCtracker::AliTPCRow::Find(Double_t y) const
-in the case of defined region of interests.
-
-Revision 1.17  2002/03/18 17:59:13  kowal2
-Chnges in the pad geometry - 3 pad lengths introduced.
-
-Revision 1.16  2001/11/08 16:39:03  hristov
-Additional protection (M.Masera)
-
-Revision 1.15  2001/11/08 16:36:33  hristov
-Updated V2 stream of tracking (Yu.Belikov). The new long waited features are: 1) Possibility to pass the primary vertex position to the trackers (both for the TPC and the ITS) 2) Possibility to specify the number of tracking passes together with applying (or not applying) the vertex constraint (ITS only) 3) Possibility to make some use of partial PID provided by the TPC when doing tracking in the ITS (ITS only) 4) V0 reconstruction with a helix minimisation of the DCA. (new macros: AliV0FindVertices.C and AliV0Comparison.C) 4a) ( Consequence of the 4) )  All the efficiencies and resolutions are from now on calculated including *secondary*particles* too. (Don't be surprised by the drop in efficiency etc)
-
-Revision 1.14  2001/10/21 19:04:55  hristov
-Several patches were done to adapt the barel reconstruction to the multi-event case. Some memory leaks were corrected. (Yu.Belikov)
-
-Revision 1.13  2001/07/23 12:01:30  hristov
-Initialisation added
-
-Revision 1.12  2001/07/20 14:32:44  kowal2
-Processing of many events possible now
-
-Revision 1.11  2001/05/23 08:50:10  hristov
-Weird inline removed
-
-Revision 1.10  2001/05/16 14:57:25  alibrary
-New files for folders and Stack
-
-Revision 1.9  2001/05/11 07:16:56  hristov
-Fix needed on Sun and Alpha
-
-Revision 1.8  2001/05/08 15:00:15  hristov
-Corrections for tracking in arbitrary magnenetic field. Changes towards a concept of global Alice track. Back propagation of reconstructed tracks (Yu.Belikov)
-
-Revision 1.5  2000/12/20 07:51:59  kowal2
-Changes suggested by Alessandra and Paolo to avoid overlapped
-data fields in encapsulated classes.
-
-Revision 1.4  2000/11/02 07:27:16  kowal2
-code corrections
-
-Revision 1.2  2000/06/30 12:07:50  kowal2
-Updated from the TPC-PreRelease branch
-
-Revision 1.1.2.1  2000/06/25 08:53:55  kowal2
-Splitted from AliTPCtracking
-
-*/
+/* $Id$ */
 
 //-------------------------------------------------------
 //          Implementation of the TPC tracker
@@ -131,42 +25,53 @@ Splitted from AliTPCtracking
 #include <TFile.h>
 #include <TTree.h>
 
-#include "AliESD.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
 
 #include "AliTPCtracker.h"
 #include "AliTPCcluster.h"
 #include "AliTPCParam.h"
 #include "AliClusters.h"
 
-extern Double_t SigmaY2(Double_t, Double_t, Double_t);
-extern Double_t SigmaZ2(Double_t, Double_t);
-
 ClassImp(AliTPCtracker)
 
+//_____________________________________________________________________________
+AliTPCtracker::AliTPCtracker(): 
+  AliTracker(), 
+  fkNIS(0), 
+  fInnerSec(0),         
+  fkNOS(0),
+  fOuterSec(0),
+  fN(0),
+  fSectors(0),
+  fParam(0),
+  fSeeds(0)
+{
+  //
+  // The default TPC tracker constructor
+  //
+}
+
 //_____________________________________________________________________________
 AliTPCtracker::AliTPCtracker(const AliTPCParam *par): 
-AliTracker(), fkNIS(par->GetNInnerSector()/2), fkNOS(par->GetNOuterSector()/2)
+  AliTracker(), 
+  fkNIS(par->GetNInnerSector()/2), 
+  fInnerSec(new AliTPCSector[fkNIS]),         
+  fkNOS(par->GetNOuterSector()/2),
+  fOuterSec(new AliTPCSector[fkNOS]),
+  fN(0),
+  fSectors(0),
+  fParam((AliTPCParam*) par),
+  fSeeds(0)
 {
   //---------------------------------------------------------------------
   // The main TPC tracker constructor
   //---------------------------------------------------------------------
-  fInnerSec=new AliTPCSector[fkNIS];         
-  fOuterSec=new AliTPCSector[fkNOS];
 
   Int_t i;
   for (i=0; i<fkNIS; i++) fInnerSec[i].Setup(par,0);
   for (i=0; i<fkNOS; i++) fOuterSec[i].Setup(par,1);
 
-  fParam = (AliTPCParam*) par;
-  fSeeds=0;
-
-  // [SR 17.03.2003]
-  
-  fBarrelFile = 0;
-  fBarrelTree = 0;
-  fBarrelArray = 0;
-  fBarrelTrack = 0;
-  
 }
 
 //_____________________________________________________________________________
@@ -180,99 +85,8 @@ AliTPCtracker::~AliTPCtracker() {
     fSeeds->Delete(); 
     delete fSeeds;
   }
-
-  // [SR, 01.04.2003]
-  if (fBarrelFile) {
-    fBarrelFile->Close();
-    delete fBarrelFile;
-  }
 }
 
-//_____________________________________________________________________________
-void AliTPCtracker::SetBarrelTree(const char *mode) {
-  //
-  // Creates a tree for BarrelTracks
-  // mode = "back" or "refit"
-  //
-  // [SR, 01.04.2003]
-  //
-  
-  if (!IsStoringBarrel()) return;
-  
-  TDirectory *sav = gDirectory;
-  if (!fBarrelFile) fBarrelFile = new TFile("AliBarrelTracks.root", "UPDATE");
-
-  char buff[40];
-  sprintf(buff, "BarrelTPC_%d_%s", GetEventNumber(), mode);
-
-  fBarrelFile->cd();
-  fBarrelTree = new TTree(buff, "Barrel TPC tracks");
-  
-  if (!fBarrelArray) fBarrelArray = new TClonesArray("AliBarrelTrack", 4);
-  for(Int_t i=0; i<4; i++) new((*fBarrelArray)[i]) AliBarrelTrack();
-  
-  fBarrelTree->Branch("tracks", &fBarrelArray);
-  
-  sav->cd();
-}
-//_____________________________________________________________________________
-
-void AliTPCtracker::StoreBarrelTrack(AliTPCtrack *ps, Int_t refPlane, Int_t isIn) {
-  //
-  // Stores Track at a given reference plane
-  // 
-  // refPlane: 1-4
-  // isIn: 1 - backward, 2 - refit
-  //
-  
-  if (!IsStoringBarrel()) return;
-  if (refPlane < 0 || refPlane > 4) return;
-  if (isIn > 2) return;
-
-  static Int_t nClusters;
-  static Int_t nWrong;
-  static Double_t chi2;
-  static Int_t index;
-
-  Int_t newClusters, newWrong;
-  Double_t newChi2;
-
-  if ( (refPlane == 1 && isIn == kTrackBack) || 
-       (refPlane == 4 && isIn == kTrackRefit) ) {
-    
-    fBarrelArray->Clear();
-    nClusters = nWrong = 0;
-    chi2 = 0.0;
-    index = 0;
-  }
-
-  // propagate
-  Double_t refX = 0;
-  if (refPlane == 1) refX = fParam->GetInnerRadiusLow();
-  if (refPlane == 2) refX = fParam->GetInnerRadiusUp();
-  if (refPlane == 3) refX = fParam->GetOuterRadiusLow();
-  if (refPlane == 4) refX = fParam->GetOuterRadiusUp();
-
-  ps->PropagateTo(refX);
-
-  fBarrelTrack = (AliBarrelTrack*)(*fBarrelArray)[index++];
-  ps->GetBarrelTrack(fBarrelTrack);
-  
-  newClusters = ps->GetNumberOfClusters() - nClusters; 
-  newWrong = ps->GetNWrong() - nWrong;
-  newChi2 = ps->GetChi2() - chi2;
-
-  nClusters =  ps->GetNumberOfClusters();
-  nWrong = ps->GetNWrong();
-  chi2 = ps->GetChi2();
-
-  fBarrelTrack->SetNClusters(newClusters, newChi2);
-  fBarrelTrack->SetNWrongClusters(newWrong);
-  fBarrelTrack->SetRefPlane(refPlane, isIn);
-}
-
-
 //_____________________________________________________________________________
 Double_t f1(Double_t x1,Double_t y1,
                    Double_t x2,Double_t y2,
@@ -335,8 +149,7 @@ Int_t AliTPCtracker::LoadClusters(TTree *cTree) {
   }
 
   AliClusters carray, *addr=&carray;
-  carray.SetClass("AliTPCcluster");
-  carray.SetArray(0);
+  addr = new AliClusters("AliTPCcluster");
   branch->SetAddress(&addr);
 
   Int_t nentr=(Int_t)cTree->GetEntries();
@@ -418,9 +231,9 @@ Int_t AliTPCtracker::FollowProlongation(AliTPCseed& t, Int_t rf) {
     UInt_t index=0;
     Double_t maxchi2=kMaxCHI2;
     const AliTPCRow &krow=fSectors[s][nr];
-    Double_t pt=t.GetConvConst()/(100/0.299792458/0.2)/t.Get1Pt();
-    Double_t sy2=SigmaY2(t.GetX(),t.GetTgl(),pt);
-    Double_t sz2=SigmaZ2(t.GetX(),t.GetTgl());
+    Double_t pt=t.GetSignedPt();
+    Double_t sy2=AliTPCcluster::SigmaY2(t.GetX(),t.GetTgl(),pt);
+    Double_t sz2=AliTPCcluster::SigmaZ2(t.GetX(),t.GetTgl());
     Double_t road=4.*sqrt(t.GetSigmaY2() + sy2), y=t.GetY(), z=t.GetZ();
 
     if (road>kMaxROAD) {
@@ -478,7 +291,7 @@ Int_t AliTPCtracker::FollowRefitInward(AliTPCseed *seed, AliTPCtrack *track) {
   // loop over rows
 
   Int_t nRows = fSectors->GetNRows();
-  for (Int_t iRow = nRows; iRow >= 0; iRow--) {
+  for (Int_t iRow = nRows-1; iRow >= 0; iRow--) {
 
     Double_t x = fSectors->GetX(iRow);
     if (!seed->PropagateTo(x)) return 0;
@@ -528,7 +341,7 @@ Int_t AliTPCtracker::FollowBackProlongation
   Int_t s=Int_t(alpha/fSectors->GetAlpha())%fN;
 
   Int_t idx=-1, sec=-1, row=-1;
-  Int_t nc=seed.GetNumber();
+  Int_t nc=track.GetNumberOfClusters();
 
   if (nc--) {
      idx=track.GetClusterIndex(nc);
@@ -540,7 +353,8 @@ Int_t AliTPCtracker::FollowBackProlongation
   Int_t nr=fSectors->GetNRows();
   for (Int_t i=0; i<nr; i++) {
     Double_t x=fSectors->GetX(i), ymax=fSectors->GetMaxY(i);
-    Double_t y=seed.GetYat(x);
+    Double_t y;
+    if (!seed.GetYAt(x,GetBz(),y)) return 0;
  
     if (y > ymax) {
        s = (s+1) % fN;
@@ -555,9 +369,9 @@ Int_t AliTPCtracker::FollowBackProlongation
     AliTPCcluster *cl=0;
     Int_t index=0;
     Double_t maxchi2=kMaxCHI2;
-    Double_t pt=seed.GetConvConst()/(100/0.299792458/0.2)/seed.Get1Pt();
-    Double_t sy2=SigmaY2(seed.GetX(),seed.GetTgl(),pt);
-    Double_t sz2=SigmaZ2(seed.GetX(),seed.GetTgl());
+    Double_t pt=seed.GetSignedPt();
+    Double_t sy2=AliTPCcluster::SigmaY2(seed.GetX(),seed.GetTgl(),pt);
+    Double_t sz2=AliTPCcluster::SigmaZ2(seed.GetX(),seed.GetTgl());
     Double_t road=4.*sqrt(seed.GetSigmaY2() + sy2), z=seed.GetZ();
     if (road>kMaxROAD) {
       Warning("FollowBackProlongation","Too broad road !"); 
@@ -586,8 +400,8 @@ Int_t AliTPCtracker::FollowBackProlongation
        const AliTPCRow &krow=fSectors[s][i];
        if (accepted>27)
        if (krow) {
-          for (Int_t i=krow.Find(y-road); i<krow; i++) {
-           AliTPCcluster *c=(AliTPCcluster*)(krow[i]);
+          for (Int_t icl=krow.Find(y-road); icl<krow; icl++) {
+           AliTPCcluster *c=(AliTPCcluster*)(krow[icl]);
            if (c->GetY() > y+road) break;
            if (c->IsUsed()) continue;
         if ((c->GetZ()-z)*(c->GetZ()-z)>16.*(seed.GetSigmaZ2()+sz2)) continue;
@@ -595,7 +409,7 @@ Int_t AliTPCtracker::FollowBackProlongation
            if (chi2 > maxchi2) continue;
            maxchi2=chi2;
            cl=c;
-            index=krow.GetIndex(i);
+            index=krow.GetIndex(icl);
           }
        }
     }
@@ -609,8 +423,6 @@ Int_t AliTPCtracker::FollowBackProlongation
 
   }
 
-  seed.SetNumber(nc);
-
   return 1;
 }
 
@@ -703,8 +515,8 @@ void AliTPCtracker::MakeSeeds(Int_t i1, Int_t i2) {
         c[13]=f30*sy1*f40+f32*sy2*f42;
         c[14]=f40*sy1*f40+f42*sy2*f42+f43*sy3*f43;
 
-        UInt_t index=kr1.GetIndex(is);
-       AliTPCseed *track=new AliTPCseed(index, x, c, x1, ns*alpha+shift);
+        Int_t index=kr1.GetIndex(is);
+       AliTPCseed *track=new AliTPCseed(x1, ns*alpha+shift, x, c, index);
         Float_t l=fSectors->GetPadPitchWidth();
         track->SetSampledEdx(kr1[is]->GetQ()/l,0);
 
@@ -743,7 +555,8 @@ Int_t AliTPCtracker::ReadSeeds(const TFile *inp) {
   Int_t n=(Int_t)seedTree->GetEntries();
   for (Int_t i=0; i<n; i++) {
      seedTree->GetEvent(i);
-     fSeeds->AddLast(new AliTPCseed(*seed,seed->GetAlpha()));
+     seed->ResetClusters();
+     fSeeds->AddLast(new AliTPCseed(*seed));
   }
   
   delete seed;
@@ -756,7 +569,7 @@ Int_t AliTPCtracker::ReadSeeds(const TFile *inp) {
 }
 
 //_____________________________________________________________________________
-Int_t AliTPCtracker::Clusters2Tracks(AliESD *event) {
+Int_t AliTPCtracker::Clusters2Tracks(AliESDEvent *event) {
   //-----------------------------------------------------------------
   // This is a track finder.
   // The clusters must be already loaded ! 
@@ -822,7 +635,7 @@ Int_t AliTPCtracker::Clusters2Tracks(AliESD *event) {
 }
 
 //_____________________________________________________________________________
-Int_t AliTPCtracker::RefitInward(AliESD* event) {
+Int_t AliTPCtracker::RefitInward(AliESDEvent* event) {
   //
   // The function propagates tracks throught TPC inward
   // using already associated clusters.
@@ -836,11 +649,16 @@ Int_t AliTPCtracker::RefitInward(AliESD* event) {
     AliESDtrack* track = event->GetTrack(i);
     ULong_t status = track->GetStatus();
 
+    if ( (status & AliESDtrack::kTPCrefit) != 0 ) continue;    
     if ( (status & AliESDtrack::kTPCout ) == 0 ) continue;
-    if ( (status & AliESDtrack::kTPCrefit) != 0 ) continue;
-    
+
+    if ( (status & AliESDtrack::kTRDout ) != 0 ) 
+      if ( (status & AliESDtrack::kTRDrefit ) == 0 ) continue;
+
     AliTPCtrack* tpcTrack = new AliTPCtrack(*track);
-    AliTPCseed* seed = new AliTPCseed(*tpcTrack, tpcTrack->GetAlpha());
+    AliTPCseed* seed=new AliTPCseed(*tpcTrack); seed->ResetClusters(); 
+
+    if ( (status & AliESDtrack::kTRDrefit) == 0 ) seed->ResetCovariance(10.);
 
     fSectors = fOuterSec;
 
@@ -870,7 +688,7 @@ Int_t AliTPCtracker::RefitInward(AliESD* event) {
   return 0;
 }
 
-Int_t AliTPCtracker::PropagateBack(AliESD *event) {
+Int_t AliTPCtracker::PropagateBack(AliESDEvent *event) {
   //-----------------------------------------------------------------
   // This function propagates tracks back through the TPC.
   // The clusters must be already loaded !
@@ -885,17 +703,13 @@ Int_t AliTPCtracker::PropagateBack(AliESD *event) {
 
     if ( (status & AliESDtrack::kTPCin ) == 0 ) continue;
     if ( (status & AliESDtrack::kTPCout) != 0 ) continue;
+    if ( (status & AliESDtrack::kITSin) != 0 )
+       if ( (status & AliESDtrack::kITSout) == 0 ) continue;
 
     const AliTPCtrack t(*esd);
-    AliTPCseed s(t,t.GetAlpha());
-
-    if ( (status & AliESDtrack::kITSout) == 0 ) s.ResetCovariance();
+    AliTPCseed s(t); s.ResetClusters();
 
-    s.ResetNWrong();
-    s.ResetNRotation();
-    
-    Int_t nc=t.GetNumberOfClusters();
-    s.SetNumber(nc); //set number of the cluster to start with
+    if ( (status & AliESDtrack::kITSout) == 0 ) s.ResetCovariance(10.);
 
     //inner sectors
     fSectors=fInnerSec; fN=fkNIS;
@@ -915,7 +729,7 @@ Int_t AliTPCtracker::PropagateBack(AliESD *event) {
     //outer sectors
     fSectors=fOuterSec; fN=fkNOS;
 
-    nc=s.GetNumberOfClusters();
+    Int_t nc=s.GetNumberOfClusters();
 
     alpha=s.GetAlpha() - fSectors->GetAlphaShift();
     if (alpha > 2.*TMath::Pi()) alpha -= 2.*TMath::Pi();
@@ -987,8 +801,10 @@ void AliTPCtracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
     lab=TMath::Abs(c->GetLabel(0));
     Int_t j;
     for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
-    lb[j]=lab;
-    (mx[j])++;
+    if (j<noc) {
+       lb[j]=lab;
+       (mx[j])++;
+    }
   }
 
   Int_t max=0;
@@ -1131,23 +947,7 @@ void AliTPCtracker::AliTPCseed::CookdEdx(Double_t low, Double_t up) {
   dedx /= (nu-nl+1);
   SetdEdx(dedx);
 
-  //Very rough PID
-  Double_t p=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt()));
-
-  Double_t log1=TMath::Log(p+0.45), log2=TMath::Log(p+0.12);
-  if (p<0.6) {
-    if (dedx < 34 + 30/(p+0.45)/(p+0.45) + 24*log1) {SetMass(0.13957); return;}
-    if (dedx < 34 + 30/(p+0.12)/(p+0.12) + 24*log2) {SetMass(0.49368); return;}
-    SetMass(0.93827); return;
-  }
-
-  if (p<1.2) {
-    if (dedx < 34 + 30/(p+0.12)/(p+0.12) + 24*log2) {SetMass(0.13957); return;}
-    SetMass(0.93827); return;
-  }
-
-  SetMass(0.13957); return;
-
+  return;
 }