]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtransform.cxx
Changes for cosmics reconstruction
[u/mrichter/AliRoot.git] / TRD / AliTRDtransform.cxx
index 0c725c659232abc0f75cc3438099c2ddac5c1a37..f5d9b18a6d52c59f461d1028f80849716b935762 100644 (file)
@@ -25,8 +25,6 @@
 #include <TGeoMatrix.h>
 
 #include "AliLog.h"
-#include "AliTracker.h"
-#include "AliCodeTimer.h"
 
 #include "AliTRDtransform.h"
 #include "AliTRDcluster.h"
@@ -40,8 +38,6 @@
 ClassImp(AliTRDtransform)
 
 //_____________________________________________________________________________
-//AliTRDtransform::AliTRDtransform()
-//  :AliTransform()
 AliTRDtransform::AliTRDtransform()
   :TObject()
   ,fGeo(0x0)
@@ -50,8 +46,9 @@ AliTRDtransform::AliTRDtransform()
   ,fCalibration(0x0)
   ,fCalVdriftROC(0x0)
   ,fCalT0ROC(0x0)
-  ,fCalVdriftDet(0x0)
-  ,fCalT0Det(0x0)
+  ,fCalPRFROC(0x0)
+  ,fkCalVdriftDet(0x0)
+  ,fkCalT0Det(0x0)
   ,fCalVdriftDetValue(0)
   ,fCalT0DetValue(0)
   ,fSamplingFrequency(0)
@@ -66,8 +63,6 @@ AliTRDtransform::AliTRDtransform()
 }
 
 //_____________________________________________________________________________
-//AliTRDtransform::AliTRDtransform(Int_t det)
-//  :AliTransform()
 AliTRDtransform::AliTRDtransform(Int_t det)
   :TObject()
   ,fGeo(0x0)
@@ -76,8 +71,9 @@ AliTRDtransform::AliTRDtransform(Int_t det)
   ,fCalibration(0x0)
   ,fCalVdriftROC(0x0)
   ,fCalT0ROC(0x0)
-  ,fCalVdriftDet(0x0)
-  ,fCalT0Det(0x0)
+  ,fCalPRFROC(0x0)
+  ,fkCalVdriftDet(0x0)
+  ,fkCalT0Det(0x0)
   ,fCalVdriftDetValue(0)
   ,fCalT0DetValue(0)
   ,fSamplingFrequency(0)
@@ -106,16 +102,14 @@ AliTRDtransform::AliTRDtransform(Int_t det)
   }
 
   // Get the calibration objects for the global calibration
-  fCalVdriftDet      = fCalibration->GetVdriftDet();
-  fCalT0Det          = fCalibration->GetT0Det();
+  fkCalVdriftDet     = fCalibration->GetVdriftDet();
+  fkCalT0Det         = fCalibration->GetT0Det();
 
   SetDetector(det);
 
 }
 
 //_____________________________________________________________________________
-//AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
-//  :AliTransform(t)
 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
   :TObject(t)
   ,fGeo(0x0)
@@ -124,8 +118,9 @@ AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
   ,fCalibration(0x0)
   ,fCalVdriftROC(0x0)
   ,fCalT0ROC(0x0)
-  ,fCalVdriftDet(0x0)
-  ,fCalT0Det(0x0)
+  ,fCalPRFROC(0x0)
+  ,fkCalVdriftDet(0x0)
+  ,fkCalT0Det(0x0)
   ,fCalVdriftDetValue(0)
   ,fCalT0DetValue(0)
   ,fSamplingFrequency(0)
@@ -153,8 +148,8 @@ AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
   if (!fCalibration) {
     AliError("Cannot find calibration object");
   }
-  fCalVdriftDet      = fCalibration->GetVdriftDet();
-  fCalT0Det          = fCalibration->GetT0Det();
+  fkCalVdriftDet     = fCalibration->GetVdriftDet();
+  fkCalT0Det         = fCalibration->GetT0Det();
 
 }
 
@@ -184,15 +179,16 @@ void AliTRDtransform::SetDetector(Int_t det)
   // Get the calibration objects for the pad-by-pad calibration
   fCalVdriftROC      = fCalibration->GetVdriftROC(det);
   fCalT0ROC          = fCalibration->GetT0ROC(det);
