]>
Commit | Line | Data |
---|---|---|
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 | |
66954e3f | 23 | // Transformation |
022ee144 | 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 | // | |
003b43ed | 31 | // Time of flight correction - |
32 | // - Depends on the vertex position | |
33 | // - by default | |
34 | // | |
022ee144 | 35 | // Usage: |
36 | // AliTPCclustererMI::AddCluster | |
37 | // AliTPCtrackerMI::Transform | |
38 | // | |
39 | //------------------------------------------------------- | |
c1bdda91 | 40 | |
41 | /* To test it: | |
42 | cdb=AliCDBManager::Instance() | |
43 | cdb->SetDefaultStorage("local:///u/mmager/mycalib1") | |
44 | c=AliTPCcalibDB::Instance() | |
45 | c->SetRun(0) | |
46 | Double_t x[]={1.0,2.0,3.0} | |
47 | Int_t i[]={4} | |
48 | AliTPCTransform trafo | |
49 | trafo.Transform(x,i,0,1) | |
50 | */ | |
51 | ||
022ee144 | 52 | /* $Id$ */ |
53 | ||
54 | #include "AliTPCROC.h" | |
55 | #include "AliTPCCalPad.h" | |
56 | #include "AliTPCCalROC.h" | |
57 | #include "AliTPCcalibDB.h" | |
58 | #include "AliTPCParam.h" | |
59 | #include "TMath.h" | |
60 | #include "AliLog.h" | |
61 | #include "AliTPCExB.h" | |
66954e3f | 62 | #include "TGeoMatrix.h" |
022ee144 | 63 | #include "AliTPCTransform.h" |
64 | ||
66954e3f | 65 | ClassImp(AliTPCTransform) |
022ee144 | 66 | |
67 | ||
003b43ed | 68 | AliTPCTransform::AliTPCTransform(): |
69 | AliTransform() | |
70 | { | |
24db6af7 | 71 | // |
c1bdda91 | 72 | // Speed it up a bit! |
24db6af7 | 73 | // |
c1bdda91 | 74 | for (Int_t i=0;i<18;++i) { |
75 | Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18)); | |
76 | fSins[i]=TMath::Sin(alpha); | |
77 | fCoss[i]=TMath::Cos(alpha); | |
78 | } | |
003b43ed | 79 | fPrimVtx[0]=0; |
80 | fPrimVtx[1]=0; | |
81 | fPrimVtx[2]=0; | |
c1bdda91 | 82 | } |
83 | ||
84 | AliTPCTransform::~AliTPCTransform() { | |
24db6af7 | 85 | // |
86 | // Destructor | |
87 | // | |
c1bdda91 | 88 | } |
89 | ||
003b43ed | 90 | void AliTPCTransform::SetPrimVertex(Double_t *vtx){ |
91 | // | |
92 | // | |
93 | // | |
94 | fPrimVtx[0]=vtx[0]; | |
95 | fPrimVtx[1]=vtx[1]; | |
96 | fPrimVtx[2]=vtx[2]; | |
97 | } | |
98 | ||
99 | ||
24db6af7 | 100 | void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/, |
003b43ed | 101 | Int_t /*coordinateType*/) { |
24db6af7 | 102 | // input: x[0] - pad row |
103 | // x[1] - pad | |
c1bdda91 | 104 | // x[2] - time in us |
105 | // i[0] - sector | |
106 | // output: x[0] - x (all in the rotated global coordinate frame) | |
107 | // x[1] - y | |
108 | // x[2] - z | |
ecc5dd8f | 109 | // |
110 | // primvtx - position of the primary vertex | |
111 | // used for the TOF correction | |
112 | // TOF of particle calculated assuming the speed-of-light and | |
113 | // line approximation | |
114 | // | |
115 | ||
116 | ||
24db6af7 | 117 | Int_t row=TMath::Nint(x[0]); |
118 | Int_t pad=TMath::Nint(x[1]); | |
c1bdda91 | 119 | Int_t sector=i[0]; |
66954e3f | 120 | AliTPCcalibDB* calib=AliTPCcalibDB::Instance(); |
24db6af7 | 121 | // |
122 | AliTPCCalPad * time0TPC = calib->GetPadTime0(); | |
123 | AliTPCParam * param = calib->GetParameters(); | |
124 | if (!time0TPC){ | |
125 | AliFatal("Time unisochronity missing"); | |
126 | } | |
c1bdda91 | 127 | |
24db6af7 | 128 | if (!param){ |
129 | AliFatal("Parameters missing"); | |
130 | } | |
c1bdda91 | 131 | |
24db6af7 | 132 | Double_t xx[3]; |
133 | // Apply Time0 correction - Pad by pad fluctuation | |
134 | // | |
135 | x[2]-=time0TPC->GetCalROC(sector)->GetValue(row,pad); | |
136 | // | |
137 | // Tranform from pad - time coordinate system to the rotated global (tracking) system | |
138 | // | |
139 | Local2RotatedGlobal(sector,x); | |
140 | // | |
141 | // | |
142 | // | |
c1bdda91 | 143 | // Alignment |
144 | //TODO: calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx); | |
c1bdda91 | 145 | RotatedGlobal2Global(sector,x); |
24db6af7 | 146 | // |
147 | // | |
148 | // ExB correction | |
149 | // | |
c1bdda91 | 150 | calib->GetExB()->Correct(x,xx); |
ecc5dd8f | 151 | // |
152 | // Time of flight correction | |
003b43ed | 153 | // |
154 | const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector(); | |
155 | Float_t sign=1; | |
156 | if (sector < kNIS) { | |
157 | sign = (sector < kNIS/2) ? 1 : -1; | |
158 | } else { | |
159 | sign = ((sector-kNIS) < kNOS/2) ? 1 : -1; | |
ecc5dd8f | 160 | } |
003b43ed | 161 | Float_t deltaDr =0; |
162 | Float_t dist=0; | |
163 | dist+=(fPrimVtx[0]-x[0])*(fPrimVtx[0]-x[0]); | |
164 | dist+=(fPrimVtx[1]-x[1])*(fPrimVtx[1]-x[1]); | |
165 | dist+=(fPrimVtx[0]-x[2])*(fPrimVtx[0]-x[2]); | |
166 | dist = TMath::Sqrt(dist); | |
167 | // drift length correction because of TOF | |
168 | // the drift velocity is in cm/s therefore multiplication by 0.01 | |
169 | deltaDr = (dist*(0.01*param->GetDriftV()))/TMath::C(); | |
170 | xx[2]+=sign*deltaDr; | |
ecc5dd8f | 171 | // |
c1bdda91 | 172 | Global2RotatedGlobal(sector,xx); |
003b43ed | 173 | // |
c1bdda91 | 174 | x[0]=xx[0];x[1]=xx[1];x[2]=xx[2]; |
175 | } | |
176 | ||
24db6af7 | 177 | void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const { |
178 | // | |
179 | // | |
022ee144 | 180 | // Tranform coordinate from |
181 | // row, pad, time to x,y,z | |
24db6af7 | 182 | // |
022ee144 | 183 | // Drift Velocity |
184 | // Current implementation - common drift velocity - for full chamber | |
24db6af7 | 185 | // TODO: use a map or parametrisation! |
186 | // | |
187 | // | |
188 | // | |
66954e3f | 189 | AliTPCcalibDB* calib=AliTPCcalibDB::Instance(); |
24db6af7 | 190 | AliTPCParam * param = calib->GetParameters(); |
191 | if (!param){ | |
192 | AliFatal("Parameters missing"); | |
193 | } | |
194 | Int_t row=TMath::Nint(x[0]); | |
9389f9a4 | 195 | // Int_t pad=TMath::Nint(x[1]); |
24db6af7 | 196 | // |
197 | const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector(); | |
198 | Double_t sign = 1.; | |
199 | Double_t zwidth = param->GetZWidth(); | |
200 | Double_t padWidth = 0; | |
201 | Double_t padLength = 0; | |
202 | Double_t maxPad = 0; | |
203 | // | |
204 | if (sector < kNIS) { | |
205 | maxPad = param->GetNPadsLow(row); | |
206 | sign = (sector < kNIS/2) ? 1 : -1; | |
207 | padLength = param->GetPadPitchLength(sector,row); | |
208 | padWidth = param->GetPadPitchWidth(sector); | |
209 | } else { | |
210 | maxPad = param->GetNPadsUp(row); | |
211 | sign = ((sector-kNIS) < kNOS/2) ? 1 : -1; | |
212 | padLength = param->GetPadPitchLength(sector,row); | |
213 | padWidth = param->GetPadPitchWidth(sector); | |
214 | } | |
215 | // | |
216 | // X coordinate | |
022ee144 | 217 | x[0] = param->GetPadRowRadii(sector,row); // padrow X position - ideal |
24db6af7 | 218 | // |
219 | // Y coordinate | |
220 | // | |
221 | x[1]=(x[1]-0.5*maxPad)*padWidth; | |
24db6af7 | 222 | // |
223 | // Z coordinate | |
224 | // | |
225 | x[2]*= zwidth; // tranform time bin to the distance to the ROC | |
226 | x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth; | |
227 | // subtract the time offsets | |
228 | x[2] = sign*( param->GetZLength(sector) - x[2]); | |
c1bdda91 | 229 | } |
230 | ||
24db6af7 | 231 | inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x) const { |
232 | // | |
233 | // transform possition rotated global to the global | |
234 | // | |
c1bdda91 | 235 | Double_t cos,sin; |
236 | GetCosAndSin(sector,cos,sin); | |
237 | Double_t tmp=x[0]; | |
238 | x[0]= cos*tmp+sin*x[1]; | |
239 | x[1]=-sin*tmp+cos*x[1]; | |
240 | } | |
241 | ||
24db6af7 | 242 | inline void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x) const { |
243 | // | |
244 | // tranform possition Global2RotatedGlobal | |
245 | // | |
c1bdda91 | 246 | Double_t cos,sin; |
247 | GetCosAndSin(sector,cos,sin); | |
248 | Double_t tmp=x[0]; | |
249 | x[0]= cos*tmp-sin*x[1]; | |
250 | x[1]= sin*tmp+cos*x[1]; | |
251 | } | |
252 | ||
253 | inline void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos, | |
254 | Double_t &sin) const { | |
255 | cos=fCoss[sector%18]; | |
256 | sin=fSins[sector%18]; | |
257 | } | |
258 | ||
c1bdda91 | 259 |