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 //_____________________________________________________________________________
41 AliTRDtransform::AliTRDtransform()
52 ,fCalVdriftDetValue(0)
55 ,fSamplingFrequency(0)
61 // AliTRDtransform default constructor
64 fParam = AliTRDCommonParam::Instance();
66 AliError("Could not get common parameters\n");
68 fSamplingFrequency = fParam->GetSamplingFrequency();
70 fCalibration = AliTRDcalibDB::Instance();
72 AliError("Cannot find calibration object");
75 // Get the calibration objects for the global calibration
76 fkCalVdriftDet = fCalibration->GetVdriftDet();
77 fkCalT0Det = fCalibration->GetT0Det();
78 fkCalExBDet = fCalibration->GetExBDet();
82 //_____________________________________________________________________________
83 AliTRDtransform::AliTRDtransform(Int_t det)
94 ,fCalVdriftDetValue(0)
97 ,fSamplingFrequency(0)
103 // AliTRDtransform constructor for a given detector
106 fParam = AliTRDCommonParam::Instance();
108 AliError("Could not get common parameters\n");
110 fSamplingFrequency = fParam->GetSamplingFrequency();
112 fCalibration = AliTRDcalibDB::Instance();
114 AliError("Cannot find calibration object");
117 // Get the calibration objects for the global calibration
118 fkCalVdriftDet = fCalibration->GetVdriftDet();
119 fkCalT0Det = fCalibration->GetT0Det();
120 fkCalExBDet = fCalibration->GetExBDet();
126 //_____________________________________________________________________________
127 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
129 ,fDetector(t.fDetector)
138 ,fCalVdriftDetValue(0)
141 ,fSamplingFrequency(0)
147 // AliTRDtransform copy constructor
150 fParam = AliTRDCommonParam::Instance();
152 AliError("Could not get common parameters\n");
154 fSamplingFrequency = fParam->GetSamplingFrequency();
156 fCalibration = AliTRDcalibDB::Instance();
158 AliError("Cannot find calibration object");
160 fkCalVdriftDet = fCalibration->GetVdriftDet();
161 fkCalT0Det = fCalibration->GetT0Det();
162 fkCalExBDet = fCalibration->GetExBDet();
165 //_____________________________________________________________________________
166 AliTRDtransform::~AliTRDtransform()
169 // AliTRDtransform destructor
174 //_____________________________________________________________________________
175 AliTRDtransform &AliTRDtransform::operator=(const AliTRDtransform &t)
178 // Assignment operator
182 ((AliTRDtransform &) t).Copy(*this);
189 //_____________________________________________________________________________
190 void AliTRDtransform::Copy(TObject &t) const
196 ((AliTRDtransform &) t).fDetector = fDetector;
197 ((AliTRDtransform &) t).fParam = AliTRDCommonParam::Instance();
198 ((AliTRDtransform &) t).fCalibration = AliTRDcalibDB::Instance();
200 ((AliTRDtransform &) t).fkCalVdriftDet = fCalibration->GetVdriftDet();
201 ((AliTRDtransform &) t).fkCalT0Det = fCalibration->GetT0Det();
202 ((AliTRDtransform &) t).fkCalExBDet = fCalibration->GetExBDet();
205 ((AliTRDtransform &) t).fkCalVdriftDet = 0;
206 ((AliTRDtransform &) t).fkCalT0Det = 0;
207 ((AliTRDtransform &) t).fkCalExBDet = 0;
209 ((AliTRDtransform &) t).fCalVdriftROC = 0x0;
210 ((AliTRDtransform &) t).fCalT0ROC = 0x0;
211 ((AliTRDtransform &) t).fCalPRFROC = 0x0;
212 ((AliTRDtransform &) t).fCalVdriftDetValue = 0;
213 ((AliTRDtransform &) t).fCalT0DetValue = 0;
214 ((AliTRDtransform &) t).fCalExBDetValue = 0;
215 ((AliTRDtransform &) t).fSamplingFrequency = 0;
216 ((AliTRDtransform &) t).fPadPlane = 0x0;
217 ((AliTRDtransform &) t).fZShiftIdeal = 0;
218 ((AliTRDtransform &) t).fMatrix = 0x0;
222 //_____________________________________________________________________________
223 AliTRDgeometry& AliTRDtransform::Geometry()
225 static AliTRDgeometry g;
226 if (!g.CreateClusterMatrixArray()) {
227 AliErrorGeneral("AliTRDtransform::Geometry()", "Could not get transformation matrices\n");
232 //_____________________________________________________________________________
233 void AliTRDtransform::SetDetector(Int_t det)
236 // Set to a new detector number and update the calibration objects
237 // and values accordingly
242 // Get the calibration objects for the pad-by-pad calibration
243 fCalVdriftROC = fCalibration->GetVdriftROC(det);
244 fCalT0ROC = fCalibration->GetT0ROC(det);
245 fCalPRFROC = fCalibration->GetPRFROC(det);
247 // Get the detector wise defined calibration values
248 fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
249 fCalT0DetValue = fkCalT0Det->GetValue(det);
250 fCalExBDetValue = fkCalExBDet->GetValue(det);
252 // Shift needed to define Z-position relative to middle of chamber
253 Int_t layer = Geometry().GetLayer(det);
254 Int_t stack = Geometry().GetStack(det);
255 fPadPlane = Geometry().GetPadPlane(layer,stack);
256 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
258 // Get the current transformation matrix
259 fMatrix = Geometry().GetClusterMatrix(det);
263 //_____________________________________________________________________________
264 Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
267 // Transforms the local cluster coordinates into calibrated
268 // space point positions defined in the local tracking system.
270 // Here the calibration for T0, Vdrift and ExB is applied as well.
272 // Input: Cluster in the local chamber coordinates
273 // Output: Tracking cluster
275 if (!fMatrix) return kFALSE;
278 // Parameters to adjust the X position of clusters in the alignable volume
279 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
282 // Retrieve calibration values
283 Int_t col = c->GetPadCol(), row = c->GetPadRow();
285 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
287 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
288 t0 /= fSamplingFrequency;
290 Double_t exb = fCalExBDetValue;//AliTRDCommonParam::Instance()->GetOmegaTau(vd);
292 Float_t x = c->GetXloc(t0, vd);
295 Double_t rs = fPadPlane->GetRowSize(row);
296 Double_t cs = fPadPlane->GetColSize(col);
298 // cluster error with diffusion corrections
299 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
302 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
304 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
306 kX0shift-x, // Invert the X-position,
307 c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
308 fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
311 // Go to tracking coordinates
313 fMatrix->LocalToMaster(loc, trk);
315 // store tracking values
316 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
317 c->SetSigmaY2(s2, dt, exb, x);
318 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
324 //_____________________________________________________________________________
325 void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
328 // Recalibrates the position of a given cluster
329 // If <setDet> is TRUE, the detector number is set for each cluster
330 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
334 if (setDet) SetDetector(c->GetDetector());