]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtracker.cxx
Corrected memory leaks
[u/mrichter/AliRoot.git] / TRD / AliTRDtracker.cxx
index 5000020a7b7a57ade44d28a6c21585ed289b4f2f..051d24aeb09edd645d23286d7f47150e692c39bf 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
                                                       
-/*
-$Log$
-Revision 1.31  2003/11/06 09:28:15  cblume
-Next round of coding conventions
-
-Revision 1.30  2003/09/18 09:06:07  cblume
-Geometry update, Removal of compiler warnings
-
-Revision 1.29  2003/07/22 15:56:14  hristov
-Implementing ESD functionality in the NewIO (Yu.Belikov)
-
-Revision 1.27.2.2  2003/07/14 09:19:33  hristov
-TOF included in the combined PID (Yu.Belikov)
-
-Revision 1.27.2.1  2003/07/11 10:53:01  hristov
-Inward refit for TPC and TRD in the ESD schema (T.Kuhr)
-
-Revision 1.27  2003/05/27 17:46:13  hristov
-TRD PID included in the ESD schema (T.Kuhr)
-
-Revision 1.26  2003/04/10 10:36:54  hristov
-Code for unified TPC/TRD tracking (S.Radomski)
-
-Revision 1.25  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.24  2003/02/19 09:02:28  hristov
-Track time measurement (S.Radomski)
-
-Revision 1.23  2003/02/10 14:06:10  cblume
-Add tracking without tilted pads as option
-
-Revision 1.22  2003/01/30 15:19:58  cblume
-New set of  parameters
-
-Revision 1.21  2003/01/27 16:34:49  cblume
-Update of tracking by Sergei and Chuncheng
-
-Revision 1.20  2002/11/07 15:52:09  cblume
-Update of tracking code for tilted pads
-
-Revision 1.19  2002/10/22 15:53:08  alibrary
-Introducing Riostream.h
-
-Revision 1.18  2002/10/14 14:57:44  hristov
-Merging the VirtualMC branch to the main development branch (HEAD)
-
-Revision 1.14.6.2  2002/07/24 10:09:31  alibrary
-Updating VirtualMC
-
-Revision 1.17  2002/06/13 12:09:58  hristov
-Minor corrections
-
-Revision 1.16  2002/06/12 09:54:36  cblume
-Update of tracking code provided by Sergei
-
-Revision 1.14  2001/11/14 10:50:46  cblume
-Changes in digits IO. Add merging of summable digits
-
-Revision 1.13  2001/05/30 12:17:47  hristov
-Loop variables declared once
-
-Revision 1.12  2001/05/28 17:07:58  hristov
-Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
-
-Revision 1.8  2000/12/20 13:00:44  cblume
-Modifications for the HP-compiler
-
-Revision 1.7  2000/12/08 16:07:02  cblume
-Update of the tracking by Sergei
-
-Revision 1.6  2000/11/30 17:38:08  cblume
-Changes to get in line with new STEER and EVGEN
-
-Revision 1.5  2000/11/14 14:40:27  cblume
-Correction for the Sun compiler (kTRUE and kFALSE)
-
-Revision 1.4  2000/11/10 14:57:52  cblume
-Changes in the geometry constants for the DEC compiler
-
-Revision 1.3  2000/10/15 23:40:01  cblume
-Remove AliTRDconst
-
-Revision 1.2  2000/10/06 16:49:46  cblume
-Made Getters const
-
-Revision 1.1.2.2  2000/10/04 16:34:58  cblume
-Replace include files by forward declarations
-
-Revision 1.1.2.1  2000/09/22 14:47:52  cblume
-Add the tracking code
-
-*/   
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -114,7 +22,6 @@ Add the tracking code
 ///////////////////////////////////////////////////////////////////////////////
 
 #include <Riostream.h>
-
 #include <TFile.h>
 #include <TBranch.h>
 #include <TTree.h>  
@@ -123,6 +30,7 @@ Add the tracking code
 #include "AliTRDgeometry.h"
 #include "AliTRDparameter.h"
 #include "AliTRDgeometryDetail.h"
+#include "AliTRDgeometryHole.h"
 #include "AliTRDcluster.h" 
 #include "AliTRDtrack.h"
 #include "AliTRDPartID.h"
@@ -161,6 +69,28 @@ const Int_t AliTRDtracker::fgkFirstPlane = 5;
 const Int_t AliTRDtracker::fgkLastPlane = 17;
 
 
