]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Write to AliESDtrack info on status of track at each ITS layer + Possibility to read...
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Dec 2007 16:38:15 +0000 (16:38 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 6 Dec 2007 16:38:15 +0000 (16:38 +0000)
ITS/AliITSRecoParam.cxx
ITS/AliITSRecoParam.h
ITS/AliITStrackMI.cxx
ITS/AliITStrackMI.h
ITS/AliITStrackV2.cxx
ITS/AliITStrackV2.h
ITS/AliITStrackerMI.cxx
ITS/AliITStrackerMI.h

index ce08d1357bf0bf55916abe5630159e49d687cfa5..9cff51f8e5f29dfd6a72cb75be0540561e1ac9f0 100644 (file)
@@ -100,6 +100,7 @@ fClusterErrorsParam(1),
 fComputePlaneEff(kFALSE),
 fExtendedEtaAcceptance(kFALSE),
 fUseDeadZonesFromOCDB(kFALSE),
+fAllowProlongationWithEmptyRoad(kFALSE),
 fFactorSAWindowSizes(1.),
 fFindV0s(kTRUE),
 fUseUnfoldingInClusterFinderSPD(kFALSE),
@@ -220,18 +221,6 @@ AliITSRecoParam *AliITSRecoParam::GetHighFluxParam()
   return param;
 }
 //_____________________________________________________________________________
-AliITSRecoParam *AliITSRecoParam::GetPlaneEffParam(Int_t i)
-{
-  //
-  // make special reconstruction parameters for Plane Efficiency study on layer i
-  //
-  AliITSRecoParam *param;
-  param = GetHighFluxParam();
-  param->SetComputePlaneEff();
-  param->SetLayerToSkip(i);
-  return param;
-}
-//_____________________________________________________________________________
 AliITSRecoParam *AliITSRecoParam::GetLowFluxParam() 
 {
   //
@@ -334,6 +323,18 @@ AliITSRecoParam *AliITSRecoParam::GetCosmicTestParam()
   return param;
 }
 //_____________________________________________________________________________
+AliITSRecoParam *AliITSRecoParam::GetPlaneEffParam(Int_t i)
+{
+  //
+  // make special reconstruction parameters for Plane Efficiency study on layer i
+  //
+  AliITSRecoParam *param;
+  param = GetHighFluxParam();
+  param->SetComputePlaneEff();
+  param->SetLayerToSkip(i);
+  return param;
+}
+//_____________________________________________________________________________
 void AliITSRecoParam::SetLayersParameters() 
 {
   //
@@ -358,3 +359,4 @@ void AliITSRecoParam::SetLayersParameters()
 
   return;
 }
+
index f8a11e8b1b0028b1b52fb50c306bb922558b886c..a4a48af83a1d8f77c11714c29c1b8b98a8e8b61a 100644 (file)
@@ -124,12 +124,15 @@ class AliITSRecoParam : public AliDetectorRecoParam
   void   SetUseAmplitudeInfo(Bool_t use=kTRUE) { for(Int_t i=0;i<AliITSgeomTGeo::kNLayers;i++) fUseAmplitudeInfo[i]=use; return; }
   void   SetUseAmplitudeInfo(Int_t ilay,Bool_t use) { fUseAmplitudeInfo[ilay]=use; return; }
   Bool_t GetUseAmplitudeInfo(Int_t ilay) const { return fUseAmplitudeInfo[ilay]; }
-//
-  void   SetComputePlaneEff(Bool_t ext=kTRUE) { fComputePlaneEff=ext; return; }
+  //
+  void   SetComputePlaneEff(Bool_t eff=kTRUE) { fComputePlaneEff=eff; return; }
   Bool_t GetComputePlaneEff() const { return fComputePlaneEff; }
-//
+  //
   void   SetExtendedEtaAcceptance(Bool_t ext=kTRUE) { fExtendedEtaAcceptance=ext; return; }
   Bool_t GetExtendedEtaAcceptance() const { return fExtendedEtaAcceptance; }
+  void   SetAllowProlongationWithEmptyRoad(Bool_t allow=kTRUE) { fAllowProlongationWithEmptyRoad=allow; return; }  
+  Bool_t GetAllowProlongationWithEmptyRoad() const { return fAllowProlongationWithEmptyRoad; }
+
   void   SetUseDeadZonesFromOCDB(Bool_t use=kTRUE) { fUseDeadZonesFromOCDB=use; return; }
   Bool_t GetUseDeadZonesFromOCDB() const { return fUseDeadZonesFromOCDB; }
 
@@ -255,9 +258,10 @@ class AliITSRecoParam : public AliDetectorRecoParam
   Bool_t fAllowSharedClusters; // if kFALSE don't set to kITSin tracks with shared clusters (MI)
   Int_t fClusterErrorsParam; // parametrization for cluster errors (MI), see AliITSRecoParam::GetError()
   Bool_t fUseAmplitudeInfo[AliITSgeomTGeo::kNLayers]; // use cluster charge in cluster-track matching (SDD,SSD) (MI)
-  Bool_t fComputePlaneEff;  // flag to enable Computation of PlaneEfficiency
+  Bool_t fComputePlaneEff;  // flag to enable computation of PlaneEfficiency
   Bool_t fExtendedEtaAcceptance;  // enable jumping from TPC to SPD at large eta (MI)
   Bool_t fUseDeadZonesFromOCDB; // enable using OCDB info on dead modules.. (MI)
+  Bool_t fAllowProlongationWithEmptyRoad; // allow to prolong even if road is empty (MI)
   Double_t fFactorSAWindowSizes; // larger window sizes in SA
 
   Bool_t fFindV0s;  // flag to enable V0 finder (MI)
index 83e08bc22cca1199011f92e342ab265631c3bbc3..e7cba4ded7f698ba93722ac2080b695f21171bf5 100644 (file)
@@ -20,6 +20,8 @@
 //     dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
 //-------------------------------------------------------------------------
 
+/* $Id$ */
+
 #include <TMatrixD.h>
 
 #include <TMath.h>
@@ -79,11 +81,6 @@ fGoldV0(kFALSE) {
 
 }
 
-void AliITStrackMI::UpdateESDtrack(ULong_t flags) {
-  fESDtrack->UpdateTrackParams(this,flags);
-  //if (flags == AliESDtrack::kITSin) fESDtrack->SetITSChi2MIP(fChi2MIP);
-}
-
 //____________________________________________________________________________
 AliITStrackMI::AliITStrackMI(const AliITStrackMI& t) : AliITStrackV2(t),
 fNUsed(t.fNUsed),
index 4d28d5de6bb517daf445fb9c8eece19d1bc74e09..687411cf17ce46a4c0e5b6b9c0371be9cc4cf10f 100644 (file)
@@ -10,6 +10,7 @@
 //     dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
 //-------------------------------------------------------------------------
 
