]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDtransform.cxx
AliDCSClient "multiSplit" option added in the DCS configuration
[u/mrichter/AliRoot.git] / TRD / AliTRDtransform.cxx
CommitLineData
af26ce80 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18////////////////////////////////////////////////////////////////////////////
19// //
20// Transforms clusters into space points with calibrated positions //
21// defined in the local tracking system //
22// //
23////////////////////////////////////////////////////////////////////////////
24
25#include <TGeoMatrix.h>
26
27#include "AliLog.h"
28#include "AliTracker.h"
29#include "AliCodeTimer.h"
30
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"
39
40ClassImp(AliTRDtransform)
41
42//_____________________________________________________________________________
43//AliTRDtransform::AliTRDtransform()
44// :AliTransform()
45AliTRDtransform::AliTRDtransform()
46 :TObject()
47 ,fGeo(0x0)
48 ,fDetector(0)
49 ,fParam(0x0)
50 ,fCalibration(0x0)
51 ,fCalVdriftROC(0x0)
52 ,fCalT0ROC(0x0)
53 ,fCalVdriftDet(0x0)
54 ,fCalT0Det(0x0)
55 ,fCalVdriftDetValue(0)
56 ,fCalT0DetValue(0)
57 ,fSamplingFrequency(0)
58 ,fPadPlane(0x0)
59 ,fZShiftIdeal(0)
60 ,fMatrix(0x0)
61{
62 //
63 // AliTRDtransform default constructor
64 //
65
66}
67
68//_____________________________________________________________________________
69//AliTRDtransform::AliTRDtransform(Int_t det)
70// :AliTransform()
71AliTRDtransform::AliTRDtransform(Int_t det)
72 :TObject()
73 ,fGeo(0x0)
74 ,fDetector(0)
75 ,fParam(0x0)
76 ,fCalibration(0x0)
77 ,fCalVdriftROC(0x0)
78 ,fCalT0ROC(0x0)
79 ,fCalVdriftDet(0x0)
80 ,fCalT0Det(0x0)
81 ,fCalVdriftDetValue(0)
82 ,fCalT0DetValue(0)
83 ,fSamplingFrequency(0)
84 ,fPadPlane(0x0)
85 ,fZShiftIdeal(0)
86 ,fMatrix(0x0)
87{
88 //
89 // AliTRDtransform constructor for a given detector
90 //
91
92 fGeo = new AliTRDgeometry();
9a96f175 93 fGeo->CreateClusterMatrixArray();
af26ce80 94
95 fParam = AliTRDCommonParam::Instance();
96 if (!fParam) {
97 AliError("Could not get common parameters\n");
98 }
99 fSamplingFrequency = fParam->GetSamplingFrequency();
100
101 fCalibration = AliTRDcalibDB::Instance();
102 if (!fCalibration) {
103 AliError("Cannot find calibration object");
104 }
105
106 // Get the calibration objects for the global calibration
107 fCalVdriftDet = fCalibration->GetVdriftDet();
108 fCalT0Det = fCalibration->GetT0Det();
109
110 SetDetector(det);
111
112}
113
114//_____________________________________________________________________________
115//AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
116// :AliTransform(t)
117AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
118 :TObject(t)
119 ,fGeo(0x0)
120 ,fDetector(t.fDetector)
121 ,fParam(0x0)
122 ,fCalibration(0x0)
123 ,fCalVdriftROC(0x0)
124 ,fCalT0ROC(0x0)
125 ,fCalVdriftDet(0x0)
126 ,fCalT0Det(0x0)
127 ,fCalVdriftDetValue(0)
128 ,fCalT0DetValue(0)
129 ,fSamplingFrequency(0)
130 ,fPadPlane(0x0)
131 ,fZShiftIdeal(0)
132 ,fMatrix(0x0)
133{
134 //
135 // AliTRDtransform copy constructor
136 //
137
138 if (fGeo) {
139 delete fGeo;
140 }
141 fGeo = new AliTRDgeometry();
9a96f175 142 fGeo->CreateClusterMatrixArray();
af26ce80 143
144 fParam = AliTRDCommonParam::Instance();
145 if (!fParam) {
146 AliError("Could not get common parameters\n");
147 }
148 fSamplingFrequency = fParam->GetSamplingFrequency();
149
150 fCalibration = AliTRDcalibDB::Instance();
151 if (!fCalibration) {
152 AliError("Cannot find calibration object");
153 }
154 fCalVdriftDet = fCalibration->GetVdriftDet();
155 fCalT0Det = fCalibration->GetT0Det();
156
157}
158
159//_____________________________________________________________________________
160AliTRDtransform::~AliTRDtransform()
161{
162 //
163 // AliTRDtransform destructor
164 //
165
166 if (fGeo) {
167 delete fGeo;
168 }
169
170}
171
172//_____________________________________________________________________________
173void AliTRDtransform::SetDetector(Int_t det)
174{
175 //
176 // Set to a new detector number and update the calibration objects
177 // and values accordingly
178 //
179
180 fDetector = det;
181
182 // Get the calibration objects for the pad-by-pad calibration
183 fCalVdriftROC = fCalibration->GetVdriftROC(det);
184 fCalT0ROC = fCalibration->GetT0ROC(det);
185
186 // Get the detector wise defined calibration values
187 fCalVdriftDetValue = fCalVdriftDet->GetValue(det);
188 fCalT0DetValue = fCalT0Det->GetValue(det);
189
190 // Shift needed to define Z-position relative to middle of chamber
191 Int_t pla = fGeo->GetPlane(det);
192 Int_t cha = fGeo->GetChamber(det);
193 fPadPlane = fGeo->GetPadPlane(pla,cha);
194 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
195
196 // Get the current transformation matrix
9a96f175 197 fMatrix = fGeo->GetClusterMatrix(det);
af26ce80 198
199}
200
201//_____________________________________________________________________________
202void AliTRDtransform::Transform(Double_t *x, Int_t *i, UInt_t time
203 , Int_t /*coordinateType*/)
204{
205 //
206 // Transforms the local cluster coordinates into calibrated
207 // space point positions defined in the local tracking system.
208 //
209 // Here the calibration for T0, Vdrift and ExB is applied as well.
210 //
211 // Input:
212 // x[0] = COL-position relative to the center pad (pad units)
213 // x[1] = cluster signal in left pad
214 // x[2] = cluster signal in middle pad
215 // x[3] = cluster signal in right pad
216 // i[0] = ROW pad number
217 // i[1] = COL pad number
218 // time = time bin number (uncalibrated for t0)
219 //
220 // Output:
221 // x[0] = X-positions in tracking CS
222 // x[1] = Y-positions in tracking CS
223 // x[2] = Z-positions in tracking CS
224 // x[3] = total cluster charge
225 // x[4] = error in Y-direction
226 // x[5] = error in Z-direction
227 // i[2] = time bin number (calibrated for t0)
228 //
229
230 Double_t posLocal[3];
231 Double_t posTracking[3];
232
233 Int_t row = i[0];
234 Int_t col = i[1];
235
236 // Parameter to adjust the X position
237 const Double_t kX0shift = 2.52;
238
1814b374 239 if (!fMatrix) {
240
241 x[0] = 0.0;
242 x[1] = 0.0;
243 x[2] = 0.0;
244 x[3] = 0.0;
245 x[4] = 0.0;
246 x[5] = 0.0;
247 i[2] = 0;
248
af26ce80 249 }
1814b374 250 else {
251
252 // Calibration values
253 Double_t vdrift = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
254 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
255
256 // T0 correction
257 Double_t timeT0Cal = time - t0;
258 // Calculate the X-position,
259 Double_t xLocal = (timeT0Cal + 0.5) / fSamplingFrequency * vdrift;
260
261 // Length of the amplification region
262 Double_t ampLength = (Double_t) AliTRDgeometry::CamHght();
263 // The drift distance
264 Double_t driftLength = TMath::Max(xLocal - 0.5*ampLength,0.0);
265 // ExB correction
266 Double_t exbCorr = fCalibration->GetOmegaTau(vdrift
267 ,-0.1*AliTracker::GetBz());
268
269 // Pad dimensions
270 Double_t rowSize = fPadPlane->GetRowSize(row);
271 Double_t colSize = fPadPlane->GetColSize(col);
272
273 // Invert the X-position,
274 // apply ExB correction to the Y-position
275 // and move to the Z-position relative to the middle of the chamber
276 posLocal[0] = -xLocal;
277 posLocal[1] = (fPadPlane->GetColPos(col) - (x[0] + 0.5) * colSize) - driftLength * exbCorr;
278 posLocal[2] = (fPadPlane->GetRowPos(row) - 0.5 * rowSize) - fZShiftIdeal;
279
280 // Go to tracking coordinates
281 fMatrix->LocalToMaster(posLocal,posTracking);
282
283 // The total charge of the cluster
284 Double_t q0 = x[1];
285 Double_t q1 = x[2];
286 Double_t q2 = x[3];
287 Double_t clusterCharge = q0 + q1 + q2;
288 Double_t clusterSigmaY2 = 0.0;
289 if (clusterCharge > 0.0) {
290 clusterSigmaY2 = (q1 * (q0 + q2) + 4.0 * q0 * q2)
291 / (clusterCharge*clusterCharge);
292 }
293
294 // Output values
295 x[0] = posTracking[0] + kX0shift;
296 x[1] = posTracking[1];
297 x[2] = posTracking[2];
298 x[3] = clusterCharge;
299 x[4] = colSize*colSize * (clusterSigmaY2 + 1.0/12.0);
300 x[5] = rowSize*rowSize / 12.0;
301 i[2] = TMath::Nint(timeT0Cal);
af26ce80 302
1814b374 303 }
af26ce80 304
305}
306
307//_____________________________________________________________________________
308void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
309{
310 //
311 // Recalibrates the position of a given cluster
312 // If <setDet> is TRUE, the detector number is set for each cluster
313 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
314 // be used.
315 //
316
317 if (setDet) {
318 SetDetector(c->GetDetector());
319 }
320
321 // Transform the local cluster coordinates into recalibrated
322 // space point positions defined in the local tracking system.
323 // Here the calibration for T0, Vdrift and ExB is applied as well.
324 Double_t clusterXYZ[6];
325 clusterXYZ[0] = c->GetCenter();
326 clusterXYZ[1] = 0.0;
327 clusterXYZ[2] = 0.0;
328 clusterXYZ[3] = 0.0;
329 clusterXYZ[4] = 0.0;
330 clusterXYZ[5] = 0.0;
331 Int_t clusterRCT[3];
332 clusterRCT[0] = c->GetPadRow();
333 clusterRCT[1] = c->GetPadCol();
334 clusterRCT[2] = 0;
335 Int_t time = c->GetPadTime();
336 Transform(clusterXYZ,clusterRCT,((UInt_t) time),0);
337
338 // Set the recalibrated coordinates
339 c->SetX(clusterXYZ[0]);
340 c->SetY(clusterXYZ[1]);
341 c->SetZ(clusterXYZ[2]);
342 c->SetLocalTimeBin(((Char_t) clusterRCT[2]));
343
344}