]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtracker.cxx
Storing angle alpha for the tracks stopped at TRD. The stored value is used for inwar...
[u/mrichter/AliRoot.git] / TRD / AliTRDtracker.cxx
index 9656c3c9d6158ef9579c80546a24d606467711b8..d1926b6936aaab0167f23be05016aab7aec37e46 100644 (file)
 
 #include "AliTRDgeometry.h"
 #include "AliTRDparameter.h"
-#include "AliTRDgeometryDetail.h"
+#include "AliTRDgeometryHole.h"
 #include "AliTRDcluster.h" 
 #include "AliTRDtrack.h"
-#include "AliTRDPartID.h"
-#include "../TPC/AliTPCtrack.h"
+#include "AliBarrelTrack.h"
+#include "AliESD.h"
 
 #include "AliTRDtracker.h"
 
@@ -68,6 +68,30 @@ 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)
+{
+  // Default constructor
+
+  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()
 {
@@ -101,8 +125,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) {  
@@ -127,6 +154,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()); 
@@ -178,9 +208,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;  
 
@@ -362,173 +401,22 @@ AliTRDcluster * AliTRDtracker::GetCluster(AliTRDtrack * track, Int_t plane, Int_
   return cl;
 }
 
-//___________________________________________________________________
-Int_t AliTRDtracker::Clusters2Tracks(const TFile *inp, TFile *out)
-{
-  //
-  // Finds tracks within the TRD. File <inp> is expected to contain seeds 
-  // at the outer part of the TRD. If <inp> is NULL, the seeds
-  // are found within the TRD if fAddTRDseeds is TRUE. 
-  // The tracks are propagated to the innermost time bin 
-  // of the TRD and stored in file <out>. 
-  //
-
-  LoadEvent();
-  TDirectory *savedir=gDirectory;
-
-  char   tname[100];
-
-  if (!out->IsOpen()) {
-    cerr<<"AliTRDtracker::Clusters2Tracks(): output file is not open !\n";
-    return 1;
-  }    
-
-  sprintf(tname,"seedTRDtoTPC_%d",GetEventNumber()); 
-  TTree tpcTree(tname,"Tree with seeds from TRD at outer TPC pad row");
-  AliTPCtrack *iotrack=0;
-  tpcTree.Branch("tracks","AliTPCtrack",&iotrack,32000,0); 
-
-  sprintf(tname,"TreeT%d_TRD",GetEventNumber());
-  TTree trdTree(tname,"TRD tracks at inner TRD time bin");
-  AliTRDtrack *iotrackTRD=0;
-  trdTree.Branch("tracks","AliTRDtrack",&iotrackTRD,32000,0);  
-
-  Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
-  Float_t foundMin = fgkMinClustersInTrack * timeBins; 
-
-  if (inp) {
-     TFile *in=(TFile*)inp;
-     if (!in->IsOpen()) {
-        cerr<<
-          "AliTRDtracker::Clusters2Tracks(): file with seeds is not open !\n";
-        cerr<<" ... going for seeds finding inside the TRD\n";
-     }
-     else {
-       in->cd();
-       sprintf(tname,"TRDb_%d",GetEventNumber());  
-       TTree *seedTree=(TTree*)in->Get(tname);  
-       if (!seedTree) {
-         cerr<<"AliTRDtracker::Clusters2Tracks(): ";
-         cerr<<"can't get a tree with track seeds !\n";
-         return 3;
-       }  
-       AliTRDtrack *seed=new AliTRDtrack;
-       seedTree->SetBranchAddress("tracks",&seed);
-
-       Int_t n=(Int_t)seedTree->GetEntries();
-       for (Int_t i=0; i<n; i++) {
-         seedTree->GetEvent(i);
-         seed->ResetCovariance(); 
-         AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
-         fSeeds->AddLast(tr);
-         fNseeds++;
-       }          
-       delete seed;
-       delete seedTree;
-     }
-  }
-
-  out->cd();
-
-
-  // find tracks from loaded seeds
-
-  Int_t nseed=fSeeds->GetEntriesFast();
-  Int_t i, found = 0;
-  Int_t innerTB = fTrSec[0]->GetInnerTimeBin();
-
-  for (i=0; i<nseed; i++) {   
-    AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt; 
-    FollowProlongation(t, innerTB); 
-    if (t.GetNumberOfClusters() >= foundMin) {
-      UseClusters(&t);
-      CookLabel(pt, 1-fgkLabelFraction);
-      //      t.CookdEdx();
-    }
-    iotrackTRD = pt;
-    trdTree.Fill();
-    found++;
-//    cout<<found<<'\r';     
-
-    if(PropagateToTPC(t)) {
-      AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
-      iotrack = tpc;
-      tpcTree.Fill();
-      delete tpc;
-    }  
-    delete fSeeds->RemoveAt(i);
-    fNseeds--;
-  }     
-
-  cout<<"Number of loaded seeds: "<<nseed<<endl;  
-  cout<<"Number of found tracks from loaded seeds: "<<found<<endl;
-
-  // after tracks from loaded seeds are found and the corresponding 
-  // clusters are used, look for additional seeds from TRD
-
-  if(fAddTRDseeds) { 
-    // Find tracks for the seeds in the TRD
-    Int_t timeBins = fTrSec[0]->GetNumberOfTimeBins();
-  
-    Int_t nSteps = (Int_t) (fgkSeedDepth / fgkSeedStep);
-    Int_t gap = (Int_t) (timeBins * fgkSeedGap);
-    Int_t step = (Int_t) (timeBins * fgkSeedStep);
-  
-    // make a first turn with tight cut on initial curvature
-    for(Int_t turn = 1; turn <= 2; turn++) {
-      if(turn == 2) {
-        nSteps = (Int_t) (fgkSeedDepth / (3*fgkSeedStep));
-        step = (Int_t) (timeBins * (3*fgkSeedStep));
-      }
-      for(Int_t i=0; i<nSteps; i++) {
-        Int_t outer=timeBins-1-i*step; 
-        Int_t inner=outer-gap;
 
-        nseed=fSeeds->GetEntriesFast();
-      
-        MakeSeeds(inner, outer, turn);
-      
-        nseed=fSeeds->GetEntriesFast();
-        printf("\n turn %d, step %d: number of seeds for TRD inward %d\n", 
-               turn, i, nseed); 
-              
-        for (Int_t i=0; i<nseed; i++) {   
-          AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt; 
-          FollowProlongation(t,innerTB); 
-          if (t.GetNumberOfClusters() >= foundMin) {
-            UseClusters(&t);
-            CookLabel(pt, 1-fgkLabelFraction);
-            t.CookdEdx();
-            found++;
-//            cout<<found<<'\r';     
-            iotrackTRD = pt;
-            trdTree.Fill();
-            if(PropagateToTPC(t)) {
-              AliTPCtrack *tpc = new AliTPCtrack(*pt,pt->GetAlpha());
-              iotrack = tpc;
-              tpcTree.Fill();
-              delete tpc;
-            }        
-          }
-          delete fSeeds->RemoveAt(i);
-          fNseeds--;
-        }
-      }
+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;
     }
   }
-  tpcTree.Write(); 
-  trdTree.Write(); 
-  
-  cout<<"Total number of found tracks: "<<found<<endl;
-    
-  UnloadEvent();
-    
-  savedir->cd();  
-  
-  return 0;    
-}     
-          
+  return lastplane;
+}
 //___________________________________________________________________
 Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
 {
@@ -603,8 +491,8 @@ Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
         MakeSeeds(inner, outer, turn);
       
         nseed=fSeeds->GetEntriesFast();
-        printf("\n turn %d, step %d: number of seeds for TRD inward %d\n", 
-               turn, i, nseed); 
+       //        printf("\n turn %d, step %d: number of seeds for TRD inward %d\n", 
+       //               turn, i, nseed); 
               
         for (Int_t i=0; i<nseed; i++) {   
           AliTRDtrack *pt=(AliTRDtrack*)fSeeds->UncheckedAt(i), &t=*pt; 
@@ -619,6 +507,7 @@ Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
              AliESDtrack track;
              track.UpdateTrackParams(pt,AliESDtrack::kTRDin);
              event->AddTrack(&track);
+             //              track.SetTRDtrack(new AliTRDtrack(*pt));
             }        
           }
           delete fSeeds->RemoveAt(i);