+//____________________________________________________________________
+AliTRDtracker::AliTRDtracker():AliTracker(),
+                              fGeom(0),
+                              fPar(0),
+                              fNclusters(0),
+                              fClusters(0),
+                              fNseeds(0),
+                              fSeeds(0),
+                              fNtracks(0),
+                              fTracks(0),
+                              fSY2corr(0),
+                              fSZ2corr(0),
+                              fTimeBinsPerPlane(0),
+                              fMaxGap(0),
+                              fVocal(kFALSE),
+                              fAddTRDseeds(kFALSE),
+                              fNoTilt(kFALSE)
+{
+  for(Int_t i=0;i<kTrackingSectors;i++) fTrSec[i]=0;
+  for(Int_t j=0;j<5;j++)
+    for(Int_t k=0;k<18;k++) fHoles[j][k]=kFALSE;
+} 
 //____________________________________________________________________
 AliTRDtracker::AliTRDtracker(const TFile *geomfile):AliTracker()
 {
@@ -194,8 +124,11 @@ AliTRDtracker::AliTRDtracker(const TFile *geomfile):AliTracker()
   }
   else { 
     printf("AliTRDtracker::AliTRDtracker(): can't find TRD geometry!\n");
-    printf("The DETAIL TRD geometry will be used\n");
-    fGeom = new AliTRDgeometryDetail();
+    //printf("The DETAIL TRD geometry will be used\n");
+    //fGeom = new AliTRDgeometryDetail();
+    fGeom = new AliTRDgeometryHole();
+    fGeom->SetPHOShole();
+    fGeom->SetRICHhole();    
   } 
 
   if (!fPar) {  
@@ -220,6 +153,9 @@ AliTRDtracker::AliTRDtracker(const TFile *geomfile):AliTracker()
   for(Int_t geomS = 0; geomS < kTrackingSectors; geomS++) {
     Int_t trS = CookSectorIndex(geomS);
     fTrSec[trS] = new AliTRDtrackingSector(fGeom, geomS, fPar);
+    for (Int_t icham=0;icham<AliTRDgeometry::kNcham; icham++){
+      fHoles[icham][trS]=fGeom->IsHole(0,icham,geomS);
+    }
   }
 
   Float_t tiltAngle = TMath::Abs(fPar->GetTiltingAngle()); 
@@ -271,9 +207,18 @@ AliTRDtracker::~AliTRDtracker()
   // Destructor of AliTRDtracker 
   //
 
-  delete fClusters;
-  delete fTracks;
-  delete fSeeds;
+  if (fClusters) {
+    fClusters->Delete();
+    delete fClusters;
+  }
+  if (fTracks) {
+    fTracks->Delete();
+    delete fTracks;
+  }
+  if (fSeeds) {
+    fSeeds->Delete();
+    delete fSeeds;
+  }
   delete fGeom;  
   delete fPar;  
 
@@ -434,6 +379,43 @@ inline Double_t f3trd(Double_t x1,Double_t y1,
   return (z1 - z2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
 }            
 
+
+AliTRDcluster * AliTRDtracker::GetCluster(AliTRDtrack * track, Int_t plane, Int_t timebin){
+  //
+  //try to find cluster in the backup list
+  //
+  AliTRDcluster * cl =0;
+  UInt_t *indexes = track->GetBackupIndexes();
+  for (UInt_t i=0;i<kMaxTimeBinIndex;i++){
+    if (indexes[i]==0) break;  
+    AliTRDcluster * cli = (AliTRDcluster*)fClusters->UncheckedAt(indexes[i]);
+    if (!cli) break;
+    if (cli->GetLocalTimeBin()!=timebin) continue;
+    Int_t iplane = fGeom->GetPlane(cli->GetDetector());
+    if (iplane==plane) {
+      cl = cli;
+      break;
+    }
+  }
+  return cl;
+}
+
+
+Int_t  AliTRDtracker::GetLastPlane(AliTRDtrack * track){
+  //
+  //return last updated plane
+  Int_t lastplane=0;
+  UInt_t *indexes = track->GetBackupIndexes();
+  for (UInt_t i=0;i<kMaxTimeBinIndex;i++){
+    AliTRDcluster * cli = (AliTRDcluster*)fClusters->UncheckedAt(indexes[i]);
+    if (!cli) break;
+    Int_t iplane = fGeom->GetPlane(cli->GetDetector());
+    if (iplane>lastplane) {
+      lastplane = iplane;
+    }
+  }
+  return lastplane;
+}
 //___________________________________________________________________
 Int_t AliTRDtracker::Clusters2Tracks(const TFile *inp, TFile *out)
 {
@@ -627,7 +609,7 @@ Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
     nseed++;
 
     AliTRDtrack* seed2 = new AliTRDtrack(*seed);
-    seed2->ResetCovariance(); 
+    //seed2->ResetCovariance(); 
     AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
     AliTRDtrack &t=*pt; 
     FollowProlongation(t, innerTB); 
@@ -923,8 +905,18 @@ Int_t AliTRDtracker::PropagateBack(AliESD* event) {
     track->SetSeedLabel(lbl);
     fNseeds++;
 
-    /*Int_t expectedClr = */FollowBackProlongation(*track);
-
+    Int_t expectedClr = FollowBackProlongation(*track);
+    if (track->GetNumberOfClusters()<expectedClr/3){
+      AliTRDtrack *track1 = new AliTRDtrack(*seed);
+      track1->SetSeedLabel(lbl);
+      FollowBackProlongation(*track1);
+      AliTRDtrack *track2= new AliTRDtrack(*seed);
+      track->SetSeedLabel(lbl);
+      FollowBackProlongation(*track2);      
+      delete track1;
+      delete track2;
+    }
+    
     Int_t foundClr = track->GetNumberOfClusters();
     if (foundClr >= foundMin) {
       if(foundClr >= 2) {
@@ -941,23 +933,41 @@ Int_t AliTRDtracker::PropagateBack(AliESD* event) {
     }
 
     //Propagation to the TOF (I.Belikov)
-    Double_t xtof=378.;
-    Double_t c2=track->GetC()*xtof - track->GetEta();
-    if (TMath::Abs(c2)>=0.9999999) continue;
-
-    Double_t ymax=xtof*TMath::Tan(0.5*AliTRDgeometry::GetAlpha());
-    Double_t y=track->GetYat(xtof);
-    if (y > ymax) {
-       if (!track->Rotate(AliTRDgeometry::GetAlpha())) return 1;
-    } else if (y <-ymax) {
-       if (!track->Rotate(-AliTRDgeometry::GetAlpha())) return 1;
+    
+    if (track->GetStop()==kFALSE){
+      Double_t xTOF = 375.5;    
+      PropagateToOuterPlane(*track,xTOF); 
+      
+      Double_t xtof=378.;
+      Double_t c2=track->GetC()*xtof - track->GetEta();
+      if (TMath::Abs(c2)>=0.9999999) continue;
+      
+      Double_t ymax=xtof*TMath::Tan(0.5*AliTRDgeometry::GetAlpha());
+      Double_t y=track->GetYat(xtof);
+      if (y > ymax) {
+       if (!track->Rotate(AliTRDgeometry::GetAlpha())) return 1;
+      } else if (y <-ymax) {
+       if (!track->Rotate(-AliTRDgeometry::GetAlpha())) return 1;
+      }
+      
+      if (track->PropagateTo(xtof)) {
+       seed->UpdateTrackParams(track, AliESDtrack::kTRDout);    
+       if (track->GetNumberOfClusters()>foundMin) found++;
+      }
+    }else{
+      if (track->GetNumberOfClusters()>15&&track->GetNumberOfClusters()>0.5*expectedClr){
+       seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
+       seed->UpdateTrackParams(track, AliESDtrack::kTRDStop);    
+       found++;
+      }
     }
 
-    if (track->PropagateTo(xtof)) {
-       seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
-       found++;
-    }
+    delete track;
+    
     //End of propagation to the TOF
+    //if (foundClr>foundMin)
+    //  seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
+    
 
   }
   
@@ -996,20 +1006,41 @@ Int_t AliTRDtracker::RefitInward(AliESD* event)
     nseed++;
 
     AliTRDtrack* seed2 = new AliTRDtrack(*seed);
-    seed2->ResetCovariance(); 
+    seed2->ResetCovariance(5.); 
     AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
+    UInt_t * indexes2 = seed2->GetIndexes();
+    UInt_t * indexes3 = pt->GetBackupIndexes();
+    for (Int_t i=0;i<200;i++) {
+      if (indexes2[i]==0) break;
+      indexes3[i] = indexes2[i];
+    }          
+    //AliTRDtrack *pt = seed2;
     AliTRDtrack &t=*pt; 
     FollowProlongation(t, innerTB); 
+
+    if (t.GetNumberOfClusters()<seed->GetTRDclusters(indexes3)*0.5){
+      // debug  - why we dont go back?
+      AliTRDtrack *pt2 = new AliTRDtrack(*seed2,seed2->GetAlpha());
+      UInt_t * indexes2 = seed2->GetIndexes();
+      UInt_t * indexes3 = pt2->GetBackupIndexes();
+      for (Int_t i=0;i<200;i++) {
+       if (indexes2[i]==0) break;
+       indexes3[i] = indexes2[i];
+      }  
+      FollowProlongation(*pt2, innerTB);
+      delete pt2;
+    }
+
     if (t.GetNumberOfClusters() >= foundMin) {
-      UseClusters(&t);
-      CookLabel(pt, 1-fgkLabelFraction);
+      //      UseClusters(&t);
+      //CookLabel(pt, 1-fgkLabelFraction);
       //      t.CookdEdx();
     }
     found++;
 //    cout<<found<<'\r';     
 
     if(PropagateToTPC(t)) {
-      seed->UpdateTrackParams(pt, AliESDtrack::kTRDin);
+      seed->UpdateTrackParams(pt, AliESDtrack::kTRDrefit);
     }  
     delete seed2;
     delete pt;
@@ -1037,6 +1068,7 @@ Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
   Float_t  wPx, wPy, wPz, wC;
   Double_t px, py, pz;
   Float_t  wSigmaC2, wSigmaTgl2, wSigmaY2, wSigmaZ2;
+  Int_t lastplane = GetLastPlane(&t);
 
   Int_t trackIndex = t.GetLabel();  
 
@@ -1124,12 +1156,6 @@ Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
       wSigmaZ2 = (Float_t) t.GetSigmaZ2();
       wChi2 = -1;            
       
-      if (road>fgkWideRoad) {
-        if (t.GetNumberOfClusters()>4)
-          cerr<<t.GetNumberOfClusters()
-              <<"FindProlongation warning: Too broad road !\n";
-        return 0;
-      }             
 
       AliTRDcluster *cl=0;
       UInt_t index=0;
@@ -1163,21 +1189,48 @@ Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
       // Now go for the real cluster search
 
       if (timeBin) {
-
-        for (Int_t i=timeBin.Find(y-road); i<timeBin; i++) {
-          AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
-          if (c->GetY() > y+road) break;
-          if (c->IsUsed() > 0) continue;
-          if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
-
-          Double_t h01 = GetTiltFactor(c);
-          Double_t chi2=t.GetPredictedChi2(c,h01);
-          
-          if (chi2 > maxChi2) continue;
-          maxChi2=chi2;
-          cl=c;
-          index=timeBin.GetIndex(i);
-        }               
+       //
+       //find cluster in history
+       cl =0;
+       
+       AliTRDcluster * cl0 = timeBin[0];
+       if (!cl0) {
+         continue;
+       }
+       Int_t plane = fGeom->GetPlane(cl0->GetDetector());
+       if (plane>lastplane) continue;
+       Int_t timebin = cl0->GetLocalTimeBin();
+       AliTRDcluster * cl2= GetCluster(&t,plane, timebin);
+       if (cl2) {
+         cl =cl2;      
+         Double_t h01 = GetTiltFactor(cl);
+         maxChi2=t.GetPredictedChi2(cl,h01);
+       }
+       if ((!cl) && road>fgkWideRoad) {
+         //if (t.GetNumberOfClusters()>4)
+         //  cerr<<t.GetNumberOfClusters()
+         //    <<"FindProlongation warning: Too broad road !\n";
+         continue;
+       }             
+
+
+       if(!cl){
+
+         for (Int_t i=timeBin.Find(y-road); i<timeBin; i++) {
+           AliTRDcluster* c=(AliTRDcluster*)(timeBin[i]);
+           if (c->GetY() > y+road) break;
+           if (c->IsUsed() > 0) continue;
+           if((c->GetZ()-z)*(c->GetZ()-z) > 3 * sz2) continue;
+           
+           Double_t h01 = GetTiltFactor(c);
+           Double_t chi2=t.GetPredictedChi2(c,h01);
+           
+           if (chi2 > maxChi2) continue;
+           maxChi2=chi2;
+           cl=c;
+           index=timeBin.GetIndex(i);
+         }               
+       }
 
         if(!cl) {
 
@@ -1197,21 +1250,25 @@ Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
             index=timeBin.GetIndex(i);
           }
         }        
-        
-
         if (cl) {
           wYclosest = cl->GetY();
           wZclosest = cl->GetZ();
           Double_t h01 = GetTiltFactor(cl);
 
           t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters()); 
-          if(!t.Update(cl,maxChi2,index,h01)) {
-            if(!tryAgain--) return 0;
+         //printf("Track   position\t%f\t%f\t%f\n",t.GetX(),t.GetY(),t.GetZ());
+         //printf("Cluster position\t%d\t%f\t%f\n",cl->GetLocalTimeBin(),cl->GetY(),cl->GetZ());
+         Int_t det = cl->GetDetector();    
+         Int_t plane = fGeom->GetPlane(det);
+
+         if(!t.UpdateMI(cl,maxChi2,index,h01,plane)) {
+           //if(!t.Update(cl,maxChi2,index,h01)) {
+            //if(!tryAgain--) return 0;
           }  
           else tryAgain=fMaxGap;
         }
         else {
-          if (tryAgain==0) break; 
+          //if (tryAgain==0) break; 
           tryAgain--;
         }
 
@@ -1286,8 +1343,9 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
 
   Double_t chi2;
   Double_t minDY;
-
-  for (Int_t nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr<outerTB+1; nr++) { 
+  Int_t zone =-10;
+  Int_t nr;
+  for (nr=fTrSec[0]->GetLayerNumber(t.GetX()); nr<outerTB+1; nr++) { 
     
     y = t.GetY(); 
     z = t.GetZ();
@@ -1301,7 +1359,21 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
     z = t.GetZ();
 
     if(!t.PropagateTo(x,radLength,rho)) break;
+    //    if (!AdjustSector(&t)) break;
+    //
+    // MI -fix untill correct material desription will be implemented
+    //
+    Float_t angle =  t.GetAlpha();  // MI - if rotation - we go through the material - 
     if (!AdjustSector(&t)) break;
+    if (TMath::Abs(angle -  t.GetAlpha())>0.000001) break; //better to stop track
+    Int_t currentzone = fTrSec[s]->GetLayer(nr)->GetZone(z);
+    if (currentzone==-10) break;  // we are in the frame
+    if (currentzone>-10){   // layer knows where we are
+      if (zone==-10) zone = currentzone;
+      if (zone!=currentzone) break;  
+    }
+    //
+    //
     s = t.GetSector();
     if (!t.PropagateTo(x,radLength,rho)) break;
 
@@ -1465,7 +1537,11 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
 
           t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters()); 
           Double_t h01 = GetTiltFactor(cl);
-          if(!t.Update(cl,maxChi2,index,h01)) {
+         Int_t det = cl->GetDetector();    
+         Int_t plane = fGeom->GetPlane(det);
+
+         if(!t.UpdateMI(cl,maxChi2,index,h01,plane)) {
+          //if(!t.Update(cl,maxChi2,index,h01)) {
             if(!tryAgain--) return 0;
           }  
           else tryAgain=fMaxGap;
@@ -1510,6 +1586,10 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
       }
     }  
   }
+  if (nr<outerTB) 
+    t.SetStop(kTRUE);
+  else
+    t.SetStop(kFALSE);
   return expectedNumberOfClusters;
 
 
@@ -1774,6 +1854,12 @@ Int_t AliTRDtracker::LoadClusters(TTree *cTree)
   cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
               
   UInt_t index;
+  for (Int_t ichamber=0;ichamber<5;ichamber++)
+    for (Int_t isector=0;isector<18;isector++){
+      fHoles[ichamber][isector]=kTRUE;
+    }
+
+
   while (ncl--) {
 //    printf("\r %d left  ",ncl); 
     AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
@@ -1781,8 +1867,12 @@ Int_t AliTRDtracker::LoadClusters(TTree *cTree)
     Int_t localTimeBin=c->GetLocalTimeBin();
     Int_t sector=fGeom->GetSector(detector);
     Int_t plane=fGeom->GetPlane(detector);
-
+      
     Int_t trackingSector = CookSectorIndex(sector);
+    if (c->GetLabel(0)>0){
+      Int_t chamber = fGeom->GetChamber(detector);
+      fHoles[chamber][trackingSector]=kFALSE;
+    }
 
     Int_t gtb = fTrSec[trackingSector]->CookTimeBinIndex(plane,localTimeBin);
     if(gtb < 0) continue; 
@@ -1792,7 +1882,16 @@ Int_t AliTRDtracker::LoadClusters(TTree *cTree)
     fTrSec[trackingSector]->GetLayer(layer)->InsertCluster(c,index);
   }    
   printf("\r\n");
-
+  //
+  //
+  /*
+  for (Int_t isector=0;isector<18;isector++){
+    for (Int_t ichamber=0;ichamber<5;ichamber++)      
+      if (fHoles[ichamber][isector]!=fGeom->IsHole(0,ichamber,17-isector)) 
+       printf("Problem \t%d\t%d\t%d\t%d\n",isector,ichamber,fHoles[ichamber][isector],
+            fGeom->IsHole(0,ichamber,17-isector));
+  }
+  */
   return 0;
 }
 
@@ -2325,6 +2424,7 @@ AliTRDtracker::AliTRDpropagationLayer::AliTRDpropagationLayer(Double_t x,
     fIndex = new UInt_t[kMaxClusterPerTimeBin];
   }
 
+  for (Int_t i=0;i<5;i++) fIsHole[i] = kFALSE;
   fHole = kFALSE;
   fHoleZc = 0;
   fHoleZmax = 0;
@@ -2343,7 +2443,6 @@ void AliTRDtracker::AliTRDpropagationLayer::SetHole(
   //
   // Sets hole in the layer 
   //
-
   fHole = kTRUE;
   fHoleZc = Zc;
   fHoleZmax = Zmax;
@@ -2366,7 +2465,16 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
   fGeomSector = gs;
   fTzeroShift = 0.13;
   fN = 0;
-
+  //
+  // get holes description from geometry
+  Bool_t holes[AliTRDgeometry::kNcham];
+  //printf("sector\t%d\t",gs);
+  for (Int_t icham=0; icham<AliTRDgeometry::kNcham;icham++){
+    holes[icham] = fGeom->IsHole(0,icham,gs);
+    //printf("%d",holes[icham]);
+  } 
+  //printf("\n");
+  
   for(UInt_t i=0; i < kMaxTimeBinIndex; i++) fTimeBinIndex[i] = -1;
 
 
@@ -2473,7 +2581,7 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
   }
 
 
-  Double_t alpha=AliTRDgeometry::GetAlpha();
+  //  Double_t alpha=AliTRDgeometry::GetAlpha();
 
   // add layers for each of the planes
 
@@ -2487,37 +2595,38 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
 
   Int_t tb, tbIndex;
   const Int_t  kNchambers = AliTRDgeometry::Ncham();
-  Double_t  ymax = 0, holeYmax = 0;
+  Double_t  ymax = 0;
+  //, holeYmax = 0;
+  Double_t ymaxsensitive=0;
   Double_t *zc = new Double_t[kNchambers];
   Double_t *zmax = new Double_t[kNchambers];
-  Double_t  holeZmax = 1000.;   // the whole sector is missing
+  Double_t *zmaxsensitive = new Double_t[kNchambers];  
+  //  Double_t  holeZmax = 1000.;   // the whole sector is missing
 
   for(Int_t plane = 0; plane < AliTRDgeometry::Nplan(); plane++) {
-
+    //
     // Radiator 
     xin = xtrd + plane * dxPlane; xout = xin + dxRad;
     steps = 12; dx = (xout - xin)/steps; rho = 0.074; radLength = 40.6; 
     for(Int_t i=0; i<steps; i++) {
       x = xin + i*dx + dx/2;
-      ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
-      if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
-      if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
+      ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);      
       InsertLayer(ppl);
     }
 
-    ymax = fGeom->GetChamberWidth(plane)/2;
+    ymax          = fGeom->GetChamberWidth(plane)/2.;
+    ymaxsensitive = (fPar->GetColPadSize(plane)*fPar->GetColMax(plane)-4)/2.;
+    
     for(Int_t ch = 0; ch < kNchambers; ch++) {
       zmax[ch] = fGeom->GetChamberLength(plane,ch)/2;
       Float_t pad = fPar->GetRowPadSize(plane,ch,0);
       Float_t row0 = fPar->GetRow0(plane,ch,0);
       Int_t nPads = fPar->GetRowMax(plane,ch,0);
-      zc[ch] = (pad * nPads)/2 + row0 - pad/2;
+      zmaxsensitive[ch] = Float_t(nPads)*pad/2.;      
+      //      zc[ch] = (pad * nPads)/2 + row0 - pad/2;
+      zc[ch] = (pad * nPads)/2 + row0;
+      //zc[ch] = row0+zmax[ch]-AliTRDgeometry::RpadW();
+
     }
 
     dx = fPar->GetTimeBinSize(); 
@@ -2526,45 +2635,26 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
     Double_t x0 = (Double_t) fPar->GetTime0(plane);
     Double_t xbottom = x0 - dxDrift;
     Double_t xtop = x0 + dxAmp;
-
+    //
     // Amplification region
-
     steps = (Int_t) (dxAmp/dx);
 
     for(tb = 0; tb < steps; tb++) {
       x = x0 + tb * dx + dx/2;
       tbIndex = CookTimeBinIndex(plane, -tb-1);
       ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
-      ppl->SetYmax(ymax);
-      for(Int_t ch = 0; ch < kNchambers; ch++) {
-        ppl->SetZmax(ch, zc[ch], zmax[ch]);
-      }
-      if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
-      if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
+      ppl->SetYmax(ymax,ymaxsensitive);
+      ppl->SetZ(zc, zmax, zmaxsensitive);
+      ppl->SetHoles(holes);
       InsertLayer(ppl);
     }
     tbIndex = CookTimeBinIndex(plane, -steps);
     x = (x + dx/2 + xtop)/2;
     dx = 2*(xtop-x);
     ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
-    ppl->SetYmax(ymax);
-    for(Int_t ch = 0; ch < kNchambers; ch++) {
-      ppl->SetZmax(ch, zc[ch], zmax[ch]);
-    }
-    if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-      holeYmax = x*TMath::Tan(0.5*alpha);
-      ppl->SetHole(holeYmax, holeZmax);
-    }
-    if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-      holeYmax = x*TMath::Tan(0.5*alpha);
-      ppl->SetHole(holeYmax, holeZmax);
-    }
+    ppl->SetYmax(ymax,ymaxsensitive);
+    ppl->SetZ(zc, zmax,zmaxsensitive);
+    ppl->SetHoles(holes);
     InsertLayer(ppl);
 
     // Drift region
@@ -2576,49 +2666,26 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
       tbIndex = CookTimeBinIndex(plane, tb);
 
       ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
-      ppl->SetYmax(ymax);
-      for(Int_t ch = 0; ch < kNchambers; ch++) {
-        ppl->SetZmax(ch, zc[ch], zmax[ch]);
-      }
-      if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
-      if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
+      ppl->SetYmax(ymax,ymaxsensitive);
+      ppl->SetZ(zc, zmax, zmaxsensitive);
+      ppl->SetHoles(holes);
       InsertLayer(ppl);
     }
     tbIndex = CookTimeBinIndex(plane, steps);
     x = (x - dx/2 + xbottom)/2;
     dx = 2*(x-xbottom);
     ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,tbIndex);
