]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerMI.cxx
Bug fix in method RefitAt: the cluster with index 0 was rejected (A. Dainese)
[u/mrichter/AliRoot.git] / ITS / AliITStrackerMI.cxx
index 3ec35bf09aadb150880e2bc8da48d02218011896..0323d1f4ac46e8b043d0bf9415d242fb868beb03 100644 (file)
@@ -61,7 +61,7 @@ fDebugStreamer(0){
 }
 
 
-AliITStrackerMI::AliITStrackerMI(const AliITSgeomTGeo *geom) : AliTracker(),
+AliITStrackerMI::AliITStrackerMI(const Char_t *geom) : AliTracker(),
 fI(kMaxLayer),
 fBestTrack(),
 fTrackToFollow(),
@@ -108,19 +108,16 @@ fDebugStreamer(0){
     for (Int_t j=1; j<nlad+1; j++) {
       for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors
         TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m);
-        Double_t *xyz=m.GetTranslation(), x=xyz[0], y=xyz[1];
-        Double_t *rot=m.GetRotationMatrix(); 
-
-        Double_t phi=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
-        phi+=TMath::Pi()/2;
-        if (i==1) phi+=TMath::Pi();
+        const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k);
+        m.Multiply(tm);
+        Double_t txyz[3]={0.}, xyz[3]={0.};
+        m.LocalToMaster(txyz,xyz);
+        Double_t r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+        Double_t phi=TMath::ATan2(xyz[1],xyz[0]);
 
         if (phi<0) phi+=TMath::TwoPi();
         else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi();
 
-        Double_t cp=TMath::Cos(phi), sp=TMath::Sin(phi);
-        Double_t r=x*cp+y*sp;
-
         AliITSdetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1); 
         new(&det) AliITSdetector(r,phi); 
       } 
@@ -212,17 +209,12 @@ Int_t AliITStrackerMI::LoadClusters(TTree *cTree) {
       if (!cTree->GetEvent(j)) continue;
       Int_t ncl=clusters->GetEntriesFast();
       SignDeltas(clusters,GetZ());
       while (ncl--) {
         AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl);
+        detector=c->GetDetectorIndex();
 
-       detector = c->GetDetectorIndex();
-        AliITSdetector &det=fgLayers[i].GetDetector(detector);
-   
-        //Shift the cluster to the misaligned position (temporary solution)
-        Double_t x=det.GetR();
-        if      (i==0) x-=0.0075; 
-        else if (i==1) x+=0.0075;
-        c->SetX(x);           
+       if (!c->Misalign()) AliWarning("Can't misalign this cluster !");
 
         fgLayers[i].InsertCluster(new AliITSRecPoint(*c));
       }
