]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDseed.cxx
Bug fix for the fitting at the SHUTTLE of the average pulse height
[u/mrichter/AliRoot.git] / TRD / AliTRDseed.cxx
index 76b7b99d1292280df639ef7bf6ad404ef8bdfe55..0b4feec503b029c12bb8e83103853dfcb24a9acc 100644 (file)
@@ -27,7 +27,6 @@
 #include "AliMathBase.h"
 
 #include "AliTRDseed.h"
-#include "AliTRDcalibDB.h"
 #include "AliTRDcluster.h"
 #include "AliTRDtracker.h"
 #include "AliTRDtrackerV1.h"
@@ -64,7 +63,7 @@ AliTRDseed::AliTRDseed()
     fY[i]        = 0;   // y position
     fZ[i]        = 0;   // z position
     fIndexes[i]  = 0;   // Indexes
-    fClusters[i] = 0x0; // Clusters
+    fClusters[i] = NULL; // Clusters
     fUsable[i]   = 0;   // Indication  - usable cluster
   }
 
@@ -185,7 +184,7 @@ void AliTRDseed::Reset()
     fY[i]        = 0;  // Y position
     fZ[i]        = 0;  // Z position
     fIndexes[i]  = 0;  // Indexes
-    fClusters[i] = 0x0;  // Clusters
+    fClusters[i] = NULL;  // Clusters
     fUsable[i]   = kFALSE;    
   }
 
@@ -280,7 +279,6 @@ void AliTRDseed::Update()
   const Int_t   kClmin  = 5;
   const Float_t kmaxtan = 2;
 
-
   if (TMath::Abs(fYref[1]) > kmaxtan){
                //printf("Exit: Abs(fYref[1]) = %3.3f, kmaxtan = %3.3f\n", TMath::Abs(fYref[1]), kmaxtan);
                return;              // Track inclined too much
@@ -313,10 +311,9 @@ void AliTRDseed::Update()
     yres[i] = 10000.0;
     if (!fClusters[i]) continue;
     if(!fClusters[i]->IsInChamber()) continue;
-    //yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] - fTilt*(fZ[i] - fZref[0]);   // Residual y
-    yres[i] = fY[i] - (fYref[0] + fX[i] * fYref[1]) - fTilt*(fZ[i] - (fZref[0] + fX[i]*fZref[1]));   // Residual y
-
-    //printf("dy[%2d]=%6.2f\n", i, yres[i]);
+    // Residual y
+    //yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] + fTilt*(fZ[i] - fZref[0]);
+    yres[i] = fY[i] - fTilt*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
     zints[fN] = Int_t(fZ[i]);
     fN++;    
   }
@@ -341,9 +338,12 @@ void AliTRDseed::Update()
   Int_t  cumul[knTimebins][2];
   Int_t  counts[2] = { 0, 0 };
   
-  // Find the break time allowing one chage on pad-rows
-  // with maximal number of accepted clusters
   if (zouts[3] >= 3) {
+
+    //
+    // Find the break time allowing one chage on pad-rows
+    // with maximal number of accepted clusters
+    //
     fNChange = 1;
     for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
       cumul[i][0] = counts[0];
@@ -353,22 +353,24 @@ void AliTRDseed::Update()
     }
     Int_t  maxcount = 0;
     for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
-      Int_t after  = counts[0]- cumul[i][0];
+      Int_t after  = cumul[AliTRDtrackerV1::GetNTimeBins()][0] - cumul[i][0];
       Int_t before = cumul[i][1];
       if (after + before > maxcount) { 
-        maxcount  = after + before; 
-        breaktime = i;
-        mbefore   = kFALSE;
+       maxcount  = after + before; 
+       breaktime = i;
+       mbefore   = kFALSE;
       }
-      after  = counts[1] - cumul[i][1];
+      after  = cumul[AliTRDtrackerV1::GetNTimeBins()-1][1] - cumul[i][1];
       before = cumul[i][0];
       if (after + before > maxcount) { 
-        maxcount  = after + before; 
-        breaktime = i;
-        mbefore   = kTRUE;
+       maxcount  = after + before; 
+       breaktime = i;
+       mbefore   = kTRUE;
       }
     }
+
     breaktime -= 1;
+
   }
 
   for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
