Applying transformation AliTPCTransform
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 24 Nov 2007 16:51:04 +0000 (16:51 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 24 Nov 2007 16:51:04 +0000 (16:51 +0000)
Time 0 and ExB effect included (Marian)

TPC/AliTPCTransform.cxx
TPC/AliTPCTransform.h
TPC/AliTPCclustererMI.cxx
TPC/AliTPCtrackerMI.cxx

index 6c6aaa974c67e237b0b2b4767d2202e1cabaffec..114e0baba3df1032fcfead6cd32d7dc35876a6e3 100755 (executable)
@@ -1,10 +1,12 @@
-#include "AliTPCTransform.h"
 #include "AliTPCROC.h"
+#include "AliTPCCalPad.h"
 #include "AliTPCCalROC.h"
 #include "AliTPCcalibDB.h"
 #include "AliTPCParam.h"
 #include "TMath.h"
+#include "AliLog.h"
 #include "AliTPCExB.h"
+#include "AliTPCTransform.h"
 
 /* To test it:
    cdb=AliCDBManager::Instance()
@@ -18,7 +20,9 @@
  */
 
 AliTPCTransform::AliTPCTransform() {
+  //
   // Speed it up a bit!
+  //
   for (Int_t i=0;i<18;++i) {
     Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18));
     fSins[i]=TMath::Sin(alpha);
@@ -27,41 +31,53 @@ AliTPCTransform::AliTPCTransform() {
 }
 
 AliTPCTransform::~AliTPCTransform() {
+  //
+  // Destructor
+  //
 }
 
-void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t time,
-                               Int_t coordinateType) {
-  // input: x[0] - pad
-  //        x[1] - pad row
+void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
+                               Int_t /*coordinateType*/) {
+  // input: x[0] - pad row
+  //        x[1] - pad 
   //        x[2] - time in us
   //        i[0] - sector
   // output: x[0] - x (all in the rotated global coordinate frame)
   //         x[1] - y
   //         x[2] - z
-  Int_t row=TMath::Nint(x[1]);
-  Int_t pad=TMath::Nint(x[0]);
+  Int_t row=TMath::Nint(x[0]);
+  Int_t pad=TMath::Nint(x[1]);
   Int_t sector=i[0];
   AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
-  Double_t xx[3];
-
-  //ugly:  calib->SetRun(time);
-
-  // Time0
-  //TODO:  x[2]-=calib->GetPadTime0()->GetCalROC(sector)->GetValue(row,pad);
-
-  // Drift Velocity
-  // (cm/us)
-  // TODO: use a map or parametrisation!
-  x[2]*=2.66;
+  //
+  AliTPCCalPad * time0TPC = calib->GetPadTime0(); 
+  AliTPCParam  * param    = calib->GetParameters(); 
+  if (!time0TPC){
+    AliFatal("Time unisochronity missing");
+  }
 
-  Pad2RotatedGlobal(pad,row,x);
+  if (!param){
+    AliFatal("Parameters missing");
+  }
 
+  Double_t xx[3];
+  //  Apply Time0 correction - Pad by pad fluctuation
+  //
+  x[2]-=time0TPC->GetCalROC(sector)->GetValue(row,pad);
+  //
+  // Tranform from pad - time coordinate system to the rotated global (tracking) system
+  //
+  Local2RotatedGlobal(sector,x);
+  //
+  //
+  //
   // Alignment
   //TODO:  calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx);
-
   RotatedGlobal2Global(sector,x);
-
-  // ExB
+  //
+  //
+  // ExB correction
+  //
   calib->GetExB()->Correct(x,xx);
 
   Global2RotatedGlobal(sector,xx);
@@ -69,17 +85,70 @@ void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t time,
   x[0]=xx[0];x[1]=xx[1];x[2]=xx[2];
 }
 
-inline void AliTPCTransform::Pad2RotatedGlobal(Int_t pad,Int_t row,Double_t *x)
-  const {
-  Float_t tmp[3];
-  AliTPCROC::Instance()->GetPositionLocal(0,row,pad,tmp);
-  x[0]=tmp[0];
-  x[1]=tmp[1];
+void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
+  //
+  //  
+  // 
+  //
+  // Drift Velocity - time bin to the 
+  // Current implementation - common drift velocity 
+  // for full chamber
+  // TODO: use a map or parametrisation!
+  //
+  //  
+  //
+  AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
+  AliTPCParam  * param    = calib->GetParameters(); 
+  if (!param){
+    AliFatal("Parameters missing");
+  }
+  Int_t row=TMath::Nint(x[0]);
+  Int_t pad=TMath::Nint(x[1]);
+  //
+  const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
+  Double_t sign = 1.;
+  Double_t zwidth    = param->GetZWidth();
+  Double_t padWidth  = 0;
+  Double_t padLength = 0;
+  Double_t    maxPad    = 0;
+  //
+  if (sector < kNIS) {
+    maxPad = param->GetNPadsLow(row);
+    sign = (sector < kNIS/2) ? 1 : -1;
+    padLength = param->GetPadPitchLength(sector,row);
+    padWidth = param->GetPadPitchWidth(sector);
+  } else {
+    maxPad = param->GetNPadsUp(row);
+    sign = ((sector-kNIS) < kNOS/2) ? 1 : -1;
+    padLength = param->GetPadPitchLength(sector,row);
+    padWidth  = param->GetPadPitchWidth(sector);
+  }
+  //
+  // X coordinate
+  x[0] = param->GetPadRowRadii(sector,row);
+  // padrow X position - ideal
+  //
+  // Y coordinate
+  //
+  x[1]=(x[1]-0.5*maxPad)*padWidth;
+  //  if (!fRecoParam->GetBYMirror()){
+  //     if (sector%36>17){
+  //       x[1] *=-1.;
+  //     }
+  //   }
+  //
+  // Z coordinate
+  //
+  x[2]*= zwidth;  // tranform time bin to the distance to the ROC
+  x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth;
+  // subtract the time offsets
+  x[2] = sign*( param->GetZLength(sector) - x[2]);
 }
 