@@ -635,196 +524,6 @@ Int_t AliTRDtracker::Clusters2Tracks(AliESD* event)
      
   
 
-//_____________________________________________________________________________
-Int_t AliTRDtracker::PropagateBack(const TFile *inp, TFile *out) {
-  //
-  // Reads seeds from file <inp>. The seeds are AliTPCtrack's found and
-  // backpropagated by the TPC tracker. Each seed is first propagated 
-  // to the TRD, and then its prolongation is searched in the TRD.
-  // If sufficiently long continuation of the track is found in the TRD
-  // the track is updated, otherwise it's stored as originaly defined 
-  // by the TPC tracker.   
-  //  
-
-  LoadEvent();
-
-  TDirectory *savedir=gDirectory;
-
-  TFile *in=(TFile*)inp;
-
-  if (!in->IsOpen()) {
-     cerr<<"AliTRDtracker::PropagateBack(): ";
-     cerr<<"file with back propagated TPC tracks is not open !\n";
-     return 1;
-  }                   
-
-  if (!out->IsOpen()) {
-     cerr<<"AliTRDtracker::PropagateBack(): ";
-     cerr<<"file for back propagated TRD tracks is not open !\n";
-     return 2;
-  }      
-
-  in->cd();
-  char   tname[100];
-  sprintf(tname,"seedsTPCtoTRD_%d",GetEventNumber());       
-  TTree *seedTree=(TTree*)in->Get(tname);
-  if (!seedTree) {
-     cerr<<"AliTRDtracker::PropagateBack(): ";
-     cerr<<"can't get a tree with seeds from TPC !\n";
-     cerr<<"check if your version of TPC tracker creates tree "<<tname<<"\n";
-     return 3;
-  }
-
-  AliTPCtrack *seed=new AliTPCtrack;
-  seedTree->SetBranchAddress("tracks",&seed);
-
-  Int_t n=(Int_t)seedTree->GetEntries();
-  for (Int_t i=0; i<n; i++) {
-     seedTree->GetEvent(i);
-     Int_t lbl = seed->GetLabel();
-     AliTRDtrack *tr = new AliTRDtrack(*seed,seed->GetAlpha());
-     tr->SetSeedLabel(lbl);
-     fSeeds->AddLast(tr);
-     fNseeds++;
-  }
-
-  delete seed;
-  delete seedTree;
-
-  out->cd();
-
-  AliTPCtrack *otrack=0;
-
-  sprintf(tname,"seedsTRDtoTOF1_%d",GetEventNumber());  
-  TTree tofTree1(tname,"Tracks back propagated through TPC and TRD");
-  tofTree1.Branch("tracks","AliTPCtrack",&otrack,32000,0);  
-
-  sprintf(tname,"seedsTRDtoTOF2_%d",GetEventNumber());  
-  TTree tofTree2(tname,"Tracks back propagated through TPC and TRD");
-  tofTree2.Branch("tracks","AliTPCtrack",&otrack,32000,0);  
-
-  sprintf(tname,"seedsTRDtoPHOS_%d",GetEventNumber());  
-  TTree phosTree(tname,"Tracks back propagated through TPC and TRD");
-  phosTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);  
-
-  sprintf(tname,"seedsTRDtoRICH_%d",GetEventNumber());  
-  TTree richTree(tname,"Tracks back propagated through TPC and TRD");
-  richTree.Branch("tracks","AliTPCtrack",&otrack,32000,0);  
-
-  sprintf(tname,"TRDb_%d",GetEventNumber());  
-  TTree trdTree(tname,"Back propagated TRD tracks at outer TRD time bin");
-  AliTRDtrack *otrackTRD=0;
-  trdTree.Branch("tracks","AliTRDtrack",&otrackTRD,32000,0);   
-     
-  if (IsStoringBarrel()) SetBarrelTree("back");
-  out->cd();
-
-  Int_t found=0;  
-  Int_t nseed=fSeeds->GetEntriesFast();
-
-  //  Float_t foundMin = fgkMinClustersInTrack * fTimeBinsPerPlane * fGeom->Nplan(); 
-  Float_t foundMin = 40;
-
-  Int_t outermostTB  = fTrSec[0]->GetOuterTimeBin();
-
-  for (Int_t i=0; i<nseed; i++) {  
-
-    AliTRDtrack *ps=(AliTRDtrack*)fSeeds->UncheckedAt(i), &s=*ps;
-    Int_t expectedClr = FollowBackProlongation(s);
-
-    if (IsStoringBarrel()) {
-      StoreBarrelTrack(ps, fgkLastPlane, kTrackBack);
-      fBarrelTree->Fill();        
-    }
-
-    Int_t foundClr = s.GetNumberOfClusters();
-    Int_t lastTB = fTrSec[0]->GetLayerNumber(s.GetX());
-
-    //    printf("seed %d: found %d out of %d expected clusters, Min is %f\n",
-    //     i, foundClr, expectedClr, foundMin);
-
-    if (foundClr >= foundMin) {
-      if(foundClr >= 2) {
-       s.CookdEdx(); 
-       CookLabel(ps, 1-fgkLabelFraction);
-       UseClusters(ps);
-      }
-      
-      // Propagate to outer reference plane [SR, GSI, 18.02.2003]
-      ps->PropagateTo(364.8);
-      otrackTRD=ps;
-      trdTree.Fill();
-      found++;
-//      cout<<found<<'\r';
-    }
-
-    if(((expectedClr < 10) && (lastTB == outermostTB)) ||
-       ((expectedClr >= 10) && 
-        (((Float_t) foundClr) / ((Float_t) expectedClr) >= 
-         fgkMinFractionOfFoundClusters) && (lastTB == outermostTB))) {
-
-      Double_t xTOF = 375.5;
-    
-      if(PropagateToOuterPlane(s,xTOF)) {
-        AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
-        otrack = pt;
-        tofTree1.Fill();
-        delete pt;
-
-        xTOF = 381.5;
-    
-        if(PropagateToOuterPlane(s,xTOF)) {
-          AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
-          otrack = pt;
-          tofTree2.Fill();
-          delete pt;
-
-          Double_t xPHOS = 460.;
-          
-          if(PropagateToOuterPlane(s,xPHOS)) {
-            AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
-            otrack = pt;
-            phosTree.Fill();
-            delete pt;
-            
-            Double_t xRICH = 490+1.267;
-            
-            if(PropagateToOuterPlane(s,xRICH)) {
-              AliTPCtrack *pt = new AliTPCtrack(*ps,ps->GetAlpha());
-              otrack = pt;
-              richTree.Fill();
-              delete pt;
-            }   
-          }
-        }
-      }      
-    }
-  }
-  
-  
-  out->cd();
-  tofTree1.Write(); 
-  tofTree2.Write(); 
-  phosTree.Write(); 
-  richTree.Write(); 
-  trdTree.Write(); 
-
-  if (IsStoringBarrel()) { // [SR, 03.04.2003]
-    fBarrelFile->cd();
-    fBarrelTree->Write();
-    fBarrelFile->Flush();
-  }
-
-  savedir->cd();  
-  cerr<<"Number of seeds: "<<nseed<<endl;  
-  cerr<<"Number of back propagated TRD tracks: "<<found<<endl;
-
-  UnloadEvent();
-
-  return 0;
-
-}
-
 //_____________________________________________________________________________
 Int_t AliTRDtracker::PropagateBack(AliESD* event) {
   //
@@ -837,7 +536,7 @@ Int_t AliTRDtracker::PropagateBack(AliESD* event) {
   //  
 
   Int_t found=0;  
-  Float_t foundMin = 40;
+  Float_t foundMin = 20;
 
   Int_t n = event->GetNumberOfTracks();
   for (Int_t i=0; i<n; i++) {
@@ -849,43 +548,105 @@ Int_t AliTRDtracker::PropagateBack(AliESD* event) {
     Int_t lbl = seed->GetLabel();
     AliTRDtrack *track = new AliTRDtrack(*seed);
     track->SetSeedLabel(lbl);
+    seed->UpdateTrackParams(track, AliESDtrack::kTRDbackup); //make backup
     fNseeds++;
-
-    /*Int_t expectedClr = */FollowBackProlongation(*track);
+    Float_t p4 = track->GetC();
+    //
+    Int_t expectedClr = FollowBackProlongation(*track);
+    /*
+      // only debug purpose
+    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;
+    }
+    */
+     if (TMath::Abs(track->GetC()-p4)/TMath::Abs(p4)>0.2) {
+      delete track;
+      continue; //too big change of curvature - to be checked
+    }
 
     Int_t foundClr = track->GetNumberOfClusters();
     if (foundClr >= foundMin) {
-      if(foundClr >= 2) {
-       track->CookdEdx(); 
-//     CookLabel(track, 1-fgkLabelFraction);
+      track->CookdEdx(); 
+      CookLabel(track, 1-fgkLabelFraction);
+      if(track->GetChi2()/track->GetNumberOfClusters()<6) {   // sign only gold tracks
        UseClusters(track);
       }
-      
-      // Propagate to outer reference plane [SR, GSI, 18.02.2003]
-//      track->PropagateTo(364.8);  why?
-      
-      //seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
-      //found++;
+      Bool_t isGold = kFALSE;
+     
+      if (track->GetChi2()/track->GetNumberOfClusters()<5) {  //full gold track
+       seed->UpdateTrackParams(track, AliESDtrack::kTRDbackup);
+       isGold = kTRUE;
+      }
+      if (!isGold && track->GetNCross()==0&&track->GetChi2()/track->GetNumberOfClusters()<7){ //almost gold track
+       seed->UpdateTrackParams(track, AliESDtrack::kTRDbackup);
+       isGold = kTRUE;
+      }
+      if (!isGold && track->GetBackupTrack()){
+       if (track->GetBackupTrack()->GetNumberOfClusters()>foundMin&&
+           (track->GetBackupTrack()->GetChi2()/(track->GetBackupTrack()->GetNumberOfClusters()+1))<7){   
+         seed->UpdateTrackParams(track->GetBackupTrack(), AliESDtrack::kTRDbackup);
+         isGold = kTRUE;
+       }
+      }
+    }
+    else{
+      continue;
     }
 
     //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;
+    
+    if (track->GetStop()==kFALSE){
 
-    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;
+      Double_t xtof=371.;
+      Double_t c2=track->GetC()*xtof - track->GetEta();
+      if (TMath::Abs(c2)>=0.85) {
+       delete track;
+       continue;
+      }
+      Double_t xTOF0 = 371. ;          
+      PropagateToOuterPlane(*track,xTOF0); 
+      //      
+      Double_t ymax=xtof*TMath::Tan(0.5*AliTRDgeometry::GetAlpha());
+      Double_t y=track->GetYat(xtof);
+      if (y > ymax) {
+       if (!track->Rotate(AliTRDgeometry::GetAlpha())) {
+         delete track;
+         continue;
+       }
+      } else if (y <-ymax) {
+       if (!track->Rotate(-AliTRDgeometry::GetAlpha())) {
+         delete track;
+         continue;
+       }
+      }
+      
+      if (track->PropagateTo(xtof)) {
+       seed->UpdateTrackParams(track, AliESDtrack::kTRDout);    
+       seed->SetTRDtrack(new AliTRDtrack(*track));
+       if (track->GetNumberOfClusters()>foundMin) found++;
+      }
+    }else{
+      if (track->GetNumberOfClusters()>15&&track->GetNumberOfClusters()>0.5*expectedClr){
+       seed->UpdateTrackParams(track, AliESDtrack::kTRDout);
+       //seed->SetStatus(AliESDtrack::kTRDStop);    
+       seed->SetTRDtrack(new AliTRDtrack(*track));
+       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);
+    
 
   }
   
@@ -918,13 +679,17 @@ Int_t AliTRDtracker::RefitInward(AliESD* event)
   Int_t n = event->GetNumberOfTracks();
   for (Int_t i=0; i<n; i++) {
     AliESDtrack* seed=event->GetTrack(i);
+    AliTRDtrack* seed2 = new AliTRDtrack(*seed);
+    if (seed2->GetX()<270){
+      seed->UpdateTrackParams(seed2, AliESDtrack::kTRDbackup); // backup TPC track - only update
+      continue;
+    }
+
     ULong_t status=seed->GetStatus();
     if ( (status & AliESDtrack::kTRDout ) == 0 ) continue;
     if ( (status & AliESDtrack::kTRDin) != 0 ) continue;
-    nseed++;
-
-    AliTRDtrack* seed2 = new AliTRDtrack(*seed);
-    seed2->ResetCovariance(2.); 
+    nseed++;    
+    seed2->ResetCovariance(5.); 
     AliTRDtrack *pt = new AliTRDtrack(*seed2,seed2->GetAlpha());
     UInt_t * indexes2 = seed2->GetIndexes();
     UInt_t * indexes3 = pt->GetBackupIndexes();
@@ -935,7 +700,7 @@ Int_t AliTRDtracker::RefitInward(AliESD* event)
     //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());
@@ -945,9 +710,10 @@ Int_t AliTRDtracker::RefitInward(AliESD* event)
        if (indexes2[i]==0) break;
        indexes3[i] = indexes2[i];
       }  
-      FollowProlongation(*pt2, innerTB); 
+      FollowProlongation(*pt2, innerTB);
+      delete pt2;
     }
-
+    */
     if (t.GetNumberOfClusters() >= foundMin) {
       //      UseClusters(&t);
       //CookLabel(pt, 1-fgkLabelFraction);
@@ -958,7 +724,17 @@ Int_t AliTRDtracker::RefitInward(AliESD* event)
 
     if(PropagateToTPC(t)) {
       seed->UpdateTrackParams(pt, AliESDtrack::kTRDrefit);
+    }else{
+      //if not prolongation to TPC - propagate without update
+      AliTRDtrack* seed2 = new AliTRDtrack(*seed);
+      seed2->ResetCovariance(5.); 
+      AliTRDtrack *pt2 = new AliTRDtrack(*seed2,seed2->GetAlpha());
+      delete seed2;
+      if (PropagateToTPC(*pt2)) 
+       seed->UpdateTrackParams(pt2, AliESDtrack::kTRDrefit);
+      delete pt2;
     }  
+
     delete seed2;
     delete pt;
   }     
@@ -985,6 +761,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();  
 
@@ -1114,10 +891,14 @@ Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
          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;       
-
+       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()
@@ -1170,15 +951,17 @@ Int_t AliTRDtracker::FollowProlongation(AliTRDtrack& t, Int_t rf)
           t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters()); 
          //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)) {
-            if(!tryAgain--) return 0;
+         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--;
         }
 
@@ -1224,6 +1007,7 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
   // layers confirms prolongation if a close cluster is found. 
   // Returns the number of clusters expected to be found in sensitive layers
 
+
   Float_t  wIndex, wTB, wChi2;
   Float_t  wYrt, wYclosest, wYcorrect, wYwindow;
   Float_t  wZrt, wZclosest, wZcorrect, wZwindow;
@@ -1253,8 +1037,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();
@@ -1268,7 +1053,29 @@ 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;
+    Int_t cross = kFALSE;
+    
+    if (TMath::Abs(angle -  t.GetAlpha())>0.000001) cross = kTRUE; //better to stop track
+    Int_t currentzone = fTrSec[s]->GetLayer(nr)->GetZone(z);
+    if (currentzone==-10) cross = kTRUE;  // we are in the frame
+    if (currentzone>-10){   // layer knows where we are
+      if (zone==-10) zone = currentzone;
+      if (zone!=currentzone) cross=kTRUE;  
+    }
+    if (cross) {
+      t.IncCross();
+      if (t.GetNCross()==1) t.MakeBackupTrack();
+      if (t.GetNCross()>2) break;
+    }
+    
+    //
+    //
     s = t.GetSector();
     if (!t.PropagateTo(x,radLength,rho)) break;
 
@@ -1432,7 +1239,11 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
 
           t.SetSampledEdx(cl->GetQ()/dx,t.GetNumberOfClusters()); 
           Double_t h01 = GetTiltFactor(cl);
-          if(!t.UpdateMI(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;
@@ -1477,6 +1288,10 @@ Int_t AliTRDtracker::FollowBackProlongation(AliTRDtrack& t)
       }
     }  
   }
+  if (nr<outerTB) 
+    t.SetStop(kTRUE);
+  else
+    t.SetStop(kFALSE);
   return expectedNumberOfClusters;
 
 
@@ -1690,42 +1505,10 @@ Int_t AliTRDtracker::PropagateToTPC(AliTRDtrack& t)
     if(!t.PropagateTo(x,radLength,rho)) return 0;
     AdjustSector(&t);
     if(!t.PropagateTo(x,radLength,rho)) return 0;
-  }
+  } 
   return 1;
 }         
 