-    ppl->SetYmax(ymax);
-    for(Int_t ch = 0; ch < kNchambers; ch++) {
-      ppl->SetZmax(ch, zc[ch], zmax[ch]);
-    }
-    if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-      holeYmax = x*TMath::Tan(0.5*alpha);
-      ppl->SetHole(holeYmax, holeZmax);
-    }
-    if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-      holeYmax = x*TMath::Tan(0.5*alpha);
-      ppl->SetHole(holeYmax, holeZmax);
-    }
+    ppl->SetYmax(ymax,ymaxsensitive);
+    ppl->SetZ(zc, zmax, zmaxsensitive);
+    ppl->SetHoles(holes);    
     InsertLayer(ppl);
 
     // Pad Plane
     xin = xtop; dx = 0.025; xout = xin + dx; rho = 1.7; radLength = 33.0;
     ppl = new AliTRDpropagationLayer(xin+dx/2,dx,rho,radLength,-1);
-    if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-      holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
-      ppl->SetHole(holeYmax, holeZmax);
-    }
-    if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-      holeYmax = (xin+dx/2)*TMath::Tan(0.5*alpha);
-      ppl->SetHole(holeYmax, holeZmax);
-    }
+    ppl->SetYmax(ymax,ymaxsensitive);
+    ppl->SetZ(zc, zmax,zmax);
+    ppl->SetHoles(holes);        
     InsertLayer(ppl);
 
     // Rohacell
