]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/ESD/AliESDtrack.cxx
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDtrack.cxx
index 00df3b23e2f330a7bbf9bb663982eb5d0487e5f0..81f7d25d1a9c0b8b692d07ac6cbf959bbaca445f 100644 (file)
 //
 //   1.AliESDtrack is the container of the information about the track/particle
 //     reconstructed during Barrel Tracking.
+//     Content:
+//        a.) Track parameters and covariance - AliExternalTrackParam  - snapshots along trajectory at differnt tracking steps 
+//            current, fIp, fTPCinner, fCp, fOp, fHMPIDp, + friendTrack (fITSout, fTPCout, fTRDin) 
+//        b.) Flags - per detector status bits
+//        c.) Track fit quality -chi2, number of clusters
+//        d.) Detector PID information
+//        d.) Different detector specific information (e.g number of tracklets in TRD, TOF cluster descriptor ...)
+//
+//
 //     The track information is propagated from one tracking detector to 
-//     other using the functionality of AliESDtrack - Current parameters.  
+//     other using the functionality of AliESDtrack (AliExternalTrackParam - current parameters)  
 //
-//     No global fit model is used.
-//     Barrel tracking use Kalman filtering technique, it gives optimal local 
-//     track parameters at given point under certian assumptions.
+//     Barrel tracking uses Kalman filtering technique (no global fit model is used). Kalman provides optimal local 
+//     track parameters estimate at given position under certian assumptions. 
+//     Following approximations were used:  
+//           a.) gaussian Multiple scattering
+//           b.) gaussian energy loss
+//           c.) gaussian error of the space point residuals  
 //             
-//     Kalman filter take into account additional effect which are 
-//     difficult to handle using global fit.
-//     Effects:
+//     Kalman filter take into account following effects which are 
+//     difficult to handle using global fit:
 //        a.) Multiple scattering
 //        b.) Energy loss
 //        c.) Non homogenous magnetic field
 //         b. ITS
 //         c. TRD
 //
-//      In general 3 reconstruction itteration are performed:
-//         1. Find tracks   - sequence TPC->ITS
-//         2. PropagateBack - sequence ITS->TPC->TRD -> Outer PID detectors
-//         3. Refit invward - sequence TRD->TPC->ITS
-//      The current tracks are updated after each detector (see bellow).
-//      In specical cases a track  sanpshots are stored.   
-// 
+//      Track findind/fitting procedure is done in 3 steps:
+//         1. Cluster2Track(in)   - inward sequence TPC->ITS    
+//         2. PropagateBack(out)   - outward sequence ITS->TPC->TRD -> Outer PID detectors
+//         3. RefitInward(refit)     - inward sequence TRD->TPC->ITS
+//      After each recosntruction step detector status is updated in the data member fFlags
+//      fFlags|=k<DetectorName><step> where step={1:in,2:out,3:refit,}
+//      For some of detectors a special flags were implemented. Declaration of list of all flags can be find in $ALICE_ROOT/STEER/STEERBase/AliVTrack.h
 //
+//  
+//      The current track parameter is updated after each detector (see bellow).
+//      In specical cases a track  snapshots (AliExternalTrackParam) are stored
+//
+// 
 //      For some type of analysis (+visualization) track local parameters at 
 //      different position are neccesary. A snapshots during the track 
-//      propagation are created.
-//      (See AliExternalTrackParam class for desctiption of variables and 
-//      functionality)
+//      propagation are created and stored either in track itself (for analysis purposes) or assiciated friend track (for calibration and debugging purposes)
+//      (See AliExternalTrackParam class for desctiption of variables and functionality)
 //      Snapshots:
-//      a. Current parameters - class itself (AliExternalTrackParam)
-//         Contributors: general case TRD->TPC->ITS
-//         Preferable usage:  Decission  - primary or secondary track
-//         NOTICE - By default the track parameters are stored at the DCA point
-//                  to the primary vertex. optimal for primary tracks, 
-//                  far from optimal for secondary tracks.
-//      b. Constrained parameters - Kalman information updated with 
-//         the Primary vertex information 
-//         Contributors: general case TRD->TPC->ITS
-//         Preferable usage: Use only for tracks selected as primary
-//         NOTICE - not real constrain - taken as additional measurement 
-//         with corresponding error
+//      a.)  Current parameters (AliESDtrack itself) 
+//         Description:  as obtained in the last succesfull tracking step
+//         Contributors: best case TRD->TPC->ITS after RefitInward
+//         Recomended way to get track parameters. It includes all of the information.
+//         NOTICE - By default the track parameters are stored at the DCA point to the primary vertex. 
+//                  Optimal for primary tracks, far from optimal for deeply secondary tracks.
+//                  To get optimal track parameters at the secondary vertex, OnTheFly V0s with associated track parameters should be used
+//
+//      b.) Constrained parameters (fCp)
+//         Description: 
+//            Kalman track  updated with the Primary vertex information with corresponding error (soft  constraint - see http://en.wikipedia.org/wiki/Constraint_(mathematics)#Hard_and_soft_constraints) 
 //         Function:  
-//       const AliExternalTrackParam *GetConstrainedParam() const {return fCp;}
-//      c. Inner parameters -  Track parameters at inner wall of the TPC 
-//         Contributors: general case TRD->TPC
-//         function:
+//            const AliExternalTrackParam *GetConstrainedParam() const {return fCp;}
+//         Contributors: best case TRD->TPC->ITS after RefitInward
+//         Recommended usage: Use only for tracks selected as primary (check GetConstrainedChi2())
+//         NOTICE - not real constraint only soft constraint
+//
+//      c.) Inner parameters (fIp) -  
+//         Description: Track parameters at inner wall of the TPC 
+//         Function:
 //           const AliExternalTrackParam *GetInnerParam() const { return fIp;}
+//         Contributors: general case TRD->TPC (during RefitInward)
+//         Recomended usage: To provide momenta for the TPC PID and to estimate quality of the track determination for further 
+//
+//      d.)  TPCinnerParam (fTPCinner):
+//         Description: TPC only parameters at DCA to the primary vertex (corrected for the material between TPC and vertex)
+//         Function:
+//                const AliExternalTrackParam *GetTPCInnerParam() const {return fTPCInner;}
+//         Contributors:  TPC only from in step  1 (Cluster2Tracks)
+//         Recomended usage: Requested for HBT study 
+//                           (smaller correlations as using also ITS information)
+//         NOTICE: Optimal for primary, far from optimal for secondary tracks (similar to track parameters a.) 
+//                 ! We should always use the c.) fIp in case of the TPC PID analysis, or undo material budget correction!
 //
-//      d. TPCinnerparam  - contributors - TPC only
-//         Contributors:  TPC
-//         Preferable usage: Requested for HBT study 
-//                         (smaller correlations as using also ITS information)
-//         NOTICE - the track parameters are propagated to the DCA to  
-//         to primary vertex
-//         Optimal for primary, far from optimal for secondary tracks
+//      e.) Outer parameters - (fOp)
+//         Description: track parameters during PropagateBack in the last sucessfull propagation  
+//                  Reason to generate backup  OuterParameters
+//                        a.) Local inclination angle bigger than threshold - 
+//                            Low momenta tracks 
+//                        b.) Catastrofic (large relative>~20 %)energy loss in material outside of the TPC
+//                        c.) No additional  space points contributing to track 
 //         Function:
-//    const AliExternalTrackParam *GetTPCInnerParam() const {return fTPCInner;}
-//     
-//      e. Outer parameters - 
-//           Contributors-  general case - ITS-> TPC -> TRD
-//           The last point - Outer parameters radius is determined
-//           e.a) Local inclination angle bigger than threshold - 
-//                Low momenta tracks 
-//           e.a) Catastrofic energy losss in material
-//           e.b) Not further improvement (no space points)
-//           Usage:             
+//            const AliExternalTrackParam *GetOuterParam() const { return fOp;}
+//         Contributors:  general case - ITS-> TPC -> TRD ( during PropagateBack )
+//         Recomended usage:             
 //              a.) Tracking: Starting parameter for Refit inward 
 //              b.) Visualization
 //              c.) QA
 //         NOTICE: Should be not used for the physic analysis
