1. Adding sorting of the Points in point array
[u/mrichter/AliRoot.git] / TPC / AliTPCTransformation.cxx
CommitLineData
94685752 1/*
2
3 Class AliTPCtransformation:
4 Should represent general non linear transformation. Currently tune for TPConly.
5 To be used:
6 1. Simulation-Digitization
7 2. Reconstruction - AliTPCTransform
8 3. Calibration/Alignment (KalmanFilter, Milipedde)
9 4. Set of transformation to be stored/retrieved as OCDB entry
10
11 Base functionality:
12
13 1. Double_t GetDeltaXYZ(Int_t coord, Int_t volID, Double_t param, Double_t x, Double_t y, Double_t z)
14 Get correction - return the delta of coordinate coord dx or dy or dz for given volID for point at point (x,y,z)
15 All coordinates are global
16
17 2. The transformation should work only for given volIDs and detector IDs
18 Currently Bitmask is used for filtering
19
20
3649eec1 21 Transformation - naming convention:
22 //
23 XXX(local)YYYZZZ
24 TPClocaldLxdGX
25 XXX - detector if detector specific
26 local - if local transforamtion
27 YYY - type of transformation
28 ZZZ - return type of transformation
94685752 29
30*/
31
32#include <string.h>
33#include "TRandom.h"
34#include "TMath.h"
35#include "TBits.h"
36#include "TFormula.h"
37#include "TF1.h"
38#include "TLinearFitter.h"
39#include "TFile.h"
40#include "TObjString.h"
41
42#include "TTreeStream.h"
43#include "AliTrackPointArray.h"
44#include "AliLog.h"
45#include "AliTPCTransformation.h"
46
47ClassImp(AliTPCTransformation)
48
49
50AliTPCTransformation::GenFuncG AliTPCTransformation::fgFormulas[10000];
51TObjArray* AliTPCTransformation::fgFormulasName = new TObjArray(10000);
52
53
54void AliTPCTransformation::RegisterFormula(const char * name, GenFuncG formula){
55 //
56 // Add Formula to the list of formulas
57 //
58 Int_t last= fgFormulasName->GetEntries();
59 fgFormulasName->AddLast(new TObjString(name));
60 fgFormulas[last]=formula;
61}
62
63Int_t AliTPCTransformation::BuildBasicFormulas(){
64 //
6d438146 65
66 //
67 //build list of basic TPC formulas - corrections
94685752 68 //
69 RegisterFormula("TPCscalingRPol",(GenFuncG)(AliTPCTransformation::TPCscalingRPol));
6d438146 70 RegisterFormula("TPCscalingRIFC",(GenFuncG)(AliTPCTransformation::TPCscalingRIFC));
71 RegisterFormula("TPCscalingROFC",(GenFuncG)(AliTPCTransformation::TPCscalingROFC));
72 //
94685752 73 RegisterFormula("TPCscalingZDr",(GenFuncG)(AliTPCTransformation::TPCscalingZDr));
ddf81107 74 RegisterFormula("TPCscalingZDrGy",(GenFuncG)(AliTPCTransformation::TPCscalingZDrGy));
94685752 75 RegisterFormula("TPCscalingPhiLocal",(GenFuncG)(AliTPCTransformation::TPCscalingPhiLocal));
0e9efcbe 76 //
3649eec1 77 // TPC Local X and Y misalignment + rotation
0e9efcbe 78 //
79 RegisterFormula("TPClocaldLxdGX",(GenFuncG)(AliTPCTransformation::TPClocaldLxdGX));
80 RegisterFormula("TPClocaldLxdGY",(GenFuncG)(AliTPCTransformation::TPClocaldLxdGY));
81 RegisterFormula("TPClocaldLydGX",(GenFuncG)(AliTPCTransformation::TPClocaldLydGX));
82 RegisterFormula("TPClocaldLydGY",(GenFuncG)(AliTPCTransformation::TPClocaldLydGY));
3649eec1 83 RegisterFormula("TPClocaldRzdGX",(GenFuncG)(AliTPCTransformation::TPClocaldRzdGX));
84 RegisterFormula("TPClocaldRzdGY",(GenFuncG)(AliTPCTransformation::TPClocaldRzdGY));
85
0e9efcbe 86 //
87 // Z offset
88 //
89 RegisterFormula("TPCDeltaZ",(GenFuncG)(AliTPCTransformation::TPCDeltaZ));
90 RegisterFormula("TPCDeltaZMediumLong",(GenFuncG)(AliTPCTransformation::TPCDeltaZMediumLong));
91 RegisterFormula("TPCTiltingZ",(GenFuncG)(AliTPCTransformation::TPCTiltingZ));
94685752 92 return 0;
93}
94
95AliTPCTransformation::GenFuncG AliTPCTransformation::FindFormula(const char * name){
96 //
97 // find formula - if registered
98 //
99 if (fgFormulasName->FindObject(name)==0) return 0;
100 Int_t entries = fgFormulasName->GetEntries();
101 for (Int_t i=0;i<entries;i++){
102 if (strcmp(fgFormulasName->At(i)->GetName(), name)==0){
103 return fgFormulas[i];
104 }
105 }
106 return 0;
107}
108
109Double_t AliTPCTransformation::Eval(const char * name, const Double_t*x,const Double_t*par){
110 //
111 // Only for test purposes - very slow
112 //
113 GenFuncG fun = FindFormula(name);
114 if (!fun) return 0;
115 return fun(x,par);
116}
117
118
119AliTPCTransformation::AliTPCTransformation():
120 TNamed(),
121 fNameX(0), // x formula name
122 fNameY(0), // y formula name
123 fNameZ(0), // z formula name
124 //
125 fBitMask(0), // bitmaps - transformation only for specified volID
126 fCoordSystem(0), // coord system of output deltas
127 fParam(0), // free parameter of transformation
128 fSigma(0), // uncertainty of the parameter
6d438146 129 fSigma2Time(0), // change of the error in time - (For kalman filter)
94685752 130 fFixedParam(0), // fixed parameters of tranformation
0e9efcbe 131 fIsActive(kTRUE), // swith - On/Off
94685752 132 //
133 fInit(kFALSE), // initialization flag - set to kTRUE if corresponding formulas found
134 fFormulaX(0), // x formula - pointer to the function
135 fFormulaY(0), // y formula - pointer to the function
136 fFormulaZ(0) // z formula - pointer to the function
137 //
138{
139 //
140 // default constructor
141 //
142}
143
144
145
6d438146 146AliTPCTransformation::AliTPCTransformation(const char *name, TBits *mask, const char *fx, const char *fy, const char *fz, Int_t coordSystem):
94685752 147 TNamed(name,name),
148 fNameX(0), // x formula name
149 fNameY(0), // y formula name
150 fNameZ(0), // z formula name
151 fBitMask(mask), // bitmaps - transformation only for specified volID
152 fCoordSystem(coordSystem), // coordinate system of output deltas
6d438146 153 fParam(0), // free parameter of transformation
154 fSigma(0),
155 fSigma2Time(0), // change of sigma in time
94685752 156 fFixedParam(0), // fixed parameters of tranformation
0e9efcbe 157 fIsActive(kTRUE), // swith - On/Off
94685752 158 //
159 fInit(kFALSE), // initialization flag - set to kTRUE if corresponding formulas found
160 fFormulaX(0), // x formula - pointer to the function
161 fFormulaY(0), // y formula - pointer to the function
162 fFormulaZ(0) // z formula - pointer to the function
163{
164 //
165 // non default constructor
166 //
167 if (fx) fNameX= new TString(fx);
168 if (fy) fNameY= new TString(fy);
169 if (fz) fNameZ= new TString(fz);
94685752 170 Init();
171}
172
6d438146 173AliTPCTransformation::AliTPCTransformation(const AliTPCTransformation&trafo):
174 TNamed(trafo),
175 fNameX(0), // x formula name
176 fNameY(0), // y formula name
177 fNameZ(0), // z formula name
178 //
179 fBitMask(0), // bitmaps - transformation only for specified volID
180 fCoordSystem(0), // coord system of output deltas
181 fParam(trafo.fParam), // free parameter of transformation
182 fSigma(trafo.fSigma), // uncertainty of the parameter
183 fSigma2Time(trafo.fSigma2Time), // change of the error in time - (For kalman filter)
e55e5512 184 fFixedParam(0), // fixed parameters of tranformation
185 fIsActive(trafo.fIsActive), // swith - On/Off
6d438146 186 //
187 fInit(kFALSE), // initialization flag - set to kTRUE if corresponding formulas found
188 fFormulaX(0), // x formula - pointer to the function
189 fFormulaY(0), // y formula - pointer to the function
190 fFormulaZ(0) // z formula - pointer to the function
191{
192 if (trafo.fNameX) fNameX = new TString(*(trafo.fNameX));
193 if (trafo.fNameY) fNameY = new TString(*(trafo.fNameY));
194 if (trafo.fNameZ) fNameZ = new TString(*(trafo.fNameZ));
195 if (trafo.fBitMask) fBitMask = new TBits(*(trafo.fBitMask));
196}
197
198AliTPCTransformation::~AliTPCTransformation(){
199 //
200 // destructor
201 //
202 delete fNameX;
203 delete fNameY;
204 delete fNameZ;
205 delete fBitMask;
206 delete fFixedParam;
207}
208void AliTPCTransformation::SetParams(Double_t param, Double_t sigma, Double_t sigma2Time, TVectorD* fixedParams){
209 //
210 // Set parameters of transformation
211 //
212 fParam = param;
213 fSigma = sigma;
214 fSigma2Time = sigma2Time;
215 if (fFixedParam) delete fFixedParam;
216 fFixedParam = new TVectorD(*fixedParams);
217 Init();
218}
94685752 219
220
221Bool_t AliTPCTransformation::Init(){
222 //
223 // associate formulas with pointer to the function
224 //
225 Bool_t isOK=kTRUE;
226 if (fNameX) {
227 fFormulaX=FindFormula(fNameX->Data());
228 if (fFormulaX==0) isOK=kFALSE;
229 }
230 if (fNameY) {
231 fFormulaY=FindFormula(fNameY->Data());
232 if (fFormulaY==0) isOK=kFALSE;
233 }
234 if (fNameZ) {
235 fFormulaZ=FindFormula(fNameZ->Data());
236 if (!fFormulaZ) isOK=kFALSE;
237 }
238 return isOK;
239}
240
0e9efcbe 241
242
94685752 243TBits * AliTPCTransformation::BitsSide(Bool_t aside){
244 //
245 TBits * bits = new TBits(72);
246 for (Int_t i=0; i<72;i++){
247 if (i%36<18 && aside) (*bits)[i]=kTRUE;
248 if (i%36<18 && (!aside)) (*bits)[i]=kFALSE;
249 if (i%36>=18 && aside) (*bits)[i]=kFALSE;
250 if (i%36>=18 && (!aside)) (*bits)[i]=kTRUE;
251 }
252 return bits;
253}
254
255TBits * AliTPCTransformation::BitsAll(){
256 //
257 //
258 //
259 TBits * bits = new TBits(72);
260 for (Int_t i=0; i<72;i++){
261 (*bits)[i]=kTRUE;
262 }
263 return bits;
264}
265
266Double_t AliTPCTransformation::GetDeltaXYZ(Int_t coord, Int_t volID, Double_t param, Double_t x, Double_t y, Double_t z){
267 //
268 //
3649eec1 269 // coord - type of coordinate
270 // - 0 -X
271 // 1 -Y
272 // 2 -Z
273 // 3 -R
274 // 4 -RPhi
0e9efcbe 275 if (!fIsActive) return 0;
94685752 276 if (fBitMask && (!(*fBitMask)[volID])) return 0;
0e9efcbe 277 Double_t xyz[5]={x,y,z, param,volID};
94685752 278 if (fCoordSystem==0){
279 // cartezian system
280 if (coord==0 && fFormulaX) return fFormulaX(xyz,fFixedParam->GetMatrixArray());
281 if (coord==1 && fFormulaY) return fFormulaY(xyz,fFixedParam->GetMatrixArray());
0e9efcbe 282 if (coord==2 && fFormulaZ) return fFormulaZ(xyz,fFixedParam->GetMatrixArray());
94685752 283 }
284 if (fCoordSystem==1){
285 // cylindrical system
286 if (coord==2) {
287 if (fFormulaZ==0) return 0;
288 return fFormulaZ(xyz,fFixedParam->GetMatrixArray());
289 }
290 Double_t rrphiz[3]={0,0,0};
291 if (fFormulaX) rrphiz[0] = fFormulaX(xyz,fFixedParam->GetMatrixArray());
292 if (fFormulaY) rrphiz[1] = fFormulaY(xyz,fFixedParam->GetMatrixArray());
293 Double_t alpha = TMath::ATan2(y,x);
294 Double_t ca = TMath::Cos(alpha);
295 Double_t sa = TMath::Sin(alpha);
296 if (coord==0) return ca*rrphiz[0]-sa*rrphiz[1];
297 if (coord==1) return sa*rrphiz[0]+ca*rrphiz[1];
298 }
299 return 0;
300}
301
302Double_t AliTPCTransformation::TPCscalingRPol(Double_t *xyz, Double_t * param){
303 //
304 // Scaling and shift of TPC radius
305 // xyz[0..2] - global xyz of point
306 // xyz[3] - scale parameter
6d438146 307 // param[0] - radial scaling power
308 // param[1] - drift scaling power
309 // radius from -1(at rInner) to 1 (rOuter)
310 // driftM from -1(at 0 drift) to 1 (250 cm drift)
311
312 Double_t rInner=78.8;
313 Double_t rOuter=258.0;
314 Double_t deltaR = rOuter-rInner;
315 Double_t radius = (TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1])-rInner)*2./deltaR;
316 Double_t driftM = (0.5 - TMath::Abs(xyz[2]/250.))*2.0;
317 Double_t delta = TMath::Power(radius,param[0])*TMath::Power(driftM,param[1]);
318 return delta*xyz[3];
94685752 319}
320
321
322Double_t AliTPCTransformation::TPCscalingZDr(Double_t *xyz, Double_t * param){
323 //
324 //
325 // Scaling and shift of TPC radius
326 // xyz[0..2] - global xyz of point
327 // xyz[3] - scale parameter
328 Double_t driftP = TMath::Power(1. - TMath::Abs(xyz[2]/250.), param[0]);
329 Double_t deltaZ = (xyz[2]>0) ? -driftP : driftP;
330 return deltaZ*xyz[3];
331}
332
ddf81107 333
334Double_t AliTPCTransformation::TPCscalingZDrGy(Double_t *xyz, Double_t * param){
335 //
336 //
337 // Scaling and shift of TPC radius
338 // xyz[0..2] - global xyz of point
339 // xyz[3] - scale parameter
340 Double_t driftP = TMath::Power(1. - TMath::Abs(xyz[2]/250.), param[0]);
341 Double_t gy = xyz[1]/250.;
342 Double_t deltaZ = (xyz[2]>0) ? -driftP : driftP;
343 return deltaZ*xyz[3]*gy;
344}
345
346
347
94685752 348Double_t AliTPCTransformation::TPCscalingPhiLocal(Double_t *xyz, Double_t * param){
349 //
350 //
351 // Scaling if the local y -phi
352 // xyz[0..2] - global xyz of point
353 // xyz[3] - scale parameter
6d438146 354 // value = 1 for ful drift length and parameter 1
94685752 355 Double_t alpha = TMath::ATan2(xyz[1],xyz[0]);
356 Double_t sector = TMath::Nint(9*alpha/TMath::Pi()-0.5);
357 Double_t localAlpha = (alpha-(sector+0.5)*TMath::Pi()/9.);
358 Double_t radius = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1])/250.;
6d438146 359 //
360 Double_t deltaAlpha = radius*TMath::Power(2.*9.*localAlpha/TMath::Pi(),param[0]);
94685752 361 return deltaAlpha*xyz[3];
362}
363
364
6d438146 365Double_t AliTPCTransformation::TPCscalingRIFC(Double_t *xyz, Double_t * param){
366 //
367 // inner field cage r distorion - proportinal to 1 over distance to the IFC
368 // param[0] - drift polynom order
369 // distortion at first pad row - is normalized to
370 Double_t rInner=78.8;
371 Double_t rFirst=85.2;
372 Double_t deltaR = rFirst-rInner;
373 Double_t ndistR = (TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1])-rInner)/deltaR;
374 Double_t driftM = (0.5 - TMath::Abs(xyz[2]/250.))*2.;
375 Double_t value = TMath::Power(driftM,param[0])/ndistR;
376 return xyz[3]*value;
377}
378
379Double_t AliTPCTransformation::TPCscalingROFC(Double_t *xyz, Double_t * param){
380 //
381 // outer field cage r distorion - proportinal to 1 over distance to the OFC
382 // param[0] - drift polynom order
383 // driftM - from -1 to 1
384 //
385 Double_t rLast=245.8;
386 Double_t rOuter=258.0;
387 Double_t deltaR = rOuter-rLast;
388 Double_t ndistR = (rOuter-TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]))/deltaR;
389 Double_t driftM = (0.5 - TMath::Abs(xyz[2]/250.))*2.;
390 Double_t value = TMath::Power(driftM,param[0])/ndistR;
391 return xyz[3]*value;
392}
0e9efcbe 393
394
395//
396// TPC sector local misalignment
397//
3649eec1 398//
399//
400Double_t AliTPCTransformation:: TPClocaldLxdGX(Double_t *xyz, Double_t * param){
0e9efcbe 401 //
402 // xyz - [0..2] - position
403 // [3] - scale parameter
404 // [4] - volID
3649eec1 405 // param[0]= n - cos(n *alpha)
406 // param[1]= n - sin(n *alpha)
407 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
0e9efcbe 408 // return delta in global coordiante system
409 //
410 Int_t sector = TMath::Nint(xyz[4]);
411 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
412 Double_t ca = TMath::Cos(alpha);
3649eec1 413 // Double_t sa = TMath::Sin(alpha);
414 const Double_t xIROCOROC = 133.4;
415 Double_t factor = xyz[3];
416 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
417 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
418 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
419 return ca*factor;
0e9efcbe 420}
421
3649eec1 422Double_t AliTPCTransformation::TPClocaldLxdGY(Double_t *xyz, Double_t * param){
0e9efcbe 423 //
424 // xyz - [0..2] - position
425 // [3] - scale parameter
426 // [4] - volID
3649eec1 427 // param[0]= n - cos(n *alpha)
428 // param[1]= n - sin(n *alpha)
429 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
0e9efcbe 430 // return delta in global coordiante system
431 //
432 Int_t sector = TMath::Nint(xyz[4]);
433 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
434 //Double_t ca = TMath::Cos(alpha);
435 Double_t sa = TMath::Sin(alpha);
3649eec1 436 const Double_t xIROCOROC = 133.4;
437 Double_t factor = xyz[3];
438 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
439 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
440 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
441 return sa*factor;
0e9efcbe 442}
443
3649eec1 444Double_t AliTPCTransformation:: TPClocaldLydGX(Double_t *xyz, Double_t * param){
0e9efcbe 445 //
446 // xyz - [0..2] - position
447 // [3] - scale parameter
448 // [4] - volID
3649eec1 449 // param[0]= n - cos(n *alpha)
450 // param[1]= n - sin(n *alpha)
451 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
0e9efcbe 452 // return delta in global coordiante system
453 //
454 Int_t sector = TMath::Nint(xyz[4]);
455 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
456 //Double_t ca = TMath::Cos(alpha);
457 Double_t sa = TMath::Sin(alpha);
3649eec1 458 const Double_t xIROCOROC = 133.4;
459 Double_t factor = xyz[3];
460 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
461 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
462 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
463 return -sa*factor;
0e9efcbe 464}
465
3649eec1 466Double_t AliTPCTransformation::TPClocaldLydGY(Double_t *xyz, Double_t * param){
0e9efcbe 467 //
468 // xyz - [0..2] - position
469 // [3] - scale parameter
470 // [4] - volID
3649eec1 471 // param[0]= n - cos(n *alpha)
472 // param[1]= n - sin(n *alpha)
473 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
0e9efcbe 474 // return delta in global coordiante system
475 //
476 Int_t sector = TMath::Nint(xyz[4]);
477 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
478 Double_t ca = TMath::Cos(alpha);
479 //Double_t sa = TMath::Sin(alpha);
3649eec1 480 const Double_t xIROCOROC = 133.4;
481 Double_t factor = xyz[3];
482 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
483 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
484 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
485 return ca*factor;
486}
487
488
489Double_t AliTPCTransformation::TPClocaldRzdGX(Double_t *xyz, Double_t * param){
490 //
491 // xyz - [0..2] - position
492 // [3] - scale parameter - rotation angle in mrad
493 // [4] - volID
494 // param[0]= n - cos(n *alpha)
495 // param[1]= n - sin(n *alpha)
496 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
497 // return delta in global coordiante system
498 //
499 Int_t sector = TMath::Nint(xyz[4]);
500 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
501 Double_t ca = TMath::Cos(alpha);
502 Double_t sa = TMath::Sin(alpha);
503 Double_t lx = xyz[0]*ca + xyz[1]*sa;
504 Double_t ly = -xyz[0]*sa + xyz[1]*ca;
505 //
506 const Double_t xIROCOROC = 133.4;
507 lx-=xIROCOROC;
508 Double_t rot = xyz[3]*0.001; // rotation in mrad
509 if (param[0]>0) rot*=TMath::Cos(alpha*param[0]);
510 if (param[1]>0) rot*=TMath::Sin(alpha*param[1]);
511 if (param[2]>0.5 && lx>0) rot*=-1;
512 //
513 Double_t dlxR = - ly*rot;
514 Double_t dlyR = lx*rot;
515 Double_t dgxR = dlxR*ca - dlyR*sa;
516 //Double_t dgyR = dlxR*sa + dlyR*ca;
517 return dgxR;
518}
519
520Double_t AliTPCTransformation::TPClocaldRzdGY(Double_t *xyz, Double_t * param){
521 //
522 // xyz - [0..2] - position
523 // [3] - scale parameter - rotation angle in mrad
524 // [4] - volID
525 // param[0]= n - cos(n *alpha)
526 // param[1]= n - sin(n *alpha)
527 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
528 // return delta in global coordiante system
529 //
530 Int_t sector = TMath::Nint(xyz[4]);
531 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
532 Double_t ca = TMath::Cos(alpha);
533 Double_t sa = TMath::Sin(alpha);
534 Double_t lx = xyz[0]*ca + xyz[1]*sa;
535 Double_t ly = -xyz[0]*sa + xyz[1]*ca;
536 //
537 const Double_t xIROCOROC = 133.4;
538 lx-=xIROCOROC;
539 Double_t rot = xyz[3]*0.001; // rotation in mrad
540 if (param[0]>0) rot*=TMath::Cos(alpha*param[0]);
541 if (param[1]>0) rot*=TMath::Sin(alpha*param[1]);
542 if (param[2]>0.5 && lx>0) rot*=-1;
543 Double_t dlxR = - ly*rot;
544 Double_t dlyR = lx*rot;
545 //Double_t dgxR = dlxR*ca - dlyR*sa;
546 Double_t dgyR = dlxR*sa + dlyR*ca;
547 return dgyR;
0e9efcbe 548}
549
550
ddf81107 551
552Double_t AliTPCTransformation::TPCDeltaZMediumLong(Double_t *xyz, Double_t * /*param*/){
0e9efcbe 553 //
554 // xyz - [0..2] - position
555 // [3] - scale parameter
556 // [4] - volID
ddf81107 557 // return delta in global coordinate system
0e9efcbe 558 //
559 Int_t sector = TMath::Nint(xyz[4]);
560 Double_t signZ = (sector%36<18) ? 1: -1; // drift direction
ddf81107 561 if (sector<36) return 0;
562 //
563 const Double_t radiusLong = 198.1;
564 //
565 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
566 Double_t ca = TMath::Cos(alpha);
567 Double_t sa = TMath::Sin(alpha);
568 Double_t lx = xyz[0]*ca + xyz[1]*sa;
569 Double_t sign = (lx<radiusLong) ? 1:-1;
570 return xyz[3]*sign*signZ;
0e9efcbe 571}
572
ddf81107 573Double_t AliTPCTransformation::TPCDeltaZ(Double_t *xyz, Double_t * param){
0e9efcbe 574 //
575 // xyz - [0..2] - position
576 // [3] - scale parameter
577 // [4] - volID
ddf81107 578 // return delta in global coordiante system
0e9efcbe 579 //
580 Int_t sector = TMath::Nint(xyz[4]);
ddf81107 581 Double_t delta = (sector%36<18) ? 1: -1; // drift direction
582 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
583 Double_t ca = TMath::Cos(alpha);
584 Double_t sa = TMath::Sin(alpha);
585 Double_t lx = xyz[0]*ca + xyz[1]*sa;
0e9efcbe 586 //
ddf81107 587 const Double_t xIROCOROC = 133.4;
588 if (param[0]>0) delta *= TMath::Cos(param[0]*alpha);
589 if (param[1]>0) delta *= TMath::Sin(param[1]*alpha);
590 if (param[2]>0.5 && lx >xIROCOROC) delta *=-1;
591 return delta*xyz[3]; // IROC shift
0e9efcbe 592}
593
ddf81107 594
0e9efcbe 595Double_t AliTPCTransformation::TPCTiltingZ(Double_t *xyz, Double_t * param){
596 // xyz - [0..2] - position
597 // [3] - scale parameter
598 // [4] - volID
599 // param[0] - n for cos
600 // param[1] - n for sin
ddf81107 601 // param[2] - IROC-ORC relative (if >0.5 )
0e9efcbe 602 // return delta in global coordinate system
0e9efcbe 603 const Double_t rFirst=85.2;
604 const Double_t rLast =245.8;
ddf81107 605 const Double_t xIROCOROC = 133.4;
606 //
607 Int_t sector = TMath::Nint(xyz[4]);
608 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
609 Double_t ca = TMath::Cos(alpha);
610 Double_t sa = TMath::Sin(alpha);
611 Double_t lx = xyz[0]*ca + xyz[1]*sa;
612 Double_t deltaR = 2.0*(lx-xIROCOROC)/(rLast-rFirst);
0e9efcbe 613 if (param[0]>0) deltaR *= TMath::Cos(param[0]*alpha);
614 if (param[1]>0) deltaR *= TMath::Sin(param[1]*alpha);
ddf81107 615 if (param[2]>0.5 && lx >xIROCOROC) deltaR *=-1;
0e9efcbe 616 return deltaR*xyz[3];
617}
618