@@ -2627,14 +2694,9 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
     for(Int_t i=0; i<steps; i++) {
       x = xin + i*dx + dx/2;
       ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
-      if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
-      if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
+      ppl->SetYmax(ymax,ymaxsensitive);
+      ppl->SetZ(zc, zmax,zmax);
+      ppl->SetHoles(holes);
       InsertLayer(ppl);
     }
 
@@ -2644,14 +2706,6 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
     for(Int_t i=0; i<steps; i++) {
       x = xin + i*dx + dx/2;
       ppl = new AliTRDpropagationLayer(x,dx,rho,radLength,-1);
-      if((fGeom->GetPHOShole()) && (fGeomSector >= 2) && (fGeomSector <= 6)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
-      if((fGeom->GetRICHhole()) && (fGeomSector >= 12) && (fGeomSector <= 14)) {
-        holeYmax = x*TMath::Tan(0.5*alpha);
-        ppl->SetHole(holeYmax, holeZmax);
-      }
       InsertLayer(ppl);
     }
   }    
@@ -2851,6 +2905,31 @@ Int_t AliTRDtracker::AliTRDtrackingSector::Find(Double_t x) const
 }             
 
 //______________________________________________________
+void AliTRDtracker::AliTRDpropagationLayer::SetZ(Double_t* center, Double_t *w, Double_t *wsensitive )
+{
+  //
+  // set centers and the width of sectors
+  for (Int_t icham=0;icham< AliTRDgeometry::kNcham;icham++){
+    fZc[icham] = center[icham];  
+    fZmax[icham] = w[icham];
+    fZmaxSensitive[icham] = wsensitive[icham];
+    //   printf("chamber\t%d\tzc\t%f\tzmax\t%f\tzsens\t%f\n",icham,fZc[icham],fZmax[icham],fZmaxSensitive[icham]);
+  }  
+}
+//______________________________________________________
+
+void AliTRDtracker::AliTRDpropagationLayer::SetHoles(Bool_t *holes)
+{
+  //
+  // set centers and the width of sectors
+  fHole = kFALSE;
+  for (Int_t icham=0;icham< AliTRDgeometry::kNcham;icham++){
+    fIsHole[icham] = holes[icham]; 
+    if (holes[icham]) fHole = kTRUE;
+  }  
+}
+
+
 
 void AliTRDtracker::AliTRDpropagationLayer::GetPropagationParameters(
         Double_t y, Double_t z, Double_t &dx, Double_t &rho, Double_t &radLength, 
@@ -2865,31 +2944,58 @@ void AliTRDtracker::AliTRDpropagationLayer::GetPropagationParameters(
   rho = fRho;
   radLength  = fX0;
   lookForCluster = kFALSE;
-
-  // check dead regions
+  //
+  // check dead regions in sensitive volume 
   if(fTimeBinIndex >= 0) {
+    //
+    Int_t zone=-1;
     for(Int_t ch = 0; ch < (Int_t) kZones; ch++) {
-      if(TMath::Abs(z - fZc[ch]) < fZmax[ch]) 
-        lookForCluster = kTRUE;
-      //  else { rho = 1.7; radLength = 33.0; } // G10 
-    }
-    if(TMath::Abs(y) > fYmax) lookForCluster = kFALSE;
-    if(!lookForCluster) { 
-      //      rho = 1.7; radLength = 33.0; // G10 
+      if  (TMath::Abs(z - fZc[ch]) < fZmaxSensitive[ch]){ 
+       zone = ch;
+       lookForCluster = !(fIsHole[zone]);
+       if(TMath::Abs(y) > fYmaxSensitive){  
+         lookForCluster = kFALSE;
+       }
+       if (fIsHole[zone]) {
+         //if hole
+         rho = 1.29e-3;
+         radLength = 36.66;
+       }
+      }    
     }
+    return;
   }
-
+  //
+  //
   // check hole
-  if(fHole && (TMath::Abs(y - fHoleYc) < fHoleYmax) && 
-              (TMath::Abs(z - fHoleZc) < fHoleZmax)) {
-    lookForCluster = kFALSE;
-    rho = fHoleRho;
-    radLength  = fHoleX0;
-  }         
-
+  if (fHole==kFALSE) return;
+  //
+  for(Int_t ch = 0; ch < (Int_t) kZones; ch++) {
+    if  (TMath::Abs(z - fZc[ch]) < fZmax[ch]){ 
+      if (fIsHole[ch]) {
+       //if hole
+       rho = 1.29e-3;
+       radLength = 36.66;
+      }
+    }
+  }
   return;
 }
 
+Int_t  AliTRDtracker::AliTRDpropagationLayer::GetZone( Double_t z) const
+{
+  //
+  //
+  if (fTimeBinIndex < 0) return -20;  //unknown 
+  Int_t zone=-10;   // dead zone
+  for(Int_t ch = 0; ch < (Int_t) kZones; ch++) {
+    if(TMath::Abs(z - fZc[ch]) < fZmax[ch]) 
+      zone = ch;
+  }
+  return zone;
+}
+
+
 //______________________________________________________
 
 void AliTRDtracker::AliTRDpropagationLayer::InsertCluster(AliTRDcluster* c,