]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtrackV1.cxx
update TRD code for PbPb 2011
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackV1.cxx
index 2678d56de1eaa908f8118286f52db2d68cd812d0..28f01efd64f6ddeffc9deb7526db80d4a5a60bf2 100644 (file)
@@ -1,3 +1,4 @@
+
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
@@ -23,6 +24,7 @@
 #include "AliTRDcluster.h"
 #include "AliTRDcalibDB.h"
 #include "AliTRDReconstructor.h"
+#include "AliTRDPIDResponse.h"
 #include "AliTRDrecoParam.h"
 
 ClassImp(AliTRDtrackV1)
@@ -237,6 +239,7 @@ AliTRDtrackV1 &AliTRDtrackV1::operator=(const AliTRDtrackV1 &t)
   //
 
   if (this != &t) {
+    AliKalmanTrack::operator=(t);
     ((AliTRDtrackV1 &) t).Copy(*this);
   }
 
@@ -346,29 +349,31 @@ Bool_t AliTRDtrackV1::CookPID()
 //<img src="TRD/trackPID.gif">
 //End_Html
 //
-  
-  /*Reset the a priori probabilities*/
-  Double_t pid = 1. / AliPID::kSPECIES;
-  for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fPID[ispec] = pid; 
-
-  UChar_t fPIDquality = SetNumberOfTrackletsPID(kTRUE);
-  // no tracklet found for PID calculations
-  if(!fPIDquality) return kFALSE;
-  
-  // slot for PID calculation @ track level for bremsstrahlung TODO
-  
-  // normalize probabilities
-  Double_t probTotal = 0.0;
-  for (Int_t is = 0; is < AliPID::kSPECIES; is++) probTotal += fPID[is];
-  
-  
-  if (probTotal <= 0.0) {
-    AliWarning("The total probability over all species <= 0. This may be caused by some error in the reference data.");
+  const AliTRDPIDResponse *pidResponse = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod());
+  if(!pidResponse){
+    AliError("PID Response not available");
     return kFALSE;
   }
-  
-  for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) fPID[iSpecies] /= probTotal;
-  
+  Int_t nslices = pidResponse->GetNumberOfSlices();
+  Double_t dEdx[kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN];
+  Float_t trackletP[kNplane];
+  memset(dEdx, 0, sizeof(Double_t) * kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN);
+  memset(trackletP, 0, sizeof(Float_t)*kNplane);
+  for(Int_t iseed = 0; iseed < kNplane; iseed++){
+    if(!fTracklet[iseed]) continue;
+    trackletP[iseed] = fTracklet[iseed]->GetMomentum();
+    fTracklet[iseed]->SetPID();
+    if(pidResponse->GetPIDmethod() == AliTRDPIDResponse::kLQ1D){
+      dEdx[iseed] = fTracklet[iseed]->GetdQdl();
+    } else {
+      fTracklet[iseed]->CookdEdx(nslices);
+      const Float_t *trackletdEdx = fTracklet[iseed]->GetdEdx();
+      for(Int_t islice = 0; islice < nslices; islice++){
+        dEdx[iseed*nslices + islice] = trackletdEdx[islice];
+      }
+    }
+  }
+  pidResponse->GetResponse(nslices, dEdx, trackletP, fPID);
   return kTRUE;
 }
 
@@ -378,52 +383,15 @@ UChar_t AliTRDtrackV1::GetNumberOfTrackletsPID() const
 // Retrieve number of tracklets used for PID calculation. 
 
   UChar_t nPID = 0;
-  Float_t *prob = NULL;
   for(int ip=0; ip<kNplane; ip++){
     if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
     if(!fTracklet[ip]->IsOK()) continue;
-    if(!(prob = fTracklet[ip]->GetProbability(kFALSE))) continue;
-
-    Int_t nspec = 0; // quality check of tracklet dEdx
-    for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
-      if(prob[ispec] < 0.) continue;
-      nspec++;
-    }
-    if(!nspec) continue;
     
-    fTracklet[ip]->SetPID();
     nPID++;
   }
   return nPID;
 }
 
