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