]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/ESD/AliESDpid.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDpid.cxx
index 36f236f3a79ed7bcb705b0b99f253567e3413bbe..88a23dc25233732a839292689506a160b973ae7a 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+/* $Id: AliESDpid.cxx 64123 2013-09-05 15:09:53Z morsch $ */
 
 //-----------------------------------------------------------------
 //           Implementation of the combined PID class
 #include "TArrayI.h"
 #include "TArrayF.h"
 
+#include "TRandom.h"
 #include "AliLog.h"
 #include "AliPID.h"
 #include "AliTOFHeader.h"
 #include "AliESDpid.h"
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
+#include "AliMCEvent.h"
+#include "AliTOFPIDParams.h"
+
+#include <AliDetectorPID.h>
 
 ClassImp(AliESDpid)
 
-Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t timeZeroTOF) const {
+Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t /*timeZeroTOF*/) const {
   //
   //  Calculate probabilities for all detectors, except if TPConly==kTRUE
   //  and combine PID
@@ -56,7 +61,7 @@ Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t timeZeroTOF
     MakeTPCPID(track);
     if (!TPConly) {
       MakeITSPID(track);
-      MakeTOFPID(track, timeZeroTOF);
+      //MakeTOFPID(track, timeZeroTOF);
       //MakeHMPIDPID(track);
       //MakeTRDPID(track);
     }
@@ -65,6 +70,92 @@ Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t timeZeroTOF
   return 0;
 }
 //_________________________________________________________________________
+Float_t AliESDpid::GetTPCsignalTunedOnData(const AliVTrack *t) const {
+    AliESDtrack *track = (AliESDtrack *) t;
+    Float_t dedx = track->GetTPCsignalTunedOnData();
+
+    if(dedx > 0) return dedx;
+
+    dedx = t->GetTPCsignal();
+    track->SetTPCsignalTunedOnData(dedx);
+    if(dedx < 20) return dedx;
+
+    AliPID::EParticleType type = AliPID::kPion;
+
+    AliMCEventHandler* eventHandler=dynamic_cast<AliMCEventHandler*>(fEventHandler);
+    if (eventHandler) {
+       AliMCEvent* mcEvent = eventHandler->MCEvent();
+       if(mcEvent){
+           Bool_t kGood = kTRUE;
+           AliMCParticle *MCpart = (AliMCParticle *) mcEvent->GetTrack(TMath::Abs(t->GetLabel()));
+           TParticle *part = MCpart->Particle();
+           
+           Int_t iS = TMath::Abs(part->GetPdgCode());
+
+           if(iS==AliPID::ParticleCode(AliPID::kElectron)){
+               type = AliPID::kElectron;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kMuon)){
+               type = AliPID::kMuon;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kPion)){
+               type = AliPID::kPion;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kKaon)){
+               type = AliPID::kKaon;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kProton)){
+               type = AliPID::kProton;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kDeuteron)){ // d
+               type = AliPID::kDeuteron;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kTriton)){ // t
+               type = AliPID::kTriton;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kHe3)){ // 3He
+               type = AliPID::kHe3;
+           }
+           else if(iS==AliPID::ParticleCode(AliPID::kAlpha)){ // 4He
+               type = AliPID::kAlpha;
+           }
+           else
+               kGood = kFALSE;
+
+           if(kGood){
+        //TODO maybe introduce different dEdxSources?
+        Double_t bethe = fTPCResponse.GetExpectedSignal(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection(),
+                                                        this->UseTPCMultiplicityCorrection());
+        Double_t sigma = fTPCResponse.GetExpectedSigma(track, type, AliTPCPIDResponse::kdEdxDefault, this->UseTPCEtaCorrection(),
+                                                       this->UseTPCMultiplicityCorrection());
+               dedx = gRandom->Gaus(bethe,sigma);
+//             if(iS == AliPID::ParticleCode(AliPID::kHe3) || iS == AliPID::ParticleCode(AliPID::kAlpha)) dedx *= 5;
+           }
+       }
+    }
+
+    track->SetTPCsignalTunedOnData(dedx);
+    return dedx;
+}
+//_________________________________________________________________________
+Float_t AliESDpid::GetTOFsignalTunedOnData(const AliVTrack *t) const {
+    AliESDtrack *track = (AliESDtrack *) t;
+    Double_t tofSignal = track->GetTOFsignalTunedOnData();
+
+    if(tofSignal <  99999) return (Float_t)tofSignal; // it has been already set
+    // read additional mismatch fraction
+    Float_t addmism = GetTOFPIDParams()->GetTOFadditionalMismForMC();
+    if(addmism > 1.){
+      Float_t centr = GetCurrentCentrality();
+      if(centr > 50) addmism *= 0.1667;
+      else if(centr > 20) addmism *= 0.33;
+    }
+
+    tofSignal = t->GetTOFsignal() + fTOFResponse.GetTailRandomValue(t->Pt(),t->Eta(),t->GetTOFsignal(),addmism);
+    track->SetTOFsignalTunedOnData(tofSignal);
+    return (Float_t)tofSignal;
+}
+//_________________________________________________________________________
 void AliESDpid::MakeTPCPID(AliESDtrack *track) const
 {
   //
@@ -137,7 +228,7 @@ void AliESDpid::MakeITSPID(AliESDtrack *track) const
       return;
     }
 