-//___________________________________________________________
-UChar_t AliTRDtrackV1::SetNumberOfTrackletsPID(Bool_t recalc)
-{
-// Retrieve number of tracklets used for PID calculation. // Recalculated PID at tracklet level by quering the PID DB.
-
-  UChar_t fPIDquality(0);
-  
-  // steer PID calculation @ tracklet level
-  Float_t *prob(NULL);
-  for(int ip=0; ip<kNplane; ip++){
-    if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
-    if(!fTracklet[ip]->IsOK()) continue;
-    if(!(prob = fTracklet[ip]->GetProbability(recalc))) return 0;
-
-    Int_t nspec = 0; // quality check of tracklet dEdx
-    for(int ispec=0; ispec<AliPID::kSPECIES; ispec++){
-      if(prob[ispec] < 0.) continue;
-      fPID[ispec] *= prob[ispec];
-      nspec++;
-    }
-    if(!nspec) continue;
-    
-    fPIDquality++;
-  }
-  return fPIDquality;
-}
-
 //_______________________________________________________________
 AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id)
 {
@@ -557,7 +525,7 @@ Int_t AliTRDtrackV1::MakeBackupTrack()
   for(Int_t il(AliTRDgeometry::kNlayer); il--;){ 
     if(!fTracklet[il]) continue;
     n++; 
-    occupancy+=fTracklet[il]->GetOccupancyTB();
+    occupancy+=fTracklet[il]->GetTBoccupancy()/AliTRDseedV1::kNtb;
     ncls += fTracklet[il]->GetN();
   }
   if(!n) return -1;
@@ -626,7 +594,7 @@ Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
   // "xrho" - thickness*density    [g/cm^2] 
   // 
 
-  if (TMath::Abs(xk - GetX())<1.e-2) return kTRUE; // 100mum limit
+  if (TMath::Abs(xk - GetX())<AliTRDReconstructor::GetEpsilon()*0.1) return kTRUE; // 10% of the tracker precision
 
   Double_t xyz0[3] = {GetX(), GetY(), GetZ()}, // track position BEFORE propagation 
            b[3];    // magnetic field 
@@ -635,6 +603,7 @@ Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
  
   // local track position AFTER propagation 
   Double_t xyz1[3] = {GetX(), GetY(), GetZ()};
+//  printf("x0[%6.2f] -> x1[%6.2f] dx[%6.2f] rho[%f]\n", xyz0[0], xyz1[0], xyz0[0]-xk, xrho/TMath::Abs(xyz0[0]-xk));
   if(xyz0[0] < xk) {
     xrho = -xrho;
     if (IsStartedTimeIntegral()) {
@@ -652,7 +621,6 @@ Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
       AddTimeStep(l2);
     }
   }
-
   if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0, xrho, GetMass())) return kFALSE;
 
 
@@ -889,7 +857,7 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
   // Update the TRD PID information in the ESD track
   //
 
-  Int_t nslices = fkReconstructor->GetRecoParam()->IsEightSlices() ? (Int_t)AliTRDpidUtil::kNNslices : (Int_t)AliTRDpidUtil::kLQslices;
+//   Int_t nslices = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod())->GetNumberOfSlices();
   // number of tracklets used for PID calculation
   UChar_t nPID = GetNumberOfTrackletsPID();
   // number of tracklets attached to the track
@@ -897,16 +865,30 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
   // pack the two numbers together and store them in the ESD
   track->SetTRDntracklets(nPID | (nTrk<<3));
   // allocate space to store raw PID signals dEdx & momentum
-  track->SetNumberOfTRDslices((nslices+2)*AliTRDgeometry::kNlayer);
+  track->SetNumberOfTRDslices((AliTRDPIDResponse::kNslicesNN+3)*AliTRDgeometry::kNlayer);
   // store raw signals
   Float_t p, sp; Double_t spd;
   for (Int_t ip = 0; ip < kNplane; ip++) {
     if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue;
     if(!fTracklet[ip]->HasPID()) continue;
+    fTracklet[ip]->CookdEdx(AliTRDPIDResponse::kNslicesNN);
     const Float_t *dedx = fTracklet[ip]->GetdEdx();
-    for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js);
-    p = fTracklet[ip]->GetMomentum(&sp); spd = sp;
+    for (Int_t js = 0; js < AliTRDPIDResponse::kNslicesNN; js++, dedx++){
+      track->SetTRDslice(*dedx, ip, js+1);
+    }
+    p = fTracklet[ip]->GetMomentum(&sp); 
+    // store global quality per tracklet instead of momentum error
+    // 26.09.11 A.Bercuci
+    // first implementation store no. of time bins filled in tracklet (5bits  see "y" bits) and
+    // no. of double clusters in case of pad row cross (4bits see "x" bits)
+    // bit map for tracklet quality xxxxyyyyy
+    // 27.10.11 A.Bercuci
+    // add chamber status bit "z" bit 
+    // bit map for tracklet quality zxxxxyyyyy
+    Int_t nCross(fTracklet[ip]->IsRowCross()?fTracklet[ip]->GetTBcross():0);
+    spd = Double_t(fTracklet[ip]->GetTBoccupancy() | (nCross<<5) | (fTracklet[ip]->IsChmbGood()<<9));
     track->SetTRDmomentum(p, ip, &spd);
+    track->SetTRDslice(fTracklet[ip]->GetdQdl(), ip, 0); // Set Summed dEdx into the first slice
   }
   // store PID probabilities
   track->SetTRDpid(fPID);