-//         Function:
-//            const AliExternalTrackParam *GetOuterParam() const { return fOp;}
 //
 //-----------------------------------------------------------------
 
@@ -581,8 +602,6 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   for (i=0;i<10;i++) {fTOFInfo[i]=0;}
   for (i=0;i<12;i++) {fITSModule[i]=-1;}
 
-  // Set the ID
-  SetID(track->GetID());
 
   // Set ITS cluster map
   fITSClusterMap=track->GetITSClusterMap();
@@ -642,7 +661,7 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   //
   SetTOFsignal(track->GetTOFsignal());
   Double_t expt[AliPID::kSPECIESC];
-  track->GetIntegratedTimes(expt);
+  track->GetIntegratedTimes(expt,AliPID::kSPECIESC);
   SetIntegratedTimes(expt);
   //
   SetTrackPhiEtaPtOnEMCal(track->GetTrackPhiOnEMCal(),track->GetTrackEtaOnEMCal(),track->GetTrackPtOnEMCal());
@@ -650,6 +669,10 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   SetLabel(track->GetLabel());
   // Set the status
   SetStatus(track->GetStatus());
+  //
+  // Set the ID
+  SetID(track->GetID());
+  //
 }
 
 //_______________________________________________________________________
@@ -1423,14 +1446,14 @@ Int_t AliESDtrack::GetTOFBunchCrossing(Double_t b, Bool_t pidTPConly) const
   const double kSpacing = 25e3; // min interbanch spacing
   const double kShift = 0;
   Int_t bcid = kTOFBCNA; // defualt one
-  if (!IsOn(kTOFout) || !IsOn(kESDpid)) return bcid; // no info
+  if (!IsOn(kTOFout)/* || !IsOn(kESDpid)*/) return bcid; // no info
   //
-  double tdif = fTOFsignal;
-  Double_t times[AliPID::kSPECIESC];
-  GetIntegratedTimes(times);
+  double tdif = GetTOFsignal();
   if (IsOn(kTIME)) { // integrated time info is there
     int pid = GetPID(pidTPConly);
-
+    Double_t times[AliPID::kSPECIESC];
+    // old esd has only AliPID::kSPECIES times
+    GetIntegratedTimes(times,pid>=AliPID::kSPECIES ? AliPID::kSPECIESC : AliPID::kSPECIES); 
     tdif -= times[pid];
   }
   else { // assume integrated time info from TOF radius and momentum
@@ -1500,7 +1523,9 @@ Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
 
   if (t->IsStartedTimeIntegral()) {
     SetStatus(kTIME);
-    Double_t times[AliPID::kSPECIESC];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
+    Double_t times[AliPID::kSPECIESC];
+    t->GetIntegratedTimes(times); 
+    SetIntegratedTimes(times);
     SetIntegratedLength(t->GetIntegratedLength());
   }
 
@@ -1837,19 +1862,19 @@ Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
 }
 
 //_______________________________________________________________________
-void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
-  Int_t index = -1;
-
+void AliESDtrack::GetIntegratedTimes(Double_t *times, Int_t nspec) const 
+{
+  // get integrated time for requested N species
+  if (nspec<1) return;
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
-
-    for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
-      if(tofcl->GetTrackIndex(i) == GetID()) index = i;
-    }
-    if(fNtofClusters>0 && index > -1){
-      for (Int_t i=0; i<AliPID::kSPECIESC; i++) times[i]=tofcl->GetIntegratedTime(i,index);
-      return;
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    //
+    for(int i=tofcl->GetNMatchableTracks();i--;){
+      if(tofcl->GetTrackIndex(i) == GetID()) {
+       for (int j=nspec; j--;) times[j]=tofcl->GetIntegratedTime(j,i);
+       return;
+      }
     }
   }
   else if(fNtofClusters>0) 