+/* $Id$ */
 
 /*****************************************************************************
  *                          December 18, 2000                                *
@@ -42,8 +43,6 @@ public:
   Bool_t UpdateMI(Double_t cy, Double_t cz, Double_t cerry, Double_t cerrz, Double_t chi2, Int_t i);  
   Int_t CorrectForMaterial(Double_t d, Double_t x0=21.82);
 
-  void UpdateESDtrack(ULong_t flags);
-
   void SetReconstructed(Bool_t sr=kTRUE){fReconstructed = sr;}  
   Bool_t GetReconstructed() const {return fReconstructed;}
   void SetChi2MIP(Int_t i,Float_t val){fChi2MIP[i]=val;}
index 469832ba137ca59d97940c74f8dd2079e3b1aac1..3ea6176c06088dd6d83f26b037bb4ce5cd93dc64 100644 (file)
@@ -13,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
+
 ///////////////////////////////////////////////////////////////////////////
 //                Implementation of the ITS track class
 //
@@ -36,8 +38,8 @@ AliITStrackV2::AliITStrackV2() : AliKalmanTrack(),
   fdEdx(0),
   fESDtrack(0)
 {
-    for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) fIndex[i]=-1;
-    for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
+  for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) {fIndex[i]=-1; fModule[i]=-1;}
+  for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
 }
 
 
@@ -75,6 +77,11 @@ AliITStrackV2::AliITStrackV2(AliESDtrack& t,Bool_t c) throw (const Char_t *) :
 
 void AliITStrackV2::UpdateESDtrack(ULong_t flags) const {
   fESDtrack->UpdateTrackParams(this,flags);
+  // copy the module indices
+  for(Int_t i=0;i<12;i++) {
+    //   printf("     %d\n",GetModuleIndex(i));
+    fESDtrack->SetITSModuleIndex(i,GetModuleIndex(i));
+  }
 }
 
 //____________________________________________________________________________
@@ -88,7 +95,10 @@ AliITStrackV2::AliITStrackV2(const AliITStrackV2& t) :
   //------------------------------------------------------------------
   Int_t i;
   for (i=0; i<4; i++) fdEdxSample[i]=t.fdEdxSample[i];
-  for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) fIndex[i]=t.fIndex[i];
+  for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
+    fIndex[i]=t.fIndex[i];
+    fModule[i]=t.fModule[i];
+  }
 }
 
 //_____________________________________________________________________________
index b5b3bc59eded44b8c3e4d12772b6ee09f3e92207..cf8d78a1383b7d5c00f1b109ce8e0944ca3048bb 100644 (file)
@@ -14,6 +14,8 @@
 #include "AliITSRecoParam.h"
 #include "AliITSgeomTGeo.h"
 
+/* $Id$ */
+
 class AliESDtrack;
 
 //_____________________________________________________________________________
@@ -72,10 +74,17 @@ public:
 
   Int_t Compare(const TObject *o) const;
   Int_t GetClusterIndex(Int_t i) const {return fIndex[i];}
+  void  SetModuleIndex(Int_t ilayer,Int_t idx) {fModule[ilayer]=idx;}
+  Int_t GetModuleIndex(Int_t ilayer) const {return fModule[ilayer];}
+  void  SetModuleIndexInfo(Int_t ilayer,Int_t idet,Int_t status=1,Float_t xloc=0,Float_t zloc=0);
+  Bool_t GetModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,Float_t &xloc,Float_t &zloc) const;
   Bool_t Invariant() const;
 
-  void  SetExtraCluster(Int_t i, Int_t idx) {fIndex[AliITSgeomTGeo::kNLayers+i]=idx;}
-  Int_t GetExtraCluster(Int_t i) const {return fIndex[AliITSgeomTGeo::kNLayers+i];}
+  void  SetExtraCluster(Int_t ilayer, Int_t idx) {fIndex[AliITSgeomTGeo::kNLayers+ilayer]=idx;}
+  Int_t GetExtraCluster(Int_t ilayer) const {return fIndex[AliITSgeomTGeo::kNLayers+ilayer];}
+
+  void  SetExtraModule(Int_t ilayer, Int_t idx) {fModule[AliITSgeomTGeo::kNLayers+ilayer]=idx;}
+  Int_t GetExtraModule(Int_t ilayer) const {return fModule[AliITSgeomTGeo::kNLayers+ilayer];}
 
 protected:
   Double_t GetBz() const ;
@@ -86,6 +95,8 @@ protected:
 
   Int_t fIndex[2*AliITSgeomTGeo::kNLayers]; // indices of associated clusters 
 
+  Int_t fModule[2*AliITSgeomTGeo::kNLayers]; // indices of crossed modules: 
+                                             // see SetModuleIndexInfo()
   AliESDtrack *fESDtrack;    //! pointer to the connected ESD track
 
 private:
@@ -93,8 +104,7 @@ private:
   ClassDef(AliITStrackV2,7)  //ITS reconstructed track
 };
 