+  fCalPRFROC         = fCalibration->GetPRFROC(det);
 
   // Get the detector wise defined calibration values
-  fCalVdriftDetValue = fCalVdriftDet->GetValue(det);
-  fCalT0DetValue     = fCalT0Det->GetValue(det);
+  fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
+  fCalT0DetValue     = fkCalT0Det->GetValue(det);
 
   // Shift needed to define Z-position relative to middle of chamber
-  Int_t pla          = fGeo->GetPlane(det);
-  Int_t cha          = fGeo->GetChamber(det);
-  fPadPlane          = fGeo->GetPadPlane(pla,cha);
+  Int_t layer        = fGeo->GetLayer(det);
+  Int_t stack        = fGeo->GetStack(det);
+  fPadPlane          = fGeo->GetPadPlane(layer,stack);
   fZShiftIdeal       = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
 
   // Get the current transformation matrix
@@ -201,7 +197,7 @@ void AliTRDtransform::SetDetector(Int_t det)
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDtransform::Transform(Double_t *x, Int_t *i, UInt_t time, Bool_t &out, Int_t  /*coordinateType*/)
+Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
 {
   //
   // Transforms the local cluster coordinates into calibrated 
@@ -209,106 +205,55 @@ Bool_t AliTRDtransform::Transform(Double_t *x, Int_t *i, UInt_t time, Bool_t &ou
   //
   // Here the calibration for T0, Vdrift and ExB is applied as well.
   //
-  // Input:
-  //   x[0] = COL-position relative to the center pad (pad units)
-  //   x[1] = cluster signal in left pad
-  //   x[2] = cluster signal in middle pad
-  //   x[3] = cluster signal in right pad
-  //   i[0] = ROW pad number
-  //   i[1] = COL pad number
-  //   time = time bin number (uncalibrated for t0)
-  //
-  // Output:
-  //   x[0] = X-positions in tracking CS
-  //   x[1] = Y-positions in tracking CS
-  //   x[2] = Z-positions in tracking CS
-  //   x[3] = total cluster charge
-  //   x[4] = error in Y-direction
-  //   x[5] = error in Z-direction
-  //   i[2] = time bin number (calibrated for t0)
-  //
-
-  Double_t posLocal[3];
-  Double_t posTracking[3];
+  // Input: Cluster in the local chamber coordinates
+  // Output: Tracking cluster
 
-  Int_t row = i[0];
-  Int_t col = i[1];
+  if (!fMatrix) return kFALSE;
 
-  // Parameter to adjust the X position
-  const Double_t kX0shift = 2.52;
 
-  if (!fMatrix) {
+  // Parameters to adjust the X position of clusters in the alignable volume
+  const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
 
-    x[0] = 0.0;
-    x[1] = 0.0;
-    x[2] = 0.0;
-    x[3] = 0.0;
-    x[4] = 0.0;
-    x[5] = 0.0;
-    i[2] = 0;
-
-    return kFALSE;
-
-  }
-  else {
  
-    // Calibration values
-    Double_t vdrift      = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
-    Double_t t0          = fCalT0DetValue     + fCalT0ROC->GetValue(col,row);
-
-    // T0 correction
-    Double_t timeT0Cal   = time - t0;
-    // Calculate the X-position,
-    Double_t xLocal      = (timeT0Cal + 0.5) / fSamplingFrequency * vdrift; 
-
-    // Length of the amplification region
-    Double_t ampLength   = (Double_t) AliTRDgeometry::CamHght();
-    // The drift distance
-    Double_t driftLength = TMath::Max(xLocal - 0.5*ampLength,0.0);
-    // ExB correction
-    Double_t exbCorr     = fCalibration->GetOmegaTau(vdrift
-                                                    ,-0.1*AliTracker::GetBz());
-
-    // Pad dimensions
-    Double_t rowSize     = fPadPlane->GetRowSize(row);
-    Double_t colSize     = fPadPlane->GetColSize(col);
-
-    // Invert the X-position,
-    // apply ExB correction to the Y-position
-    // and move to the Z-position relative to the middle of the chamber
-    posLocal[0] = -xLocal;
-    posLocal[1] =  (fPadPlane->GetColPos(col) - (x[0] + 0.5) * colSize) - driftLength * exbCorr;
-    posLocal[2] =  (fPadPlane->GetRowPos(row) -         0.5  * rowSize) - fZShiftIdeal;
-
-    // Go to tracking coordinates
-    fMatrix->LocalToMaster(posLocal,posTracking);
-
-    // The total charge of the cluster
-    Double_t q0             = x[1];
-    Double_t q1             = x[2];
-    Double_t q2             = x[3];
-    Double_t clusterCharge  = q0 + q1 + q2; 
-    Double_t clusterSigmaY2 = 0.0;
-    if (clusterCharge > 0.0) {
-      clusterSigmaY2 = (q1 * (q0 + q2) + 4.0 * q0 * q2)
-                    / (clusterCharge*clusterCharge);
-    }
-
-    // Output values
-    x[0] = posTracking[0] + kX0shift;
-    x[1] = posTracking[1];
-    x[2] = posTracking[2];
-    x[3] = clusterCharge;
-    x[4] = colSize*colSize * (clusterSigmaY2 + 1.0/12.0);
-    x[5] = rowSize*rowSize / 12.0;                                       
-    i[2] = TMath::Nint(timeT0Cal);
-               
-               // A.Bercuci for TRD tracking calibration awareness
-               out = (i[2] < 0 || i[2] > Int_t(3.5*fSamplingFrequency/vdrift)) ? kTRUE : kFALSE; 
-
-    return kTRUE;
-
-  }
+  // Retrieve calibration values
+  Int_t col = c->GetPadCol(), row = c->GetPadRow();
+  // drift velocity
+  Double_t vd  = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
+  // t0
+  Double_t t0  = fCalT0DetValue     + fCalT0ROC->GetValue(col,row);
+  t0 /= fSamplingFrequency;
+  // ExB correction
+  Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
+
+  Float_t x = c->GetXloc(t0, vd);
+
+  // Pad dimensions
+  Double_t rs = fPadPlane->GetRowSize(row);
+  Double_t cs = fPadPlane->GetColSize(col);
+
+  // cluster error with diffusion corrections
+  Double_t s2  = cs*fCalPRFROC->GetValue(col, row); 
+  s2 *= s2; 
+  Float_t dl, dt;
+  AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
+
+  Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
+  Double_t loc[] = {
+    kX0shift-x,                    // Invert the X-position,
+    c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
+    fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
+  };
+
+  // Go to tracking coordinates
+  Double_t trk[3];
+  fMatrix->LocalToMaster(loc, trk);
+
+  // store tracking values
+  c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
+  c->SetSigmaY2(s2, dt, exb, x);
+  c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
+  
+  return kTRUE;
 
 }
 
@@ -322,32 +267,7 @@ void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
   // be used.
   //
 
-  if (setDet) {
-    SetDetector(c->GetDetector());
-  }
+  if (setDet) SetDetector(c->GetDetector());
+  Transform(c);
 
-  // Transform the local cluster coordinates into recalibrated 
-  // space point positions defined in the local tracking system.
-  // Here the calibration for T0, Vdrift and ExB is applied as well.
-  Double_t clusterXYZ[6];
-  clusterXYZ[0] = c->GetCenter();
-  clusterXYZ[1] = 0.0;
-  clusterXYZ[2] = 0.0;
-  clusterXYZ[3] = 0.0;
-  clusterXYZ[4] = 0.0;
-  clusterXYZ[5] = 0.0;
-  Int_t    clusterRCT[3];
-  clusterRCT[0] = c->GetPadRow();
-  clusterRCT[1] = c->GetPadCol();
-  clusterRCT[2] = 0;
-  Int_t time    = c->GetPadTime();
-  Bool_t out;
-  Transform(clusterXYZ,clusterRCT,((UInt_t) time), out, 0);
-
-  // Set the recalibrated coordinates
-  c->SetX(clusterXYZ[0]);
-  c->SetY(clusterXYZ[1]);
-  c->SetZ(clusterXYZ[2]);
-  c->SetLocalTimeBin(((Char_t) clusterRCT[2]));
-       c->SetInChamber(!out);
 }