-//TODO rotation in the right direction?
-inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x)
-  const {
+inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x) const {
+  //
+  // transform possition rotated global to the global
+  //
   Double_t cos,sin;
   GetCosAndSin(sector,cos,sin);
   Double_t tmp=x[0];
@@ -87,8 +156,10 @@ inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x)
   x[1]=-sin*tmp+cos*x[1];
 }
 
-inline void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x)
-  const {
+inline void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x) const {
+  //
+  // tranform possition Global2RotatedGlobal
+  //
   Double_t cos,sin;
   GetCosAndSin(sector,cos,sin);
   Double_t tmp=x[0];
index eed9ee00ab6a6b356085f3d8885952c4e8043fd9..7040f8822d20c01caf5a4b771ab19b1a63f15521 100755 (executable)
@@ -11,7 +11,7 @@ public:
   virtual void Transform(Double_t *x,Int_t *i,UInt_t time,
                         Int_t coordinateType);
 protected:
-  void Pad2RotatedGlobal(Int_t pad,Int_t row,Double_t *x) const;
+  void Local2RotatedGlobal(Int_t sec,  Double_t *x) const;
   void RotatedGlobal2Global(Int_t sector,Double_t *x) const;
   void Global2RotatedGlobal(Int_t sector,Double_t *x) const;
   void GetCosAndSin(Int_t sector,Double_t &cos,Double_t &sin) const;
index c4a6dd39815872e4e793e28bc31ca028d7d152b8..b48ee755949d7e0ee63936aba11a8652e1e13b6d 100644 (file)
@@ -545,11 +545,13 @@ void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c, Float_t * matrix, Int_t p
   w=fZWidth;
   c.SetSigmaZ2(s2*w*w);
   c.SetY((meani - 2.5 - 0.5*fMaxPad)*fParam->GetPadPitchWidth(fSector));
+  c.SetPad(meani-2.5);
   if (!fRecoParam->GetBYMirror()){
     if (fSector%36>17){
       c.SetY(-(meani - 2.5 - 0.5*fMaxPad)*fParam->GetPadPitchWidth(fSector));
     }
   }
+  c.SetTimeBin(meanj-3);
   c.SetZ(fZWidth*(meanj-3)); 
   c.SetZ(c.GetZ() - 3.*fParam->GetZSigma() + fParam->GetNTBinsL1()*fParam->GetZWidth()); // PASA delay + L1 delay
   c.SetZ(fSign*(fParam->GetZLength(fSector) - c.GetZ()));
index 9d519cc3945cd031f585db589faf9b6587cda26c..9fe3a6f51c2f9193deadeedbef452eb30337d5e6 100644 (file)
 #include "AliAlignObj.h"
 #include "AliTrackPointArray.h"
 #include "TRandom.h"
-//#include "AliTPCTransform.h"
+#include "AliTPCcalibDB.h"
+#include "AliTPCTransform.h"
 
 //
 
@@ -1301,19 +1302,28 @@ void   AliTPCtrackerMI::Transform(AliTPCclusterMI * cluster){
   //
   //
   //
-//   AliTPCTransform trafo;
-
-//   Double_t x[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
-//   Int_t i[1]={cluster->GetDetector()};
-
-//   trafo.Transform(x,i,0,1);
-
-//   cluster->SetX(x[0]);
-//   cluster->SetY(x[1]);
-//   cluster->SetZ(x[2]);
-
-//   return;
-
+  AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
+  if (!transform) {
+    AliFatal("Tranformations not in calibDB");
+  }
+  Double_t x[3]={cluster->GetRow(),cluster->GetPad(),cluster->GetTimeBin()};
+  Int_t i[1]={cluster->GetDetector()};
+  transform->Transform(x,i,0,1);
+  //
+  // in debug mode  check the transformation
+  //
+  if (AliTPCReconstructor::StreamLevel()>-1) {
+    TTreeSRedirector &cstream = *fDebugStreamer;
+    cstream<<"Transform"<<
+      "x0="<<x[0]<<
+      "x1="<<x[1]<<
+      "x2="<<x[2]<<
+      "Cl.="<<cluster<<
+      "\n"; 
+  }
+  cluster->SetX(x[0]);
+  cluster->SetY(x[1]);
+  cluster->SetZ(x[2]);
   // The old stuff:
 
   //
@@ -1328,9 +1338,9 @@ void   AliTPCtrackerMI::Transform(AliTPCclusterMI * cluster){
   else{
     // chack Loading of Geo matrices from GeoManager - TEMPORARY FIX
   }
-  //cluster->SetX(posC[0]);
-  //cluster->SetY(posC[1]);
-  //cluster->SetZ(posC[2]);
+  cluster->SetX(posC[0]);
+  cluster->SetY(posC[1]);
+  cluster->SetZ(posC[2]);
 }
 
 //_____________________________________________________________________________