-inline
-void AliITStrackV2::SetSampledEdx(Float_t q, Int_t i) {
+inline void AliITStrackV2::SetSampledEdx(Float_t q, Int_t i) {
   //----------------------------------------------------------------------
   // This function stores dEdx sample corrected for the track segment length 
   // Origin: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
@@ -104,8 +114,119 @@ void AliITStrackV2::SetSampledEdx(Float_t q, Int_t i) {
   Double_t s=GetSnp(), t=GetTgl();
   q *= TMath::Sqrt((1-s*s)/(1+t*t));
   fdEdxSample[i]=q;
+  return;
 }
 
+inline void  AliITStrackV2::SetModuleIndexInfo(Int_t ilayer,Int_t idet,Int_t status,
+                                              Float_t xloc,Float_t zloc) {
+  //----------------------------------------------------------------------
+  // This function encodes in the module number also the status of cluster association
+  // "status" can have the following values: 
+  // 1 "found" (cluster is associated), 
+  // 2 "dead" (module is dead from OCDB), 
+  // 3 "skipped" (module or layer forced to be skipped),
+  // 4 "outinz" (track out of z acceptance), 
+  // 5 "nocls" (no clusters in the road), 
+  // 6 "norefit" (cluster rejected during refit) 
+  // 7 "deadzspd" (holes in z in SPD)
+  // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliESDtrack::GetITSModuleIndexInfo()!
+  //----------------------------------------------------------------------
+
+  if(idet<0) {
+    idet=0;
+  } else {
+    // same detector numbering as in AliITSCalib classes
+    if(ilayer==1) idet+=AliITSgeomTGeo::GetNLadders(1)*AliITSgeomTGeo::GetNDetectors(1);
+    if(ilayer==3) idet+=AliITSgeomTGeo::GetNLadders(3)*AliITSgeomTGeo::GetNDetectors(3);
+    if(ilayer==5) idet+=AliITSgeomTGeo::GetNLadders(5)*AliITSgeomTGeo::GetNDetectors(5);
+  }
+
+  Int_t xInt = Int_t(xloc*10.);
+  Int_t zInt = Int_t(zloc*10.);
+
+  if(TMath::Abs(xloc*10.-(Float_t)xInt)>0.5)
+    if(zloc>0) { xInt++; } else { xInt--; }
+  if(TMath::Abs(zloc*10.-(Float_t)zInt)>0.5)
+    if(zloc>0) { zInt++; } else { zInt--; }
+
+  Int_t signs=0;
+  if(xInt>=0 && zInt>=0) signs=10000;
+  if(xInt>=0 && zInt<0)  signs=20000;
+  if(xInt<0 && zInt>=0)  signs=30000;
+  if(xInt<0 && zInt<0)   signs=40000;
+
+  Int_t modindex = signs;
+  
+  modindex += TMath::Abs(zInt);
+  modindex += TMath::Abs(xInt)*100;
+
+  modindex += status*100000;
+
+  modindex += idet*1000000;
+
+  SetModuleIndex(ilayer,modindex);
+  return;
+}
+
+inline Bool_t AliITStrackV2::GetModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
+                                              Float_t &xloc,Float_t &zloc) const {
+  //----------------------------------------------------------------------
+  // This function encodes in the module number also the status of cluster association
+  // "status" can have the following values: 
+  // 1 "found" (cluster is associated), 
+  // 2 "dead" (module is dead from OCDB), 
+  // 3 "skipped" (module or layer forced to be skipped),
+  // 4 "outinz" (track out of z acceptance), 
+  // 5 "nocls" (no clusters in the road), 
+  // 6 "norefit" (cluster rejected during refit), 
+  // 7 "deadzspd" (holes in z in SPD)
+  // Also given are the coordinates of the crossing point of track and module
+  // (in the local module ref. system)
+  // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliESDtrack::GetITSModuleIndexInfo()!
+  //----------------------------------------------------------------------
+
+
+  if(fModule[ilayer]==-1) {
+    AliError("fModule was not set !");
+    idet = -1;
+    status=0;
+    xloc=-99.; zloc=-99.;
+    return kFALSE;
+  }
+
+  Int_t module = fModule[ilayer];
+
+  idet = Int_t(module/1000000);
+
+  module -= idet*1000000;
+
+  status = Int_t(module/100000);
+
+  module -= status*100000;
+
+  Int_t signs = Int_t(module/10000);
+
+  module-=signs*10000;
+
+  Int_t xInt = Int_t(module/100);
+  module -= xInt*100;
+
+  Int_t zInt = module;
+
+  if(signs==1) { xInt*=1; zInt*=1; }
+  if(signs==2) { xInt*=1; zInt*=-1; }
+  if(signs==3) { xInt*=-1; zInt*=1; }
+  if(signs==4) { xInt*=-1; zInt*=-1; }
+
+  xloc = 0.1*(Float_t)xInt;
+  zloc = 0.1*(Float_t)zInt;
+
+  if(status==4) idet = -1;
+
+  return kTRUE;
+}
+
+
 #endif
 
 
index c604384ee54c7cb61437f82428ade1b602bed30e..a88f59f3914ff51a04c03a440c6d95a686600f45 100644 (file)
 #include "AliHelix.h"
 #include "AliITSRecPoint.h"
 #include "AliITSgeomTGeo.h"
-#include "AliITStrackerMI.h"
 #include "AliITSReconstructor.h"
 #include "AliTrackPointArray.h"
 #include "AliAlignObj.h"
 #include "AliITSClusterParam.h"
 #include "AliITSPlaneEff.h"
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliITSCalibrationSPD.h"
+#include "AliITSCalibrationSDD.h"
+#include "AliITSCalibrationSSD.h"
+#include "AliITStrackerMI.h"
 
 ClassImp(AliITStrackerMI)
 
@@ -75,7 +80,7 @@ fxTimesRhoShieldTrks(0),
 fxOverX0LayerTrks(0),
 fxTimesRhoLayerTrks(0),
 fDebugStreamer(0),
-fPlaneEff(0){
+fPlaneEff(0) {
   //Default constructor
   Int_t i;
   for(i=0;i<4;i++) fSPDdetzcentre[i]=0.;
@@ -108,7 +113,7 @@ fxTimesRhoShieldTrks(0),
 fxOverX0LayerTrks(0),
 fxTimesRhoLayerTrks(0),
 fDebugStreamer(0),
-fPlaneEff(0){
+fPlaneEff(0) {
   //--------------------------------------------------------------------
   //This is the AliITStrackerMI constructor
   //--------------------------------------------------------------------
@@ -227,7 +232,7 @@ fxTimesRhoShieldTrks(0),
 fxOverX0LayerTrks(0),
 fxTimesRhoLayerTrks(0),
 fDebugStreamer(tracker.fDebugStreamer),
-fPlaneEff(tracker.fPlaneEff){
+fPlaneEff(tracker.fPlaneEff) {
   //Copy constructor
   Int_t i;
   for(i=0;i<4;i++) {
@@ -480,7 +485,7 @@ Int_t AliITStrackerMI::Clusters2Tracks(AliESDEvent *event) {
 
        SortTrackHypothesys(fCurrentEsdTrack,20,0);  //MI change
        //
-       AliITStrackMI * besttrack = GetBestHypothesys(fCurrentEsdTrack,t,15);
+       AliITStrackMI *besttrack = GetBestHypothesys(fCurrentEsdTrack,t,15);
        if (!besttrack) continue;
        besttrack->SetLabel(tpcLabel);
        //       besttrack->CookdEdx();
@@ -627,7 +632,7 @@ Int_t AliITStrackerMI::RefitInward(AliESDEvent *event) {
       fTrackToFollow.ResetCovariance(10.);
 
     //Refitting...
-    if (RefitAt(AliITSRecoParam::GetrInsideSPD1(), &fTrackToFollow, t,kTRUE)) {
+    if (RefitAt(AliITSRecoParam::GetrInsideSPD1(),&fTrackToFollow,t,kTRUE)) {
        fTrackToFollow.SetLabel(t->GetLabel());
        //       fTrackToFollow.CookdEdx();
        CookdEdx(&fTrackToFollow);
@@ -636,8 +641,10 @@ Int_t AliITStrackerMI::RefitInward(AliESDEvent *event) {
 
        //The beam pipe
        if (CorrectForPipeMaterial(&fTrackToFollow,"inward")) {
+        fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSrefit);
         AliESDtrack  *esdTrack =fTrackToFollow.GetESDtrack();
-        esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit);
+        //printf("                                       %d\n",esdTrack->GetITSModuleIndex(0));
+        //esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit); //original line
         Float_t r[3]={0.,0.,0.};
         Double_t maxD=3.;
         esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD);
@@ -827,6 +834,8 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
   new (&(tracks[6][0])) AliITStrackMI(*otrack);
   ntracks[6]=1;
   for (Int_t i=0;i<7;i++) nindexes[i][0]=0;
+  Int_t modstatus = 1; // found 
+  Float_t xloc,zloc;
   // 
   //
   // follow prolongations
@@ -880,6 +889,9 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
        CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward");
        vtrack->SetNDeadZone(vtrack->GetNDeadZone()+1);
        vtrack->SetClIndex(ilayer,0);
+       modstatus = (skip==1 ? 3 : 4); // skipped : out in z
+       LocalModuleCoord(ilayer,idet,vtrack,xloc,zloc); // local module coords
+       vtrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc);
        if(constrain) vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx);
        ntracks[ilayer]++;
        continue;
@@ -892,6 +904,7 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
       const AliITSdetector &det=layer.GetDetector(idet);
       new(&currenttrack2)  AliITStrackMI(currenttrack1);
       if (!currenttrack1.Propagate(det.GetPhi(),det.GetR())) continue;
+      LocalModuleCoord(ilayer,idet,&currenttrack1,xloc,zloc); // local module coords
       currenttrack2.Propagate(det.GetPhi(),det.GetR());
       currenttrack1.SetDetectorIndex(idet);
       currenttrack2.SetDetectorIndex(idet);
@@ -963,11 +976,22 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
       Bool_t deadzoneSPD=kFALSE;
       currenttrack = &currenttrack1;
 
-      // check if the road contains a dead zone and create a prolongation
-      Int_t dead = CheckDeadZone(/*currenttrack,*/ilayer,/*idet,*/zmin,zmax/*,ymin,ymax*/);
-      if (dead) {
+      // check if the road contains a dead zone 
+      Int_t dead = CheckDeadZone(ilayer,idet,zmin,zmax); 
+      // create a prolongation without clusters (check also if there are no clusters in the road)
+      if (dead || 
+         ((layer.GetNextCluster(clidx,kTRUE))==0 && 
+          AliITSReconstructor::GetRecoParam()->GetAllowProlongationWithEmptyRoad())) {
        AliITStrackMI * updatetrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(*currenttrack);
        updatetrack->SetClIndex(ilayer,0);
+       if (dead==0) {
+         modstatus = 5; // no cls in road
+       } else if (dead==1) {
+         modstatus = 7; // holes in z in SPD
+       } else if (dead==2) {
+         modstatus = 2; // dead from OCDB
+       }
+       updatetrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc);
        // apply correction for material of the current layer
        CorrectForLayerMaterial(updatetrack,ilayer,trackGlobXYZ1,"inward");
        if (constrain) { // apply vertex constrain
@@ -982,14 +1006,17 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
          }
          if (isPrim) updatetrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx);
        }
-       updatetrack->SetNDeadZone(updatetrack->GetNDeadZone()+1);
-       if (dead==1) { // dead zone at z=0,+-7cm in SPD
-         updatetrack->SetDeadZoneProbability(GetSPDDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2())));
-         deadzoneSPD=kTRUE;
+       if (dead) {
+         updatetrack->SetNDeadZone(updatetrack->GetNDeadZone()+1);
+         if (dead==1) { // dead zone at z=0,+-7cm in SPD
+           updatetrack->SetDeadZoneProbability(GetSPDDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2())));
+           deadzoneSPD=kTRUE;
+         }
        }
        ntracks[ilayer]++;
       }
 
+      clidx=-1;
       // loop over clusters in the road
       while ((cl=layer.GetNextCluster(clidx))!=0) { 
        if (ntracks[ilayer]>95) break; //space for skipped clusters  
@@ -1034,13 +1061,23 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
          AliITStrackMI * updatetrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(*currenttrack);
          updatetrack->SetClIndex(ilayer,0);
          if (changedet) new (&currenttrack2) AliITStrackMI(backuptrack);
-         
+
          if (cl->GetQ()!=0) { // real cluster
            if (!UpdateMI(updatetrack,cl,chi2trkcl,(ilayer<<28)+clidx)) continue; 
            updatetrack->SetSampledEdx(cl->GetQ(),updatetrack->GetNumberOfClusters()-1); //b.b.
+           modstatus = 1; // found
          } else {             // virtual cluster in dead zone
            updatetrack->SetNDeadZone(updatetrack->GetNDeadZone()+1);
            updatetrack->SetDeadZoneProbability(GetSPDDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2())));
+           modstatus = 7; // holes in z in SPD
+         }
+
+         if (changedet) {
+           Float_t xlocnewdet,zlocnewdet;
+           LocalModuleCoord(ilayer,idet,updatetrack,xlocnewdet,zlocnewdet); // local module coords
+           updatetrack->SetModuleIndexInfo(ilayer,idet,modstatus,xlocnewdet,zlocnewdet);
+         } else {
+           updatetrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc);
          }
          if (cl->IsUsed()) updatetrack->IncrementNUsed();
 
@@ -1069,6 +1106,8 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
        // apply correction for material of the current layer
        CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward");
        vtrack->SetClIndex(ilayer,0);
+       modstatus = 3; // skipped 
+       vtrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc);
        vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx);
        vtrack->IncrementNSkipped();
        ntracks[ilayer]++;