@@ -382,11 +384,12 @@ void AliTRDseed::Update()
     // Tracklet z-direction not in correspondance with track z direction 
     //
     fNChange = 0;
-    // Only longest taken
-    for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) allowedz[i] = zouts[0];
+    for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
+      allowedz[i] = zouts[0];  // Only longest taken
+    } 
   }
   
-/*  if (fNChange > 0) {
+  if (fNChange > 0) {
     //
     // Cross pad -row tracklet  - take the step change into account
     //
@@ -395,15 +398,14 @@ void AliTRDseed::Update()
       if(!fClusters[i]->IsInChamber()) continue;
       if (TMath::Abs(fZ[i] - allowedz[i]) > 2) continue;
       // Residual y
-      yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] + fTilt*(fZ[i] - fZref[0]);
-      printf("dy[%2d]=%6.2f\n", i, yres[i]);
-      if (TMath::Abs(fZ[i] - fZProb) < 2.) continue;
-      // correction for pad row change
-      if (fZ[i] > fZProb) yres[i] += fTilt * fPadLength;
-      if (fZ[i] < fZProb) yres[i] -= fTilt * fPadLength;
-      printf("z[%7.2f] zp[%7.2f] yres[%6.2f]\n", fZ[i], fZProb, yres[i]);
+      //yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] /*+ fTilt*(fZ[i] - fZref[0])*/;   
+      yres[i] = fY[i] - fTilt*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
+/*      if (TMath::Abs(fZ[i] - fZProb) > 2) {
+        if (fZ[i] > fZProb) yres[i] += fTilt * fPadLength;
+        if (fZ[i] < fZProb) yres[i] -= fTilt * fPadLength;
+      }*/
     }
-  }*/
+  }
   
   Double_t yres2[knTimebins];
   Double_t mean;
@@ -444,8 +446,8 @@ void AliTRDseed::Update()
     fUsable[i] = kFALSE;
     if (!fClusters[i]) continue;
     if (!fClusters[i]->IsInChamber()) continue;
-    if (TMath::Abs(fZ[i] - allowedz[i]) > 2){fClusters[i] = 0x0; continue;}
-    if (TMath::Abs(yres[i] - mean) > 4.0 * sigma){fClusters[i] = 0x0;  continue;}
+    if (TMath::Abs(fZ[i] - allowedz[i]) > 2){fClusters[i] = NULL; continue;}
+    if (TMath::Abs(yres[i] - mean) > 4.0 * sigma){fClusters[i] = NULL;  continue;}
     fUsable[i] = kTRUE;
     fN2++;
     fMPads += fClusters[i]->GetNPads();
@@ -498,10 +500,10 @@ void AliTRDseed::Update()
   fZfitR[1]  = (sumw   * sumwxz - sumwx * sumwz)  / det;
   fZfit[0]   = (sumwx2 * sumwz  - sumwx * sumwxz) / det;
   fZfit[1]   = (sumw   * sumwxz - sumwx * sumwz)  / det;
-  fYfitR[0] += fYref[0] + correction;
-  fYfitR[1] += fYref[1];
+//   fYfitR[0] += fYref[0] + correction;
+//   fYfitR[1] += fYref[1];
   fYfit[0]   = fYfitR[0];
-  fYfit[1]   = fYfitR[1];
+  fYfit[1]   = -fYfitR[1];
 
        //printf("y0 = %7.3f tgy = %7.3f z0 = %7.3f tgz = %7.3f \n", fYfitR[0], fYfitR[1], fZfitR[0], fZfitR[1]);
 
@@ -635,7 +637,7 @@ Float_t AliTRDseed::FitRiemanTilt(AliTRDseed * cseed, Bool_t terror)
     if (-params[2]*params[0] + params[1]*params[1] + 1 > 0) {
       Double_t rm1 = params[0] / TMath::Sqrt(-params[2]*params[0] + params[1]*params[1] + 1); 
       if (1.0/(rm1*rm1) - (x-x0) * (x-x0) > 0.0) {
-                               Double_t res = (x - x0) / TMath::Sqrt(1.0 / (rm1*rm1) - (x-x0)*(x-x0));
+                               Double_t res = (x - x0) / TMath::Sqrt((1./rm1-(x-x0))*(1./rm1+(x-x0)));
                                if (params[0] < 0) res *= -1.0;
                                dy = res;
       }