]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtransform.cxx
Fix coverity defect
[u/mrichter/AliRoot.git] / TRD / AliTRDtransform.cxx
index e0bd25109fb76e7b5d983e8774d66036f19f7e21..4528a09a5bab5341631743a25e6901965f0f661d 100644 (file)
@@ -25,8 +25,6 @@
 #include <TGeoMatrix.h>
 
 #include "AliLog.h"
-#include "AliTracker.h"
-#include "AliCodeTimer.h"
 
 #include "AliTRDtransform.h"
 #include "AliTRDcluster.h"
 
 ClassImp(AliTRDtransform)
 
+AliTRDgeometry* AliTRDtransform::fgGeo = NULL;
+
 //_____________________________________________________________________________
-//AliTRDtransform::AliTRDtransform()
-//  :AliTransform()
 AliTRDtransform::AliTRDtransform()
   :TObject()
-  ,fGeo(0x0)
   ,fDetector(0)
   ,fParam(0x0)
   ,fCalibration(0x0)
   ,fCalVdriftROC(0x0)
   ,fCalT0ROC(0x0)
-  ,fCalVdriftDet(0x0)
-  ,fCalT0Det(0x0)
+  ,fCalPRFROC(0x0)
+  ,fkCalVdriftDet(0x0)
+  ,fkCalT0Det(0x0)
   ,fCalVdriftDetValue(0)
   ,fCalT0DetValue(0)
   ,fSamplingFrequency(0)
@@ -63,21 +61,41 @@ 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)
-//  :AliTransform()
 AliTRDtransform::AliTRDtransform(Int_t det)
   :TObject()
-  ,fGeo(0x0)
   ,fDetector(0)
   ,fParam(0x0)
   ,fCalibration(0x0)
   ,fCalVdriftROC(0x0)
   ,fCalT0ROC(0x0)
-  ,fCalVdriftDet(0x0)
-  ,fCalT0Det(0x0)
+  ,fCalPRFROC(0x0)
+  ,fkCalVdriftDet(0x0)
+  ,fkCalT0Det(0x0)
   ,fCalVdriftDetValue(0)
   ,fCalT0DetValue(0)
   ,fSamplingFrequency(0)
@@ -89,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();
@@ -106,26 +126,24 @@ 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)
   ,fDetector(t.fDetector)
   ,fParam(0x0)
   ,fCalibration(0x0)
   ,fCalVdriftROC(0x0)
   ,fCalT0ROC(0x0)
-  ,fCalVdriftDet(0x0)
-  ,fCalT0Det(0x0)
+  ,fCalPRFROC(0x0)
+  ,fkCalVdriftDet(0x0)
+  ,fkCalT0Det(0x0)
   ,fCalVdriftDetValue(0)
   ,fCalT0DetValue(0)
   ,fSamplingFrequency(0)
@@ -137,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");
@@ -153,8 +165,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();
 
 }
 
@@ -165,9 +177,50 @@ AliTRDtransform::~AliTRDtransform()
   // AliTRDtransform destructor
   //
 
-  if (fGeo) {
-    delete fGeo;
+}
+
+//_____________________________________________________________________________
+AliTRDtransform &AliTRDtransform::operator=(const AliTRDtransform &t)
+{
+  //
+  // Assignment operator
+  //
+
+  if (this != &t) {
+    ((AliTRDtransform &) t).Copy(*this);
+  }
+
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+void AliTRDtransform::Copy(TObject &t) const
+{
+  //
+  // Copy function
+  //
+
+  ((AliTRDtransform &) t).fDetector          = fDetector;
+  ((AliTRDtransform &) t).fParam             = AliTRDCommonParam::Instance();
+  ((AliTRDtransform &) t).fCalibration       = AliTRDcalibDB::Instance();
+  if (fCalibration) {
+    ((AliTRDtransform &) t).fkCalVdriftDet   = fCalibration->GetVdriftDet();
+    ((AliTRDtransform &) t).fkCalT0Det       = fCalibration->GetT0Det();
+  }
+  else {
+    ((AliTRDtransform &) t).fkCalVdriftDet   = 0;
+    ((AliTRDtransform &) t).fkCalT0Det       = 0;
   }
+  ((AliTRDtransform &) t).fCalVdriftROC      = 0x0;
+  ((AliTRDtransform &) t).fCalT0ROC          = 0x0;
+  ((AliTRDtransform &) t).fCalPRFROC         = 0x0;
+  ((AliTRDtransform &) t).fCalVdriftDetValue = 0; 
+  ((AliTRDtransform &) t).fCalT0DetValue     = 0;
+  ((AliTRDtransform &) t).fSamplingFrequency = 0;
+  ((AliTRDtransform &) t).fPadPlane          = 0x0;
+  ((AliTRDtransform &) t).fZShiftIdeal       = 0;
+  ((AliTRDtransform &) t).fMatrix            = 0x0;
 
 }
 
@@ -184,19 +237,20 @@ 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 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);
 
 }
 
@@ -225,21 +279,22 @@ 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);
 
   Float_t x = c->GetXloc(t0, vd);
 
-  // pad response width with diffusion corrections
-  Double_t s2  = AliTRDcalibDB::Instance()->GetPRFWidth(fDetector, col, row); s2 *= s2; 
-  Float_t dl, dt;
-  AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
-  s2 += dl*dl*x/(1.+2.*exb*exb);
-  s2 -= - 1.5e-1;
-
   // 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,
@@ -253,10 +308,11 @@ Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
 
   // store tracking values
   c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
-  c->SetSigmaY2(s2);
+  c->SetSigmaY2(s2, dt, exb, x);
   c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
   
   return kTRUE;
+
 }
 
 //_____________________________________________________________________________
@@ -271,4 +327,5 @@ void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
 
   if (setDet) SetDetector(c->GetDetector());
   Transform(c);
+
 }