@@ -1080,6 +1119,8 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
        // apply correction for material of the current layer
        CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward");
        vtrack->SetClIndex(ilayer,0);
+       modstatus = 3; // skipped
+       vtrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc);
        vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx);
        vtrack->SetNDeadZone(vtrack->GetNDeadZone()+1);
        ntracks[ilayer]++;
@@ -1512,14 +1553,14 @@ void  AliITStrackerMI::AliITSlayer::SortClusters()
   //
   for (Int_t i=0;i<fN-1;i++){
     if (fZ[i]>fZ[i+1]){
-      printf("Bugg\n");
+      printf("Bug\n");
     }
   }
   //
   for (Int_t slice=0;slice<21;slice++)
   for (Int_t i=0;i<fN20[slice]-1;i++){
     if (fZ20[slice][i]>fZ20[slice][i+1]){
-      printf("Bugg\n");
+      printf("Bug\n");
     }
   }
 
@@ -1560,10 +1601,12 @@ SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) {
   Double_t circle=2*TMath::Pi()*fR;
   fYmin = ymin; fYmax =ymax;
   Float_t ymiddle = (fYmin+fYmax)*0.5;
-  if (ymiddle<fYB[0]) {fYmin+=circle; fYmax+=circle;ymiddle+=circle;}
-  else{
-    if (ymiddle>fYB[1]) {fYmin-=circle; fYmax-=circle;ymiddle-=circle;}
+  if (ymiddle<fYB[0]) {
+    fYmin+=circle; fYmax+=circle; ymiddle+=circle;
+  } else if (ymiddle>fYB[1]) {
+    fYmin-=circle; fYmax-=circle; ymiddle-=circle;
   }
+  
   //
   fCurrentSlice =-1;
   // defualt take all
@@ -1611,7 +1654,7 @@ SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) {
     if (slice<0) slice=0;
     if (slice>5) slice=5;
     Bool_t isOK = (fYmin>fBy5[slice][0]&&fYmax<fBy5[slice][1]);
-    if ( isOK){
+    if (isOK) {
       fCurrentSlice=slice;
       fClustersCs = fClusters5[fCurrentSlice];
       fClusterIndexCs = fClusterIndex5[fCurrentSlice];
@@ -1657,12 +1700,13 @@ FindDetectorIndex(Double_t phi, Double_t z) const {
   return np*fNdetectors + nz;
 }
 //------------------------------------------------------------------------
-const AliITSRecPoint *AliITStrackerMI::AliITSlayer::GetNextCluster(Int_t &ci){
+const AliITSRecPoint *AliITStrackerMI::AliITSlayer::GetNextCluster(Int_t &ci,Bool_t test)
+{
   //--------------------------------------------------------------------
   // This function returns clusters within the "window" 
   //--------------------------------------------------------------------
 
-  if (fCurrentSlice<0){
+  if (fCurrentSlice<0) {
     Double_t rpi2 = 2.*fR*TMath::Pi();
     for (Int_t i=fI; i<fImax; i++) {
       Double_t y = fY[i];
@@ -1672,17 +1716,16 @@ const AliITSRecPoint *AliITStrackerMI::AliITSlayer::GetNextCluster(Int_t &ci){
       if (y>fYmax) continue;
       if (fClusters[i]->GetQ()==0&&fSkip==2) continue;
       ci=i;
-      fI=i+1;
+      if (!test) fI=i+1;
       return fClusters[i];
     }
-  }
-  else{
+  } else {
     for (Int_t i=fI; i<fImax; i++) {
       if (fYcs[i]<fYmin) continue;
       if (fYcs[i]>fYmax) continue;
       if (fClustersCs[i]->GetQ()==0&&fSkip==2) continue;
       ci=fClusterIndexCs[i];
-      fI=i+1;
+      if (!test) fI=i+1;
       return fClustersCs[i];
     }
   }
@@ -1825,7 +1868,7 @@ Double_t AliITStrackerMI::GetEffectiveThickness()
 }
 //------------------------------------------------------------------------
 Int_t AliITStrackerMI::AliITSlayer::InRoad() const {
-  //--------------------------------------------------------------------
+  //-------------------------------------------------------------------
   // This function returns number of clusters within the "window" 
   //--------------------------------------------------------------------
   Int_t ncl=0;
@@ -1846,209 +1889,68 @@ Int_t AliITStrackerMI::AliITSlayer::InRoad() const {
   return ncl;
 }
 //------------------------------------------------------------------------
-Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,
-                               const AliITStrackMI *c, Bool_t extra) {
+Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track,
+                               const AliITStrackMI *clusters,Bool_t extra) 
+{
   //--------------------------------------------------------------------
-  // This function refits the track "t" at the position "x" using
-  // the clusters from "c"
+  // This function refits the track "track" at the position "x" using
+  // the clusters from "clusters"
   // If "extra"==kTRUE, 
-  //    the clusters from overlapped modules get attached to "t" 
+  //    the clusters from overlapped modules get attached to "track
   //--------------------------------------------------------------------
 
   Int_t index[AliITSgeomTGeo::kNLayers];
   Int_t k;
   for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) index[k]=-1;
-  Int_t nc=c->GetNumberOfClusters();
+  Int_t nc=clusters->GetNumberOfClusters();
   for (k=0; k<nc; k++) { 
-    Int_t idx=c->GetClusterIndex(k),nl=(idx&0xf0000000)>>28;
-    index[nl]=idx; 
-  }
-
-  // special for cosmics: check which is the innermost layer crossed
-  // by the track
-  Int_t innermostlayer=5;
-  Double_t d = TMath::Abs(t->GetD(0.,0.));
-  for(innermostlayer=0; innermostlayer<AliITSgeomTGeo::GetNLayers(); innermostlayer++)
-    if(d<fgLayers[innermostlayer].GetR()) break;
-  //printf(" d  %f  innermost %d\n",d,innermostlayer);
-
-  Int_t from, to, step;
-  if (xx > t->GetX()) {
-      from=innermostlayer; to=AliITSgeomTGeo::GetNLayers();
-      step=+1;
-  } else {
-      from=AliITSgeomTGeo::GetNLayers()-1; to=innermostlayer-1;
-      step=-1;
+    Int_t idx=clusters->GetClusterIndex(k);
+    Int_t ilayer=(idx&0xf0000000)>>28;
+    index[ilayer]=idx; 
   }
-  TString dir=(step>0 ? "outward" : "inward");
-
-  // loop on the layers
-  for (Int_t ilayer=from; ilayer != to; ilayer += step) {
-     AliITSlayer &layer=fgLayers[ilayer];
-     Double_t r=layer.GetR();
-     // material between SSD and SDD, SDD and SPD
-     Double_t hI=ilayer-0.5*step; 
-     if (TMath::Abs(hI-3.5)<0.01) // SDDouter
-       if(!CorrectForShieldMaterial(t,"SDD",dir)) return kFALSE;
-     if (TMath::Abs(hI-1.5)<0.01) // SPDouter
-       if(!CorrectForShieldMaterial(t,"SPD",dir)) return kFALSE;
-     
-     // remember old position [SR, GSI 18.02.2003]
-     Double_t oldX=0., oldY=0., oldZ=0.;
-     if (t->IsStartedTimeIntegral() && step==1) {
-        t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ);
-     }
-     //
-
-     Double_t oldGlobXYZ[3];
-     t->GetXYZ(oldGlobXYZ);
-
-     Double_t phi,z;
-     if (!t->GetPhiZat(r,phi,z)) return kFALSE;
-
-     Int_t idet=layer.FindDetectorIndex(phi,z);
-
-     // check if we allow a prolongation without point for large-eta tracks
-     Int_t skip = CheckSkipLayer(t,ilayer,idet);
-     if (skip==2) {
-       // propagate to the layer radius
-       Double_t xToGo; t->GetLocalXat(r,xToGo);
-       t->AliExternalTrackParam::PropagateTo(xToGo,GetBz());
-       // apply correction for material of the current layer
-       CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir);
-       // track time update [SR, GSI 17.02.2003]
-       if (t->IsStartedTimeIntegral() && step==1) {
-        Double_t newX, newY, newZ;
-        t->GetGlobalXYZat(t->GetX(),newX,newY,newZ);
-        Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + 
-                       (oldZ-newZ)*(oldZ-newZ);
-        t->AddTimeStep(TMath::Sqrt(dL2));
-       }
-       continue;
-     }
-     
-     if (idet<0) return kFALSE;
-
-     const AliITSdetector &det=layer.GetDetector(idet);
-     phi=det.GetPhi();
-     if (!t->Propagate(phi,det.GetR())) return kFALSE;
-     t->SetDetectorIndex(idet);
-
-     const AliITSRecPoint *cl=0;
-     Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2();
-
-     Int_t idx=index[ilayer];
-     if (idx>=0) {
-        const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); 
-       if (c) {
-         if (idet != c->GetDetectorIndex()) {
-           idet=c->GetDetectorIndex();
-           const AliITSdetector &det=layer.GetDetector(idet);
-           if (!t->Propagate(det.GetPhi(),det.GetR())) {
-             return kFALSE;
-           }
-           t->SetDetectorIndex(idet);
-         }
-         //Double_t chi2=t->GetPredictedChi2(c);
-         Int_t layer = (idx & 0xf0000000) >> 28;;
-         Double_t chi2=GetPredictedChi2MI(t,c,layer);
-         if (chi2<maxchi2) { 
-           cl=c; 
-           maxchi2=chi2; 
-         } else {
-           return kFALSE;
-         }
-       }
-     }
-
-     if (cl) {
-       if (!UpdateMI(t,cl,maxchi2,idx)) return kFALSE;
-       t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1);
-     }
-
-     if (extra) { //search for extra clusters
-        AliITStrackV2 tmp(*t);
-        Double_t dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer));
-        if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl());
-        Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer));
-        if (dy < 0.5*TMath::Abs(tmp.GetSnp())) dy=0.5*TMath::Abs(tmp.GetSnp());
-        Double_t zmin=t->GetZ() - dz;
-        Double_t zmax=t->GetZ() + dz;
-        Double_t ymin=t->GetY() + phi*r - dy;
-        Double_t ymax=t->GetY() + phi*r + dy;
-        layer.SelectClusters(zmin,zmax,ymin,ymax);
-
-        const AliITSRecPoint *c=0; Int_t ci=-1,cci=-1;
-        Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(), tolerance=0.1;
-        while ((c=layer.GetNextCluster(ci))!=0) {
-           if (idet == c->GetDetectorIndex()) continue;
-
-          const AliITSdetector &det=layer.GetDetector(c->GetDetectorIndex());
-
-          if (!tmp.Propagate(det.GetPhi(),det.GetR())) continue;
-           
-          if (TMath::Abs(tmp.GetZ() - c->GetZ()) > tolerance) continue;
-           if (TMath::Abs(tmp.GetY() - c->GetY()) > tolerance) continue;
-
-           Double_t chi2=tmp.GetPredictedChi2(c);
-           if (chi2<maxchi2) { maxchi2=chi2; cci=ci; }
-        }
-        if (cci>=0) t->SetExtraCluster(ilayer,(ilayer<<28)+cci);
-     }
-
-     // track time update [SR, GSI 17.02.2003]
-     if (t->IsStartedTimeIntegral() && step==1) {
-        Double_t newX, newY, newZ;
-        t->GetGlobalXYZat(t->GetX(),newX,newY,newZ);
-        Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + 
-                       (oldZ-newZ)*(oldZ-newZ);
-        t->AddTimeStep(TMath::Sqrt(dL2));
-     }
-     //
 
