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)
54 ,fSamplingFrequency(0)
60 // AliTRDtransform default constructor
63 fGeo = new AliTRDgeometry();
64 if (!fGeo->CreateClusterMatrixArray()) {
65 AliError("Could not get transformation matrices\n");
68 fParam = AliTRDCommonParam::Instance();
70 AliError("Could not get common parameters\n");
72 fSamplingFrequency = fParam->GetSamplingFrequency();
74 fCalibration = AliTRDcalibDB::Instance();
76 AliError("Cannot find calibration object");
79 // Get the calibration objects for the global calibration
80 fkCalVdriftDet = fCalibration->GetVdriftDet();
81 fkCalT0Det = fCalibration->GetT0Det();
85 //_____________________________________________________________________________
86 AliTRDtransform::AliTRDtransform(Int_t det)
97 ,fCalVdriftDetValue(0)
99 ,fSamplingFrequency(0)
105 // AliTRDtransform constructor for a given detector
108 fGeo = new AliTRDgeometry();
109 if (!fGeo->CreateClusterMatrixArray()) {
110 AliError("Could not get transformation matrices\n");
113 fParam = AliTRDCommonParam::Instance();
115 AliError("Could not get common parameters\n");
117 fSamplingFrequency = fParam->GetSamplingFrequency();
119 fCalibration = AliTRDcalibDB::Instance();
121 AliError("Cannot find calibration object");
124 // Get the calibration objects for the global calibration
125 fkCalVdriftDet = fCalibration->GetVdriftDet();
126 fkCalT0Det = fCalibration->GetT0Det();
132 //_____________________________________________________________________________
133 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
136 ,fDetector(t.fDetector)
144 ,fCalVdriftDetValue(0)
146 ,fSamplingFrequency(0)
152 // AliTRDtransform copy constructor
158 fGeo = new AliTRDgeometry();
159 fGeo->CreateClusterMatrixArray();
161 fParam = AliTRDCommonParam::Instance();
163 AliError("Could not get common parameters\n");
165 fSamplingFrequency = fParam->GetSamplingFrequency();
167 fCalibration = AliTRDcalibDB::Instance();
169 AliError("Cannot find calibration object");
171 fkCalVdriftDet = fCalibration->GetVdriftDet();
172 fkCalT0Det = fCalibration->GetT0Det();
176 //_____________________________________________________________________________
177 AliTRDtransform::~AliTRDtransform()
180 // AliTRDtransform destructor
189 //_____________________________________________________________________________
190 void AliTRDtransform::SetDetector(Int_t det)
193 // Set to a new detector number and update the calibration objects
194 // and values accordingly
199 // Get the calibration objects for the pad-by-pad calibration
200 fCalVdriftROC = fCalibration->GetVdriftROC(det);
201 fCalT0ROC = fCalibration->GetT0ROC(det);
202 fCalPRFROC = fCalibration->GetPRFROC(det);
204 // Get the detector wise defined calibration values
205 fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
206 fCalT0DetValue = fkCalT0Det->GetValue(det);
208 // Shift needed to define Z-position relative to middle of chamber
209 Int_t layer = fGeo->GetLayer(det);
210 Int_t stack = fGeo->GetStack(det);
211 fPadPlane = fGeo->GetPadPlane(layer,stack);
212 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
214 // Get the current transformation matrix
215 fMatrix = fGeo->GetClusterMatrix(det);
219 //_____________________________________________________________________________
220 Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
223 // Transforms the local cluster coordinates into calibrated
224 // space point positions defined in the local tracking system.
226 // Here the calibration for T0, Vdrift and ExB is applied as well.
228 // Input: Cluster in the local chamber coordinates
229 // Output: Tracking cluster
231 if (!fMatrix) return kFALSE;
234 // Parameters to adjust the X position of clusters in the alignable volume
235 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
238 // Retrieve calibration values
239 Int_t col = c->GetPadCol(), row = c->GetPadRow();
241 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
243 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
244 t0 /= fSamplingFrequency;
246 Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
248 Float_t x = c->GetXloc(t0, vd);
251 Double_t rs = fPadPlane->GetRowSize(row);
252 Double_t cs = fPadPlane->GetColSize(col);
254 // cluster error with diffusion corrections
255 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
258 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
260 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
262 kX0shift-x, // Invert the X-position,
263 c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
264 fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
267 // Go to tracking coordinates
269 fMatrix->LocalToMaster(loc, trk);
271 // store tracking values
272 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
273 c->SetSigmaY2(s2, dt, exb, x);
274 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
280 //_____________________________________________________________________________
281 void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
284 // Recalibrates the position of a given cluster
285 // If <setDet> is TRUE, the detector number is set for each cluster
286 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
290 if (setDet) SetDetector(c->GetDetector());