-    Double_t p[10];
+    Double_t p[AliPID::kSPECIES];
 
     Bool_t mismatch=kTRUE, heavy=kTRUE;
     for (Int_t j=0; j<AliPID::kSPECIES; j++) {
@@ -186,7 +277,7 @@ void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t /*timeZeroTOF*/) const
   Int_t ibin = fTOFResponse.GetMomBin(track->GetP());
   Float_t timezero = fTOFResponse.GetT0bin(ibin);
 
-  Double_t time[AliPID::kSPECIESN];
+  Double_t time[AliPID::kSPECIESC];
   track->GetIntegratedTimes(time);
 
   Double_t sigma[AliPID::kSPECIES];
@@ -214,7 +305,8 @@ void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t /*timeZeroTOF*/) const
   Double_t tof = track->GetTOFsignal() - timezero;
 
   Double_t p[AliPID::kSPECIES];
-  Bool_t mismatch = kTRUE, heavy = kTRUE;
+//   Bool_t mismatch = kTRUE;
+  Bool_t heavy = kTRUE;
   for (Int_t j=0; j<AliPID::kSPECIES; j++) {
     Double_t sig = sigma[j];
     if (TMath::Abs(tof-time[j]) > (fRange+2)*sig) {
@@ -223,23 +315,28 @@ void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t /*timeZeroTOF*/) const
       p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
 
     // Check the mismatching
-    Double_t mass = AliPID::ParticleMass(j);
-    Double_t pm = fTOFResponse.GetMismatchProbability(track->GetP(),mass);
-    if (p[j]>pm) mismatch = kFALSE;
+    
+//     Double_t mass = AliPID::ParticleMass(j);
+//     Double_t pm = fTOFResponse.GetMismatchProbability(track->GetP(),mass);
+//     if (p[j]>pm) mismatch = kFALSE;
 
     // Check for particles heavier than (AliPID::kSPECIES - 1)
     if (tof < (time[j] + fRange*sig)) heavy=kFALSE;
 
   }
 
-  if (mismatch)
+  /*
+    if (mismatch)
     for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
+  */
 
   track->SetTOFpid(p);
 
-  if (heavy) track->ResetStatus(AliESDtrack::kTOFpid);    
-  if (!CheckTOFMatching(track)) track->SetStatus(AliESDtrack::kTOFmismatch);
+  if (heavy) track->ResetStatus(AliESDtrack::kTOFpid);
   
+  // kTOFmismatch flas is not set because deprecated from 18/02/2013
+  //  if (!CheckTOFMatching(track)) track->SetStatus(AliESDtrack::kTOFmismatch);
+  //  else track->ResetStatus(AliESDtrack::kTOFmismatch);
 }
 //_________________________________________________________________________
 void AliESDpid::MakeTRDPID(AliESDtrack *track) const
