]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCTransform.cxx
Using the AliTPCtransform in the reconstruction (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCTransform.cxx
CommitLineData
022ee144 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//-------------------------------------------------------
17// Implementation of the TPC transformation class
18//
19// Origin: Marian Ivanov Marian.Ivanov@cern.ch
20// Magnus Mager
21//
22// Class for tranformation of the coordinate frame
23// Tranformation
24// local coordinate frame (sector, padrow, pad, timebine) ==>
25// rotated global (tracking) cooridnate frame (sector, lx,ly,lz)
26//
27// Unisochronity - (substract time0 - pad by pad)
28// Drift velocity - Currently common drift velocity - functionality of AliTPCParam
29// ExB effect -
30//
31// Usage:
32// AliTPCclustererMI::AddCluster
33// AliTPCtrackerMI::Transform
34//
35//-------------------------------------------------------
c1bdda91 36
37/* To test it:
38 cdb=AliCDBManager::Instance()
39 cdb->SetDefaultStorage("local:///u/mmager/mycalib1")
40 c=AliTPCcalibDB::Instance()
41 c->SetRun(0)
42 Double_t x[]={1.0,2.0,3.0}
43 Int_t i[]={4}
44 AliTPCTransform trafo
45 trafo.Transform(x,i,0,1)
46 */
47
022ee144 48/* $Id$ */
49
50#include "AliTPCROC.h"
51#include "AliTPCCalPad.h"
52#include "AliTPCCalROC.h"
53#include "AliTPCcalibDB.h"
54#include "AliTPCParam.h"
55#include "TMath.h"
56#include "AliLog.h"
57#include "AliTPCExB.h"
58#include "AliTPCTransform.h"
59
60
61
c1bdda91 62AliTPCTransform::AliTPCTransform() {
24db6af7 63 //
c1bdda91 64 // Speed it up a bit!
24db6af7 65 //
c1bdda91 66 for (Int_t i=0;i<18;++i) {
67 Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18));
68 fSins[i]=TMath::Sin(alpha);
69 fCoss[i]=TMath::Cos(alpha);
70 }
71}
72
73AliTPCTransform::~AliTPCTransform() {
24db6af7 74 //
75 // Destructor
76 //
c1bdda91 77}
78
24db6af7 79void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
80 Int_t /*coordinateType*/) {
81 // input: x[0] - pad row
82 // x[1] - pad
c1bdda91 83 // x[2] - time in us
84 // i[0] - sector
85 // output: x[0] - x (all in the rotated global coordinate frame)
86 // x[1] - y
87 // x[2] - z
24db6af7 88 Int_t row=TMath::Nint(x[0]);
89 Int_t pad=TMath::Nint(x[1]);
c1bdda91 90 Int_t sector=i[0];
91 AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
24db6af7 92 //
93 AliTPCCalPad * time0TPC = calib->GetPadTime0();
94 AliTPCParam * param = calib->GetParameters();
95 if (!time0TPC){
96 AliFatal("Time unisochronity missing");
97 }
c1bdda91 98
24db6af7 99 if (!param){
100 AliFatal("Parameters missing");
101 }
c1bdda91 102
24db6af7 103 Double_t xx[3];
104 // Apply Time0 correction - Pad by pad fluctuation
105 //
106 x[2]-=time0TPC->GetCalROC(sector)->GetValue(row,pad);
107 //
108 // Tranform from pad - time coordinate system to the rotated global (tracking) system
109 //
110 Local2RotatedGlobal(sector,x);
111 //
112 //
113 //
c1bdda91 114 // Alignment
115 //TODO: calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx);
c1bdda91 116 RotatedGlobal2Global(sector,x);
24db6af7 117 //
118 //
119 // ExB correction
120 //
c1bdda91 121 calib->GetExB()->Correct(x,xx);
122
123 Global2RotatedGlobal(sector,xx);
124
125 x[0]=xx[0];x[1]=xx[1];x[2]=xx[2];
126}
127
24db6af7 128void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
129 //
130 //
022ee144 131 // Tranform coordinate from
132 // row, pad, time to x,y,z
24db6af7 133 //
022ee144 134 // Drift Velocity
135 // Current implementation - common drift velocity - for full chamber
24db6af7 136 // TODO: use a map or parametrisation!
137 //
138 //
139 //
140 AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
141 AliTPCParam * param = calib->GetParameters();
142 if (!param){
143 AliFatal("Parameters missing");
144 }
145 Int_t row=TMath::Nint(x[0]);
146 Int_t pad=TMath::Nint(x[1]);
147 //
148 const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
149 Double_t sign = 1.;
150 Double_t zwidth = param->GetZWidth();
151 Double_t padWidth = 0;
152 Double_t padLength = 0;
153 Double_t maxPad = 0;
154 //
155 if (sector < kNIS) {
156 maxPad = param->GetNPadsLow(row);
157 sign = (sector < kNIS/2) ? 1 : -1;
158 padLength = param->GetPadPitchLength(sector,row);
159 padWidth = param->GetPadPitchWidth(sector);
160 } else {
161 maxPad = param->GetNPadsUp(row);
162 sign = ((sector-kNIS) < kNOS/2) ? 1 : -1;
163 padLength = param->GetPadPitchLength(sector,row);
164 padWidth = param->GetPadPitchWidth(sector);
165 }
166 //
167 // X coordinate
022ee144 168 x[0] = param->GetPadRowRadii(sector,row); // padrow X position - ideal
24db6af7 169 //
170 // Y coordinate
171 //
172 x[1]=(x[1]-0.5*maxPad)*padWidth;
24db6af7 173 //
174 // Z coordinate
175 //
176 x[2]*= zwidth; // tranform time bin to the distance to the ROC
177 x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth;
178 // subtract the time offsets
179 x[2] = sign*( param->GetZLength(sector) - x[2]);
c1bdda91 180}
181
24db6af7 182inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x) const {
183 //
184 // transform possition rotated global to the global
185 //
c1bdda91 186 Double_t cos,sin;
187 GetCosAndSin(sector,cos,sin);
188 Double_t tmp=x[0];
189 x[0]= cos*tmp+sin*x[1];
190 x[1]=-sin*tmp+cos*x[1];
191}
192
24db6af7 193inline void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x) const {
194 //
195 // tranform possition Global2RotatedGlobal
196 //
c1bdda91 197 Double_t cos,sin;
198 GetCosAndSin(sector,cos,sin);
199 Double_t tmp=x[0];
200 x[0]= cos*tmp-sin*x[1];
201 x[1]= sin*tmp+cos*x[1];
202}
203
204inline void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos,
205 Double_t &sin) const {
206 cos=fCoss[sector%18];
207 sin=fSins[sector%18];
208}
209
210ClassImp(AliTPCTransform)
211