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>
28 #include "AliTracker.h"
29 #include "AliCodeTimer.h"
31 #include "AliTRDtransform.h"
32 #include "AliTRDcluster.h"
33 #include "AliTRDgeometry.h"
34 #include "AliTRDpadPlane.h"
35 #include "AliTRDCommonParam.h"
36 #include "AliTRDcalibDB.h"
37 #include "Cal/AliTRDCalDet.h"
38 #include "Cal/AliTRDCalROC.h"
40 ClassImp(AliTRDtransform)
42 //_____________________________________________________________________________
43 //AliTRDtransform::AliTRDtransform()
45 AliTRDtransform::AliTRDtransform()
55 ,fCalVdriftDetValue(0)
57 ,fSamplingFrequency(0)
63 // AliTRDtransform default constructor
68 //_____________________________________________________________________________
69 //AliTRDtransform::AliTRDtransform(Int_t det)
71 AliTRDtransform::AliTRDtransform(Int_t det)
81 ,fCalVdriftDetValue(0)
83 ,fSamplingFrequency(0)
89 // AliTRDtransform constructor for a given detector
92 fGeo = new AliTRDgeometry();
93 if (!fGeo->CreateClusterMatrixArray()) {
94 AliError("Could not get transformation matrices\n");
97 fParam = AliTRDCommonParam::Instance();
99 AliError("Could not get common parameters\n");
101 fSamplingFrequency = fParam->GetSamplingFrequency();
103 fCalibration = AliTRDcalibDB::Instance();
105 AliError("Cannot find calibration object");
108 // Get the calibration objects for the global calibration
109 fCalVdriftDet = fCalibration->GetVdriftDet();
110 fCalT0Det = fCalibration->GetT0Det();
116 //_____________________________________________________________________________
117 //AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
119 AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
122 ,fDetector(t.fDetector)
129 ,fCalVdriftDetValue(0)
131 ,fSamplingFrequency(0)
137 // AliTRDtransform copy constructor
143 fGeo = new AliTRDgeometry();
144 fGeo->CreateClusterMatrixArray();
146 fParam = AliTRDCommonParam::Instance();
148 AliError("Could not get common parameters\n");
150 fSamplingFrequency = fParam->GetSamplingFrequency();
152 fCalibration = AliTRDcalibDB::Instance();
154 AliError("Cannot find calibration object");
156 fCalVdriftDet = fCalibration->GetVdriftDet();
157 fCalT0Det = fCalibration->GetT0Det();
161 //_____________________________________________________________________________
162 AliTRDtransform::~AliTRDtransform()
165 // AliTRDtransform destructor
174 //_____________________________________________________________________________
175 void AliTRDtransform::SetDetector(Int_t det)
178 // Set to a new detector number and update the calibration objects
179 // and values accordingly
184 // Get the calibration objects for the pad-by-pad calibration
185 fCalVdriftROC = fCalibration->GetVdriftROC(det);
186 fCalT0ROC = fCalibration->GetT0ROC(det);
188 // Get the detector wise defined calibration values
189 fCalVdriftDetValue = fCalVdriftDet->GetValue(det);
190 fCalT0DetValue = fCalT0Det->GetValue(det);
192 // Shift needed to define Z-position relative to middle of chamber
193 Int_t pla = fGeo->GetPlane(det);
194 Int_t cha = fGeo->GetChamber(det);
195 fPadPlane = fGeo->GetPadPlane(pla,cha);
196 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
198 // Get the current transformation matrix
199 fMatrix = fGeo->GetClusterMatrix(det);
203 //_____________________________________________________________________________
204 Bool_t AliTRDtransform::Transform(Double_t *x, Int_t *i, UInt_t time
205 , Int_t /*coordinateType*/)
208 // Transforms the local cluster coordinates into calibrated
209 // space point positions defined in the local tracking system.
211 // Here the calibration for T0, Vdrift and ExB is applied as well.
214 // x[0] = COL-position relative to the center pad (pad units)
215 // x[1] = cluster signal in left pad
216 // x[2] = cluster signal in middle pad
217 // x[3] = cluster signal in right pad
218 // i[0] = ROW pad number
219 // i[1] = COL pad number
220 // time = time bin number (uncalibrated for t0)
223 // x[0] = X-positions in tracking CS
224 // x[1] = Y-positions in tracking CS
225 // x[2] = Z-positions in tracking CS
226 // x[3] = total cluster charge
227 // x[4] = error in Y-direction
228 // x[5] = error in Z-direction
229 // i[2] = time bin number (calibrated for t0)
232 Double_t posLocal[3];
233 Double_t posTracking[3];
238 // Parameter to adjust the X position
239 const Double_t kX0shift = 2.52;
256 // Calibration values
257 Double_t vdrift = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
258 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
261 Double_t timeT0Cal = time - t0;
262 // Calculate the X-position,
263 Double_t xLocal = (timeT0Cal + 0.5) / fSamplingFrequency * vdrift;
265 // Length of the amplification region
266 Double_t ampLength = (Double_t) AliTRDgeometry::CamHght();
267 // The drift distance
268 Double_t driftLength = TMath::Max(xLocal - 0.5*ampLength,0.0);
270 Double_t exbCorr = fCalibration->GetOmegaTau(vdrift
271 ,-0.1*AliTracker::GetBz());
274 Double_t rowSize = fPadPlane->GetRowSize(row);
275 Double_t colSize = fPadPlane->GetColSize(col);
277 // Invert the X-position,
278 // apply ExB correction to the Y-position
279 // and move to the Z-position relative to the middle of the chamber
280 posLocal[0] = -xLocal;
281 posLocal[1] = (fPadPlane->GetColPos(col) - (x[0] + 0.5) * colSize) - driftLength * exbCorr;
282 posLocal[2] = (fPadPlane->GetRowPos(row) - 0.5 * rowSize) - fZShiftIdeal;
284 // Go to tracking coordinates
285 fMatrix->LocalToMaster(posLocal,posTracking);
287 // The total charge of the cluster
291 Double_t clusterCharge = q0 + q1 + q2;
292 Double_t clusterSigmaY2 = 0.0;
293 if (clusterCharge > 0.0) {
294 clusterSigmaY2 = (q1 * (q0 + q2) + 4.0 * q0 * q2)
295 / (clusterCharge*clusterCharge);
299 x[0] = posTracking[0] + kX0shift;
300 x[1] = posTracking[1];
301 x[2] = posTracking[2];
302 x[3] = clusterCharge;
303 x[4] = colSize*colSize * (clusterSigmaY2 + 1.0/12.0);
304 x[5] = rowSize*rowSize / 12.0;
305 i[2] = TMath::Nint(timeT0Cal);
313 //_____________________________________________________________________________
314 void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
317 // Recalibrates the position of a given cluster
318 // If <setDet> is TRUE, the detector number is set for each cluster
319 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
324 SetDetector(c->GetDetector());
327 // Transform the local cluster coordinates into recalibrated
328 // space point positions defined in the local tracking system.
329 // Here the calibration for T0, Vdrift and ExB is applied as well.
330 Double_t clusterXYZ[6];
331 clusterXYZ[0] = c->GetCenter();
338 clusterRCT[0] = c->GetPadRow();
339 clusterRCT[1] = c->GetPadCol();
341 Int_t time = c->GetPadTime();
342 Transform(clusterXYZ,clusterRCT,((UInt_t) time),0);
344 // Set the recalibrated coordinates
345 c->SetX(clusterXYZ[0]);
346 c->SetY(clusterXYZ[1]);
347 c->SetZ(clusterXYZ[2]);
348 c->SetLocalTimeBin(((Char_t) clusterRCT[2]));