-void AliTRDtracker::LoadEvent()
-{
-  // Fills clusters into TRD tracking_sectors 
-  // Note that the numbering scheme for the TRD tracking_sectors 
-  // differs from that of TRD sectors
-
-  ReadClusters(fClusters);
-  Int_t ncl=fClusters->GetEntriesFast();
-  cout<<"\n LoadSectors: sorting "<<ncl<<" clusters"<<endl;
-              
-  UInt_t index;
-  while (ncl--) {
-//    printf("\r %d left  ",ncl); 
-    AliTRDcluster *c=(AliTRDcluster*)fClusters->UncheckedAt(ncl);
-    Int_t detector=c->GetDetector();
-    Int_t localTimeBin=c->GetLocalTimeBin();
-    Int_t sector=fGeom->GetSector(detector);
-    Int_t plane=fGeom->GetPlane(detector);
-
-    Int_t trackingSector = CookSectorIndex(sector);
-
-    Int_t gtb = fTrSec[trackingSector]->CookTimeBinIndex(plane,localTimeBin);
-    if(gtb < 0) continue; 
-    Int_t layer = fTrSec[trackingSector]->GetLayerNumber(gtb);
-
-    index=ncl;
-    fTrSec[trackingSector]->GetLayer(layer)->InsertCluster(c,index);
-  }    
-  printf("\r\n");
-
-}
-
 //_____________________________________________________________________________
 Int_t AliTRDtracker::LoadClusters(TTree *cTree)
 {
@@ -1738,9 +1521,16 @@ Int_t AliTRDtracker::LoadClusters(TTree *cTree)
      return 1;
   }
   Int_t ncl=fClusters->GetEntriesFast();
