]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCTransform.cxx
AliTPCcalibDButil.cxx - make function public -possibility to debug from command...
[u/mrichter/AliRoot.git] / TPC / AliTPCTransform.cxx
index 57aa516e1825f8b9a357791496c84d5a8025559a..daadb94bd2a59d041133d2270997b469b3974884 100755 (executable)
 #include "TMath.h"
 #include "AliLog.h"
 #include "AliTPCExB.h"
+#include "AliTPCCorrection.h"
 #include "TGeoMatrix.h"
 #include "AliTPCRecoParam.h"
 #include "AliTPCCalibVdrift.h"
 #include "AliTPCTransform.h"
+#include "AliMagF.h"
+#include "TGeoGlobalMagField.h"
+#include "AliTracker.h"
 #include <AliCTPTimeParams.h>
 
 ClassImp(AliTPCTransform)
@@ -143,7 +147,12 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   AliTPCcalibDB*  calib=AliTPCcalibDB::Instance();  
   //
   AliTPCCalPad * time0TPC = calib->GetPadTime0(); 
+  AliTPCCalPad * distortionMapY = calib->GetDistortionMap(0); 
+  AliTPCCalPad * distortionMapZ = calib->GetDistortionMap(1); 
+  AliTPCCalPad * distortionMapR = calib->GetDistortionMap(2); 
   AliTPCParam  * param    = calib->GetParameters(); 
+  AliTPCCorrection * correction = calib->GetTPCComposedCorrection();   // first user defined correction  // if does not exist  try to get it from calibDB array
+  if (!correction) correction = calib->GetTPCComposedCorrection(AliTracker::GetBz());
   if (!time0TPC){
     AliFatal("Time unisochronity missing");
   }
@@ -166,9 +175,9 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   // Alignment
   //TODO:  calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx);
   RotatedGlobal2Global(sector,x);
+  
   //
-  //
-  // ExB correction
+  // old ExB correction 
   //
   if(fCurrentRecoParam&&fCurrentRecoParam->GetUseExBCorrection()) {
 
@@ -181,6 +190,18 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
     xx[2] = x[2];
   }
 
+  //
+  // new composed  correction  - will replace soon ExB correction
+  //
+  if(fCurrentRecoParam&&fCurrentRecoParam->GetUseComposedCorrection()&&correction) {
+    Float_t distPoint[3]={xx[0],xx[1],xx[2]};
+    correction->CorrectPoint(distPoint, sector);
+    xx[0]=distPoint[0];
+    xx[1]=distPoint[1];
+    xx[2]=distPoint[2];
+  } 
+
+
   //
   // Time of flight correction
   // 
@@ -209,6 +230,40 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
 
   //
   Global2RotatedGlobal(sector,xx);
+
+  //
+  // Apply non linear distortion correction  
+  //
+  if (distortionMapY ){
+    // wt - to get it form the OCDB
+    // ignore T1 and T2
+    AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+    Double_t bzField = magF->SolenoidField()/10.; //field in T
+    Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us]   // From dataBase: to be updated: per second (ideally)
+    Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
+    if (sector%36<18) ezField*=-1;
+    Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
+    Double_t c0=1./(1.+wt*wt);
+    Double_t c1=wt/c0;
+    
+    //can be switch on for each dimension separatelly
+    if (fCurrentRecoParam->GetUseFieldCorrection()&0x2)
+      if (distortionMapY){
+       xx[1]-= c0*distortionMapY->GetCalROC(sector)->GetValue(row,pad);
+       xx[0]-= c1*distortionMapY->GetCalROC(sector)->GetValue(row,pad);
+      }
+    if (fCurrentRecoParam->GetUseFieldCorrection()&0x4) 
+      if (distortionMapZ)
+       xx[2]-=distortionMapZ->GetCalROC(sector)->GetValue(row,pad);
+    if (fCurrentRecoParam->GetUseFieldCorrection()&0x8) 
+      if (distortionMapR){
+       xx[0]-= c0*distortionMapR->GetCalROC(sector)->GetValue(row,pad);
+       xx[1]-=-c1*distortionMapR->GetCalROC(sector)->GetValue(row,pad)*wt;
+      }
+    
+  }
+  //
+
   //
   x[0]=xx[0];x[1]=xx[1];x[2]=xx[2];
 }
@@ -289,7 +344,8 @@ void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
   //
   const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
   Double_t sign = 1.;
-  Double_t zwidth    = param->GetZWidth()*driftCorr*vdcorrectionTime;
+  Double_t zwidth    = param->GetZWidth()*driftCorr;
+  if (AliTPCRecoParam:: GetUseTimeCalibration()) zwidth*=vdcorrectionTime;
   Double_t padWidth  = 0;
   Double_t padLength = 0;
   Double_t    maxPad    = 0;
@@ -325,8 +381,11 @@ void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
   if (AliTPCcalibDB::Instance()->IsTrgL0()){
     // by defualt we assume L1 trigger is used - make a correction in case of  L0
     AliCTPTimeParams* ctp = AliTPCcalibDB::Instance()->GetCTPTimeParams();
-    Double_t delay = ctp->GetDelayL1L0()*0.000000025;
-    x[2]-=delay/param->GetTSample();
+    if (ctp){
+      //for TPC standalone runs no ctp info
+      Double_t delay = ctp->GetDelayL1L0()*0.000000025;
+      x[2]-=delay/param->GetTSample();
+    }
   }
   x[2]-= param->GetNTBinsL1();
   x[2]*= zwidth;  // tranform time bin to the distance to the ROC