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()
51 ,fCalVdriftDetValue(0)
53 ,fSamplingFrequency(0)
59 // AliTRDtransform default constructor
62 fParam = AliTRDCommonParam::Instance();
64 AliError("Could not get common parameters\n");
66 fSamplingFrequency = fParam->GetSamplingFrequency();
68 fCalibration = AliTRDcalibDB::Instance();
70 AliError("Cannot find calibration object");
73 // Get the calibration objects for the global calibration
74 fkCalVdriftDet = fCalibration->GetVdriftDet();
75 fkCalT0Det = fCalibration->GetT0Det();
79 //_____________________________________________________________________________
80 AliTRDtransform::AliTRDtransform(Int_t det)
90 ,fCalVdriftDetValue(0)
92 ,fSamplingFrequency(0)
98 // AliTRDtransform constructor for a given detector
101 fParam = AliTRDCommonParam::Instance();
103 AliError("Could not get common parameters\n");
105 fSamplingFrequency = fParam->GetSamplingFrequency();
107 fCalibration = AliTRDcalibDB::Instance();
109 AliError("Cannot find calibration object");
112 // Get the calibration objects for the global calibration
113 fkCalVdriftDet = fCalibration->GetVdriftDet();
114 fkCalT0Det = fCalibration->GetT0Det();
120 //_____________________________________________________________________________
121 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
123 ,fDetector(t.fDetector)
131 ,fCalVdriftDetValue(0)
133 ,fSamplingFrequency(0)
139 // AliTRDtransform copy constructor
142 fParam = AliTRDCommonParam::Instance();
144 AliError("Could not get common parameters\n");
146 fSamplingFrequency = fParam->GetSamplingFrequency();
148 fCalibration = AliTRDcalibDB::Instance();
150 AliError("Cannot find calibration object");
152 fkCalVdriftDet = fCalibration->GetVdriftDet();
153 fkCalT0Det = fCalibration->GetT0Det();
157 //_____________________________________________________________________________
158 AliTRDtransform::~AliTRDtransform()
161 // AliTRDtransform destructor
166 //_____________________________________________________________________________
167 AliTRDtransform &AliTRDtransform::operator=(const AliTRDtransform &t)
170 // Assignment operator
174 ((AliTRDtransform &) t).Copy(*this);
181 //_____________________________________________________________________________
182 void AliTRDtransform::Copy(TObject &t) const
188 ((AliTRDtransform &) t).fDetector = fDetector;
189 ((AliTRDtransform &) t).fParam = AliTRDCommonParam::Instance();
190 ((AliTRDtransform &) t).fCalibration = AliTRDcalibDB::Instance();
192 ((AliTRDtransform &) t).fkCalVdriftDet = fCalibration->GetVdriftDet();
193 ((AliTRDtransform &) t).fkCalT0Det = fCalibration->GetT0Det();
196 ((AliTRDtransform &) t).fkCalVdriftDet = 0;
197 ((AliTRDtransform &) t).fkCalT0Det = 0;
199 ((AliTRDtransform &) t).fCalVdriftROC = 0x0;
200 ((AliTRDtransform &) t).fCalT0ROC = 0x0;
201 ((AliTRDtransform &) t).fCalPRFROC = 0x0;
202 ((AliTRDtransform &) t).fCalVdriftDetValue = 0;
203 ((AliTRDtransform &) t).fCalT0DetValue = 0;
204 ((AliTRDtransform &) t).fSamplingFrequency = 0;
205 ((AliTRDtransform &) t).fPadPlane = 0x0;
206 ((AliTRDtransform &) t).fZShiftIdeal = 0;
207 ((AliTRDtransform &) t).fMatrix = 0x0;
211 //_____________________________________________________________________________
212 AliTRDgeometry& AliTRDtransform::Geometry()
214 static AliTRDgeometry g;
215 if (!g.CreateClusterMatrixArray()) {
216 AliErrorGeneral("AliTRDtransform::Geometry()", "Could not get transformation matrices\n");
221 //_____________________________________________________________________________
222 void AliTRDtransform::SetDetector(Int_t det)
225 // Set to a new detector number and update the calibration objects
226 // and values accordingly
231 // Get the calibration objects for the pad-by-pad calibration
232 fCalVdriftROC = fCalibration->GetVdriftROC(det);
233 fCalT0ROC = fCalibration->GetT0ROC(det);
234 fCalPRFROC = fCalibration->GetPRFROC(det);
236 // Get the detector wise defined calibration values
237 fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
238 fCalT0DetValue = fkCalT0Det->GetValue(det);
240 // Shift needed to define Z-position relative to middle of chamber
241 Int_t layer = Geometry().GetLayer(det);
242 Int_t stack = Geometry().GetStack(det);
243 fPadPlane = Geometry().GetPadPlane(layer,stack);
244 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
246 // Get the current transformation matrix
247 fMatrix = Geometry().GetClusterMatrix(det);
251 //_____________________________________________________________________________
252 Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
255 // Transforms the local cluster coordinates into calibrated
256 // space point positions defined in the local tracking system.
258 // Here the calibration for T0, Vdrift and ExB is applied as well.
260 // Input: Cluster in the local chamber coordinates
261 // Output: Tracking cluster
263 if (!fMatrix) return kFALSE;
266 // Parameters to adjust the X position of clusters in the alignable volume
267 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
270 // Retrieve calibration values
271 Int_t col = c->GetPadCol(), row = c->GetPadRow();
273 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
275 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
276 t0 /= fSamplingFrequency;
278 Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
280 Float_t x = c->GetXloc(t0, vd);
283 Double_t rs = fPadPlane->GetRowSize(row);
284 Double_t cs = fPadPlane->GetColSize(col);
286 // cluster error with diffusion corrections
287 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
290 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
292 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
294 kX0shift-x, // Invert the X-position,
295 c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
296 fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
299 // Go to tracking coordinates
301 fMatrix->LocalToMaster(loc, trk);
303 // store tracking values
304 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
305 c->SetSigmaY2(s2, dt, exb, x);
306 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
312 //_____________________________________________________________________________
313 void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
316 // Recalibrates the position of a given cluster
317 // If <setDet> is TRUE, the detector number is set for each cluster
318 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
322 if (setDet) SetDetector(c->GetDetector());