1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Transforms clusters into space points with calibrated positions //
21 // defined in the local tracking system //
23 ////////////////////////////////////////////////////////////////////////////
25 #include <TGeoMatrix.h>
28 #include "AliTracker.h"
29 #include "AliCodeTimer.h"
31 #include "AliTRDtransform.h"
32 #include "AliTRDcluster.h"
33 #include "AliTRDgeometry.h"
34 #include "AliTRDpadPlane.h"
35 #include "AliTRDCommonParam.h"
36 #include "AliTRDcalibDB.h"
37 #include "Cal/AliTRDCalDet.h"
38 #include "Cal/AliTRDCalROC.h"
40 ClassImp(AliTRDtransform)
42 //_____________________________________________________________________________
43 //AliTRDtransform::AliTRDtransform()
45 AliTRDtransform::AliTRDtransform()
56 ,fCalVdriftDetValue(0)
58 ,fSamplingFrequency(0)
64 // AliTRDtransform default constructor
69 //_____________________________________________________________________________
70 //AliTRDtransform::AliTRDtransform(Int_t det)
72 AliTRDtransform::AliTRDtransform(Int_t det)
83 ,fCalVdriftDetValue(0)
85 ,fSamplingFrequency(0)
91 // AliTRDtransform constructor for a given detector
94 fGeo = new AliTRDgeometry();
95 if (!fGeo->CreateClusterMatrixArray()) {
96 AliError("Could not get transformation matrices\n");
99 fParam = AliTRDCommonParam::Instance();
101 AliError("Could not get common parameters\n");
103 fSamplingFrequency = fParam->GetSamplingFrequency();
105 fCalibration = AliTRDcalibDB::Instance();
107 AliError("Cannot find calibration object");
110 // Get the calibration objects for the global calibration
111 fCalVdriftDet = fCalibration->GetVdriftDet();
112 fCalT0Det = fCalibration->GetT0Det();
118 //_____________________________________________________________________________
119 //AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
121 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
124 ,fDetector(t.fDetector)
132 ,fCalVdriftDetValue(0)
134 ,fSamplingFrequency(0)
140 // AliTRDtransform copy constructor
146 fGeo = new AliTRDgeometry();
147 fGeo->CreateClusterMatrixArray();
149 fParam = AliTRDCommonParam::Instance();
151 AliError("Could not get common parameters\n");
153 fSamplingFrequency = fParam->GetSamplingFrequency();
155 fCalibration = AliTRDcalibDB::Instance();
157 AliError("Cannot find calibration object");
159 fCalVdriftDet = fCalibration->GetVdriftDet();
160 fCalT0Det = fCalibration->GetT0Det();
164 //_____________________________________________________________________________
165 AliTRDtransform::~AliTRDtransform()
168 // AliTRDtransform destructor
177 //_____________________________________________________________________________
178 void AliTRDtransform::SetDetector(Int_t det)
181 // Set to a new detector number and update the calibration objects
182 // and values accordingly
187 // Get the calibration objects for the pad-by-pad calibration
188 fCalVdriftROC = fCalibration->GetVdriftROC(det);
189 fCalT0ROC = fCalibration->GetT0ROC(det);
190 fCalPRFROC = fCalibration->GetPRFROC(det);
192 // Get the detector wise defined calibration values
193 fCalVdriftDetValue = fCalVdriftDet->GetValue(det);
194 fCalT0DetValue = fCalT0Det->GetValue(det);
196 // Shift needed to define Z-position relative to middle of chamber
197 Int_t layer = fGeo->GetLayer(det);
198 Int_t stack = fGeo->GetStack(det);
199 fPadPlane = fGeo->GetPadPlane(layer,stack);
200 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
202 // Get the current transformation matrix
203 fMatrix = fGeo->GetClusterMatrix(det);
207 //_____________________________________________________________________________
208 Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
211 // Transforms the local cluster coordinates into calibrated
212 // space point positions defined in the local tracking system.
214 // Here the calibration for T0, Vdrift and ExB is applied as well.
216 // Input: Cluster in the local chamber coordinates
217 // Output: Tracking cluster
219 if (!fMatrix) return kFALSE;
222 // Parameters to adjust the X position of clusters in the alignable volume
223 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
226 // Retrieve calibration values
227 Int_t col = c->GetPadCol(), row = c->GetPadRow();
229 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
231 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
233 Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
235 Float_t x = c->GetXloc(t0, vd);
238 Double_t rs = fPadPlane->GetRowSize(row);
239 Double_t cs = fPadPlane->GetColSize(col);
241 // cluster error with diffusion corrections
242 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
245 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
247 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
249 kX0shift-x, // Invert the X-position,
250 c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
251 fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
254 // Go to tracking coordinates
256 fMatrix->LocalToMaster(loc, trk);
258 // store tracking values
259 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
260 c->SetSigmaY2(s2, dt, exb, x);
261 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
266 //_____________________________________________________________________________
267 void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
270 // Recalibrates the position of a given cluster
271 // If <setDet> is TRUE, the detector number is set for each cluster
272 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
276 if (setDet) SetDetector(c->GetDetector());