@@ -248,7 +345,7 @@ void AliESDpid::MakeTRDPID(AliESDtrack *track) const
   // Method to recalculate the TRD PID probabilities
   //
   Double_t prob[AliPID::kSPECIES];
-  ComputeTRDProbability(track, AliPID::kSPECIES, prob);
+  GetComputeTRDProbability(track, AliPID::kSPECIES, prob);
   track->SetTRDpid(prob);
 }
 //_________________________________________________________________________
@@ -258,37 +355,36 @@ void AliESDpid::CombinePID(AliESDtrack *track) const
   // Combine the information of various detectors
   // to determine the Particle Identification
   //
-  Int_t ns=AliPID::kSPECIES;
-  Double_t p[10]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};
+  Double_t p[AliPID::kSPECIES]={1.};
 
   if (track->IsOn(AliESDtrack::kITSpid)) {
-    Double_t d[10];
+    Double_t d[AliPID::kSPECIES];
     track->GetITSpid(d);
-    for (Int_t j=0; j<ns; j++) p[j]*=d[j];
+    for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]*=d[j];
   }
 
   if (track->IsOn(AliESDtrack::kTPCpid)) {
-    Double_t d[10];
+    Double_t d[AliPID::kSPECIES];
     track->GetTPCpid(d);
-    for (Int_t j=0; j<ns; j++) p[j]*=d[j];
+    for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]*=d[j];
   }
 
   if (track->IsOn(AliESDtrack::kTRDpid)) {
-    Double_t d[10];
+    Double_t d[AliPID::kSPECIES];
     track->GetTRDpid(d);
-    for (Int_t j=0; j<ns; j++) p[j]*=d[j];
+    for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]*=d[j];
   }
 
   if (track->IsOn(AliESDtrack::kTOFpid)) {
-    Double_t d[10];
+    Double_t d[AliPID::kSPECIES];
     track->GetTOFpid(d);
-    for (Int_t j=0; j<ns; j++) p[j]*=d[j];
+    for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]*=d[j];
   }
 
   if (track->IsOn(AliESDtrack::kHMPIDpid)) {
-    Double_t d[10];
+    Double_t d[AliPID::kSPECIES];
     track->GetHMPIDpid(d);
-    for (Int_t j=0; j<ns; j++) p[j]*=d[j];
+    for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]*=d[j];
   }
 
   track->SetESDpid(p);
