]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtransform.cxx
Bug fix (Alessandro)
[u/mrichter/AliRoot.git] / TRD / AliTRDtransform.cxx
index 77ca47c1b5c7d714241e2e8d080e229b0e720991..3ea14e21a19cc099d2dc60b381a9896e44c37132 100644 (file)
 
 ClassImp(AliTRDtransform)
 
+AliTRDgeometry* AliTRDtransform::fgGeo = NULL;
+
 //_____________________________________________________________________________
 AliTRDtransform::AliTRDtransform()
   :TObject()
-  ,fGeo(0x0)
   ,fDetector(0)
   ,fParam(0x0)
   ,fCalibration(0x0)
@@ -60,12 +61,33 @@ AliTRDtransform::AliTRDtransform()
   // AliTRDtransform default constructor
   //
 
+  if(!fgGeo){
+    fgGeo = new AliTRDgeometry();
+    if (!fgGeo->CreateClusterMatrixArray()) {
+      AliError("Could not get transformation matrices\n");
+    }
+  }
+
+  fParam             = AliTRDCommonParam::Instance();
+  if (!fParam) {
+    AliError("Could not get common parameters\n");
+  }
+  fSamplingFrequency = fParam->GetSamplingFrequency();
+
+  fCalibration       = AliTRDcalibDB::Instance();
+  if (!fCalibration) {
+    AliError("Cannot find calibration object");
+  }
+
+  // Get the calibration objects for the global calibration
+  fkCalVdriftDet     = fCalibration->GetVdriftDet();
+  fkCalT0Det         = fCalibration->GetT0Det();
+
 }
 
 //_____________________________________________________________________________
 AliTRDtransform::AliTRDtransform(Int_t det)
   :TObject()
-  ,fGeo(0x0)
   ,fDetector(0)
   ,fParam(0x0)
   ,fCalibration(0x0)
@@ -85,9 +107,11 @@ AliTRDtransform::AliTRDtransform(Int_t det)
   // AliTRDtransform constructor for a given detector
   //
 
-  fGeo               = new AliTRDgeometry();
-  if (!fGeo->CreateClusterMatrixArray()) {
-    AliError("Could not get transformation matrices\n");
+  if(!fgGeo){
+    fgGeo = new AliTRDgeometry();
+    if (!fgGeo->CreateClusterMatrixArray()) {
+      AliError("Could not get transformation matrices\n");
+    }
   }
 
   fParam             = AliTRDCommonParam::Instance();
@@ -112,7 +136,6 @@ AliTRDtransform::AliTRDtransform(Int_t det)
 //_____________________________________________________________________________
 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
   :TObject(t)
-  ,fGeo(0x0)
   ,fDetector(t.fDetector)
   ,fParam(0x0)
   ,fCalibration(0x0)
@@ -132,12 +155,6 @@ AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
   // AliTRDtransform copy constructor
   //
 
-  if (fGeo) {
-    delete fGeo;
-  }
-  fGeo               = new AliTRDgeometry();
-  fGeo->CreateClusterMatrixArray();
-
   fParam             = AliTRDCommonParam::Instance();
   if (!fParam) {
     AliError("Could not get common parameters\n");
@@ -160,10 +177,6 @@ AliTRDtransform::~AliTRDtransform()
   // AliTRDtransform destructor
   //
 
-  if (fGeo) {
-    delete fGeo;
-  }
-
 }
 
 //_____________________________________________________________________________
@@ -186,13 +199,13 @@ void AliTRDtransform::SetDetector(Int_t det)
   fCalT0DetValue     = fkCalT0Det->GetValue(det);
 
   // Shift needed to define Z-position relative to middle of chamber
-  Int_t layer        = fGeo->GetLayer(det);
-  Int_t stack        = fGeo->GetStack(det);
-  fPadPlane          = fGeo->GetPadPlane(layer,stack);
+  Int_t layer        = fgGeo->GetLayer(det);
+  Int_t stack        = fgGeo->GetStack(det);
+  fPadPlane          = fgGeo->GetPadPlane(layer,stack);
   fZShiftIdeal       = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
 
   // Get the current transformation matrix
-  fMatrix            = fGeo->GetClusterMatrix(det);
+  fMatrix            = fgGeo->GetClusterMatrix(det);
 
 }
 
@@ -221,6 +234,7 @@ Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
   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);