]>
Commit | Line | Data |
---|---|---|
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 | ||
40 | ClassImp(AliTRDtransform) | |
41 | ||
42 | //_____________________________________________________________________________ | |
43 | //AliTRDtransform::AliTRDtransform() | |
44 | // :AliTransform() | |
45 | AliTRDtransform::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() | |
71 | AliTRDtransform::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(); | |
93 | if (!fGeo->CreateClusterMatrixArray()) { | |
94 | AliError("Could not get transformation matrices\n"); | |
95 | } | |
96 | ||
97 | fParam = AliTRDCommonParam::Instance(); | |
98 | if (!fParam) { | |
99 | AliError("Could not get common parameters\n"); | |
100 | } | |
101 | fSamplingFrequency = fParam->GetSamplingFrequency(); | |
102 | ||
103 | fCalibration = AliTRDcalibDB::Instance(); | |
104 | if (!fCalibration) { | |
105 | AliError("Cannot find calibration object"); | |
106 | } | |
107 | ||
108 | // Get the calibration objects for the global calibration | |
109 | fCalVdriftDet = fCalibration->GetVdriftDet(); | |
110 | fCalT0Det = fCalibration->GetT0Det(); | |
111 | ||
112 | SetDetector(det); | |
113 | ||
114 | } | |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | //AliTRDtransform::AliTRDtransform(const AliTRDtransform &t) | |
118 | // :AliTransform(t) | |
119 | AliTRDtransform::AliTRDtransform(const AliTRDtransform &t) | |
120 | :TObject(t) | |
121 | ,fGeo(0x0) | |
122 | ,fDetector(t.fDetector) | |
123 | ,fParam(0x0) | |
124 | ,fCalibration(0x0) | |
125 | ,fCalVdriftROC(0x0) | |
126 | ,fCalT0ROC(0x0) | |
127 | ,fCalVdriftDet(0x0) | |
128 | ,fCalT0Det(0x0) | |
129 | ,fCalVdriftDetValue(0) | |
130 | ,fCalT0DetValue(0) | |
131 | ,fSamplingFrequency(0) | |
132 | ,fPadPlane(0x0) | |
133 | ,fZShiftIdeal(0) | |
134 | ,fMatrix(0x0) | |
135 | { | |
136 | // | |
137 | // AliTRDtransform copy constructor | |
138 | // | |
139 | ||
140 | if (fGeo) { | |
141 | delete fGeo; | |
142 | } | |
143 | fGeo = new AliTRDgeometry(); | |
144 | fGeo->CreateClusterMatrixArray(); | |
145 | ||
146 | fParam = AliTRDCommonParam::Instance(); | |
147 | if (!fParam) { | |
148 | AliError("Could not get common parameters\n"); | |
149 | } | |
150 | fSamplingFrequency = fParam->GetSamplingFrequency(); | |
151 | ||
152 | fCalibration = AliTRDcalibDB::Instance(); | |
153 | if (!fCalibration) { | |
154 | AliError("Cannot find calibration object"); | |
155 | } | |
156 | fCalVdriftDet = fCalibration->GetVdriftDet(); | |
157 | fCalT0Det = fCalibration->GetT0Det(); | |
158 | ||
159 | } | |
160 | ||
161 | //_____________________________________________________________________________ | |
162 | AliTRDtransform::~AliTRDtransform() | |
163 | { | |
164 | // | |
165 | // AliTRDtransform destructor | |
166 | // | |
167 | ||
168 | if (fGeo) { | |
169 | delete fGeo; | |
170 | } | |
171 | ||
172 | } | |
173 | ||
174 | //_____________________________________________________________________________ | |
175 | void AliTRDtransform::SetDetector(Int_t det) | |
176 | { | |
177 | // | |
178 | // Set to a new detector number and update the calibration objects | |
179 | // and values accordingly | |
180 | // | |
181 | ||
182 | fDetector = det; | |
183 | ||
184 | // Get the calibration objects for the pad-by-pad calibration | |
185 | fCalVdriftROC = fCalibration->GetVdriftROC(det); | |
186 | fCalT0ROC = fCalibration->GetT0ROC(det); | |
187 | ||
188 | // Get the detector wise defined calibration values | |
189 | fCalVdriftDetValue = fCalVdriftDet->GetValue(det); | |
190 | fCalT0DetValue = fCalT0Det->GetValue(det); | |
191 | ||
192 | // Shift needed to define Z-position relative to middle of chamber | |
193 | Int_t layer = fGeo->GetLayer(det); | |
194 | Int_t stack = fGeo->GetStack(det); | |
195 | fPadPlane = fGeo->GetPadPlane(layer,stack); | |
196 | fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd()); | |
197 | ||
198 | // Get the current transformation matrix | |
199 | fMatrix = fGeo->GetClusterMatrix(det); | |
200 | ||
201 | } | |
202 | ||
203 | //_____________________________________________________________________________ | |
204 | Bool_t AliTRDtransform::Transform(Double_t *x, Int_t *i, UInt_t time, Bool_t &out, Int_t /*coordinateType*/) | |
205 | { | |
206 | // | |
207 | // Transforms the local cluster coordinates into calibrated | |
208 | // space point positions defined in the local tracking system. | |
209 | // | |
210 | // Here the calibration for T0, Vdrift and ExB is applied as well. | |
211 | // | |
212 | // Input: | |
213 | // x[0] = COL-position relative to the center pad (pad units) | |
214 | // x[1] = cluster signal in left pad | |
215 | // x[2] = cluster signal in middle pad | |
216 | // x[3] = cluster signal in right pad | |
217 | // i[0] = ROW pad number | |
218 | // i[1] = COL pad number | |
219 | // time = time bin number (uncalibrated for t0) | |
220 | // | |
221 | // Output: | |
222 | // x[0] = X-positions in tracking CS | |
223 | // x[1] = Y-positions in tracking CS | |
224 | // x[2] = Z-positions in tracking CS | |
225 | // x[3] = total cluster charge | |
226 | // x[4] = error in Y-direction | |
227 | // x[5] = error in Z-direction | |
228 | // i[2] = time bin number (calibrated for t0) | |
229 | // | |
230 | ||
231 | Double_t posLocal[3]; | |
232 | Double_t posTracking[3]; | |
233 | ||
234 | Int_t row = i[0]; | |
235 | Int_t col = i[1]; | |
236 | ||
237 | // Parameters to adjust the X position of clusters | |
238 | const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm] | |
239 | // TRF rising time (fitted) | |
240 | // It should be absorbed by the t0. For the moment t0 is 0 for simulations. | |
241 | // A.Bercuci (Mar 26 2009) | |
242 | const Double_t kT0shift = 0.189; //[us] | |
243 | ||
244 | if (!fMatrix) { | |
245 | ||
246 | x[0] = 0.0; | |
247 | x[1] = 0.0; | |
248 | x[2] = 0.0; | |
249 | x[3] = 0.0; | |
250 | x[4] = 0.0; | |
251 | x[5] = 0.0; | |
252 | i[2] = 0; | |
253 | ||
254 | return kFALSE; | |
255 | ||
256 | } | |
257 | else { | |
258 | ||
259 | // Calibration values | |
260 | Double_t vdrift = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row); | |
261 | Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row); | |
262 | ||
263 | // T0 correction | |
264 | Double_t timeT0Cal = time - t0; | |
265 | // Calculate the X-position, | |
266 | Double_t xLocal = ((timeT0Cal + 0.5) / fSamplingFrequency - kT0shift) * vdrift + AliTRDcluster::GetXcorr(TMath::Nint(timeT0Cal)); | |
267 | ||
268 | // Length of the amplification region | |
269 | //Double_t ampLength = (Double_t) AliTRDgeometry::CamHght(); | |
270 | // The drift distance | |
271 | Double_t driftLength = TMath::Max(xLocal,0.0); | |
272 | // ExB correction | |
273 | Double_t exbCorr = AliTRDCommonParam::Instance()->GetOmegaTau(vdrift); | |
274 | ||
275 | // Pad dimensions | |
276 | Double_t rowSize = fPadPlane->GetRowSize(row); | |
277 | Double_t colSize = fPadPlane->GetColSize(col); | |
278 | ||
279 | // Invert the X-position, | |
280 | // apply ExB correction to the Y-position | |
281 | // and move to the Z-position relative to the middle of the chamber | |
282 | posLocal[0] = kX0shift-xLocal; | |
283 | posLocal[1] = (fPadPlane->GetColPos(col) + (0.5 + x[0]) * colSize) - driftLength * exbCorr; | |
284 | posLocal[2] = (fPadPlane->GetRowPos(row) - 0.5 * rowSize) - fZShiftIdeal; | |
285 | ||
286 | // Go to tracking coordinates | |
287 | fMatrix->LocalToMaster(posLocal,posTracking); | |
288 | ||
289 | // The total charge of the cluster | |
290 | Double_t q0 = x[1]; | |
291 | Double_t q1 = x[2]; | |
292 | Double_t q2 = x[3]; | |
293 | Double_t clusterCharge = q0 + q1 + q2; | |
294 | Double_t clusterSigmaY2 = 0.0; | |
295 | if (clusterCharge > 0.0) { | |
296 | clusterSigmaY2 = (q1 * (q0 + q2) + 4.0 * q0 * q2) | |
297 | / (clusterCharge*clusterCharge); | |
298 | } | |
299 | ||
300 | // Output values | |
301 | x[0] = posTracking[0]; | |
302 | x[1] = posTracking[1]; | |
303 | x[2] = posTracking[2]; | |
304 | x[3] = clusterCharge; | |
305 | x[4] = colSize*colSize * (clusterSigmaY2 + 1.0/12.0); | |
306 | x[5] = rowSize*rowSize / 12.0; | |
307 | i[2] = TMath::Nint(timeT0Cal); | |
308 | ||
309 | // For TRD tracking calibration awareness | |
310 | out = ((i[2] < 0) || (i[2] > Int_t(3.5 * fSamplingFrequency/vdrift))) ? kTRUE : kFALSE; | |
311 | ||
312 | return kTRUE; | |
313 | ||
314 | } | |
315 | ||
316 | } | |
317 | ||
318 | //_____________________________________________________________________________ | |
319 | void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet) | |
320 | { | |
321 | // | |
322 | // Recalibrates the position of a given cluster | |
323 | // If <setDet> is TRUE, the detector number is set for each cluster | |
324 | // automatically. Otherwise, AliTRDtransform::SetDetector() has to | |
325 | // be used. | |
326 | // | |
327 | ||
328 | if (setDet) { | |
329 | SetDetector(c->GetDetector()); | |
330 | } | |
331 | ||
332 | // Transform the local cluster coordinates into recalibrated | |
333 | // space point positions defined in the local tracking system. | |
334 | // Here the calibration for T0, Vdrift and ExB is applied as well. | |
335 | Double_t clusterXYZ[6]; | |
336 | clusterXYZ[0] = c->GetCenter(); | |
337 | clusterXYZ[1] = 0.0; | |
338 | clusterXYZ[2] = 0.0; | |
339 | clusterXYZ[3] = 0.0; | |
340 | clusterXYZ[4] = 0.0; | |
341 | clusterXYZ[5] = 0.0; | |
342 | Int_t clusterRCT[3]; | |
343 | clusterRCT[0] = c->GetPadRow(); | |
344 | clusterRCT[1] = c->GetPadCol(); | |
345 | clusterRCT[2] = 0; | |
346 | Int_t time = c->GetPadTime(); | |
347 | Bool_t out; | |
348 | Transform(clusterXYZ,clusterRCT,((UInt_t) time), out, 0); | |
349 | ||
350 | // Set the recalibrated coordinates | |
351 | c->SetX(clusterXYZ[0]); | |
352 | c->SetY(clusterXYZ[1]); | |
353 | c->SetZ(clusterXYZ[2]); | |
354 | c->SetLocalTimeBin(((Char_t) clusterRCT[2])); | |
355 | c->SetInChamber(!out); | |
356 | ||
357 | } |