@@ -300,7 +396,7 @@ Bool_t AliESDpid::CheckTOFMatching(AliESDtrack *track) const{
   //
     Bool_t status = kFALSE;
     
-    Double_t exptimes[5];
+    Double_t exptimes[AliPID::kSPECIESC];
     track->GetIntegratedTimes(exptimes);
     
     Float_t p = track->P();
@@ -312,7 +408,7 @@ Bool_t AliESDpid::CheckTOFMatching(AliESDtrack *track) const{
     track->GetInnerPxPyPz(ptpc);
     Float_t momtpc=TMath::Sqrt(ptpc[0]*ptpc[0] + ptpc[1]*ptpc[1] + ptpc[2]*ptpc[2]);
     
-    for(Int_t i=0;i < 5;i++){
+    for(Int_t i=0;i < AliPID::kSPECIES;i++){
        AliPID::EParticleType type=AliPID::EParticleType(i);
        
        Float_t resolutionTOF = fTOFResponse.GetExpectedSigma(p, exptimes[i], AliPID::ParticleMass(i));
@@ -333,214 +429,90 @@ Bool_t AliESDpid::CheckTOFMatching(AliESDtrack *track) const{
     
     return status;
 }
+
 //_________________________________________________________________________
-void AliESDpid::SetTOFResponse(AliVEvent *vevent,EStartTimeType_t option){
+Float_t AliESDpid::GetSignalDeltaTOFold(const AliVParticle *track, AliPID::EParticleType type, Bool_t ratio/*=kFALSE*/) const
+{
   //
-  // Set TOF response function
-  // Input option for event_time used
+  // TOF signal - expected
   //
-
-    AliESDEvent *event=(AliESDEvent*)vevent;
+  AliVTrack *vtrack=(AliVTrack*)track;
   
-    Float_t t0spread = 0.; //event->GetEventTimeSpread();
-    if(t0spread < 10) t0spread = 80;
-
-    // T0 from TOF algorithm
-
-    Bool_t flagT0TOF=kFALSE;
-    Bool_t flagT0T0=kFALSE;
-    Float_t *startTime = new Float_t[fTOFResponse.GetNmomBins()];
-    Float_t *startTimeRes = new Float_t[fTOFResponse.GetNmomBins()];
-    Int_t *startTimeMask = new Int_t[fTOFResponse.GetNmomBins()];
-
-    // T0-TOF arrays
-    Float_t *estimatedT0event = new Float_t[fTOFResponse.GetNmomBins()];
-    Float_t *estimatedT0resolution = new Float_t[fTOFResponse.GetNmomBins()];
-    for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-      estimatedT0event[i]=0.0;
-      estimatedT0resolution[i]=0.0;
-      startTimeMask[i] = 0;
-    }
-
-    Float_t resT0A=75,resT0C=65,resT0AC=55;
-    if(event->GetT0TOF()){ // check if T0 detector information is available
-       flagT0T0=kTRUE;
-    }
-
+  const Double_t expTime = fTOFResponse.GetExpectedSignal(vtrack,type);
+  Double_t tofTime = 99999;
+  if (fTuneMConData && ((fTuneMConDataMask & kDetTOF) == kDetTOF) ) tofTime = (Double_t)this->GetTOFsignalTunedOnData((AliVTrack*)vtrack);
+  else tofTime=vtrack->GetTOFsignal();
+  tofTime = tofTime  - fTOFResponse.GetStartTime(vtrack->P());
+  Double_t delta=-9999.;
+
+  if (!ratio) delta=tofTime-expTime;
+  else if (expTime>1.e-20) delta=tofTime/expTime;
+  
+  return delta;
+}
 
-    AliTOFHeader *tofHeader =(AliTOFHeader*)event->GetTOFHeader();
+//_________________________________________________________________________
+Float_t AliESDpid::GetNumberOfSigmasTOFold(const AliVParticle *track, AliPID::EParticleType type) const
+{
+  //
+  // Number of sigma implementation for the TOF
+  //
 
-    if(tofHeader){ // read global info and T0-TOF info from ESD
-      fTOFResponse.SetTimeResolution(tofHeader->GetTOFResolution());
-      t0spread = tofHeader->GetT0spread(); // read t0 sprad
-      if(t0spread < 10) t0spread = 80;
+  AliVTrack *vtrack=(AliVTrack*)track;
+  Double_t tofTime = 99999;
+  if (fTuneMConData && ((fTuneMConDataMask & kDetTOF) == kDetTOF) ) tofTime = (Double_t)this->GetTOFsignalTunedOnData((AliVTrack*)vtrack);
+  else tofTime=vtrack->GetTOFsignal();
+  
+  Double_t expTime = fTOFResponse.GetExpectedSignal(vtrack,type);
+  return (tofTime - fTOFResponse.GetStartTime(vtrack->P()) - expTime)/fTOFResponse.GetExpectedSigma(vtrack->P(),expTime,AliPID::ParticleMassZ(type));
+}
 
-      flagT0TOF=kTRUE;
-      for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){ // read T0-TOF default value
-       startTime[i]=tofHeader->GetDefaultEventTimeVal();
-       startTimeRes[i]=tofHeader->GetDefaultEventTimeRes();
-       if(startTimeRes[i] < 1.e-5) startTimeRes[i] = t0spread;
-      }
+//_________________________________________________________________________
+void AliESDpid::SetPIDForTracking(AliESDtrack *esdtr) const
+{
+  // assign mass for tracking
+  //
 
-      TArrayI *ibin=tofHeader->GetNvalues();
-      TArrayF *t0Bin=tofHeader->GetEventTimeValues();
-      TArrayF *t0ResBin=tofHeader->GetEventTimeRes();
-      for(Int_t j=0;j < tofHeader->GetNbins();j++){ // fill T0-TOF in p-bins
-       Int_t icurrent = (Int_t)ibin->GetAt(j);
-       startTime[icurrent]=t0Bin->GetAt(j);
-       startTimeRes[icurrent]=t0ResBin->GetAt(j);
-       if(startTimeRes[icurrent] < 1.e-5) startTimeRes[icurrent] = t0spread;
-     }
-    }
+  // in principle AliPIDCombined could be used to also set priors
+  //AliPIDCombined pidProb;
+  //pidProb.SetDetectorMask(kDetTPC);              // use only TPC information, couls also be changed
+  //pidProb.SetSelectedSpecies(AliPID::kSPECIESC); // number of species to use
+  //pidProb.SetDefaultTPCPriors();                 // load default priors
+
+  Double_t prob[AliPID::kSPECIESC]={0.};
+  EDetPidStatus pidStatus=ComputePIDProbability(kTPC, esdtr, AliPID::kSPECIESC, prob);
+  // check if a valid signal was found, otherwise return pion mass
+  if (pidStatus!=kDetPidOk) {
+    esdtr->SetPIDForTracking(AliPID::kPion);
+    return;
+  }
 
-    // for cut of 3 sigma on t0 spread
-    Float_t t0cut = 3 * t0spread;
-    if(t0cut < 500) t0cut = 500;
+  // or with AliPIDCombined
+  // pidProb.ComputeProbabilities(esdtr, this, p);
 
-    if(option == kFILL_T0){ // T0-FILL is used
-       for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-         estimatedT0event[i]=0.0;
-         estimatedT0resolution[i]=t0spread;
-       }
-       fTOFResponse.SetT0event(estimatedT0event);
-       fTOFResponse.SetT0resolution(estimatedT0resolution);
-    }
+  // find max probability
+  Float_t max=0.;
+  Int_t pid=-1;
+  for (Int_t i=0; i<AliPID::kSPECIESC; ++i) if (prob[i]>max) {pid=i; max=prob[i];}
 
-    if(option == kTOF_T0){ // T0-TOF is used when available (T0-FILL otherwise) from ESD
-       if(flagT0TOF){
-           fTOFResponse.SetT0event(startTime);
-           fTOFResponse.SetT0resolution(startTimeRes);
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             if(startTimeRes[i]<t0spread) startTimeMask[i]=1;
-             fTOFResponse.SetT0binMask(i,startTimeMask[i]);
-           }
-       }
-       else{
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             estimatedT0event[i]=0.0;
-             estimatedT0resolution[i]=t0spread;
-             fTOFResponse.SetT0binMask(i,startTimeMask[i]);
-           }
-           fTOFResponse.SetT0event(estimatedT0event);
-           fTOFResponse.SetT0resolution(estimatedT0resolution);
-       }
-    }
-    else if(option == kBest_T0){ // T0-T0 or T0-TOF are used when available (T0-FILL otherwise) from ESD
-       Float_t t0AC=-10000;
-       Float_t t0A=-10000;
-       Float_t t0C=-10000;
-       if(flagT0T0){
-           t0AC= event->GetT0TOF()[0];
-           t0A= event->GetT0TOF()[1];
-           t0C= event->GetT0TOF()[2];
-       }
+  //int pid = AliPID::kPion; // this should be substituted by real most probable TPC pid (e,mu -> pion) or poin if no PID possible
 
-       Float_t t0t0Best = 0;
-       Float_t t0t0BestRes = 9999;
-       Int_t t0used=0;
-       if(TMath::Abs(t0A) < t0cut && TMath::Abs(t0C) < t0cut && TMath::Abs(t0C-t0A) < 500){
-           t0t0Best = t0AC;
-           t0t0BestRes = resT0AC;
-           t0used=6;
-       }
-       else if(TMath::Abs(t0C) < t0cut){
-           t0t0Best = t0C;
-           t0t0BestRes = resT0C;
-           t0used=4;
-       }
-       else if(TMath::Abs(t0A) < t0cut){
-           t0t0Best = t0A;
-           t0t0BestRes = resT0A;
-           t0used=2;
-       }
+  //
+  if (pid>AliPID::kSPECIESC-1) pid = AliPID::kPion;
+  //
+  esdtr->SetPIDForTracking( pid );
+  //
+}
 
-       if(flagT0TOF){ // if T0-TOF info is available
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-               if(t0t0BestRes < 999){
-                 if(startTimeRes[i] < t0spread){
-                   Double_t wtot = 1./startTimeRes[i]/startTimeRes[i] + 1./t0t0BestRes/t0t0BestRes;
-                   Double_t t0best = startTime[i]/startTimeRes[i]/startTimeRes[i] + t0t0Best/t0t0BestRes/t0t0BestRes;
-                   estimatedT0event[i]=t0best / wtot;
-                   estimatedT0resolution[i]=1./TMath::Sqrt(wtot);
-                   startTimeMask[i] = t0used+1;
-                 }
-                 else {
-                   estimatedT0event[i]=t0t0Best;
-                   estimatedT0resolution[i]=t0t0BestRes;
-                   startTimeMask[i] = t0used;
-                 }
-               }
-               else{
-                 estimatedT0event[i]=startTime[i];
-                 estimatedT0resolution[i]=startTimeRes[i];
-                 if(startTimeRes[i]<t0spread) startTimeMask[i]=1;
-               }
-               fTOFResponse.SetT0binMask(i,startTimeMask[i]);
-           }
-           fTOFResponse.SetT0event(estimatedT0event);
-           fTOFResponse.SetT0resolution(estimatedT0resolution);
-       }
-       else{ // if no T0-TOF info is available
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             fTOFResponse.SetT0binMask(i,t0used);
-             if(t0t0BestRes < 999){
-               estimatedT0event[i]=t0t0Best;
-               estimatedT0resolution[i]=t0t0BestRes;
-             }
-             else{
-               estimatedT0event[i]=0.0;
-               estimatedT0resolution[i]=t0spread;
-             }
-           }
-           fTOFResponse.SetT0event(estimatedT0event);
-           fTOFResponse.SetT0resolution(estimatedT0resolution);
-       }
-    }
 
