]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODTrack.cxx
AliPIDResponse related
[u/mrichter/AliRoot.git] / STEER / AliAODTrack.cxx
index f90018c9d756299b9780e1819ca9904a02823bd9..f2a95e73da604ed2b182507bae069dff0dc7cb44 100644 (file)
 /* $Id$ */
 
 //-------------------------------------------------------------------------
-//     AOD track implementation of AliVParticle
+//     AOD track implementation of AliVTrack
 //     Author: Markus Oldenburg, CERN
 //     Markus.Oldenburg@cern.ch
 //-------------------------------------------------------------------------
 
 #include "AliLog.h"
+#include "AliExternalTrackParam.h"
+#include "AliVVertex.h"
 #include "AliAODTrack.h"
 
 ClassImp(AliAODTrack)
 
 //______________________________________________________________________________
 AliAODTrack::AliAODTrack() : 
-  AliVParticle(),
+  AliVTrack(),
+  fRAtAbsorberEnd(0.),
   fChi2perNDF(-999.),
   fChi2MatchTrigger(0.),
   fFlags(0),
   fLabel(-999),
   fITSMuonClusterMap(0),
   fFilterMap(0),
+  fTPCClusterMap(),
+  fTPCSharedMap(),
+  fTPCnclsF(0),
   fID(-999),
   fCharge(-99),
   fType(kUndef),
@@ -68,13 +74,17 @@ AliAODTrack::AliAODTrack(Short_t id,
                         AODTrk_t ttype,
                         UInt_t selectInfo,
                         Float_t chi2perNDF) :
-  AliVParticle(),
+  AliVTrack(),
+  fRAtAbsorberEnd(0.),
   fChi2perNDF(chi2perNDF),
   fChi2MatchTrigger(0.),
   fFlags(0),
   fLabel(label),
   fITSMuonClusterMap(0),
   fFilterMap(selectInfo),
+  fTPCClusterMap(),
+  fTPCSharedMap(),
+  fTPCnclsF(0),
   fID(id),
   fCharge(charge),
   fType(ttype),
@@ -112,13 +122,17 @@ AliAODTrack::AliAODTrack(Short_t id,
                         AODTrk_t ttype,
                         UInt_t selectInfo,
                         Float_t chi2perNDF) :
-  AliVParticle(),
+  AliVTrack(),
+  fRAtAbsorberEnd(0.),
   fChi2perNDF(chi2perNDF),
   fChi2MatchTrigger(0.),
   fFlags(0),
   fLabel(label),
   fITSMuonClusterMap(0),
   fFilterMap(selectInfo),
+  fTPCClusterMap(),
+  fTPCSharedMap(),
+  fTPCnclsF(0),
   fID(id),
   fCharge(charge),
   fType(ttype),
@@ -144,18 +158,23 @@ AliAODTrack::~AliAODTrack()
 {
   // destructor
   delete fCovMatrix;
+  delete fDetPid;
 }
 
 
 //______________________________________________________________________________
 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
-  AliVParticle(trk),
+  AliVTrack(trk),
+  fRAtAbsorberEnd(trk.fRAtAbsorberEnd),
   fChi2perNDF(trk.fChi2perNDF),
   fChi2MatchTrigger(trk.fChi2MatchTrigger),
   fFlags(trk.fFlags),
   fLabel(trk.fLabel),
   fITSMuonClusterMap(trk.fITSMuonClusterMap),
   fFilterMap(trk.fFilterMap),
+  fTPCClusterMap(trk.fTPCClusterMap),
+  fTPCSharedMap(trk.fTPCSharedMap),
+  fTPCnclsF(trk.fTPCnclsF),
   fID(trk.fID),
   fCharge(trk.fCharge),
   fType(trk.fType),