@@ -1857,16 +1882,17 @@ void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
 
   // Returns the array with integrated times for each particle hypothesis
   if(fTrackTime)
-    for (Int_t i=0; i<AliPID::kSPECIESC; i++) times[i]=fTrackTime[i];
+    for (int i=nspec; i--;) times[i]=fTrackTime[i];
   else
-    for (Int_t i=0; i<AliPID::kSPECIESC; i++) times[i]=0.0;
+    for (int i=AliPID::kSPECIESC; i--;) times[i]=0.0;
+  //
 }
 //_______________________________________________________________________
 Double_t AliESDtrack::GetIntegratedLength() const{
   Int_t index = -1;
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
       if(tofcl->GetTrackIndex(i) == GetID()) index = i;
@@ -1881,15 +1907,16 @@ Double_t AliESDtrack::GetIntegratedLength() const{
 }
 
 //_______________________________________________________________________
-void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
+void AliESDtrack::SetIntegratedTimes(const Double_t *times) 
+{
   // Sets the array with integrated times for each particle hypotesis
-  if(!fTrackTime)
-    fTrackTime = new Double32_t[AliPID::kSPECIESC];
-  for (Int_t i=0; i<AliPID::kSPECIESC; i++) fTrackTime[i]=times[i];
+  if(!fTrackTime) fTrackTime = new Double32_t[AliPID::kSPECIESC];
+  for (int i=AliPID::kSPECIESC; i--;) fTrackTime[i]=times[i];
 }
 
 //_______________________________________________________________________
-void AliESDtrack::SetITSpid(const Double_t *p) {
+void AliESDtrack::SetITSpid(const Double_t *p) 
+{
   // Sets values for the probability of each particle type (in ITS)
   if (!fITSr) fITSr = new Double32_t[AliPID::kSPECIESC];
   SetPIDValues(fITSr,p,AliPID::kSPECIES);
@@ -2354,9 +2381,19 @@ void AliESDtrack::SetTOFpid(const Double_t *p) {
 
 //_______________________________________________________________________
 void AliESDtrack::SetTOFLabel(const Int_t *p) {  
-  // Sets  (in TOF)
-  if(!fTOFLabel) fTOFLabel = new Int_t[3]; 
-  for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
+
+  if(fNtofClusters>0){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    AliESDTOFHit* hit = tofcl->GetTOFHit(0);
+
+    if(hit) hit->SetTOFLabel(p);
+  }
+  else{
+    // Sets  (in TOF)
+    if(!fTOFLabel) fTOFLabel = new Int_t[3]; 
+    for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
+  }
 }
 
 //_______________________________________________________________________
@@ -2369,14 +2406,14 @@ void AliESDtrack::GetTOFpid(Double_t *p) const {
 void AliESDtrack::GetTOFLabel(Int_t *p) const {
   // Gets (in TOF)
   if(fNtofClusters>0){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     for (Int_t i=0; i<3; i++) p[i]=tofcl->GetLabel(i);
   }
   else{
-    if(fTOFLabel)
-      for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
+    if(fTOFLabel) for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
+    else for (int i=3;i--;) p[i] = -1;
   }
 }
 
@@ -2885,7 +2922,7 @@ Double_t AliESDtrack::GetLengthInActiveZone( Int_t mode, Double_t deltaY, Double
   return 0;
 }
 
-Double_t AliESDtrack::GetLengthInActiveZone(const AliExternalTrackParam  *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi , TTreeSRedirector * pcstream) const {
+Double_t AliESDtrack::GetLengthInActiveZone(const AliExternalTrackParam  *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi , TTreeSRedirector * pcstream) {
   //
   // Numerical code to calculate the length of the track in active region of the TPC
   // ( can be speed up if somebody wants to invest time - analysical version shoult be possible) 
@@ -2962,7 +2999,8 @@ Double_t AliESDtrack::GetMassForTracking() const
   return (fPIDForTracking==AliPID::kHe3 || fPIDForTracking==AliPID::kAlpha) ? -m : m;
 }
 
-void    AliESDtrack::SetTOFclusterArray(Int_t ncluster,Int_t *TOFcluster){
+
+void    AliESDtrack::SetTOFclusterArray(Int_t /*ncluster*/,Int_t */*TOFcluster*/){
   AliInfo("Method has to be implemented!");
 //   fNtofClusters=ncluster;
 //   if(TOFcluster == fTOFcluster) return;
@@ -2980,7 +3018,69 @@ void    AliESDtrack::SetTOFclusterArray(Int_t ncluster,Int_t *TOFcluster){
 //     fTOFcluster = 0;
 }
 
-void    AliESDtrack::AddTOFcluster(Int_t icl){
+//____________________________________________
+void  AliESDtrack::SuppressTOFMatches()
+{
+  // remove reference to this track from TOF clusters
+  if (!fNtofClusters || !GetESDEvent()) return;
+  TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+  for (;fNtofClusters--;) {
+    AliESDTOFCluster* clTOF = (AliESDTOFCluster*)tofclArray->At(fTOFcluster[fNtofClusters]);
+    clTOF->SuppressMatchedTrack(GetID());
+    if (!clTOF->GetNMatchableTracks()) { // remove this cluster
+      int last = tofclArray->GetEntriesFast()-1;
+      AliESDTOFCluster* clTOFL = (AliESDTOFCluster*)tofclArray->At(last);
+      if (last != fTOFcluster[fNtofClusters]) {
+       *clTOF = *clTOFL; // move last cluster to the place of eliminated one
+       // fix the references on this cluster
+       clTOF->FixSelfReferences(last,fTOFcluster[fNtofClusters]);
+      }
+      tofclArray->RemoveAt(last);
+    }
+  }
+}
+
+//____________________________________________
+void  AliESDtrack::ReplaceTOFTrackID(int oldID, int newID)
+{
+  // replace the ID in TOF clusters references to this track
+  if (!fNtofClusters || !GetESDEvent()) return;
+  TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+  for (int it=fNtofClusters;it--;) {
+    AliESDTOFCluster* clTOF = (AliESDTOFCluster*)tofclArray->At(fTOFcluster[it]);
+    clTOF->ReplaceMatchedTrackID(oldID,newID);
+  }
+}
+
+//____________________________________________
+void  AliESDtrack::ReplaceTOFClusterID(int oldID, int newID)
+{
+  // replace the referenc on TOF cluster oldID by newID
+  if (!fNtofClusters || !GetESDEvent()) return;
+  for (int it=fNtofClusters;it--;) {
+    if (fTOFcluster[it] == oldID) {
+      fTOFcluster[it] = newID;
+      return;
+    }
+  }
+}
+
+//____________________________________________
+void  AliESDtrack::ReplaceTOFMatchID(int oldID, int newID)
+{
+  // replace in the ESDTOFCluster associated with this track the id of the corresponding
+  // ESDTOFMatch from oldID to newID
+  if (!fNtofClusters || !GetESDEvent()) return;
+  TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+  for (int it=fNtofClusters;it--;) {
+    AliESDTOFCluster* clTOF = (AliESDTOFCluster*)tofclArray->At(fTOFcluster[it]);
+    clTOF->ReplaceMatchID(oldID,newID);
+  }
+}
+
+//____________________________________________
+void AliESDtrack::AddTOFcluster(Int_t icl)
+{
   fNtofClusters++;
   
   Int_t *old = fTOFcluster;
@@ -2989,17 +3089,147 @@ void    AliESDtrack::AddTOFcluster(Int_t icl){
   for(Int_t i=0;i < fNtofClusters-1;i++) fTOFcluster[i] = old[i];
   fTOFcluster[fNtofClusters-1] = icl;
 
-  if(fNtofClusters-1){ // delete previous content    
-    delete old;
-    old = NULL;
-  }
+  if(fNtofClusters-1)  delete[] old; // delete previous content    
  
 }
 
-Double_t AliESDtrack::GetTOFsignal() const {
+//____________________________________________
+void AliESDtrack::SetTOFsignal(Double_t tof)
+{
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    AliESDTOFHit* hit = tofcl->GetTOFHit(0);
+    if(hit) hit->SetTime(tof);
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFsignal=tof;
+  }
+}
+//____________________________________________
+void AliESDtrack::SetTOFCalChannel(Int_t index){
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    AliESDTOFHit* hit = tofcl->GetTOFHit(0);
+    if(hit) hit->SetTOFchannel(index);
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFCalChannel=index;
+  }
+}
+//____________________________________________
+void AliESDtrack::SetTOFsignalToT(Double_t ToT){
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    AliESDTOFHit* hit = tofcl->GetTOFHit(0);
+    if(hit) hit->SetTOT(ToT);
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFsignalToT=ToT;
+  }
+}
+//____________________________________________
+void AliESDtrack::SetTOFsignalRaw(Double_t tof){
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    AliESDTOFHit* hit = tofcl->GetTOFHit(0);
+    if(hit) hit->SetTimeRaw(tof);
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFsignalRaw=tof;
+  }
+}
+//____________________________________________
+void AliESDtrack::SetTOFsignalDz(Double_t dz){
+  Int_t index = -1;
+  AliESDTOFCluster *tofcl;
+
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+
+    for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
+      if(tofcl->GetTrackIndex(i) == GetID()) index = i;
+    }
+
+  }
+  if(index > -1){
+    AliESDTOFMatch* match = tofcl->GetTOFMatch(index);
+    if(match){
+      match->SetDz(dz);
+    }
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFsignalDz=dz;
+  }
+
+
+}
+//____________________________________________
+void AliESDtrack::SetTOFsignalDx(Double_t dx){
+  Int_t index = -1;
+  AliESDTOFCluster *tofcl;
+
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+
+    for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
+      if(tofcl->GetTrackIndex(i) == GetID()) index = i;
+    }
+
+  }
+  if(index > -1){
+    AliESDTOFMatch* match = tofcl->GetTOFMatch(index);
+    if(match){
+      match->SetDx(dx);
+    }
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFsignalDx=dx;
+  }
+}
+//____________________________________________
+void AliESDtrack::SetTOFDeltaBC(Short_t deltaBC){
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    AliESDTOFHit* hit = tofcl->GetTOFHit(0);
+    if(hit) hit->SetDeltaBC(deltaBC);
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFdeltaBC=deltaBC;
+  }
+}
+//____________________________________________
+void AliESDtrack::SetTOFL0L1(Short_t l0l1){
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
+    AliESDTOFHit* hit = tofcl->GetTOFHit(0);
+    if(hit) hit->SetL0L1Latency(l0l1);
+  }
+  else{
+    if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
+    fTOFl0l1=l0l1;
+  }
+}
+//____________________________________________
+Double_t AliESDtrack::GetTOFsignal() const 
+{
+  if(fNtofClusters>0 && GetESDEvent()){
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     return tofcl->GetTime();
   }
@@ -3008,11 +3238,12 @@ Double_t AliESDtrack::GetTOFsignal() const {
   return fTOFsignal;
 }
 
+//____________________________________________
 Double_t AliESDtrack::GetTOFsignalToT() const 
 {
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     return tofcl->GetTOT();
   }
@@ -3021,11 +3252,12 @@ Double_t AliESDtrack::GetTOFsignalToT() const
   return fTOFsignalToT;
 }
 
+//____________________________________________
 Double_t AliESDtrack::GetTOFsignalRaw() const 
 {
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     return tofcl->GetTimeRaw();
   }
@@ -3034,15 +3266,16 @@ Double_t AliESDtrack::GetTOFsignalRaw() const
   return fTOFsignalRaw;
 }
 
