]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtransform.cxx
AliTPCcalibDB.cxx.difF Add possibility to get RCU configuration, RCU Trigger...
[u/mrichter/AliRoot.git] / TRD / AliTRDtransform.cxx
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
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
38 ClassImp(AliTRDtransform)
39
40 //_____________________________________________________________________________
41 AliTRDtransform::AliTRDtransform()
42   :TObject()
43   ,fGeo(0x0)
44   ,fDetector(0)
45   ,fParam(0x0)
46   ,fCalibration(0x0)
47   ,fCalVdriftROC(0x0)
48   ,fCalT0ROC(0x0)
49   ,fCalPRFROC(0x0)
50   ,fkCalVdriftDet(0x0)
51   ,fkCalT0Det(0x0)
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 //_____________________________________________________________________________
66 AliTRDtransform::AliTRDtransform(Int_t det)
67   :TObject()
68   ,fGeo(0x0)
69   ,fDetector(0)
70   ,fParam(0x0)
71   ,fCalibration(0x0)
72   ,fCalVdriftROC(0x0)
73   ,fCalT0ROC(0x0)
74   ,fCalPRFROC(0x0)
75   ,fkCalVdriftDet(0x0)
76   ,fkCalT0Det(0x0)
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();
89   if (!fGeo->CreateClusterMatrixArray()) {
90     AliError("Could not get transformation matrices\n");
91   }
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
105   fkCalVdriftDet     = fCalibration->GetVdriftDet();
106   fkCalT0Det         = fCalibration->GetT0Det();
107
108   SetDetector(det);
109
110 }
111
112 //_____________________________________________________________________________
113 AliTRDtransform::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)
121   ,fCalPRFROC(0x0)
122   ,fkCalVdriftDet(0x0)
123   ,fkCalT0Det(0x0)
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();
139   fGeo->CreateClusterMatrixArray();
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   }
151   fkCalVdriftDet     = fCalibration->GetVdriftDet();
152   fkCalT0Det         = fCalibration->GetT0Det();
153
154 }
155
156 //_____________________________________________________________________________
157 AliTRDtransform::~AliTRDtransform()
158 {
159   //
160   // AliTRDtransform destructor
161   //
162
163   if (fGeo) {
164     delete fGeo;
165   }
166
167 }
168
169 //_____________________________________________________________________________
170 void 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);
182   fCalPRFROC         = fCalibration->GetPRFROC(det);
183
184   // Get the detector wise defined calibration values
185   fCalVdriftDetValue = fkCalVdriftDet->GetValue(det);
186   fCalT0DetValue     = fkCalT0Det->GetValue(det);
187
188   // Shift needed to define Z-position relative to middle of chamber
189   Int_t layer        = fGeo->GetLayer(det);
190   Int_t stack        = fGeo->GetStack(det);
191   fPadPlane          = fGeo->GetPadPlane(layer,stack);
192   fZShiftIdeal       = 0.5 * (fPadPlane->GetRow0() + fPadPlane->GetRowEnd());
193
194   // Get the current transformation matrix
195   fMatrix            = fGeo->GetClusterMatrix(det);
196
197 }
198
199 //_____________________________________________________________________________
200 Bool_t AliTRDtransform::Transform(AliTRDcluster *c)
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   //
208   // Input: Cluster in the local chamber coordinates
209   // Output: Tracking cluster
210
211   if (!fMatrix) return kFALSE;
212
213
214   // Parameters to adjust the X position of clusters in the alignable volume
215   const Double_t kX0shift = AliTRDgeometry::AnodePos(); //[cm]
216
217  
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);
224   t0 /= fSamplingFrequency;
225   // ExB correction
226   Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
227
228   Float_t x = c->GetXloc(t0, vd);
229
230   // Pad dimensions
231   Double_t rs = fPadPlane->GetRowSize(row);
232   Double_t cs = fPadPlane->GetColSize(col);
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
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]);
253   c->SetSigmaY2(s2, dt, exb, x);
254   c->SetSigmaZ2(fPadPlane->GetRowSize(row)*fPadPlane->GetRowSize(row)/12.);
255   
256   return kTRUE;
257
258 }
259
260 //_____________________________________________________________________________
261 void 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
270   if (setDet) SetDetector(c->GetDetector());
271   Transform(c);
272
273 }