@@ -182,7 +201,7 @@ AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
   // Assignment operator
   if(this!=&trk) {
 
-    AliVParticle::operator=(trk);
+    AliVTrack::operator=(trk);
 
     trk.GetP(fMomentum);
     trk.GetPosition(fPosition);
@@ -191,6 +210,8 @@ AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
     SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
     SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
     
+    fRAtAbsorberEnd = trk.fRAtAbsorberEnd;
+    
     fChi2perNDF = trk.fChi2perNDF;
     fChi2MatchTrigger = trk.fChi2MatchTrigger;
 
@@ -329,27 +350,22 @@ AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
   // Returns the most probable PID array element.
   
   Int_t nPID = 10;
-  if (fPID) {
-    AODTrkPID_t loc = kUnknown;
-    Double_t max = 0.;
-    Bool_t allTheSame = kTRUE;
-    
-    for (Int_t iPID = 0; iPID < nPID; iPID++) {
-      if (fPID[iPID] >= max) {
-       if (fPID[iPID] > max) {
-         allTheSame = kFALSE;
-         max = fPID[iPID];
-         loc = (AODTrkPID_t)iPID;
-       } else {
-         allTheSame = kTRUE;
-       }
+  AODTrkPID_t loc = kUnknown;
+  Double_t max = 0.;
+  Bool_t allTheSame = kTRUE;
+  
+  for (Int_t iPID = 0; iPID < nPID; iPID++) {
+    if (fPID[iPID] >= max) {
+      if (fPID[iPID] > max) {
+       allTheSame = kFALSE;
+       max = fPID[iPID];
+       loc = (AODTrkPID_t)iPID;
+      } else {
+       allTheSame = kTRUE;
       }
     }
-    
-    return allTheSame ? kUnknown : loc;
-  } else {
-    return kUnknown;
   }
+  return allTheSame ? kUnknown : loc;
 }
 
 //______________________________________________________________________________
@@ -449,9 +465,10 @@ void AliAODTrack::Print(Option_t* /* option */) const
   printf("    charge = %d\n", Charge());
 }
 
-void AliAODTrack::SetMatchTrigger(Int_t matchTrig){
-//
-// Set the MUON trigger information
+//______________________________________________________________________________
+void AliAODTrack::SetMatchTrigger(Int_t matchTrig)
+{
+  // Set the MUON trigger information
   switch(matchTrig){
     case 0: // 0 track does not match trigger
       fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
@@ -471,182 +488,135 @@ void AliAODTrack::SetMatchTrigger(Int_t matchTrig){
   }
 }
 
-Int_t AliAODTrack::HitsMT(Int_t istation, Int_t iplane, Char_t *cathode){
-//
-// Retrieve hit information for MUON identified by  (station, plane, cathode)
-  if(cathode){
-    if(cathode[0]=='x'||cathode[0]=='X'){
-      if(istation==1){
-        if(iplane==1)
-         return (fITSMuonClusterMap&0x8000)?1:0;
-       else if(iplane==2)
-         return (fITSMuonClusterMap&0x4000)?1:0;
-       else
-         return 0;
-      }else if(istation==2){
-        if(iplane==1)
-         return (fITSMuonClusterMap&0x2000)?1:0;
-       else if(iplane==2)
-         return (fITSMuonClusterMap&0x1000)?1:0;
-       else
-         return 0;
-      }else{
-        return 0;
-      }
-    }else if(cathode[0]=='y'||cathode[0]=='Y'){
-      if(istation==1){
-        if(iplane==1)
-         return (fITSMuonClusterMap&0x0800)?1:0;
-       else if(iplane==2)
-         return (fITSMuonClusterMap&0x0400)?1:0;
-       else
-         return 0;
-      }else if(istation==2){
-        if(iplane==1)
-         return (fITSMuonClusterMap&0x0200)?1:0;
-       else if(iplane==2)
-         return (fITSMuonClusterMap&0x0100)?1:0;
-       else
-         return 0;
-      }else{
-        return 0;
-      }
-    }else{
-      return 0;
-    }
-  }else{
-    if(istation==1){
-      if(iplane==1)
-       return (HitsMT(1,1,"X")||HitsMT(1,1,"Y"))?1:0;
-      else if(iplane==2)
-       return (HitsMT(1,2,"X")||HitsMT(1,2,"Y"))?1:0;
-      else
-       return 0;
-    }else if(istation==2){
-      if(iplane==1)
-       return (HitsMT(2,1,"X")||HitsMT(2,1,"Y"))?1:0;
-      else if(iplane==2)
-       return (HitsMT(2,2,"X")||HitsMT(2,2,"Y"))?1:0;
-      else
-       return 0;
-    }else{
-      return 0;
-    }
+//______________________________________________________________________________
+Bool_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber, Int_t cathode) const
+{
+  // return kTRUE if the track fires the given tracking or trigger chamber.
+  // If the chamber is a trigger one:
+  // - if cathode = 0 or 1, the track matches the corresponding cathode
+  // - if cathode = -1, the track matches both cathodes
+  
+  if (MuonChamber < 0) return kFALSE;
+  
+  if (MuonChamber < 10) return TESTBIT(GetMUONClusterMap(), MuonChamber);
+  
+  if (MuonChamber < 14) {
+    
+    if (cathode < 0) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber) &&
+                            TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+4);
+    
+    if (cathode < 2) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+(1-cathode)*4);
+    
   }
+  
+  return kFALSE;
 }
 
-Int_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber){
-  //
-  // Retrieve hit information for MUON Tracker/Trigger Chamber
-  // WARNING: chamber number start from 1 instead of 0
+//______________________________________________________________________________
+Bool_t AliAODTrack::MatchTriggerDigits() const
+{
+  // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
   
-  if (MuonChamber > 0 && MuonChamber < 11) {
-    return ((GetMUONClusterMap() & BIT(MuonChamber-1)) != 0) ? 1 : 0;
-  } else {
-    switch(MuonChamber){
-      case 11:
-       return HitsMT(1,1);
-      case 12:
-       return HitsMT(1,2);
-      case 13:
-       return HitsMT(2,1);
-      case 14:
-       return HitsMT(2,2);
-      default:
-       printf("Unknown MUON chamber: %d\n",MuonChamber);
-       return 0;
-    }
+  Int_t nMatchedChambers = 0;
+  for (Int_t ich=10; ich<14; ich++) if (HitsMuonChamber(ich)) nMatchedChambers++;
+  
+  return (nMatchedChambers >= 2);
+}
+
+//______________________________________________________________________________
+Bool_t AliAODTrack::PropagateToDCA(const AliVVertex *vtx, 
+    Double_t b, Double_t maxd, Double_t dz[2], Double_t covar[3])
+{
+  // compute impact parameters to the vertex vtx and their covariance matrix
+  // b is the Bz, needed to propagate correctly the track to vertex 
+  // only the track parameters are update after the propagation (pos and mom),
+  // not the covariance matrix. This is OK for propagation over short distance
+  // inside the beam pipe.
+  // return kFALSE is something went wrong
+
+  // convert to AliExternalTrackParam
+  AliExternalTrackParam etp(this);  
+
+  Float_t xstart = etp.GetX();
+  if(xstart>3.) {
+    AliError("This method can be used only for propagation inside the beam pipe");
+    return kFALSE; 
   }
+
+  if(!etp.PropagateToDCA(vtx,b,maxd,dz,covar)) return kFALSE;
+
+  // update track position and momentum
+  Double_t mom[3];
+  etp.GetPxPyPz(mom);
+  SetP(mom,kTRUE);
+  etp.GetXYZ(mom);
+  SetPosition(mom,kFALSE);
+
+
+  return kTRUE;
 }
 
-Bool_t AliAODTrack::PropagateTo(Double_t xk, Double_t b) {
-  //----------------------------------------------------------------
-  // Propagate this track to the plane X=xk (cm) in the field "b" (kG)
-  // This is in local coordinates!!!
-  //----------------------------------------------------------------
-
-  Double_t alpha = 0.;
-  Double_t localP[3] = {Px(), Py(), Pz()}; // set global (sic!) p
-  Global2LocalMomentum(localP, Charge(), alpha); // convert global to local momentum
-
-  AliAODVertex *origin = (AliAODVertex*)fProdVertex.GetObject();
-  Double_t localX[3] = {origin->GetX(), origin->GetY(), origin->GetZ()}; // set global (sic!) location of first track point
-  Global2LocalPosition(localX, alpha); // convert global to local position
-
-  Double_t &fX = localX[0];
-
-  Double_t dx=xk-fX;
-  if (TMath::Abs(dx)<=kAlmost0)  return kTRUE;
-
-  Double_t crv=localP[0]*b*kB2C;
-  if (TMath::Abs(b) < kAlmost0Field) crv=0.;
-
-  Double_t f1=localP[1], f2=f1 + crv*dx;
-  if (TMath::Abs(f1) >= kAlmost1) return kFALSE;
-  if (TMath::Abs(f2) >= kAlmost1) return kFALSE;
-
-  Double_t &fP0=localX[1], &fP1=localX[2], &fP2=localP[0], &fP3=localP[1], &fP4=localP[2];
-  /* covariance matrix to be fixed! 
-  Double_t 
-  &fC00=fC[0],
-  &fC10=fC[1],   &fC11=fC[2],  
-  &fC20=fC[3],   &fC21=fC[4],   &fC22=fC[5],
-  &fC30=fC[6],   &fC31=fC[7],   &fC32=fC[8],   &fC33=fC[9],  
-  &fC40=fC[10],  &fC41=fC[11],  &fC42=fC[12],  &fC43=fC[13], &fC44=fC[14];
-  */
-  Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
-
-  fX=xk;
-  fP0 += dx*(f1+f2)/(r1+r2);
-  fP1 += dx*(r2 + f2*(f1+f2)/(r1+r2))*fP3;
-  fP2 += dx*crv;
-
-  //f = F - 1
-   
-  //Double_t f02=    dx/(r1*r1*r1);            
-  Double_t cc=crv/fP4;
-  Double_t f04=0.5*dx*dx/(r1*r1*r1);         f04*=cc;
-  //Double_t f12=    dx*fP3*f1/(r1*r1*r1);
-  Double_t f14=0.5*dx*dx*fP3*f1/(r1*r1*r1);  f14*=cc;
-  //Double_t f13=    dx/r1;
-  Double_t f24=    dx;                       f24*=cc;
+//______________________________________________________________________________
+Bool_t AliAODTrack::GetPxPyPz(Double_t p[3]) const 
+{
+    //---------------------------------------------------------------------
+    // This function returns the global track momentum components
+    //---------------------------------------------------------------------
+  p[0]=Px(); p[1]=Py(); p[2]=Pz();
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+Float_t AliAODTrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1) const
+{
+  //
+  // TPC cluster information
+  // type 0: get fraction of found/findable clusters with neighbourhood definition
+  //      1: findable clusters with neighbourhood definition
+  //      2: found clusters
+  //
+  // definition of findable clusters:
+  //            a cluster is defined as findable if there is another cluster
+  //           within +- nNeighbours pad rows. The idea is to overcome threshold
+  //           effects with a very simple algorithm.
+  //
   
-  /* covariance matrix to be fixed!
-  //b = C*ft
-  Double_t b00=f02*fC20 + f04*fC40, b01=f12*fC20 + f14*fC40 + f13*fC30;
-  Double_t b02=f24*fC40;
-  Double_t b10=f02*fC21 + f04*fC41, b11=f12*fC21 + f14*fC41 + f13*fC31;
-  Double_t b12=f24*fC41;
-  Double_t b20=f02*fC22 + f04*fC42, b21=f12*fC22 + f14*fC42 + f13*fC32;
-  Double_t b22=f24*fC42;
-  Double_t b40=f02*fC42 + f04*fC44, b41=f12*fC42 + f14*fC44 + f13*fC43;
-  Double_t b42=f24*fC44;
-  Double_t b30=f02*fC32 + f04*fC43, b31=f12*fC32 + f14*fC43 + f13*fC33;
-  Double_t b32=f24*fC43;
+  if (type==2) return fTPCClusterMap.CountBits();
   
-  //a = f*b = f*C*ft
-  Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a02=f02*b22+f04*b42;
-  Double_t a11=f12*b21+f14*b41+f13*b31,a12=f12*b22+f14*b42+f13*b32;
-  Double_t a22=f24*b42;
-
-  //F*C*Ft = C + (b + bt + a)
-  fC00 += b00 + b00 + a00;
-  fC10 += b10 + b01 + a01; 
-  fC20 += b20 + b02 + a02;
-  fC30 += b30;
-  fC40 += b40;
-  fC11 += b11 + b11 + a11;
-  fC21 += b21 + b12 + a12;
-  fC31 += b31; 
-  fC41 += b41;
-  fC22 += b22 + b22 + a22;
-  fC32 += b32;
-  fC42 += b42;
-  */
+  Int_t found=0;
+  Int_t findable=0;
+  Int_t last=-nNeighbours;
   
-  Local2GlobalMomentum(localP, alpha); // convert local to global momentum
-  SetP(localP);
-
-  return kTRUE;
+  for (Int_t i=row0; i<row1; ++i){
+    //look to current row
+    if (fTPCClusterMap[i]) {
+      last=i;
+      ++found;
+      ++findable;
+      continue;
+    }
+    //look to nNeighbours before
+    if ((i-last)<=nNeighbours) {
+      ++findable;
+      continue;
+    }
+    //look to nNeighbours after
+    for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
+      if (fTPCClusterMap[j]){
+        ++findable;
+        break;
+      }
+    }
+  }
+  if (type==1) return findable;
+  
+  if (type==0){
+    Float_t fraction=0;
+    if (findable>0)
+      fraction=(Float_t)found/(Float_t)findable;
+    else
+      fraction=0;
+    return fraction;
+  }
+  return 0;  // undefined type - default value
 }
-