+//____________________________________________
 Double_t AliESDtrack::GetTOFsignalDz() const 
 {
 
-  AliESDTOFcluster *tofcl;
+  AliESDTOFCluster *tofcl;
 
   Int_t index = -1;
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
       if(tofcl->GetTrackIndex(i) == GetID()) index = i;
@@ -3056,14 +3289,15 @@ Double_t AliESDtrack::GetTOFsignalDz() const
   return fTOFsignalDz;
 }
 
+//____________________________________________
 Double_t AliESDtrack::GetTOFsignalDx() const 
 {
-  AliESDTOFcluster *tofcl;
+  AliESDTOFCluster *tofcl;
 
   Int_t index = -1;
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
     for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
       if(tofcl->GetTrackIndex(i) == GetID()) index = i;
     }
@@ -3075,11 +3309,12 @@ Double_t AliESDtrack::GetTOFsignalDx() const
   return fTOFsignalDx;
 }
 
+//____________________________________________
 Short_t  AliESDtrack::GetTOFDeltaBC() const 
 {
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
     return tofcl->GetDeltaBC();
   }
   else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
@@ -3087,11 +3322,12 @@ Short_t  AliESDtrack::GetTOFDeltaBC() const
   return fTOFdeltaBC;
 }
 
+//____________________________________________
 Short_t  AliESDtrack::GetTOFL0L1() const 
 {
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     return tofcl->GetL0L1Latency();
   }
