]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDtransform.cxx
Changes for cosmics reconstruction
[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()
43 ,fGeo(0x0)
44 ,fDetector(0)
45 ,fParam(0x0)
46 ,fCalibration(0x0)
47 ,fCalVdriftROC(0x0)
48 ,fCalT0ROC(0x0)
a60b4183 49 ,fCalPRFROC(0x0)
c893147d 50 ,fkCalVdriftDet(0x0)
51 ,fkCalT0Det(0x0)
af26ce80 52 ,fCalVdriftDetValue(0)
53 ,fCalT0DetValue(0)
54 ,fSamplingFrequency(0)
55 ,fPadPlane(0x0)
56 ,fZShiftIdeal(0)
57 ,fMatrix(0x0)
58{
59 //
60 // AliTRDtransform default constructor
61 //
62
63}
64
65//_____________________________________________________________________________
af26ce80 66AliTRDtransform::AliTRDtransform(Int_t det)
67 :TObject()
68 ,fGeo(0x0)
69 ,fDetector(0)
70 ,fParam(0x0)
71 ,fCalibration(0x0)
72 ,fCalVdriftROC(0x0)
73 ,fCalT0ROC(0x0)
a60b4183 74 ,fCalPRFROC(0x0)
c893147d 75 ,fkCalVdriftDet(0x0)
76 ,fkCalT0Det(0x0)
af26ce80 77 ,fCalVdriftDetValue(0)
78 ,fCalT0DetValue(0)
79 ,fSamplingFrequency(0)
80 ,fPadPlane(0x0)
81 ,fZShiftIdeal(0)
82 ,fMatrix(0x0)
83{
84 //
85 // AliTRDtransform constructor for a given detector
86 //
87
88 fGeo = new AliTRDgeometry();
a938cf15 89 if (!fGeo->CreateClusterMatrixArray()) {
90 AliError("Could not get transformation matrices\n");
91 }
af26ce80 92
93 fParam = AliTRDCommonParam::Instance();
94 if (!fParam) {
95 AliError("Could not get common parameters\n");
96 }
97 fSamplingFrequency = fParam->GetSamplingFrequency();
98
99 fCalibration = AliTRDcalibDB::Instance();
100 if (!fCalibration) {
101 AliError("Cannot find calibration object");
102 }
103
104 // Get the calibration objects for the global calibration
c893147d 105 fkCalVdriftDet = fCalibration->GetVdriftDet();
106 fkCalT0Det = fCalibration->GetT0Det();
af26ce80 107
108 SetDetector(det);
109
110}
111
112//_____________________________________________________________________________
af26ce80 113AliTRDtransform::AliTRDtransform(const AliTRDtransform &t)
114 :TObject(t)
115 ,fGeo(0x0)
116 ,fDetector(t.fDetector)
117 ,fParam(0x0)
118 ,fCalibration(0x0)
119 ,fCalVdriftROC(0x0)
120 ,fCalT0ROC(0x0)
a60b4183 121 ,fCalPRFROC(0x0)
c893147d 122 ,fkCalVdriftDet(0x0)
123 ,fkCalT0Det(0x0)
af26ce80 124 ,fCalVdriftDetValue(0)
125 ,fCalT0DetValue(0)
126 ,fSamplingFrequency(0)
127 ,fPadPlane(0x0)
128 ,fZShiftIdeal(0)
129 ,fMatrix(0x0)
130{
131 //
132 // AliTRDtransform copy constructor
133 //
134
135 if (fGeo) {
136 delete fGeo;
137 }
138 fGeo = new AliTRDgeometry();
9a96f175 139 fGeo->CreateClusterMatrixArray();
af26ce80 140
141 fParam = AliTRDCommonParam::Instance();
142 if (!fParam) {
143 AliError("Could not get common parameters\n");
144 }
145 fSamplingFrequency = fParam->GetSamplingFrequency();
146
147 fCalibration = AliTRDcalibDB::Instance();
148 if (!fCalibration) {
149 AliError("Cannot find calibration object");
150 }
c893147d 151 fkCalVdriftDet = fCalibration->GetVdriftDet();
152 fkCalT0Det = fCalibration->GetT0Det();
af26ce80 153
154}
155
156//_____________________________________________________________________________
157AliTRDtransform::~AliTRDtransform()
158{
159 //
160 // AliTRDtransform destructor
161 //
162
163 if (fGeo) {
164 delete fGeo;
165 }
166
167}
168
169//_____________________________________________________________________________
170void AliTRDtransform::SetDetector(Int_t det)
171{
172 //
173 // Set to a new detector number and update the calibration objects
174 // and values accordingly
175 //
176
177 fDetector = det;
178
179 // Get the calibration objects for the pad-by-pad calibration
180 fCalVdriftROC = fCalibration->GetVdriftROC(det);
181 fCalT0ROC = fCalibration->GetT0ROC(det);
a60b4183 182 fCalPRFROC = fCalibration->GetPRFROC(det);
af26ce80 183
184 // Get the detector wise defined calibration values
c893147d 185 fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
186 fCalT0DetValue = fkCalT0Det->GetValue(det);
af26ce80 187
188 // Shift needed to define Z-position relative to middle of chamber
053767a4 189 Int_t layer = fGeo->GetLayer(det);
190 Int_t stack = fGeo->GetStack(det);
191 fPadPlane = fGeo->GetPadPlane(layer,stack);
af26ce80 192 fZShiftIdeal = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
193
194 // Get the current transformation matrix
9a96f175 195 fMatrix = fGeo->GetClusterMatrix(det);
af26ce80 196
197}
198
199//_____________________________________________________________________________
b72f4eaf 200Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
af26ce80 201{
202 //
203 // Transforms the local cluster coordinates into calibrated
204 // space point positions defined in the local tracking system.
205 //
206 // Here the calibration for T0, Vdrift and ExB is applied as well.
207 //
b72f4eaf 208 // Input: Cluster in the local chamber coordinates
209 // Output: Tracking cluster
af26ce80 210
b72f4eaf 211 if (!fMatrix) return kFALSE;
af26ce80 212
af26ce80 213
b72f4eaf 214 // Parameters to adjust the X position of clusters in the alignable volume
ec3f0161 215 const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
1814b374 216
1814b374 217
b72f4eaf 218 // Retrieve calibration values
219 Int_t col = c->GetPadCol(), row = c->GetPadRow();
220 // drift velocity
221 Double_t vd = fCalVdriftDetValue * fCalVdriftROC->GetValue(col,row);
222 // t0
223 Double_t t0 = fCalT0DetValue + fCalT0ROC->GetValue(col,row);
566bf887 224 t0 /= fSamplingFrequency;
b72f4eaf 225 // ExB correction
226 Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
227
228 Float_t x = c->GetXloc(t0, vd);
229
b72f4eaf 230 // Pad dimensions
231 Double_t rs = fPadPlane->GetRowSize(row);
232 Double_t cs = fPadPlane->GetColSize(col);
1fd9389f 233
234 // cluster error with diffusion corrections
235 Double_t s2 = cs*fCalPRFROC->GetValue(col, row);
236 s2 *= s2;
237 Float_t dl, dt;
238 AliTRDCommonParam::Instance()->GetDiffCoeff(dl, dt, vd);
239
b72f4eaf 240 Double_t y0 = fPadPlane->GetColPos(col) + .5*cs;
241 Double_t loc[] = {
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
245 };
246
247 // Go to tracking coordinates
248 Double_t trk[3];
249 fMatrix->LocalToMaster(loc, trk);
250
251 // store tracking values
252 c->SetX(trk[0]);c->SetY(trk[1]);c->SetZ(trk[2]);
1fd9389f 253 c->SetSigmaY2(s2, dt, exb, x);
b72f4eaf 254 c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
255
256 return kTRUE;
c893147d 257
af26ce80 258}
259
260//_____________________________________________________________________________
261void AliTRDtransform::Recalibrate(AliTRDcluster *c, Bool_t setDet)
262{
263 //
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
267 // be used.
268 //
269
b72f4eaf 270 if (setDet) SetDetector(c->GetDetector());
271 Transform(c);
c893147d 272
af26ce80 273}