]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCTransform.cxx
AliCFGridSparse : propagate the bin labels during projections
[u/mrichter/AliRoot.git] / TPC / AliTPCTransform.cxx
index 81cd03669bd20d3865a720dc528ff7c7c111bf0a..6781ba97c48d24dd09a3c4eb905e98230df63649 100755 (executable)
@@ -63,6 +63,7 @@
 #include "AliTPCRecoParam.h"
 #include "AliTPCCalibVdrift.h"
 #include "AliTPCTransform.h"
+#include <AliCTPTimeParams.h>
 
 ClassImp(AliTPCTransform)
 
@@ -136,13 +137,14 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   //                line approximation  
   //
   
-
   Int_t row=TMath::Nint(x[0]);
   Int_t pad=TMath::Nint(x[1]);
   Int_t sector=i[0];
   AliTPCcalibDB*  calib=AliTPCcalibDB::Instance();  
   //
   AliTPCCalPad * time0TPC = calib->GetPadTime0(); 
+  AliTPCCalPad * distortionMapY = calib->GetDistortionMap(0); 
+  AliTPCCalPad * distortionMapZ = calib->GetDistortionMap(1); 
   AliTPCParam  * param    = calib->GetParameters(); 
   if (!time0TPC){
     AliFatal("Time unisochronity missing");
@@ -170,7 +172,17 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
   //
   // ExB correction
   //
-  calib->GetExB()->Correct(x,xx);
+  if(fCurrentRecoParam&&fCurrentRecoParam->GetUseExBCorrection()) {
+
+    calib->GetExB()->Correct(x,xx);
+
+  } else {
+
+    xx[0] = x[0];
+    xx[1] = x[1];
+    xx[2] = x[2];
+  }
+
   //
   // Time of flight correction
   // 
@@ -199,6 +211,19 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
 
   //
   Global2RotatedGlobal(sector,xx);
+
+  //
+  // Apply non linear distortion correction  
+  //
+  if (distortionMapY ){
+    //can be switch on for each dimension separatelly
+    if (fCurrentRecoParam->GetUseFieldCorrection()&0x2) 
+      xx[1]-=distortionMapY->GetCalROC(sector)->GetValue(row,pad);
+    if (fCurrentRecoParam->GetUseFieldCorrection()&0x4) 
+      xx[2]-=distortionMapZ->GetCalROC(sector)->GetValue(row,pad);
+  }
+
+
   //
   x[0]=xx[0];x[1]=xx[1];x[2]=xx[2];
 }
@@ -236,7 +261,39 @@ void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
       
     }
   }
-  
+  //
+  // simple caching non thread save
+  static Double_t vdcorrectionTime=1;
+  static Double_t time0corrTime=0;
+  static Int_t    lastStampT=-1;
+  //
+  if (lastStampT!=(Int_t)fCurrentTimeStamp){
+    lastStampT=fCurrentTimeStamp;
+    if(fCurrentRecoParam&&fCurrentRecoParam->GetUseDriftCorrectionTime()>0) {
+      vdcorrectionTime = (1+AliTPCcalibDB::Instance()->
+                         GetVDriftCorrectionTime(fCurrentTimeStamp, 
+                                                 fCurrentRun,
+                                                 sector%36>=18,
+                                                 fCurrentRecoParam->GetUseDriftCorrectionTime()));                       
+      time0corrTime= AliTPCcalibDB::Instance()->
+       GetTime0CorrectionTime(fCurrentTimeStamp, 
+                              fCurrentRun,
+                              sector%36>=18,
+                              fCurrentRecoParam->GetUseDriftCorrectionTime()); 
+    }
+    //
+    if(fCurrentRecoParam&&fCurrentRecoParam->GetUseDriftCorrectionGY()>0) {
+      Float_t xyzPad[3];
+      AliTPCROC::Instance()->GetPositionGlobal(sector, TMath::Nint(x[0]) ,TMath::Nint(x[1]), xyzPad);
+      
+      Double_t corrGy= (1+(xyzPad[1])*AliTPCcalibDB::Instance()->
+                       GetVDriftCorrectionGy(fCurrentTimeStamp, 
+                                             AliTPCcalibDB::Instance()->GetRun(),
+                                             sector%36>=18,
+                                             fCurrentRecoParam->GetUseDriftCorrectionGY()));
+      vdcorrectionTime *=corrGy;
+    }
+  }
 
 
   if (!param){
@@ -248,6 +305,7 @@ 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;
+  if (AliTPCRecoParam:: GetUseTimeCalibration()) zwidth*=vdcorrectionTime;
   Double_t padWidth  = 0;
   Double_t padLength = 0;
   Double_t    maxPad    = 0;
@@ -280,8 +338,18 @@ void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
   //
   // Z coordinate
   //
+  if (AliTPCcalibDB::Instance()->IsTrgL0()){
+    // by defualt we assume L1 trigger is used - make a correction in case of  L0
+    AliCTPTimeParams* ctp = AliTPCcalibDB::Instance()->GetCTPTimeParams();
+    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
-  x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth;
+  x[2]-= 3.*param->GetZSigma() + time0corrTime;
   // subtract the time offsets
   x[2] = sign*( param->GetZLength(sector) - x[2]);
 }
@@ -315,3 +383,12 @@ void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos,
 }
 
 
+void AliTPCTransform::ApplyTransformations(Double_t */*xyz*/, Int_t /*volID*/){
+  //
+  // Modify global position
+  // xyz    - global xyz position
+  // volID  - volID of detector (sector number)
+  //
+  //
+  
+}