@@ -3100,11 +3336,12 @@ Short_t  AliESDtrack::GetTOFL0L1() const
   return fTOFl0l1;
 }
 
+//____________________________________________
 Int_t   AliESDtrack::GetTOFCalChannel() const 
 {
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     return tofcl->GetTOFchannel();
   }
@@ -3113,11 +3350,12 @@ Int_t   AliESDtrack::GetTOFCalChannel() const
   return fTOFCalChannel;
 }
 
+//____________________________________________
 Int_t   AliESDtrack::GetTOFcluster() const 
 {
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     return tofcl->GetClusterIndex();
   }
@@ -3126,15 +3364,17 @@ Int_t   AliESDtrack::GetTOFcluster() const
   return fTOFindex;
 }
 
+//____________________________________________
 Int_t   AliESDtrack::GetTOFclusterN() const
 {
   return fNtofClusters;
 }
 
+//____________________________________________
 Bool_t  AliESDtrack::IsTOFHitAlreadyMatched() const{
   if(fNtofClusters>0 && GetESDEvent()){
-    TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
-    AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[0]);
+    TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
+    AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
 
     if (tofcl->GetNMatchableTracks() > 1)
       return kTRUE;
@@ -3144,6 +3384,7 @@ Bool_t  AliESDtrack::IsTOFHitAlreadyMatched() const{
   return kFALSE;
 }
 
+//____________________________________________
 void AliESDtrack::ReMapTOFcluster(Int_t ncl,Int_t *mapping){
   for(Int_t i=0;i<fNtofClusters;i++){
     if(fTOFcluster[i]<ncl && fTOFcluster[i]>-1)
@@ -3153,12 +3394,13 @@ void AliESDtrack::ReMapTOFcluster(Int_t ncl,Int_t *mapping){
   }
 }
 
+//____________________________________________
 void AliESDtrack::SortTOFcluster(){
-  TObjArray *tofclArray = GetESDEvent()->GetTOFcluster();
+  TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
 
   for(Int_t i=0;i<fNtofClusters-1;i++){
     for(Int_t j=i+1;j<fNtofClusters;j++){
-      AliESDTOFcluster *tofcl = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[i]);
+      AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[i]);
       Int_t index1 = -1;
       for(Int_t it=0;it < tofcl->GetNMatchableTracks();it++){
          if(tofcl->GetTrackIndex(it) == GetID()) index1 = it;
@@ -3171,7 +3413,7 @@ void AliESDtrack::SortTOFcluster(){
       timedist1 *= 0.03; // in cm
       Double_t radius1 = tofcl->GetDx(index1)*tofcl->GetDx(index1) + tofcl->GetDz(index1)*tofcl->GetDz(index1) + timedist1*timedist1;
 
-      AliESDTOFcluster *tofcl2 = (AliESDTOFcluster *) tofclArray->At(fTOFcluster[j]);
+      AliESDTOFCluster *tofcl2 = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[j]);
       Int_t index2 = -1;
       for(Int_t it=0;it < tofcl2->GetNMatchableTracks();it++){
          if(tofcl2->GetTrackIndex(it) == GetID()) index2 = it;
@@ -3195,6 +3437,80 @@ void AliESDtrack::SortTOFcluster(){
   }
 }
 
+//____________________________________________
 const AliTOFHeader* AliESDtrack::GetTOFHeader() const {
   return fESDEvent->GetTOFHeader();
 }
+
+//___________________________________________
+void AliESDtrack::SetID(Short_t id) 
+{
+  // set track ID taking care about dependencies
+  if (fNtofClusters) ReplaceTOFTrackID(fID,id); 
+  fID=id;
+}
+
+
+Double_t  AliESDtrack::GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t qID, Int_t valueID){
+  //
+  // Interface to get the calibrated dEdx information 
+  // For details of arguments and return values see 
+  //     AliTPCdEdxInfo::GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t valueID)
+  //
+  if (!fTPCdEdxInfo) return 0;
+  if (!fIp) return 0;
+  return fTPCdEdxInfo->GetdEdxInfo(fIp, regionID, calibID, qID, valueID);
+}
+
+
+Double_t AliESDtrack::GetdEdxInfoTRD(Int_t method, Double_t p0, Double_t p1, Double_t p2){
+  //
+  // Methods
+  // mean values:
+  //     0.)   linear
+  //     1.)   logarithmic
+  //     2.)   1/sqrt
+  //     3.)   power()
+  // time COG:
+  //     4.)   linear
+  //     5.)   logarithmic
+  //     6.)   square
+  Int_t nSlicesPerLayer=GetNumberOfTRDslices();
+  Int_t nSlicesAll=GetNumberOfTRDslices()*kTRDnPlanes;
+
+  if (method<=3){
+    Double_t sumAmp=0;
+    Int_t    sumW=0;
+    for (Int_t ibin=0; ibin<nSlicesAll; ibin++){
+      if (fTRDslices[ibin]<=0) continue; 
+      sumW++;
+      if (method==0) sumAmp+=fTRDslices[ibin];
+      if (method==1) sumAmp+=TMath::Log(TMath::Abs(fTRDslices[ibin])+p0);
+      if (method==2) sumAmp+=1/TMath::Sqrt(TMath::Abs(fTRDslices[ibin])+p0);
+      if (method==3) sumAmp+=TMath::Power(TMath::Abs(fTRDslices[ibin])+p0,p1);
+    }
+    if (sumW==0) return 0;
+    Double_t dEdx=sumAmp/sumW;
+    if (method==1) dEdx= TMath::Exp(dEdx);
+    if (method==2) dEdx= 1/(dEdx*dEdx);
+    if (method==3) dEdx= TMath::Power(dEdx,1/p1);
+    return dEdx;
+  }
+  if (method>3){
+    Double_t sumWT=0;
+    Double_t sumW=0;
+    for (Int_t ibin=0; ibin<nSlicesAll; ibin++){
+      if (fTRDslices[ibin]<=0) continue; 
+      Double_t time=(ibin%nSlicesPerLayer);
+      Double_t weight=fTRDslices[ibin];
+      if (method==5) weight=TMath::Log((weight+p0)/p0);
+      if (method==6) weight=TMath::Power(weight+p0,p1);
+      sumWT+=time*weight;
+      sumW+=weight;
+    }
+    if (sumW<=0) return 0;
+    Double_t meanTime=sumWT/sumW;
+    return meanTime;
+  }
+  return 0;
+}