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
65 //_____________________________________________________________________________
66 AliTRDtransform::AliTRDtransform(Int_t det)
77 ,fCalVdriftDetValue(0)
79 ,fSamplingFrequency(0)
85 // AliTRDtransform constructor for a given detector
88 fGeo = new AliTRDgeometry();
89 if (!fGeo->CreateClusterMatrixArray()) {
90 AliError("Could not get transformation matrices\n");
93 fParam = AliTRDCommonParam::Instance();
95 AliError("Could not get common parameters\n");
97 fSamplingFrequency = fParam->GetSamplingFrequency();
99 fCalibration = AliTRDcalibDB::Instance();
101 AliError("Cannot find calibration object");
104 // Get the calibration objects for the global calibration
105 fkCalVdriftDet = fCalibration->GetVdriftDet();
106 fkCalT0Det = fCalibration->GetT0Det();
112 //_____________________________________________________________________________
113 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
116 ,fDetector(t.fDetector)
124 ,fCalVdriftDetValue(0)
126 ,fSamplingFrequency(0)
132 // AliTRDtransform copy constructor
138 fGeo = new AliTRDgeometry();
139 fGeo->CreateClusterMatrixArray();
141 fParam = AliTRDCommonParam::Instance();
143 AliError("Could not get common parameters\n");
145 fSamplingFrequency = fParam->GetSamplingFrequency();
147 fCalibration = AliTRDcalibDB::Instance();
149 AliError("Cannot find calibration object");
151 fkCalVdriftDet = fCalibration->GetVdriftDet();
152 fkCalT0Det = fCalibration->GetT0Det();
156 //_____________________________________________________________________________
157 AliTRDtransform::~AliTRDtransform()
160 // AliTRDtransform destructor
169 //_____________________________________________________________________________
170 void AliTRDtransform::SetDetector(Int_t det)
173 // Set to a new detector number and update the calibration objects
174 // and values accordingly
179 // Get the calibration objects for the pad-by-pad calibration
180 fCalVdriftROC = fCalibration->GetVdriftROC(det);
181 fCalT0ROC = fCalibration->GetT0ROC(det);
182 fCalPRFROC = fCalibration->GetPRFROC(det);
184 // Get the detector wise defined calibration values
185 fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
186 fCalT0DetValue = fkCalT0Det->GetValue(det);
188 // Shift needed to define Z-position relative to middle of chamber
189 Int_t layer = fGeo->GetLayer(det);
190 Int_t stack = fGeo->GetStack(det);
191 fPadPlane = fGeo->GetPadPlane(layer,stack);
192 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
194 // Get the current transformation matrix
195 fMatrix = fGeo->GetClusterMatrix(det);
199 //_____________________________________________________________________________
200 Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
203 // Transforms the local cluster coordinates into calibrated
204 // space point positions defined in the local tracking system.
206 // Here the calibration for T0, Vdrift and ExB is applied as well.
208 // Input: Cluster in the local chamber coordinates
209 // Output: Tracking cluster
211 if (!fMatrix) return kFALSE;
214 // Parameters to adjust the X position of clusters in the alignable volume
215 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
218 // Retrieve calibration values
219 Int_t col = c->GetPadCol(), row = c->GetPadRow();
221 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
223 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
224 t0 /= fSamplingFrequency;
226 Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
228 Float_t x = c->GetXloc(t0, vd);
231 Double_t rs = fPadPlane->GetRowSize(row);
232 Double_t cs = fPadPlane->GetColSize(col);
234 // cluster error with diffusion corrections
235 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
238 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
240 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
242 kX0shift-x, // Invert the X-position,
243 c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
244 fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
247 // Go to tracking coordinates
249 fMatrix->LocalToMaster(loc, trk);
251 // store tracking values
252 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
253 c->SetSigmaY2(s2, dt, exb, x);
254 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
260 //_____________________________________________________________________________
261 void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
264 // Recalibrates the position of a given cluster
265 // If <setDet> is TRUE, the detector number is set for each cluster
266 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
270 if (setDet) SetDetector(c->GetDetector());