-     // Correct for material of the current layer
-     if(!CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir)) return kFALSE;
-
-  } // end loop on the layers
-
-  if (!t->PropagateTo(xx,0.,0.)) return kFALSE;
-  return kTRUE;
+  return RefitAt(xx,track,index,extra); // call the method below
 }
 //------------------------------------------------------------------------
-Bool_t 
-AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) {
+Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track,
+                               const Int_t *clusters,Bool_t extra) 
+{
   //--------------------------------------------------------------------
-  // This function refits the track "t" at the position "x" using
+  // This function refits the track "track" at the position "x" using
   // the clusters from array
+  // If "extra"==kTRUE, 
+  //    the clusters from overlapped modules get attached to "track" 
   //--------------------------------------------------------------------
   Int_t index[AliITSgeomTGeo::kNLayers];
   Int_t k;
   for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) index[k]=-1;
   //
   for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) { 
-    index[k]=clindex[k]; 
+    index[k]=clusters[k]; 
   }
 
   // special for cosmics: check which the innermost layer crossed
   // by the track
   Int_t innermostlayer=5;
-  Double_t d = TMath::Abs(t->GetD(0.,0.));
-  for(innermostlayer=0; innermostlayer<AliITSgeomTGeo::GetNLayers(); innermostlayer++)
-    if(d<fgLayers[innermostlayer].GetR()) break;
-  //printf(" d  %f  innermost %d\n",d,innermostlayer);
+  Double_t drphi = TMath::Abs(track->GetD(0.,0.));
+  for(innermostlayer=0; innermostlayer<AliITSgeomTGeo::GetNLayers(); innermostlayer++) {
+    if(drphi < fgLayers[innermostlayer].GetR()) break;
+  }
+  //printf(" drphi  %f  innermost %d\n",drphi,innermostlayer);
 
