]>
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" | |
cf5b0aa0 | 62 | #include "AliTPCCorrection.h" |
66954e3f | 63 | #include "TGeoMatrix.h" |
9430b11a | 64 | #include "AliTPCRecoParam.h" |
65 | #include "AliTPCCalibVdrift.h" | |
022ee144 | 66 | #include "AliTPCTransform.h" |
1e6337b1 | 67 | #include <AliCTPTimeParams.h> |
022ee144 | 68 | |
66954e3f | 69 | ClassImp(AliTPCTransform) |
022ee144 | 70 | |
71 | ||
9430b11a | 72 | AliTPCTransform::AliTPCTransform(): |
73 | AliTransform(), | |
74 | fCurrentRecoParam(0), //! current reconstruction parameters | |
75 | fCurrentRun(0), //! current run | |
76 | fCurrentTimeStamp(0) //! current time stamp | |
77 | { | |
78 | // | |
79 | // Speed it up a bit! | |
80 | // | |
81 | for (Int_t i=0;i<18;++i) { | |
82 | Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18)); | |
83 | fSins[i]=TMath::Sin(alpha); | |
84 | fCoss[i]=TMath::Cos(alpha); | |
85 | } | |
86 | fPrimVtx[0]=0; | |
87 | fPrimVtx[1]=0; | |
88 | fPrimVtx[2]=0; | |
89 | } | |
90 | AliTPCTransform::AliTPCTransform(const AliTPCTransform& transform): | |
91 | AliTransform(transform), | |
92 | fCurrentRecoParam(transform.fCurrentRecoParam), //! current reconstruction parameters | |
93 | fCurrentRun(transform.fCurrentRun), //! current run | |
94 | fCurrentTimeStamp(transform.fCurrentTimeStamp) //! current time stamp | |
003b43ed | 95 | { |
24db6af7 | 96 | // |
c1bdda91 | 97 | // Speed it up a bit! |
24db6af7 | 98 | // |
c1bdda91 | 99 | for (Int_t i=0;i<18;++i) { |
100 | Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18)); | |
101 | fSins[i]=TMath::Sin(alpha); | |
102 | fCoss[i]=TMath::Cos(alpha); | |
103 | } | |
003b43ed | 104 | fPrimVtx[0]=0; |
105 | fPrimVtx[1]=0; | |
106 | fPrimVtx[2]=0; | |
c1bdda91 | 107 | } |
108 | ||
109 | AliTPCTransform::~AliTPCTransform() { | |
24db6af7 | 110 | // |
111 | // Destructor | |
112 | // | |
c1bdda91 | 113 | } |
114 | ||
003b43ed | 115 | void AliTPCTransform::SetPrimVertex(Double_t *vtx){ |
116 | // | |
117 | // | |
118 | // | |
119 | fPrimVtx[0]=vtx[0]; | |
120 | fPrimVtx[1]=vtx[1]; | |
121 | fPrimVtx[2]=vtx[2]; | |
122 | } | |
123 | ||
124 | ||
24db6af7 | 125 | void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/, |
003b43ed | 126 | Int_t /*coordinateType*/) { |
24db6af7 | 127 | // input: x[0] - pad row |
128 | // x[1] - pad | |
c1bdda91 | 129 | // x[2] - time in us |
130 | // i[0] - sector | |
131 | // output: x[0] - x (all in the rotated global coordinate frame) | |
132 | // x[1] - y | |
133 | // x[2] - z | |
ecc5dd8f | 134 | // |
135 | // primvtx - position of the primary vertex | |
136 | // used for the TOF correction | |
137 | // TOF of particle calculated assuming the speed-of-light and | |
138 | // line approximation | |
139 | // | |
140 | ||
24db6af7 | 141 | Int_t row=TMath::Nint(x[0]); |
142 | Int_t pad=TMath::Nint(x[1]); | |
c1bdda91 | 143 | Int_t sector=i[0]; |
9430b11a | 144 | AliTPCcalibDB* calib=AliTPCcalibDB::Instance(); |
24db6af7 | 145 | // |
146 | AliTPCCalPad * time0TPC = calib->GetPadTime0(); | |
2293155b | 147 | AliTPCCalPad * distortionMapY = calib->GetDistortionMap(0); |
148 | AliTPCCalPad * distortionMapZ = calib->GetDistortionMap(1); | |
24db6af7 | 149 | AliTPCParam * param = calib->GetParameters(); |
cf5b0aa0 | 150 | AliTPCCorrection * correction = calib->GetTPCComposedCorrection(); |
24db6af7 | 151 | if (!time0TPC){ |
152 | AliFatal("Time unisochronity missing"); | |
153 | } | |
c1bdda91 | 154 | |
24db6af7 | 155 | if (!param){ |
156 | AliFatal("Parameters missing"); | |
157 | } | |
c1bdda91 | 158 | |
24db6af7 | 159 | Double_t xx[3]; |
160 | // Apply Time0 correction - Pad by pad fluctuation | |
161 | // | |
162 | x[2]-=time0TPC->GetCalROC(sector)->GetValue(row,pad); | |
163 | // | |
164 | // Tranform from pad - time coordinate system to the rotated global (tracking) system | |
165 | // | |
166 | Local2RotatedGlobal(sector,x); | |
167 | // | |
168 | // | |
169 | // | |
c1bdda91 | 170 | // Alignment |
171 | //TODO: calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx); | |
c1bdda91 | 172 | RotatedGlobal2Global(sector,x); |
cf5b0aa0 | 173 | |
24db6af7 | 174 | // |
cf5b0aa0 | 175 | // old ExB correction |
24db6af7 | 176 | // |
3ce45991 | 177 | if(fCurrentRecoParam&&fCurrentRecoParam->GetUseExBCorrection()) { |
178 | ||
179 | calib->GetExB()->Correct(x,xx); | |
180 | ||
181 | } else { | |
182 | ||
183 | xx[0] = x[0]; | |
184 | xx[1] = x[1]; | |
185 | xx[2] = x[2]; | |
186 | } | |
187 | ||
cf5b0aa0 | 188 | // |
189 | // new composed correction - will replace soon ExB correction | |
190 | // | |
191 | if(fCurrentRecoParam&&fCurrentRecoParam->GetUseComposedCorrection()&&correction) { | |
192 | Float_t distPoint[3]={xx[0],xx[1],xx[2]}; | |
193 | correction->CorrectPoint(distPoint, sector); | |
194 | xx[0]=distPoint[0]; | |
195 | xx[1]=distPoint[1]; | |
196 | xx[2]=distPoint[2]; | |
197 | } | |
198 | ||
199 | ||
ecc5dd8f | 200 | // |
201 | // Time of flight correction | |
003b43ed | 202 | // |
9430b11a | 203 | if (fCurrentRecoParam&&fCurrentRecoParam->GetUseTOFCorrection()){ |
204 | const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector(); | |
205 | Float_t sign=1; | |
206 | if (sector < kNIS) { | |
207 | sign = (sector < kNIS/2) ? 1 : -1; | |
208 | } else { | |
209 | sign = ((sector-kNIS) < kNOS/2) ? 1 : -1; | |
210 | } | |
211 | Float_t deltaDr =0; | |
212 | Float_t dist=0; | |
213 | dist+=(fPrimVtx[0]-x[0])*(fPrimVtx[0]-x[0]); | |
214 | dist+=(fPrimVtx[1]-x[1])*(fPrimVtx[1]-x[1]); | |
215 | dist+=(fPrimVtx[2]-x[2])*(fPrimVtx[2]-x[2]); | |
216 | dist = TMath::Sqrt(dist); | |
217 | // drift length correction because of TOF | |
218 | // the drift velocity is in cm/s therefore multiplication by 0.01 | |
219 | deltaDr = (dist*(0.01*param->GetDriftV()))/TMath::C(); | |
220 | xx[2]+=sign*deltaDr; | |
ecc5dd8f | 221 | } |
9430b11a | 222 | // |
223 | // | |
224 | // | |
225 | ||
ecc5dd8f | 226 | // |
c1bdda91 | 227 | Global2RotatedGlobal(sector,xx); |
2293155b | 228 | |
229 | // | |
230 | // Apply non linear distortion correction | |
231 | // | |
232 | if (distortionMapY ){ | |
233 | //can be switch on for each dimension separatelly | |
234 | if (fCurrentRecoParam->GetUseFieldCorrection()&0x2) | |
235 | xx[1]-=distortionMapY->GetCalROC(sector)->GetValue(row,pad); | |
236 | if (fCurrentRecoParam->GetUseFieldCorrection()&0x4) | |
237 | xx[2]-=distortionMapZ->GetCalROC(sector)->GetValue(row,pad); | |
238 | } | |
239 | ||
240 | ||
003b43ed | 241 | // |
c1bdda91 | 242 | x[0]=xx[0];x[1]=xx[1];x[2]=xx[2]; |
243 | } | |
244 | ||
24db6af7 | 245 | void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const { |
246 | // | |
247 | // | |
022ee144 | 248 | // Tranform coordinate from |
249 | // row, pad, time to x,y,z | |
24db6af7 | 250 | // |
022ee144 | 251 | // Drift Velocity |
252 | // Current implementation - common drift velocity - for full chamber | |
24db6af7 | 253 | // TODO: use a map or parametrisation! |
254 | // | |
255 | // | |
256 | // | |
9430b11a | 257 | const Int_t kMax =60; // cache for 60 seconds |
258 | static Int_t lastStamp=-1; //cached values | |
259 | static Double_t lastCorr = 1; | |
260 | // | |
66954e3f | 261 | AliTPCcalibDB* calib=AliTPCcalibDB::Instance(); |
24db6af7 | 262 | AliTPCParam * param = calib->GetParameters(); |
9430b11a | 263 | AliTPCCalibVdrift *driftCalib = AliTPCcalibDB::Instance()->GetVdrift(fCurrentRun); |
264 | Double_t driftCorr = 1.; | |
265 | if (driftCalib){ | |
266 | // | |
267 | // caching drift correction - temp. fix | |
268 | // Extremally slow procedure | |
269 | if ( TMath::Abs((lastStamp)-Int_t(fCurrentTimeStamp))<kMax){ | |
270 | driftCorr = lastCorr; | |
271 | }else{ | |
272 | driftCorr = 1.+(driftCalib->GetPTRelative(fCurrentTimeStamp,0)+ driftCalib->GetPTRelative(fCurrentTimeStamp,1))*0.5; | |
273 | lastCorr=driftCorr; | |
274 | lastStamp=fCurrentTimeStamp; | |
275 | ||
276 | } | |
277 | } | |
43a74775 | 278 | // |
a8f8b6a1 | 279 | // simple caching non thread save |
280 | static Double_t vdcorrectionTime=1; | |
281 | static Double_t time0corrTime=0; | |
282 | static Int_t lastStampT=-1; | |
283 | // | |
817766d5 | 284 | if (lastStampT!=(Int_t)fCurrentTimeStamp){ |
a8f8b6a1 | 285 | lastStampT=fCurrentTimeStamp; |
286 | if(fCurrentRecoParam&&fCurrentRecoParam->GetUseDriftCorrectionTime()>0) { | |
287 | vdcorrectionTime = (1+AliTPCcalibDB::Instance()-> | |
288 | GetVDriftCorrectionTime(fCurrentTimeStamp, | |
fefec90f | 289 | fCurrentRun, |
a8f8b6a1 | 290 | sector%36>=18, |
291 | fCurrentRecoParam->GetUseDriftCorrectionTime())); | |
292 | time0corrTime= AliTPCcalibDB::Instance()-> | |
293 | GetTime0CorrectionTime(fCurrentTimeStamp, | |
fefec90f | 294 | fCurrentRun, |
a8f8b6a1 | 295 | sector%36>=18, |
296 | fCurrentRecoParam->GetUseDriftCorrectionTime()); | |
297 | } | |
298 | // | |
299 | if(fCurrentRecoParam&&fCurrentRecoParam->GetUseDriftCorrectionGY()>0) { | |
300 | Float_t xyzPad[3]; | |
301 | AliTPCROC::Instance()->GetPositionGlobal(sector, TMath::Nint(x[0]) ,TMath::Nint(x[1]), xyzPad); | |
302 | ||
303 | Double_t corrGy= (1+(xyzPad[1])*AliTPCcalibDB::Instance()-> | |
304 | GetVDriftCorrectionGy(fCurrentTimeStamp, | |
305 | AliTPCcalibDB::Instance()->GetRun(), | |
306 | sector%36>=18, | |
307 | fCurrentRecoParam->GetUseDriftCorrectionGY())); | |
308 | vdcorrectionTime *=corrGy; | |
309 | } | |
43a74775 | 310 | } |
9430b11a | 311 | |
312 | ||
24db6af7 | 313 | if (!param){ |
314 | AliFatal("Parameters missing"); | |
315 | } | |
316 | Int_t row=TMath::Nint(x[0]); | |
9389f9a4 | 317 | // Int_t pad=TMath::Nint(x[1]); |
24db6af7 | 318 | // |
319 | const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector(); | |
320 | Double_t sign = 1.; | |
502d13b5 | 321 | Double_t zwidth = param->GetZWidth()*driftCorr; |
322 | if (AliTPCRecoParam:: GetUseTimeCalibration()) zwidth*=vdcorrectionTime; | |
24db6af7 | 323 | Double_t padWidth = 0; |
324 | Double_t padLength = 0; | |
325 | Double_t maxPad = 0; | |
326 | // | |
327 | if (sector < kNIS) { | |
328 | maxPad = param->GetNPadsLow(row); | |
329 | sign = (sector < kNIS/2) ? 1 : -1; | |
330 | padLength = param->GetPadPitchLength(sector,row); | |
331 | padWidth = param->GetPadPitchWidth(sector); | |
332 | } else { | |
333 | maxPad = param->GetNPadsUp(row); | |
334 | sign = ((sector-kNIS) < kNOS/2) ? 1 : -1; | |
335 | padLength = param->GetPadPitchLength(sector,row); | |
336 | padWidth = param->GetPadPitchWidth(sector); | |
337 | } | |
338 | // | |
339 | // X coordinate | |
022ee144 | 340 | x[0] = param->GetPadRowRadii(sector,row); // padrow X position - ideal |
24db6af7 | 341 | // |
342 | // Y coordinate | |
343 | // | |
344 | x[1]=(x[1]-0.5*maxPad)*padWidth; | |
afbaa016 | 345 | // pads are mirrorred on C-side |
346 | if (sector%36>17){ | |
347 | x[1]*=-1; | |
348 | } | |
349 | ||
350 | // | |
351 | ||
24db6af7 | 352 | // |
353 | // Z coordinate | |
354 | // | |
1e6337b1 | 355 | if (AliTPCcalibDB::Instance()->IsTrgL0()){ |
356 | // by defualt we assume L1 trigger is used - make a correction in case of L0 | |
357 | AliCTPTimeParams* ctp = AliTPCcalibDB::Instance()->GetCTPTimeParams(); | |
3d1b41c1 | 358 | if (ctp){ |
359 | //for TPC standalone runs no ctp info | |
360 | Double_t delay = ctp->GetDelayL1L0()*0.000000025; | |
361 | x[2]-=delay/param->GetTSample(); | |
362 | } | |
1e6337b1 | 363 | } |
364 | x[2]-= param->GetNTBinsL1(); | |
24db6af7 | 365 | x[2]*= zwidth; // tranform time bin to the distance to the ROC |
1e6337b1 | 366 | x[2]-= 3.*param->GetZSigma() + time0corrTime; |
24db6af7 | 367 | // subtract the time offsets |
368 | x[2] = sign*( param->GetZLength(sector) - x[2]); | |
c1bdda91 | 369 | } |
370 | ||
c2da420d | 371 | void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x) const { |
24db6af7 | 372 | // |
373 | // transform possition rotated global to the global | |
374 | // | |
c1bdda91 | 375 | Double_t cos,sin; |
376 | GetCosAndSin(sector,cos,sin); | |
377 | Double_t tmp=x[0]; | |
e81544f7 | 378 | x[0]= cos*tmp-sin*x[1]; |
379 | x[1]=+sin*tmp+cos*x[1]; | |
c1bdda91 | 380 | } |
381 | ||
c2da420d | 382 | void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x) const { |
24db6af7 | 383 | // |
384 | // tranform possition Global2RotatedGlobal | |
385 | // | |
c1bdda91 | 386 | Double_t cos,sin; |
387 | GetCosAndSin(sector,cos,sin); | |
388 | Double_t tmp=x[0]; | |
e81544f7 | 389 | x[0]= cos*tmp+sin*x[1]; |
390 | x[1]= -sin*tmp+cos*x[1]; | |
c1bdda91 | 391 | } |
392 | ||
c2da420d | 393 | void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos, |
c1bdda91 | 394 | Double_t &sin) const { |
395 | cos=fCoss[sector%18]; | |
396 | sin=fSins[sector%18]; | |
397 | } | |
398 | ||
c1bdda91 | 399 | |
43a74775 | 400 | void AliTPCTransform::ApplyTransformations(Double_t */*xyz*/, Int_t /*volID*/){ |
401 | // | |
402 | // Modify global position | |
403 | // xyz - global xyz position | |
404 | // volID - volID of detector (sector number) | |
405 | // | |
406 | // | |
407 | ||
408 | } |