]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerMI.cxx
Bug fix: adding SHLIB to SYSLIBS (C.Holm)
[u/mrichter/AliRoot.git] / ITS / AliITStrackerMI.cxx
index 7756b16b118605fff66ab220baac5944729914c4..97cc085c21f050df658e7353ea8a79913ff2aaf1 100644 (file)
@@ -31,7 +31,6 @@
 #include <TString.h>
 #include <TRandom.h>
 
-
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
 #include "AliESDVertex.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 "AliITSPlaneEff.h"
+#include "AliITSPlaneEffSPD.h"
+#include "AliITSPlaneEffSDD.h"
+#include "AliITSPlaneEffSSD.h"
 #include "AliITStrackerMI.h"
 
 ClassImp(AliITStrackerMI)
@@ -205,6 +207,23 @@ fPlaneEff(0) {
   
   fDebugStreamer = new TTreeSRedirector("ITSdebug.root");
 
+  // only for plane efficiency evaluation
+  if (AliITSReconstructor::GetRecoParam()->GetComputePlaneEff()) {
+    for(Int_t ilay=0;ilay<6;ilay++) { 
+      if(AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilay)) {
+        if (ilay<2) fPlaneEff = new AliITSPlaneEffSPD();
+        else if (ilay<4) fPlaneEff = new AliITSPlaneEffSDD();
+        else fPlaneEff = new AliITSPlaneEffSSD();
+        break; // only one layer type to skip at once
+      }
+    }
+    if(AliITSReconstructor::GetRecoParam()->GetReadPlaneEffFromOCDB())
+       if(!fPlaneEff->ReadFromCDB()) {AliWarning("AliITStrackerMI reading of AliITSPlaneEff from OCDB failed") ;}
+    if(AliITSReconstructor::GetRecoParam()->GetHistoPlaneEff()) {
+      fPlaneEff->SetCreateHistos(kTRUE); 
+      //fPlaneEff->ReadHistosFromFile();
+    }
+  }
 }
 //------------------------------------------------------------------------
 AliITStrackerMI::AliITStrackerMI(const AliITStrackerMI &tracker):AliTracker(tracker),
@@ -383,6 +402,8 @@ Int_t AliITStrackerMI::Clusters2Tracks(AliESDEvent *event) {
   // This functions reconstructs ITS tracks
   // The clusters must be already loaded !
   //--------------------------------------------------------------------
+
+
   fTrackingPhase="Clusters2Tracks";
 
   TObjArray itsTracks(15000);
@@ -502,11 +523,9 @@ Int_t AliITStrackerMI::Clusters2Tracks(AliESDEvent *event) {
      GetBestHypothesysMIP(itsTracks); 
   } // end loop on the two tracking passes
 
-  //GetBestHypothesysMIP(itsTracks);
   if(event->GetNumberOfV0s()>0) UpdateTPCV0(event);
   if(AliITSReconstructor::GetRecoParam()->GetFindV0s()) FindV02(event);
   fAfterV0 = kTRUE;
-  //GetBestHypothesysMIP(itsTracks);
   //
   itsTracks.Delete();
   //
@@ -632,7 +651,8 @@ Int_t AliITStrackerMI::RefitInward(AliESDEvent *event) {
       fTrackToFollow.ResetCovariance(10.);
 
     //Refitting...
-    if (RefitAt(AliITSRecoParam::GetrInsideSPD1(),&fTrackToFollow,t,kTRUE)) {
+    Bool_t pe=AliITSReconstructor::GetRecoParam()->GetComputePlaneEff();
+    if (RefitAt(AliITSRecoParam::GetrInsideSPD1(),&fTrackToFollow,t,kTRUE,pe)) {
        fTrackToFollow.SetLabel(t->GetLabel());
        //       fTrackToFollow.CookdEdx();
        CookdEdx(&fTrackToFollow);
@@ -1890,13 +1910,15 @@ Int_t AliITStrackerMI::AliITSlayer::InRoad() const {
 }
 //------------------------------------------------------------------------
 Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track,
-                               const AliITStrackMI *clusters,Bool_t extra) 
+                               const AliITStrackMI *clusters,Bool_t extra, Bool_t planeeff
 {
   //--------------------------------------------------------------------
   // 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 "track" 
+  // If "planeff"==kTRUE,
+  //    special approach for plane efficiency evaluation is applyed
   //--------------------------------------------------------------------
 
   Int_t index[AliITSgeomTGeo::kNLayers];
@@ -1909,17 +1931,19 @@ Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track,
     index[ilayer]=idx; 
   }
 
-  return RefitAt(xx,track,index,extra); // call the method below
+  return RefitAt(xx,track,index,extra,planeeff); // call the method below
 }
 //------------------------------------------------------------------------
 Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track,
-                               const Int_t *clusters,Bool_t extra) 
+                               const Int_t *clusters,Bool_t extra, Bool_t planeeff
 {
   //--------------------------------------------------------------------
   // 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" 
+  // If "planeff"==kTRUE,
+  //    special approach for plane efficiency evaluation is applyed
   //--------------------------------------------------------------------
   Int_t index[AliITSgeomTGeo::kNLayers];
   Int_t k;
@@ -2032,12 +2056,17 @@ Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track,
           maxchi2=chi2; 
           modstatus = 1; // found
         } else {
-          return kFALSE;
+           return kFALSE; //
         }
        }
      } else { // no cluster in this layer
        if (skip==1) {
         modstatus = 3; // skipped
+         // Plane Eff determination: 
+         if (planeeff && AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilayer)) { 
+           if (IsOKForPlaneEff(track,ilayer))  // only adequate track for plane eff. evaluation
+              UseTrackForPlaneEff(track,ilayer); 
+         }
        } else {
         modstatus = 5; // no cls in road
         // check dead
@@ -2827,7 +2856,8 @@ void AliITStrackerMI::AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex)
   // add track to the list of hypothesys
   //------------------------------------------------------------------
 
