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>
29 #include "AliTRDtransform.h"
30 #include "AliTRDcluster.h"
31 #include "AliTRDgeometry.h"
32 #include "AliTRDpadPlane.h"
33 #include "AliTRDCommonParam.h"
34 #include "AliTRDcalibDB.h"
35 #include "Cal/AliTRDCalDet.h"
36 #include "Cal/AliTRDCalROC.h"
38 ClassImp(AliTRDtransform)
40 AliTRDgeometry* AliTRDtransform::fgGeo = NULL;
42 //_____________________________________________________________________________
43 AliTRDtransform::AliTRDtransform()
53 ,fCalVdriftDetValue(0)
55 ,fSamplingFrequency(0)
61 // AliTRDtransform default constructor
65 fgGeo = new AliTRDgeometry();
66 if (!fgGeo->CreateClusterMatrixArray()) {
67 AliError("Could not get transformation matrices\n");
71 fParam = AliTRDCommonParam::Instance();
73 AliError("Could not get common parameters\n");
75 fSamplingFrequency = fParam->GetSamplingFrequency();
77 fCalibration = AliTRDcalibDB::Instance();
79 AliError("Cannot find calibration object");
82 // Get the calibration objects for the global calibration
83 fkCalVdriftDet = fCalibration->GetVdriftDet();
84 fkCalT0Det = fCalibration->GetT0Det();
88 //_____________________________________________________________________________
89 AliTRDtransform::AliTRDtransform(Int_t det)
99 ,fCalVdriftDetValue(0)
101 ,fSamplingFrequency(0)
107 // AliTRDtransform constructor for a given detector
111 fgGeo = new AliTRDgeometry();
112 if (!fgGeo->CreateClusterMatrixArray()) {
113 AliError("Could not get transformation matrices\n");
117 fParam = AliTRDCommonParam::Instance();
119 AliError("Could not get common parameters\n");
121 fSamplingFrequency = fParam->GetSamplingFrequency();
123 fCalibration = AliTRDcalibDB::Instance();
125 AliError("Cannot find calibration object");
128 // Get the calibration objects for the global calibration
129 fkCalVdriftDet = fCalibration->GetVdriftDet();
130 fkCalT0Det = fCalibration->GetT0Det();
136 //_____________________________________________________________________________
137 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
139 ,fDetector(t.fDetector)
147 ,fCalVdriftDetValue(0)
149 ,fSamplingFrequency(0)
155 // AliTRDtransform copy constructor
158 fParam = AliTRDCommonParam::Instance();
160 AliError("Could not get common parameters\n");
162 fSamplingFrequency = fParam->GetSamplingFrequency();
164 fCalibration = AliTRDcalibDB::Instance();
166 AliError("Cannot find calibration object");
168 fkCalVdriftDet = fCalibration->GetVdriftDet();
169 fkCalT0Det = fCalibration->GetT0Det();
173 //_____________________________________________________________________________
174 AliTRDtransform::~AliTRDtransform()
177 // AliTRDtransform destructor
182 //_____________________________________________________________________________
183 void AliTRDtransform::SetDetector(Int_t det)
186 // Set to a new detector number and update the calibration objects
187 // and values accordingly
192 // Get the calibration objects for the pad-by-pad calibration
193 fCalVdriftROC = fCalibration->GetVdriftROC(det);
194 fCalT0ROC = fCalibration->GetT0ROC(det);
195 fCalPRFROC = fCalibration->GetPRFROC(det);
197 // Get the detector wise defined calibration values
198 fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
199 fCalT0DetValue = fkCalT0Det->GetValue(det);
201 // Shift needed to define Z-position relative to middle of chamber
202 Int_t layer = fgGeo->GetLayer(det);
203 Int_t stack = fgGeo->GetStack(det);
204 fPadPlane = fgGeo->GetPadPlane(layer,stack);
205 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
207 // Get the current transformation matrix
208 fMatrix = fgGeo->GetClusterMatrix(det);
212 //_____________________________________________________________________________
213 Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
216 // Transforms the local cluster coordinates into calibrated
217 // space point positions defined in the local tracking system.
219 // Here the calibration for T0, Vdrift and ExB is applied as well.
221 // Input: Cluster in the local chamber coordinates
222 // Output: Tracking cluster
224 if (!fMatrix) return kFALSE;
227 // Parameters to adjust the X position of clusters in the alignable volume
228 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
231 // Retrieve calibration values
232 Int_t col = c->GetPadCol(), row = c->GetPadRow();
234 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
236 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
237 t0 /= fSamplingFrequency;
239 Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
241 Float_t x = c->GetXloc(t0, vd);
244 Double_t rs = fPadPlane->GetRowSize(row);
245 Double_t cs = fPadPlane->GetColSize(col);
247 // cluster error with diffusion corrections
248 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
251 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
253 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
255 kX0shift-x, // Invert the X-position,
256 c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
257 fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
260 // Go to tracking coordinates
262 fMatrix->LocalToMaster(loc, trk);
264 // store tracking values
265 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
266 c->SetSigmaY2(s2, dt, exb, x);
267 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
273 //_____________________________________________________________________________
274 void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
277 // Recalibrates the position of a given cluster
278 // If <setDet> is TRUE, the detector number is set for each cluster
279 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
283 if (setDet) SetDetector(c->GetDetector());