]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDtransform.cxx
robust write tracklet quality to ESD track
[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"
af26ce80 28
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"
37
38ClassImp(AliTRDtransform)
39
40//_____________________________________________________________________________
af26ce80 41AliTRDtransform::AliTRDtransform()
42 :TObject()
af26ce80 43 ,fDetector(0)
44 ,fParam(0x0)
45 ,fCalibration(0x0)
46 ,fCalVdriftROC(0x0)
47 ,fCalT0ROC(0x0)
a60b4183 48 ,fCalPRFROC(0x0)
c893147d 49 ,fkCalVdriftDet(0x0)
50 ,fkCalT0Det(0x0)
803dc399 51 ,fkCalExBDet(0x0)
af26ce80 52 ,fCalVdriftDetValue(0)
53 ,fCalT0DetValue(0)
803dc399 54 ,fCalExBDetValue(0)
af26ce80 55 ,fSamplingFrequency(0)
56 ,fPadPlane(0x0)
57 ,fZShiftIdeal(0)
58 ,fMatrix(0x0)
59{
60 //
61 // AliTRDtransform default constructor
62 //
63
225096c8 64 fParam = AliTRDCommonParam::Instance();
65 if (!fParam) {
66 AliError("Could not get common parameters\n");
67 }
68 fSamplingFrequency = fParam->GetSamplingFrequency();
69
70 fCalibration = AliTRDcalibDB::Instance();
71 if (!fCalibration) {
72 AliError("Cannot find calibration object");
73 }
74
75 // Get the calibration objects for the global calibration
76 fkCalVdriftDet = fCalibration->GetVdriftDet();
77 fkCalT0Det = fCalibration->GetT0Det();
803dc399 78 fkCalExBDet = fCalibration->GetExBDet();
225096c8 79
af26ce80 80}
81
82//_____________________________________________________________________________
af26ce80 83AliTRDtransform::AliTRDtransform(Int_t det)
84 :TObject()
af26ce80 85 ,fDetector(0)
86 ,fParam(0x0)
87 ,fCalibration(0x0)
88 ,fCalVdriftROC(0x0)
89 ,fCalT0ROC(0x0)
a60b4183 90 ,fCalPRFROC(0x0)
c893147d 91 ,fkCalVdriftDet(0x0)
92 ,fkCalT0Det(0x0)
803dc399 93 ,fkCalExBDet(0x0)
af26ce80 94 ,fCalVdriftDetValue(0)
95 ,fCalT0DetValue(0)
803dc399 96 ,fCalExBDetValue(0)
af26ce80 97 ,fSamplingFrequency(0)
98 ,fPadPlane(0x0)
99 ,fZShiftIdeal(0)
100 ,fMatrix(0x0)
101{
102 //
103 // AliTRDtransform constructor for a given detector
104 //
105
af26ce80 106 fParam = AliTRDCommonParam::Instance();
107 if (!fParam) {
108 AliError("Could not get common parameters\n");
109 }
110 fSamplingFrequency = fParam->GetSamplingFrequency();
111
112 fCalibration = AliTRDcalibDB::Instance();
113 if (!fCalibration) {
114 AliError("Cannot find calibration object");
115 }
116
117 // Get the calibration objects for the global calibration
c893147d 118 fkCalVdriftDet = fCalibration->GetVdriftDet();
119 fkCalT0Det = fCalibration->GetT0Det();
803dc399 120 fkCalExBDet = fCalibration->GetExBDet();
af26ce80 121
122 SetDetector(det);
123
124}
125
126//_____________________________________________________________________________
af26ce80 127AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
128 :TObject(t)
af26ce80 129 ,fDetector(t.fDetector)
130 ,fParam(0x0)
131 ,fCalibration(0x0)
132 ,fCalVdriftROC(0x0)
133 ,fCalT0ROC(0x0)
a60b4183 134 ,fCalPRFROC(0x0)
c893147d 135 ,fkCalVdriftDet(0x0)
136 ,fkCalT0Det(0x0)
803dc399 137 ,fkCalExBDet(0x0)
af26ce80 138 ,fCalVdriftDetValue(0)
139 ,fCalT0DetValue(0)
803dc399 140 ,fCalExBDetValue(0)
af26ce80 141 ,fSamplingFrequency(0)
142 ,fPadPlane(0x0)
143 ,fZShiftIdeal(0)
144 ,fMatrix(0x0)
145{
146 //
147 // AliTRDtransform copy constructor
148 //
149
af26ce80 150 fParam = AliTRDCommonParam::Instance();
151 if (!fParam) {
152 AliError("Could not get common parameters\n");
153 }
154 fSamplingFrequency = fParam->GetSamplingFrequency();
155
156 fCalibration = AliTRDcalibDB::Instance();
157 if (!fCalibration) {
158 AliError("Cannot find calibration object");
159 }
c893147d 160 fkCalVdriftDet = fCalibration->GetVdriftDet();
161 fkCalT0Det = fCalibration->GetT0Det();
803dc399 162 fkCalExBDet = fCalibration->GetExBDet();
af26ce80 163}
164
165//_____________________________________________________________________________
166AliTRDtransform::~AliTRDtransform()
167{
168 //
169 // AliTRDtransform destructor
170 //
171
af26ce80 172}
173
fc1c9d79 174//_____________________________________________________________________________
175AliTRDtransform &AliTRDtransform::operator=(const AliTRDtransform &t)
176{
177 //
178 // Assignment operator
179 //
180
181 if (this != &t) {
182 ((AliTRDtransform &) t).Copy(*this);
183 }
184
185 return *this;
186
187}
188
189//_____________________________________________________________________________
190void AliTRDtransform::Copy(TObject &t) const
191{
192 //
193 // Copy function
194 //
195
196 ((AliTRDtransform &) t).fDetector = fDetector;
197 ((AliTRDtransform &) t).fParam = AliTRDCommonParam::Instance();
198 ((AliTRDtransform &) t).fCalibration = AliTRDcalibDB::Instance();
199 if (fCalibration) {
200 ((AliTRDtransform &) t).fkCalVdriftDet = fCalibration->GetVdriftDet();
201 ((AliTRDtransform &) t).fkCalT0Det = fCalibration->GetT0Det();
803dc399 202 ((AliTRDtransform &) t).fkCalExBDet = fCalibration->GetExBDet();
fc1c9d79 203 }
204 else {
205 ((AliTRDtransform &) t).fkCalVdriftDet = 0;
206 ((AliTRDtransform &) t).fkCalT0Det = 0;
803dc399 207 ((AliTRDtransform &) t).fkCalExBDet = 0;
fc1c9d79 208 }
209 ((AliTRDtransform &) t).fCalVdriftROC = 0x0;
210 ((AliTRDtransform &) t).fCalT0ROC = 0x0;
211 ((AliTRDtransform &) t).fCalPRFROC = 0x0;
212 ((AliTRDtransform &) t).fCalVdriftDetValue = 0;
213 ((AliTRDtransform &) t).fCalT0DetValue = 0;
803dc399 214 ((AliTRDtransform &) t).fCalExBDetValue = 0;
fc1c9d79 215 ((AliTRDtransform &) t).fSamplingFrequency = 0;
216 ((AliTRDtransform &) t).fPadPlane = 0x0;
217 ((AliTRDtransform &) t).fZShiftIdeal = 0;
218 ((AliTRDtransform &) t).fMatrix = 0x0;
219
220}
221
9dcc64cc 222//_____________________________________________________________________________
223AliTRDgeometry& AliTRDtransform::Geometry()
224{
225 static AliTRDgeometry g;
226 if (!g.CreateClusterMatrixArray()) {
227 AliErrorGeneral("AliTRDtransform::Geometry()", "Could not get transformation matrices\n");
228 }
229 return g;
230}
231
af26ce80 232//_____________________________________________________________________________
233void AliTRDtransform::SetDetector(Int_t det)
234{
235 //
236 // Set to a new detector number and update the calibration objects
237 // and values accordingly
238 //
239
240 fDetector = det;
241
242 // Get the calibration objects for the pad-by-pad calibration
243 fCalVdriftROC = fCalibration->GetVdriftROC(det);
244 fCalT0ROC = fCalibration->GetT0ROC(det);
a60b4183 245 fCalPRFROC = fCalibration->GetPRFROC(det);
af26ce80 246
247 // Get the detector wise defined calibration values
c893147d 248 fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
249 fCalT0DetValue = fkCalT0Det->GetValue(det);
803dc399 250 fCalExBDetValue = fkCalExBDet->GetValue(det);
af26ce80 251
252 // Shift needed to define Z-position relative to middle of chamber
9dcc64cc 253 Int_t layer = Geometry().GetLayer(det);
254 Int_t stack = Geometry().GetStack(det);
255 fPadPlane = Geometry().GetPadPlane(layer,stack);
af26ce80 256 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
257
258 // Get the current transformation matrix
9dcc64cc 259 fMatrix = Geometry().GetClusterMatrix(det);
af26ce80 260
261}
262
263//_____________________________________________________________________________
b72f4eaf 264Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
af26ce80 265{
266 //
267 // Transforms the local cluster coordinates into calibrated
268 // space point positions defined in the local tracking system.
269 //
270 // Here the calibration for T0, Vdrift and ExB is applied as well.
271 //
b72f4eaf 272 // Input: Cluster in the local chamber coordinates
273 // Output: Tracking cluster
af26ce80 274
b72f4eaf 275 if (!fMatrix) return kFALSE;
af26ce80 276
af26ce80 277
b72f4eaf 278 // Parameters to adjust the X position of clusters in the alignable volume
ec3f0161 279 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
1814b374 280
1814b374 281
b72f4eaf 282 // Retrieve calibration values
283 Int_t col = c->GetPadCol(), row = c->GetPadRow();
284 // drift velocity
285 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
286 // t0
287 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
566bf887 288 t0 /= fSamplingFrequency;
b72f4eaf 289 // ExB correction
803dc399 290 Double_t exb = fCalExBDetValue;//AliTRDCommonParam::Instance()->GetOmegaTau(vd);
b72f4eaf 291
292 Float_t x = c->GetXloc(t0, vd);
293
b72f4eaf 294 // Pad dimensions
295 Double_t rs = fPadPlane->GetRowSize(row);
296 Double_t cs = fPadPlane->GetColSize(col);
1fd9389f 297
298 // cluster error with diffusion corrections
299 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
300 s2 *= s2;
301 Float_t dl, dt;
302 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
303
b72f4eaf 304 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
305 Double_t loc[] = {
306 kX0shift-x, // Invert the X-position,
307 c->GetYloc(y0, s2, cs) - x*exb,// apply ExB correction
308 fPadPlane->GetRowPos(row) - .5*rs - fZShiftIdeal // move the Z-position relative to the middle of the chamber
309 };
310
311 // Go to tracking coordinates
312 Double_t trk[3];
313 fMatrix->LocalToMaster(loc, trk);
314
315 // store tracking values
316 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
1fd9389f 317 c->SetSigmaY2(s2, dt, exb, x);
b72f4eaf 318 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
319
320 return kTRUE;
c893147d 321
af26ce80 322}
323
324//_____________________________________________________________________________
325void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
326{
327 //
328 // Recalibrates the position of a given cluster
329 // If <setDet> is TRUE, the detector number is set for each cluster
330 // automatically. Otherwise, AliTRDtransform::SetDetector() has to
331 // be used.
332 //
333
b72f4eaf 334 if (setDet) SetDetector(c->GetDetector());
335 Transform(c);
c893147d 336
af26ce80 337}