@@ -231,7 +223,7 @@ Int_t AliITStrackerMI::LoadClusters(TTree *cTree) {
       if (i<2){
        for (Float_t ydead = 0; ydead < 1.31 ; ydead+=(i+1.)*0.018){     
          Int_t lab[4] = {0,0,0,detector};
-         Int_t info[3] = {0,0,0};
+         Int_t info[3] = {0,0,i};
          Float_t hit[5]={0,0,0.004/12.,0.001/12.,0};
          if (i==0) hit[0] =ydead-0.4;
          if (i==1) hit[0]=ydead-3.75; 
@@ -586,62 +578,22 @@ AliCluster *AliITStrackerMI::GetCluster(Int_t index) const {
   return fgLayers[l].GetCluster(c);
 }
 
-#include "TGeoManager.h"
-#include "TGeoMatrix.h"
-#include "TGeoPhysicalNode.h"
-
 Bool_t AliITStrackerMI::GetTrackPoint(Int_t index, AliTrackPoint& p) const {
   //
   // Get track space point with index i
   //
+
   Int_t l=(index & 0xf0000000) >> 28;
   Int_t c=(index & 0x0fffffff) >> 00;
   AliITSRecPoint *cl = fgLayers[l].GetCluster(c);
   Int_t idet = cl->GetDetectorIndex();
 
-  const char* name = AliAlignObj::SymName((AliAlignObj::ELayerID)
-                                         (l+AliAlignObj::kFirstLayer), idet);
-  TGeoPNEntry *mapPN = gGeoManager->GetAlignableEntry(name);
+  Float_t xyz[3];
+  Float_t cov[6];
+  cl->GetGlobalXYZ(xyz);
+  cl->GetGlobalCov(cov);
+  p.SetXYZ(xyz, cov);
 
-  if (!mapPN) return kFALSE;
-  TGeoPhysicalNode *node = mapPN->GetPhysicalNode();
-  if (!node) {
-    gGeoManager->MakeAlignablePN(name);
-    node = mapPN->GetPhysicalNode();
-  }
-  if (!node) return kFALSE;
-  TGeoHMatrix* matrix = node->GetMatrix();
-  if (!matrix) return kFALSE;
-
-  //
-  // Calculate the global coordinates
-  //
-  Double_t localCoord[]  = {cl->GetDetLocalX(), 0, cl->GetDetLocalZ()};
-  // LG  AliAlignObj makes life simple but keep in mind that alignable
-  // LG  volume doesn't mean sensitive volume. There might be a shift
-  // LG  between the 2, has it is here for the SPD :
-  if (l<2) localCoord[1] = 0.01;
-  // LG   !!!   Check for this when the new geometry comes   !!!
-  Double_t globalCoord[3] = {0};
-  matrix->LocalToMaster(localCoord, globalCoord);
-  Float_t xyz[3]= {globalCoord[0], globalCoord[1], globalCoord[2]};
-
-  //
-  // Calculate the cov matrix
-  //
-  TGeoRotation rotMatrix(*matrix);
-  TGeoRotation rotMatrixTr(rotMatrix.Inverse());
-  Double_t sigmaArray[] = {cl->GetSigmaY2(),0,0, 0,0,0, 0,0,cl->GetSigmaZ2()};
-  TGeoRotation sigmMatrix;
-  sigmMatrix.SetMatrix( sigmaArray );
-  sigmMatrix.MultiplyBy(&rotMatrixTr, kFALSE);
-  sigmMatrix.MultiplyBy(&rotMatrix, kTRUE);
-  const Double_t *globalSigma =  sigmMatrix.GetRotationMatrix();
-  Float_t cov[6]= { globalSigma[0], globalSigma[1], globalSigma[2],
-                                   globalSigma[4], globalSigma[5],
-                                                   globalSigma[8] };
-
-  p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
   AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer; 
   switch (l) {
   case 0:
@@ -751,13 +703,10 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
          continue;
        }
       }
-      //
-      //find intersection with layer
-      Double_t x,y,z;  
-      if (!currenttrack1.GetGlobalXYZat(r,x,y,z)) {
-       continue;
-      }
-      Double_t phi=TMath::ATan2(y,x);
+
+      Double_t phi,z;
+      if (!currenttrack1.GetPhiZat(r,phi,z)) continue;
+
       Int_t idet=layer.FindDetectorIndex(phi,z);
       if (idet<0) {
        continue;
@@ -1452,7 +1401,12 @@ FindDetectorIndex(Double_t phi, Double_t z) const {
   //--------------------------------------------------------------------
   //This function finds the detector crossed by the track
   //--------------------------------------------------------------------
-  Double_t dphi=-(phi-fPhiOffset);
+  Double_t dphi;
+  if (fZOffset<0)            // old geometry
+    dphi = -(phi-fPhiOffset);
+  else                       // new geometry
+    dphi = phi-fPhiOffset;
+
   if      (dphi <  0) dphi += 2*TMath::Pi();
   else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi();
   Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5);
@@ -1700,15 +1654,14 @@ Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,
      }
      //
 
-     Double_t x,y,z;
-     if (!t->GetGlobalXYZat(r,x,y,z)) { 
-       return kFALSE;
-     }
-     Double_t phi=TMath::ATan2(y,x);
+     Double_t phi,z;
+     if (!t->GetPhiZat(r,phi,z)) return kFALSE;
+
      Int_t idet=layer.FindDetectorIndex(phi,z);
      if (idet<0) { 
        return kFALSE;
      }
+
      const AliITSdetector &det=layer.GetDetector(idet);
      phi=det.GetPhi();
      if (!t->Propagate(phi,det.GetR())) {
@@ -1720,7 +1673,7 @@ Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,
      Double_t maxchi2=1000.*kMaxChi2;
 
      Int_t idx=index[i];
-     if (idx>0) {
+     if (idx>=0) {
         const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); 
        if (c){
          if (idet != c->GetDetectorIndex()) {
@@ -1848,12 +1801,9 @@ AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) {
         t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ);
      }
      //
+     Double_t phi,z;
+     if (!t->GetPhiZat(r,phi,z)) return kFALSE;
 
-     Double_t x,y,z;
-     if (!t->GetGlobalXYZat(r,x,y,z)) { 
-       return kFALSE;
-     }
-     Double_t phi=TMath::ATan2(y,x);
      Int_t idet=layer.FindDetectorIndex(phi,z);
      if (idet<0) { 
        return kFALSE;
@@ -1869,7 +1819,7 @@ AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) {
      Double_t maxchi2=1000.*kMaxChi2;
 
      Int_t idx=index[i];
-     if (idx>0) {
+     if (idx>=0) {
         const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); 
        if (c){
          if (idet != c->GetDetectorIndex()) {
@@ -3255,9 +3205,12 @@ Int_t    AliITStrackerMI::UpdateMI(AliITStrackMI* track, const AliITSRecPoint* c
     track->SetdEdxMismatch(track->GetdEdxMismatch()+(0.5-track->GetNormQ(layer)/track->GetExpQ())*10.);
   }
 
-  if (cl->GetQ()>0)  // ingore the "virtual" clusters
-     if (!track->PropagateTo(cl->GetX(),0.,0.)) return 0; // Alignment
+  if (cl->GetQ()<=0) return 0;  // ingore the "virtual" clusters
 
+  // Take into account the mis-alignment
+  Double_t x=track->GetX()+cl->GetX();
+  if (!track->PropagateTo(x,0.,0.)) return 0;
+  
   return track->UpdateMI(cl->GetY(),cl->GetZ(),track->GetSigmaY(layer),track->GetSigmaZ(layer),chi2,index);
 }