-    else if(option == kT0_T0){ // T0-T0 is used when available (T0-FILL otherwise) from ESD
-       Float_t t0AC=-10000;
-       Float_t t0A=-10000;
-       Float_t t0C=-10000;
-       if(flagT0T0){
-           t0AC= event->GetT0TOF()[0];
-           t0A= event->GetT0TOF()[1];
-           t0C= event->GetT0TOF()[2];
-       }
+//_________________________________________________________________________
+void AliESDpid::MakePIDForTracking(AliESDEvent *event) const
+{
+  // assign masses using for tracking
+  Int_t nTrk=event->GetNumberOfTracks();
+  for (Int_t iTrk=nTrk; iTrk--;) {  
+    AliESDtrack *track = event->GetTrack(iTrk);
+    SetPIDForTracking(track);
+  }
 
-       if(TMath::Abs(t0A) < t0cut && TMath::Abs(t0C) < t0cut && TMath::Abs(t0C-t0A) < 500){
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             estimatedT0event[i]=t0AC;
-             estimatedT0resolution[i]=resT0AC;
-             fTOFResponse.SetT0binMask(i,6);
-           }
-       }
-       else if(TMath::Abs(t0C) < t0cut){
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             estimatedT0event[i]=t0C;
-             estimatedT0resolution[i]=resT0C;
-             fTOFResponse.SetT0binMask(i,4);
-           }
-       }
-       else if(TMath::Abs(t0A) < t0cut){
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             estimatedT0event[i]=t0A;
-             estimatedT0resolution[i]=resT0A;
-             fTOFResponse.SetT0binMask(i,2);
-           }
-       }
-       else{
-           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
-             estimatedT0event[i]=0.0;
-             estimatedT0resolution[i]=t0spread;
-             fTOFResponse.SetT0binMask(i,0);
-           }
-       }
-       fTOFResponse.SetT0event(estimatedT0event);
-       fTOFResponse.SetT0resolution(estimatedT0resolution);
-    }
-    delete [] startTime;
-    delete [] startTimeRes;
-    delete [] startTimeMask;
-    delete [] estimatedT0event;
-    delete [] estimatedT0resolution;
 }