+  Int_t modstatus=1; // found
+  Float_t xloc,zloc;
   Int_t from, to, step;
-  if (xx > t->GetX()) {
+  if (xx > track->GetX()) {
       from=innermostlayer; to=AliITSgeomTGeo::GetNLayers();
       step=+1;
   } else {
       from=AliITSgeomTGeo::GetNLayers()-1; to=innermostlayer-1;
       step=-1;
   }
-  TString dir=(step>0 ? "outward" : "inward");
+  TString dir = (step>0 ? "outward" : "inward");
 
-  for (Int_t ilayer=from; ilayer != to; ilayer += step) {
+  for (Int_t ilayer = from; ilayer != to; ilayer += step) {
      AliITSlayer &layer=fgLayers[ilayer];
      Double_t r=layer.GetR();
      if (step<0 && xx>r) break;
@@ -2056,97 +1958,163 @@ AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) {
      // material between SSD and SDD, SDD and SPD
      Double_t hI=ilayer-0.5*step; 
      if (TMath::Abs(hI-3.5)<0.01) // SDDouter
-       if(!CorrectForShieldMaterial(t,"SDD",dir)) return kFALSE;
+       if(!CorrectForShieldMaterial(track,"SDD",dir)) return kFALSE;
      if (TMath::Abs(hI-1.5)<0.01) // SPDouter
-       if(!CorrectForShieldMaterial(t,"SPD",dir)) return kFALSE;
+       if(!CorrectForShieldMaterial(track,"SPD",dir)) return kFALSE;
 
      // remember old position [SR, GSI 18.02.2003]
      Double_t oldX=0., oldY=0., oldZ=0.;
-     if (t->IsStartedTimeIntegral() && step==1) {
-        t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ);
+     if (track->IsStartedTimeIntegral() && step==1) {
+        track->GetGlobalXYZat(track->GetX(),oldX,oldY,oldZ);
      }
      //
+
      Double_t oldGlobXYZ[3];
-     t->GetXYZ(oldGlobXYZ);
+     track->GetXYZ(oldGlobXYZ);
 
      Double_t phi,z;
-     if (!t->GetPhiZat(r,phi,z)) return kFALSE;
+     if (!track->GetPhiZat(r,phi,z)) return kFALSE;
 
      Int_t idet=layer.FindDetectorIndex(phi,z);
 
      // check if we allow a prolongation without point for large-eta tracks
-     Int_t skip = CheckSkipLayer(t,ilayer,idet);
+     Int_t skip = CheckSkipLayer(track,ilayer,idet);
      if (skip==2) {
        // propagate to the layer radius
-       Double_t xToGo; t->GetLocalXat(r,xToGo);
-       t->AliExternalTrackParam::PropagateTo(xToGo,GetBz());
+       Double_t xToGo; track->GetLocalXat(r,xToGo);
+       track->AliExternalTrackParam::PropagateTo(xToGo,GetBz());
        // apply correction for material of the current layer
-       CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir);
+       CorrectForLayerMaterial(track,ilayer,oldGlobXYZ,dir);
+       modstatus = 4; // out in z
+       LocalModuleCoord(ilayer,idet,track,xloc,zloc); // local module coords
+       track->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc);
        // track time update [SR, GSI 17.02.2003]
-       if (t->IsStartedTimeIntegral() && step==1) {
+       if (track->IsStartedTimeIntegral() && step==1) {
         Double_t newX, newY, newZ;
-        t->GetGlobalXYZat(t->GetX(),newX,newY,newZ);
+        track->GetGlobalXYZat(track->GetX(),newX,newY,newZ);
         Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + 
                        (oldZ-newZ)*(oldZ-newZ);
-        t->AddTimeStep(TMath::Sqrt(dL2));
+        track->AddTimeStep(TMath::Sqrt(dL2));
        }
        continue;
      }
 
      if (idet<0) return kFALSE;
+
      const AliITSdetector &det=layer.GetDetector(idet);
      phi=det.GetPhi();
-     if (!t->Propagate(phi,det.GetR())) return kFALSE;
-     t->SetDetectorIndex(idet);
+     if (!track->Propagate(phi,det.GetR())) return kFALSE;
+     track->SetDetectorIndex(idet);
+     LocalModuleCoord(ilayer,idet,track,xloc,zloc); // local module coords
 
-     const AliITSRecPoint *cl=0;
+     Double_t dz,zmin,zmax;
+
+     const AliITSRecPoint *clAcc=0;
      Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2();
 
      Int_t idx=index[ilayer];
-     if (idx>=0) {
-        const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); 
-       if (c){
-         if (idet != c->GetDetectorIndex()) {
-           idet=c->GetDetectorIndex();
-           const AliITSdetector &det=layer.GetDetector(idet);
-           if (!t->Propagate(det.GetPhi(),det.GetR())) {
-             return kFALSE;
-           }
-           t->SetDetectorIndex(idet);
-         }
-         //Double_t chi2=t->GetPredictedChi2(c);
-         Int_t layer = (idx & 0xf0000000) >> 28;;
-         Double_t chi2=GetPredictedChi2MI(t,c,layer);
-         if (chi2<maxchi2) { 
-           cl=c; 
-           maxchi2=chi2; 
-         } else {
-           return kFALSE;
-         }
-       }
+     if (idx>=0) { // cluster in this layer
+       modstatus = 6; // no refit
+       const AliITSRecPoint *cl=(AliITSRecPoint *)GetCluster(idx); 
+       if (cl) {
+        if (idet != cl->GetDetectorIndex()) {
+          idet=cl->GetDetectorIndex();
+          const AliITSdetector &det=layer.GetDetector(idet);
+          if (!track->Propagate(det.GetPhi(),det.GetR())) return kFALSE;
+          track->SetDetectorIndex(idet);
+          LocalModuleCoord(ilayer,idet,track,xloc,zloc); // local module coords
+        }
+        //Double_t chi2=track->GetPredictedChi2(cl);
+        Int_t cllayer = (idx & 0xf0000000) >> 28;;
+        Double_t chi2=GetPredictedChi2MI(track,cl,cllayer);
+        if (chi2<maxchi2) { 
+          clAcc=cl; 
+          maxchi2=chi2; 
+          modstatus = 1; // found
+        } else {
+          return kFALSE;
+        }
+       }
+     } else { // no cluster in this layer
+       if (skip==1) {
+        modstatus = 3; // skipped
+       } else {
+        modstatus = 5; // no cls in road
+        // check dead
+        dz=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadZ()*
+                    TMath::Sqrt(track->GetSigmaZ2() + 
+                   AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+                   AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+                   AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer));
+        zmin=track->GetZ() - dz;
+        zmax=track->GetZ() + dz;
+        Int_t dead = CheckDeadZone(ilayer,idet,zmin,zmax);
+        if (dead==1) modstatus = 7; // holes in z in SPD
+        if (dead==2) modstatus = 2; // dead from OCDB
+       }
      }
-
-     if (cl) {
-       if (!UpdateMI(t,cl,maxchi2,idx)) return kFALSE;
-       t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1);
+     
+     if (clAcc) {
+       if (!UpdateMI(track,clAcc,maxchi2,idx)) return kFALSE;
+       track->SetSampledEdx(clAcc->GetQ(),track->GetNumberOfClusters()-1);
      }
-
+     track->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc);
+
+
+     if (extra) { // search for extra clusters in overlapped modules
+       AliITStrackV2 tmp(*track);
+       Double_t dy,ymin,ymax;
+       dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer));
+       if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl());
+       dy=4*TMath::Sqrt(track->GetSigmaY2()+AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer));
+       if (dy < 0.5*TMath::Abs(tmp.GetSnp())) dy=0.5*TMath::Abs(tmp.GetSnp());
+       zmin=track->GetZ() - dz;
+       zmax=track->GetZ() + dz;
+       ymin=track->GetY() + phi*r - dy;
+       ymax=track->GetY() + phi*r + dy;
+       layer.SelectClusters(zmin,zmax,ymin,ymax);
+       
+       const AliITSRecPoint *clExtra=0; Int_t ci=-1,cci=-1;
+       Int_t idetExtra=-1;  
+       Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(), tolerance=0.1;
+       while ((clExtra=layer.GetNextCluster(ci))!=0) {
+        // only clusters in another module! (overlaps)
+        idetExtra = clExtra->GetDetectorIndex();
+        if (idet == idetExtra) continue;
+        
+        const AliITSdetector &det=layer.GetDetector(idetExtra);
+        
+        if (!tmp.Propagate(det.GetPhi(),det.GetR())) continue;
+        
+        if (TMath::Abs(tmp.GetZ() - clExtra->GetZ()) > tolerance) continue;
+        if (TMath::Abs(tmp.GetY() - clExtra->GetY()) > tolerance) continue;
+        
+        Double_t chi2=tmp.GetPredictedChi2(clExtra);
+        if (chi2<maxchi2) { maxchi2=chi2; cci=ci; }
+       }
+       if (cci>=0) {
+        track->SetExtraCluster(ilayer,(ilayer<<28)+cci);
+        track->SetExtraModule(ilayer,idetExtra);
+       }
+     } // end search for extra clusters in overlapped modules
+     
      // Correct for material of the current layer