+  fNclusters=ncl;
   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);
@@ -1748,8 +1538,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; 
@@ -1758,13 +1552,22 @@ Int_t AliTRDtracker::LoadClusters(TTree *cTree)
     index=ncl;
     fTrSec[trackingSector]->GetLayer(layer)->InsertCluster(c,index);
   }    
-  printf("\r\n");
-
+  //  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;
 }
 
 //_____________________________________________________________________________
-void AliTRDtracker::UnloadEvent() 
+void AliTRDtracker::UnloadClusters() 
 { 
   //
   // Clears the arrays of clusters and tracks. Resets sectors and timebins 
@@ -1774,6 +1577,7 @@ void AliTRDtracker::UnloadEvent()
 
   nentr = fClusters->GetEntriesFast();
   for (i = 0; i < nentr; i++) delete fClusters->RemoveAt(i);
+  fNclusters = 0;
 
   nentr = fSeeds->GetEntriesFast();
   for (i = 0; i < nentr; i++) delete fSeeds->RemoveAt(i);
@@ -1963,7 +1767,7 @@ void AliTRDtracker::MakeSeeds(Int_t inner, Int_t outer, Int_t turn)
 }            
 
 //_____________________________________________________________________________
-Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree) 
+Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree) const
 {
   //
   // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0) 
@@ -1980,12 +1784,12 @@ Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree)
   branch->SetAddress(&clusterArray); 
   
   Int_t nEntries = (Int_t) ClusterTree->GetEntries();