-  if (esdindex>=fTrackHypothesys.GetEntriesFast()) fTrackHypothesys.Expand(esdindex*2+10);
+  if (esdindex>=fTrackHypothesys.GetEntriesFast()) 
+    fTrackHypothesys.Expand(TMath::Max(fTrackHypothesys.GetSize(),esdindex*2+10));
   //
   TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
   if (!array) {
@@ -3108,7 +3138,8 @@ AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI
   delete forwardtrack;
   Int_t accepted=0;
   for (Int_t i=0;i<entries;i++){    
-    AliITStrackMI * track = (AliITStrackMI*)array->At(i);   
+    AliITStrackMI * track = (AliITStrackMI*)array->At(i);
+   
     if (!track) continue;
     
     if (accepted>checkmax || track->GetChi2MIP(3)>AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3)*6. || 
@@ -3126,6 +3157,7 @@ AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI
   //
   array->Compress();
   SortTrackHypothesys(esdindex,checkmax,1);
+
   array = (TObjArray*) fTrackHypothesys.At(esdindex);
   if (!array) return 0; // PH What can be the reason? Check SortTrackHypothesys
   besttrack = (AliITStrackMI*)array->At(0);  
@@ -3428,12 +3460,14 @@ Int_t AliITStrackerMI::UpdateMI(AliITStrackMI* track, const AliITSRecPoint* cl,D
 
   if (cl->GetQ()<=0) return 0;  // ingore the "virtual" clusters
 
-  //Float_t clxyz[3]; cl->GetGlobalXYZ(clxyz);Double_t trxyz[3]; track->GetXYZ(trxyz);printf("gtr %f %f %f\n",trxyz[0],trxyz[1],trxyz[2]);printf("gcl %f %f %f\n",clxyz[0],clxyz[1],clxyz[2]);
+  //  Float_t clxyz[3]; cl->GetGlobalXYZ(clxyz);Double_t trxyz[3]; track->GetXYZ(trxyz);//printf("gtr %f %f %f\n",trxyz[0],trxyz[1],trxyz[2]);printf("gcl %f %f %f\n",clxyz[0],clxyz[1],clxyz[2]);
 
 
   // Take into account the mis-alignment
   Double_t x=track->GetX()+cl->GetX();
   if (!track->PropagateTo(x,0.,0.)) return 0;
+
+
   
   AliCluster c(*cl);
   c.SetSigmaY2(track->GetSigmaY(layer)*track->GetSigmaY(layer));
@@ -4860,7 +4894,7 @@ Int_t AliITStrackerMI::CheckDeadZone(/*AliITStrackMI *track,*/
     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;
+    if (calibSDD->IsBad()) return 2;
   } else if (ilayer==4 || ilayer==5) { // SSD
   } else {
     Error("CheckDeadZone","Wrong layer number\n");
@@ -4901,3 +4935,275 @@ Bool_t AliITStrackerMI::LocalModuleCoord(Int_t ilayer,Int_t idet,
   return kTRUE;
 }
 //------------------------------------------------------------------------
+Bool_t AliITStrackerMI::IsOKForPlaneEff(AliITStrackMI* track, Int_t ilayer) const {
+// Method still to be implemented: 
+//
+// it will apply a pre-selection to obtain good quality tracks.  
+// Here also  you will have the possibility to put a control on the 
+// impact point of the track on the basic block, in order to exclude border regions 
+// this will be done by calling a proper method of the AliITSPlaneEff class.  
+//
+// input: AliITStrackMI* track, ilayer= layer number [0,5]
+// output: Bool_t   -> kTRUE 2f usable track, kFALSE if not usable. 
+  if(!fPlaneEff) 
+    {AliWarning("IsOKForPlaneEff: null pointer to AliITSPlaneEff"); return kFALSE;}
+  AliITSlayer &layer=fgLayers[ilayer];
+  Double_t r=layer.GetR();
+  //AliITStrackV2 tmp(*track);
+  AliITStrackMI tmp(*track);
+
+// detector number
+  Double_t phi,z;
+  if (!tmp.GetPhiZat(r,phi,z)) return kFALSE;
+  Int_t idet=layer.FindDetectorIndex(phi,z);
+  if(idet<0) { AliInfo(Form("cannot find detector"));
+    return kFALSE;}
+
+  // here check if it has good Chi Square.
+
+  //propagate to the intersection with the detector plane
+  const AliITSdetector &det=layer.GetDetector(idet);
+  if (!tmp.Propagate(det.GetPhi(),det.GetR())) return kFALSE;
+
+  Float_t locx; //
+  Float_t locz; //
+  LocalModuleCoord(ilayer,idet,&tmp,locx,locz);
+  UInt_t key=fPlaneEff->GetKeyFromDetLocCoord(ilayer,idet,locx,locz);
+  if(key>fPlaneEff->Nblock()) return kFALSE;
+  Float_t blockXmn,blockXmx,blockZmn,blockZmx;
+  if (!fPlaneEff->GetBlockBoundaries(key,blockXmn,blockXmx,blockZmn,blockZmx)) return kFALSE;
+  // transform Local boundaries of the basic block into 
+  //  Global (i.e. ALICE, not tracking reference) coordinate
+  //
+  Double_t a1[3]={blockXmn,0.,blockZmn};
+  Double_t a2[3]={blockXmx,0.,blockZmn};
+  Double_t a3[3]={blockXmn,0.,blockZmx};
+  Int_t ndet=AliITSgeomTGeo::GetNDetectors(ilayer+1); // layers from 1 to 6
+  Int_t lad = Int_t(idet/ndet) + 1;
+  Int_t hdet = idet - (lad-1)*ndet + 1;
+  Double_t xyzGlob[3];
+  AliITSgeomTGeo::LocalToGlobal(ilayer+1,lad,hdet,a1,a1);
+  AliITSgeomTGeo::LocalToGlobal(ilayer+1,lad,hdet,a2,a2);
+  AliITSgeomTGeo::LocalToGlobal(ilayer+1,lad,hdet,a3,a3);
+  Double_t gBlockYmn,gBlockYmx,gBlockZmn,gBlockZmx;
+  if(a1[1]>a2[1]) {gBlockYmn=a2[1]; gBlockYmx=a1[1];}
+  else            {gBlockYmn=a1[1]; gBlockYmx=a2[1];}
+  if(a2[2]>a3[2]) {gBlockZmn=a3[2]; gBlockZmx=a2[2];}
+  else            {gBlockZmn=a2[2]; gBlockZmx=a3[2];}
+  AliDebug(2,Form("Boundaries in Global system Ymin=%f, Ymax=%f, Zmin=%f, Zmax=%f", 
+           gBlockYmn,gBlockYmx,gBlockZmn,gBlockZmx));
+
+  //***************
+  // DEFINITION OF SEARCH ROAD FOR accepting a track 
+  //
+  //For the time being they are hard-wired, later on from AliITSRecoParam
+  Double_t dz=4.*TMath::Sqrt(tmp.GetSigmaZ2());  // those are precisions in the tracking reference system
+  Double_t dy=4.*TMath::Sqrt(tmp.GetSigmaY2());  // dy needs to be reduced (it is max now) if you do  
+                                                 // comparison in Global Reference system 
+  Float_t gdz=dz;
+  Float_t gdy=dy*TMath::Abs(TMath::Cos(tmp.GetAlpha()));
+
+ // exclude tracks at boundary between detectors
+  //Double_t boundaryWidth=AliITSRecoParam::GetBoundaryWidth();
+  Double_t boundaryWidth=0; // for the time being hard-wired, later on from AliITSRecoParam
+  AliDebug(2,Form("Tracking: track impact x=%f, y=%f, z=%f",tmp.GetX(), tmp.GetY(), tmp.GetZ()));
+  tmp.GetXYZ(xyzGlob);
+  AliDebug(2,Form("Global:   track impact x=%f, y=%f, z=%f",xyzGlob[0],xyzGlob[1],xyzGlob[2]));
+  //AliInfo(Form("TEST GLOBAL track y = %f, z=%f",tmp.GetY(),tmp.GetZ()));
+  AliDebug(2,Form("Search Road. Tracking: dy=%f , dz=%f",dy,dz));
+  AliDebug(2,Form("Search Road. Global: Gdy=%f , Gdz=%f",gdy,gdz));
+  if ( (xyzGlob[1]-gdy < gBlockYmn+boundaryWidth) ||
+       (xyzGlob[1]+gdy > gBlockYmx-boundaryWidth) ||
+       (xyzGlob[2]-gdz < gBlockZmn+boundaryWidth) ||
+       (xyzGlob[2]+gdz > gBlockZmx-boundaryWidth) ) return kFALSE;
+
+  return kTRUE;
+}
+//------------------------------------------------------------------------
+void AliITStrackerMI::UseTrackForPlaneEff(AliITStrackMI* track, Int_t ilayer) {
+//
+// This Method has to be optimized! For the time-being it uses the same criteria
+// as those used in the search of extra clusters for overlapping modules.
+//
+// Method Purpose: estabilish whether a track has produced a recpoint or not
+//                 in the layer under study (For Plane efficiency)
+//
+// inputs: AliITStrackMI* track  (pointer to a usable track)
+// outputs: none
+// side effects: update (by 1 count) the Plane Efficiency statistics of the basic block
+//               traversed by this very track. In details:
+//               - if a cluster can be associated to the track then call
+//                  AliITSPlaneEff::UpDatePlaneEff(key,kTRUE);
+//               - if not, the AliITSPlaneEff::UpDatePlaneEff(key,kFALSE) is called
+//
+  if(!fPlaneEff)
+    {AliWarning("UseTrackForPlaneEff: null pointer to AliITSPlaneEff"); return;}
+  AliITSlayer &layer=fgLayers[ilayer];
+  Double_t r=layer.GetR();
+  //AliITStrackV2 tmp(*track);
+  AliITStrackMI tmp(*track);
+
+// detector number
+  Double_t phi,z;
+  if (!tmp.GetPhiZat(r,phi,z)) return;
+  Int_t idet=layer.FindDetectorIndex(phi,z);
+
+  if(idet<0) { AliInfo(Form("cannot find detector"));
+    return;}
+
+  //Double_t trackGlobXYZ1[3];
+  //tmp.GetXYZ(trackGlobXYZ1);
+
+//propagate to the intersection with the detector plane
+  const AliITSdetector &det=layer.GetDetector(idet);
+  if (!tmp.Propagate(det.GetPhi(),det.GetR())) return;
+
+  //Float_t xloc,zloc;
+
+//***************
+// DEFINITION OF SEARCH ROAD FOR CLUSTERS SELECTION
+//
+  Double_t dz=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadZ()*
+                    TMath::Sqrt(tmp.GetSigmaZ2() +
+                    AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+                    AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+                    AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer));
+  Double_t dy=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadY()*
+                    TMath::Sqrt(tmp.GetSigmaY2() +
+                    AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+                    AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+                    AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer));
+
+// road in global (rphi,z) [i.e. in tracking ref. system]
+  Double_t zmin = tmp.GetZ() - dz;
+  Double_t zmax = tmp.GetZ() + dz;
+  Double_t ymin = tmp.GetY() + r*det.GetPhi() - dy;
+  Double_t ymax = tmp.GetY() + r*det.GetPhi() + dy;
+
+// select clusters in road
+  layer.SelectClusters(zmin,zmax,ymin,ymax);
+
+// Define criteria for track-cluster association
+  Double_t msz = tmp.GetSigmaZ2() +
+  AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+  AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+  AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer);
+  Double_t msy = tmp.GetSigmaY2() +
+  AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+  AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+  AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer);
+  if (tmp.GetConstrain()) {
+    msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZC();
+    msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYC();
+  }  else {
+    msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZNonC();
+    msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYNonC();
+  }
+  msz = 1./msz; // 1/RoadZ^2
+  msy = 1./msy; // 1/RoadY^2
+//
+
+  const AliITSRecPoint *cl=0; Int_t clidx=-1, ci=-1;
+  Int_t idetc=-1;
+  Double_t chi2trkcl=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2();
+  //Double_t  tolerance=0.2;
+  /*while ((cl=layer.GetNextCluster(clidx))!=0) {
+    idetc = cl->GetDetectorIndex();
+    if(idet!=idetc) continue;
+    //Int_t ilay = cl->GetLayer();
+
+    if (TMath::Abs(tmp.GetZ() - cl->GetZ()) > tolerance) continue;
+    if (TMath::Abs(tmp.GetY() - cl->GetY()) > tolerance) continue;
+
+    Double_t chi2=tmp.GetPredictedChi2(cl);
+    if (chi2<chi2trkcl) { chi2trkcl=chi2; ci=clidx; }
+  }*/
+  Float_t locx; //
+  Float_t locz; //
+  LocalModuleCoord(ilayer,idet,&tmp,locx,locz);
+//
+  AliDebug(2,Form("ilayer= %d, idet=%d, x= %f, z=%f",ilayer,idet,locx,locz));
+  UInt_t key=fPlaneEff->GetKeyFromDetLocCoord(ilayer,idet,locx,locz);
+  if(key>fPlaneEff->Nblock()) return;
+  Bool_t found=kFALSE;
+  //if (ci>=0) {
+  Double_t chi2;
+  while ((cl=layer.GetNextCluster(clidx))!=0) {
+    idetc = cl->GetDetectorIndex();
+    if(idet!=idetc) continue;
+    // here real control to see whether the cluster can be associated to the track.
+    // cluster not associated to track
+    if ( (tmp.GetZ()-cl->GetZ())*(tmp.GetZ()-cl->GetZ())*msz +
+         (tmp.GetY()-cl->GetY())*(tmp.GetY()-cl->GetY())*msy   > 1. ) continue;
+    // calculate track-clusters chi2
+    chi2 = GetPredictedChi2MI(&tmp,cl,ilayer); // note that this method change track tmp
+                                               // in particular, the error associated to the cluster 
+    //Double_t chi2 = tmp.GetPredictedChi(cl); // this method does not change track tmp
+    // chi2 cut
+    if (chi2 > AliITSReconstructor::GetRecoParam()->GetMaxChi2s(ilayer)) continue;
+    found=kTRUE;
+    if (chi2<chi2trkcl) { chi2trkcl=chi2; ci=clidx; } // this just to trace which cluster is selected
+   // track->SetExtraCluster(ilayer,(ilayer<<28)+ci);
+   // track->SetExtraModule(ilayer,idetExtra);
+  }
+  if(!fPlaneEff->UpDatePlaneEff(found,key))
+       AliWarning(Form("UseTrackForPlaneEff: cannot UpDate PlaneEff for key=%d",key));
+  if(fPlaneEff->GetCreateHistos()&&  AliITSReconstructor::GetRecoParam()->GetHistoPlaneEff()) {
+    Float_t tr[4]={99999.,99999.,9999.,9999.};    // initialize to high values 
+    Float_t clu[4]={-99999.,-99999.,9999.,9999.}; // (in some cases GetCov fails) 
+    Int_t cltype[2]={-999,-999};
+    Int_t ndet=AliITSgeomTGeo::GetNDetectors(ilayer+1); // layers from 1 to 6
+    Int_t lad = Int_t(idet/ndet) + 1;
+    Int_t hdet = idet - (lad-1)*ndet + 1;
+    Double_t xyzGlob[3],xyzLoc[3],cv[21],exyzLoc[3],exyzGlob[3];
+    if(tmp.GetXYZ(xyzGlob)) {
+      if (AliITSgeomTGeo::GlobalToLocal(ilayer+1,lad,hdet,xyzGlob,xyzLoc)) {
+        tr[0]=xyzLoc[0];
+        tr[1]=xyzLoc[2];
+      }
+    }
+    if(tmp.GetCovarianceXYZPxPyPz(cv)) {
+      exyzGlob[0]=TMath::Sqrt(cv[0]);
+      exyzGlob[1]=TMath::Sqrt(cv[2]);
+      exyzGlob[2]=TMath::Sqrt(cv[5]);
+      if (AliITSgeomTGeo::GlobalToLocalVect(AliITSgeomTGeo::GetModuleIndex(ilayer+1,lad,hdet),exyzGlob,exyzLoc)) { 
+        tr[2]=TMath::Abs(exyzLoc[0]);
+        tr[3]=TMath::Abs(exyzLoc[2]);
+      }
+    }
+    if (found){
+      clu[0]=layer.GetCluster(ci)->GetDetLocalX();
+      clu[1]=layer.GetCluster(ci)->GetDetLocalZ();
+      cltype[0]=layer.GetCluster(ci)->GetNy();
+      cltype[1]=layer.GetCluster(ci)->GetNz();
+     
+     // Without the following 6 lines you would retrieve the nominal error of a cluster (e.g. for the SPD:
+     //  X->50/sqrt(12)=14 micron   Z->450/sqrt(12)= 120 micron) 
+     // Within AliTrackerMI/AliTrackMI the error on the cluster is associated to the AliITStrackMI (fSigmaY,Z)
+     // It is computed properly by calling the method 
+     // AliITStrackerMI::GetPredictedChi2MI(AliITStrackMI* track, const AliITSRecPoint *cluster,Int_t layer)
+     // T
+     //Double_t x=0.5*(tmp.GetX()+layer.GetCluster(ci)->GetX()); // Take into account the mis-alignment
+      //if (tmp.PropagateTo(x,0.,0.)) {
+        chi2=GetPredictedChi2MI(&tmp,layer.GetCluster(ci),ilayer);
+        AliCluster c(*layer.GetCluster(ci));
+        c.SetSigmaY2(tmp.GetSigmaY(ilayer)*tmp.GetSigmaY(ilayer));
+        c.SetSigmaZ2(tmp.GetSigmaZ(ilayer)*tmp.GetSigmaZ(ilayer));
+        Float_t cov[6];
+        //if (layer.GetCluster(ci)->GetGlobalCov(cov))  // by using this, instead, you got nominal cluster errors
+        if (c.GetGlobalCov(cov)) 
+        {
+          exyzGlob[0]=TMath::Sqrt(cov[0]);
+          exyzGlob[1]=TMath::Sqrt(cov[3]);
+          exyzGlob[2]=TMath::Sqrt(cov[5]);
+          if (AliITSgeomTGeo::GlobalToLocalVect(AliITSgeomTGeo::GetModuleIndex(ilayer+1,lad,hdet),exyzGlob,exyzLoc)) {
+            clu[2]=TMath::Abs(exyzLoc[0]);  
+            clu[3]=TMath::Abs(exyzLoc[2]);  
+          }
+        }
+      //}
+    }
+    fPlaneEff->FillHistos(key,found,tr,clu,cltype);
+  }
+return;
+}