-     if(!CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir)) return kFALSE;
+     if(!CorrectForLayerMaterial(track,ilayer,oldGlobXYZ,dir)) return kFALSE;
                  
      // track time update [SR, GSI 17.02.2003]
-     if (t->IsStartedTimeIntegral() && step==1) {
+     if (track->IsStartedTimeIntegral() && step==1) {
         Double_t newX, newY, newZ;
-        t->GetGlobalXYZat(t->GetX(),newX,newY,newZ);
+        track->GetGlobalXYZat(track->GetX(),newX,newY,newZ);
         Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + 
                        (oldZ-newZ)*(oldZ-newZ);
-        t->AddTimeStep(TMath::Sqrt(dL2));
+        track->AddTimeStep(TMath::Sqrt(dL2));
      }
      //
 
-  }
+  } // end loop on layers
+
+  if (!track->PropagateTo(xx,0.,0.)) return kFALSE;
 
-  if (!t->PropagateTo(xx,0.,0.)) return kFALSE;
   return kTRUE;
 }
 //------------------------------------------------------------------------
@@ -3565,7 +3533,7 @@ void AliITStrackerMI::UpdateESDtrack(AliITStrackMI* track, ULong_t flags) const
 //------------------------------------------------------------------------
 Int_t AliITStrackerMI::GetNearestLayer(const Double_t *xr) const{
   //
-  //Get nearest upper layer close to the point xr.
+  // Get nearest upper layer close to the point xr.
   // rough approximation 
   //
   const Float_t kRadiuses[6]={4,6.5,15.03,24.,38.5,43.7};
@@ -4826,14 +4794,14 @@ Int_t AliITStrackerMI::CheckSkipLayer(AliITStrackMI *track,
 }
 //------------------------------------------------------------------------
 Int_t AliITStrackerMI::CheckDeadZone(/*AliITStrackMI *track,*/
-                                    Int_t ilayer,/*Int_t idet,*/
+                                    Int_t ilayer,Int_t idet,
                                     Double_t zmin,Double_t zmax/*,Double_t ymin,Double_t ymax*/) const {
   //-----------------------------------------------------------------
   // This method is used to decide whether to allow a prolongation 
-  // without clusters, because there is dead zone in the road.
+  // without clusters, because there is dead zone in the road.
   // In this case the return value is > 0:
   // return 1: dead zone at z=0,+-7cm in SPD
-  // return 2: dead area from the OCDB
+  // return 2: dead area from the OCDB // NOT YET IMPLEMENTED
   //-----------------------------------------------------------------
 
   // check dead zones at z=0,+-7cm in the SPD
@@ -4845,17 +4813,82 @@ Int_t AliITStrackerMI::CheckDeadZone(/*AliITStrackMI *track,*/
                          fSPDdetzcentre[2] - 0.5*AliITSRecoParam::GetSPDdetzlength(),
                          fSPDdetzcentre[3] - 0.5*AliITSRecoParam::GetSPDdetzlength()};
     for (Int_t i=0; i<3; i++)
-      if (zmin<zmaxdead[i] && zmax>zmindead[i]) return 1;
-     
+      if (zmin<zmaxdead[i] && zmax>zmindead[i]) return 1;  
   }
 
-  if (AliITSReconstructor::GetRecoParam()->GetUseDeadZonesFromOCDB()) {
-    // NOT YET IMPLEMENTED
-    // look in OCDB
-    //if (deadfromOCDB) return 2;
+  // check dead zones from OCDB
+  if (!AliITSReconstructor::GetRecoParam()->GetUseDeadZonesFromOCDB()) return 0;
+
+  if(idet<0) return 0;
+
+  // look in OCDB (only entire dead modules for the moment)
+  if (ilayer==0 || ilayer==1) { // SPD
+    AliCDBEntry* cdbEntry = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
+    if (!cdbEntry) {
+      Error("CheckDeadZone","Cannot get CDB entry for SPD\n");
+      return 0;
+    }
+    TObjArray* spdEntry = (TObjArray*)cdbEntry->GetObject();
+    if (!spdEntry) {
+      Error("CheckDeadZone","Cannot get CDB entry for SPD\n");
+      return 0;
+    }
+    if(ilayer==1) idet += AliITSgeomTGeo::GetNLadders(1)*AliITSgeomTGeo::GetNDetectors(1);
+    //printf("SPD det: %d\n",idet);
+    AliITSCalibrationSPD *calibSPD = (AliITSCalibrationSPD*)spdEntry->At(idet);
+    if (calibSPD->IsBad()) return 2;
+  } else if (ilayer==2 || ilayer==3) { // SDD
+    AliCDBEntry* cdbEntry = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
+    if (!cdbEntry) {
+      Error("CheckDeadZone","Cannot get CDB entry for SDD\n");
+      return 0;
+    }
+    TObjArray* sddEntry = (TObjArray*)cdbEntry->GetObject();
+    if (!sddEntry) {
+      Error("CheckDeadZone","Cannot get CDB entry for SDD\n");
+      return 0;
+    }
+    if(ilayer==3) idet += AliITSgeomTGeo::GetNLadders(3)*AliITSgeomTGeo::GetNDetectors(3);
+    //printf("SDD det: %d\n",idet);
+    AliITSCalibrationSDD *calibSDD = (AliITSCalibrationSDD*)sddEntry->At(idet);
+    if (calibSDD->IsDead()) return 2;
+  } else if (ilayer==4 || ilayer==5) { // SSD
+  } else {
+    Error("CheckDeadZone","Wrong layer number\n");
+    if(ilayer==5) idet += AliITSgeomTGeo::GetNLadders(5)*AliITSgeomTGeo::GetNDetectors(5);
+    return 0;
   }
 
   return 0;
 }
 //------------------------------------------------------------------------
+Bool_t AliITStrackerMI::LocalModuleCoord(Int_t ilayer,Int_t idet,
+                                      AliITStrackMI *track,
+                                      Float_t &xloc,Float_t &zloc) const {
+  //-----------------------------------------------------------------
+  // Gives position of track in local module ref. frame
+  //-----------------------------------------------------------------
+
+  xloc=0.; 
+  zloc=0.;
+
+  if(idet<0) return kFALSE;
+
+  Int_t ndet=AliITSgeomTGeo::GetNDetectors(ilayer+1); // layers from 1 to 6 
+
+  Int_t lad = Int_t(idet/ndet) + 1;
 
+  Int_t det = idet - (lad-1)*ndet + 1;
+
+  Double_t xyzGlob[3],xyzLoc[3];
+
+  track->GetXYZ(xyzGlob);
+
+  AliITSgeomTGeo::GlobalToLocal(ilayer+1,lad,det,xyzGlob,xyzLoc);
+
+  xloc = (Float_t)xyzLoc[0];
+  zloc = (Float_t)xyzLoc[2];
+
+  return kTRUE;
+}
+//------------------------------------------------------------------------
index 9c9ab1b3f56a7f3b5bb9c13701a06c31bb815432..33dbc3703f8719e7c87cc43173076dec737f76b3 100644 (file)
@@ -18,8 +18,8 @@ class AliESDEvent;
 #include <TObjArray.h>
 #include "AliITSRecPoint.h"
 #include "AliITStrackMI.h"
-#include "AliTracker.h"
 #include "AliITSPlaneEff.h"
+#include "AliTracker.h"
 
 //-------------------------------------------------------------------------
 class AliITStrackerMI : public AliTracker {
@@ -40,9 +40,10 @@ public:
   Int_t Clusters2Tracks(AliESDEvent *event);
   Int_t PropagateBack(AliESDEvent *event);
   Int_t RefitInward(AliESDEvent *event);
-  Bool_t RefitAt(Double_t x, AliITStrackMI *seed, 
-                const AliITStrackMI *t, Bool_t extra=kFALSE);
-  Bool_t RefitAt(Double_t x, AliITStrackMI *seed, const Int_t *clindex);
+  Bool_t RefitAt(Double_t x, AliITStrackMI *track, 
+                const AliITStrackMI *clusters, Bool_t extra=kFALSE);
+  Bool_t RefitAt(Double_t x, AliITStrackMI *track, 
+                const Int_t *clusters, Bool_t extra=kFALSE);
   void SetupFirstPass(Int_t *flags, Double_t *cuts=0);
   void SetupSecondPass(Int_t *flags, Double_t *cuts=0);
 
@@ -89,7 +90,7 @@ public:
     void ResetClusters();
     void ResetWeights();
     void SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin,Double_t ymax);
-    const AliITSRecPoint *GetNextCluster(Int_t &ci);
+    const AliITSRecPoint *GetNextCluster(Int_t &ci,Bool_t test=kFALSE);
     void ResetRoad();
     Double_t GetRoad() const {return fRoad;}
     Double_t GetR() const {return fR;}
@@ -221,7 +222,9 @@ protected:
   Int_t CorrectForLayerMaterial(AliITStrackMI *t, Int_t layerindex, Double_t oldGlobXYZ[3], TString direction="inward");
   void UpdateESDtrack(AliITStrackMI* track, ULong_t flags) const;
   Int_t CheckSkipLayer(AliITStrackMI *track,Int_t ilayer,Int_t idet) const;
-  Int_t CheckDeadZone(/*AliITStrackMI *track,*/Int_t ilayer,/*Int_t idet,*/Double_t zmin,Double_t zmax/*,Double_t ymin,Double_t ymax*/) const;
+  Int_t CheckDeadZone(/*AliITStrackMI *track,*/Int_t ilayer,Int_t idet,Double_t zmin,Double_t zmax/*,Double_t ymin,Double_t ymax*/) const;
+  Bool_t LocalModuleCoord(Int_t ilayer,Int_t idet,AliITStrackMI *track,
+                         Float_t &xloc,Float_t &zloc) const;
   Int_t fI;                              // index of the current layer
   static AliITSlayer fgLayers[AliITSgeomTGeo::kNLayers];// ITS layers
   AliITStrackMI fTracks[AliITSgeomTGeo::kNLayers];      // track estimations at the ITS layers
@@ -256,8 +259,7 @@ protected:
   Float_t *fxOverX0LayerTrks;            //! material budget
   Float_t *fxTimesRhoLayerTrks;          //! material budget
   TTreeSRedirector *fDebugStreamer;      //!debug streamer
-//
-  AliITSPlaneEff *fPlaneEff;             //| Pointer to the ITS plane efficicency
+  AliITSPlaneEff *fPlaneEff;             //! Pointer to the ITS plane efficicency
 private:
   AliITStrackerMI(const AliITStrackerMI &tracker);
   AliITStrackerMI & operator=(const AliITStrackerMI &tracker);
@@ -267,8 +269,6 @@ private:
 
 
 
-
-
 /////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////