-  printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
+  //  printf("found %d entries in %s.\n",nEntries,ClusterTree->GetName());
   
   // Loop through all entries in the tree
-  Int_t nbytes;
+  Int_t nbytes = 0;
   AliTRDcluster *c = 0;
-  printf("\n");
+  //  printf("\n");
 
   for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {    
     
@@ -2014,139 +1818,6 @@ Int_t AliTRDtracker::ReadClusters(TObjArray *array, TTree *ClusterTree)
   return 0;
 }
 
-//______________________________________________________________________
-void AliTRDtracker::ReadClusters(TObjArray *array, const Char_t *filename)
-{
-  //
-  // Reads AliTRDclusters from file <filename>. The names of the cluster
-  // tree and branches should match the ones used in
-  // AliTRDclusterizer::WriteClusters()
-  // if <array> == 0, clusters are added into AliTRDtracker fCluster array
-  //
-
-  TDirectory *savedir=gDirectory;
-
-  TFile *file = TFile::Open(filename);
-  if (!file->IsOpen()) {
-    cerr<<"Can't open file with TRD clusters"<<endl;
-    return;
-  }
-
-  Char_t treeName[12];
-  sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
-  TTree *clusterTree = (TTree*) gDirectory->Get(treeName);
-
-  if (!clusterTree) {
-     cerr<<"AliTRDtracker::ReadClusters(): ";
-     cerr<<"can't get a tree with clusters !\n";
-     return;
-  }
-
-  TObjArray *clusterArray = new TObjArray(400);
-
-  clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray);
-
-  Int_t nEntries = (Int_t) clusterTree->GetEntries();
-  cout<<"found "<<nEntries<<" in clusterTree"<<endl;   
-
-  // Loop through all entries in the tree
-  Int_t nbytes;
-  AliTRDcluster *c = 0;
-
-  printf("\n");
-
-  for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
-
-    // Import the tree
-    nbytes += clusterTree->GetEvent(iEntry);
-
-    // Get the number of points in the detector
-    Int_t nCluster = clusterArray->GetEntriesFast();
-    printf("\n Read %d clusters from entry %d", nCluster, iEntry);
-
-    // Loop through all TRD digits
-    for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
-      c = (AliTRDcluster*)clusterArray->UncheckedAt(iCluster);
-      AliTRDcluster *co = new AliTRDcluster(*c);
-      co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
-      Int_t ltb = co->GetLocalTimeBin();
-      if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
-      else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
-      array->AddLast(co);
-      delete clusterArray->RemoveAt(iCluster);
-    }
-  }
-
-  file->Close();
-  delete clusterArray;
-  savedir->cd();
-
-}                      
-
-void AliTRDtracker::ReadClusters(TObjArray *array, const TFile *inp) 
-{
-  //
-  // Reads AliTRDclusters (option >= 0) or AliTRDrecPoints (option < 0) 
-  // from the file. The names of the cluster tree and branches 
-  // should match the ones used in AliTRDclusterizer::WriteClusters()
-  //
-
-  TDirectory *savedir=gDirectory; 
-
-  if (inp) {
-     TFile *in=(TFile*)inp;
-     if (!in->IsOpen()) {
-        cerr<<"AliTRDtracker::ReadClusters(): input file is not open !\n";
-        return;
-     }
-     else{
-       in->cd();
-     }
-  }
-
-  Char_t treeName[12];
-  sprintf(treeName,"TreeR%d_TRD",GetEventNumber());
-  TTree *clusterTree = (TTree*) gDirectory->Get(treeName);
-  
-  TObjArray *clusterArray = new TObjArray(400); 
-  
-  clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray); 
-  
-  Int_t nEntries = (Int_t) clusterTree->GetEntries();
-  printf("found %d entries in %s.\n",nEntries,clusterTree->GetName());
-  
-  // Loop through all entries in the tree
-  Int_t nbytes;
-  AliTRDcluster *c = 0;
-  printf("\n");
-
-  for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {    
-    
-    // Import the tree
-    nbytes += clusterTree->GetEvent(iEntry);  
-    
-    // Get the number of points in the detector
-    Int_t nCluster = clusterArray->GetEntriesFast();  
-//    printf("\r Read %d clusters from entry %d", nCluster, iEntry);
-    
-    // Loop through all TRD digits
-    for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { 
-      c = (AliTRDcluster*)clusterArray->UncheckedAt(iCluster);
-      AliTRDcluster *co = new AliTRDcluster(*c);
-      co->SetSigmaY2(c->GetSigmaY2() * fSY2corr);
-      Int_t ltb = co->GetLocalTimeBin();
-      if(ltb == 19) co->SetSigmaZ2(c->GetSigmaZ2());
-      else if(fNoTilt) co->SetSigmaZ2(c->GetSigmaZ2() * fSZ2corr);
-      array->AddLast(co);
-      delete clusterArray->RemoveAt(iCluster); 
-    }
-  }
-
-  delete clusterArray;
-  savedir->cd();   
-
-}
-
 //__________________________________________________________________
 void AliTRDtracker::CookLabel(AliKalmanTrack* pt, Float_t wrong) const 
 {
@@ -2292,6 +1963,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;
@@ -2310,7 +1982,6 @@ void AliTRDtracker::AliTRDpropagationLayer::SetHole(
   //
   // Sets hole in the layer 
   //
-
   fHole = kTRUE;
   fHoleZc = Zc;
   fHoleZmax = Zmax;
@@ -2333,7 +2004,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;
 
 
@@ -2440,7 +2120,7 @@ AliTRDtracker::AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry* geo, I
   }
 
 
-  Double_t alpha=AliTRDgeometry::GetAlpha();
+  //  Double_t alpha=AliTRDgeometry::GetAlpha();
 
   // add layers for each of the planes
 
@@ -2454,37 +2134,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(); 
@@ -2493,45 +2174,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
@@ -2543,49 +2205,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
@@ -2594,14 +2233,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);
     }
 
@@ -2611,14 +2245,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);
     }
   }    
@@ -2817,8 +2443,33 @@ Int_t AliTRDtracker::AliTRDtrackingSector::Find(Double_t x) const
   return m;
 }             
 
+//______________________________________________________
+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, 
         Bool_t &lookForCluster) const
@@ -2832,31 +2483,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, 
@@ -2908,7 +2586,8 @@ Double_t AliTRDtracker::GetTiltFactor(const AliTRDcluster* c) {
   Int_t det = c->GetDetector();    
   Int_t plane = fGeom->GetPlane(det);
 
-  if((plane == 1) || (plane == 3) || (plane == 5)) h01=-h01;
+  //if((plane == 1) || (plane == 3) || (plane == 5)) h01=-h01;
+  if((plane == 0) || (plane == 2) || (plane == 4)) h01=-h01;
 
   if(fNoTilt) h01 = 0;