3 Class AliTPCtransformation:
4 Should represent general non linear transformation. Currently tune for TPConly.
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
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
17 2. The transformation should work only for given volIDs and detector IDs
18 Currently Bitmask is used for filtering
21 Transformation - naming convention:
25 XXX - detector if detector specific
26 local - if local transforamtion
27 YYY - type of transformation
28 ZZZ - return type of transformation
38 #include "TLinearFitter.h"
40 #include "TObjString.h"
42 #include "TTreeStream.h"
43 #include "AliTrackPointArray.h"
45 #include "AliTPCTransformation.h"
47 ClassImp(AliTPCTransformation)
50 AliTPCTransformation::GenFuncG AliTPCTransformation::fgFormulas[10000];
51 TObjArray* AliTPCTransformation::fgFormulasName = new TObjArray(10000);
54 void AliTPCTransformation::RegisterFormula(const char * name, GenFuncG formula){
56 // Add Formula to the list of formulas
58 Int_t last= fgFormulasName->GetEntries();
59 fgFormulasName->AddLast(new TObjString(name));
60 fgFormulas[last]=formula;
63 Int_t AliTPCTransformation::BuildBasicFormulas(){
67 //build list of basic TPC formulas - corrections
69 RegisterFormula("TPCscalingRPol",(GenFuncG)(AliTPCTransformation::TPCscalingRPol));
70 RegisterFormula("TPCscalingRIFC",(GenFuncG)(AliTPCTransformation::TPCscalingRIFC));
71 RegisterFormula("TPCscalingROFC",(GenFuncG)(AliTPCTransformation::TPCscalingROFC));
73 RegisterFormula("TPCscalingZDr",(GenFuncG)(AliTPCTransformation::TPCscalingZDr));
74 RegisterFormula("TPCscalingPhiLocal",(GenFuncG)(AliTPCTransformation::TPCscalingPhiLocal));
76 // TPC Local X and Y misalignment + rotation
78 RegisterFormula("TPClocaldLxdGX",(GenFuncG)(AliTPCTransformation::TPClocaldLxdGX));
79 RegisterFormula("TPClocaldLxdGY",(GenFuncG)(AliTPCTransformation::TPClocaldLxdGY));
80 RegisterFormula("TPClocaldLydGX",(GenFuncG)(AliTPCTransformation::TPClocaldLydGX));
81 RegisterFormula("TPClocaldLydGY",(GenFuncG)(AliTPCTransformation::TPClocaldLydGY));
82 RegisterFormula("TPClocaldRzdGX",(GenFuncG)(AliTPCTransformation::TPClocaldRzdGX));
83 RegisterFormula("TPClocaldRzdGY",(GenFuncG)(AliTPCTransformation::TPClocaldRzdGY));
88 RegisterFormula("TPCDeltaZ",(GenFuncG)(AliTPCTransformation::TPCDeltaZ));
89 RegisterFormula("TPCDeltaZMediumLong",(GenFuncG)(AliTPCTransformation::TPCDeltaZMediumLong));
90 RegisterFormula("TPCTiltingZ",(GenFuncG)(AliTPCTransformation::TPCTiltingZ));
94 AliTPCTransformation::GenFuncG AliTPCTransformation::FindFormula(const char * name){
96 // find formula - if registered
98 if (fgFormulasName->FindObject(name)==0) return 0;
99 Int_t entries = fgFormulasName->GetEntries();
100 for (Int_t i=0;i<entries;i++){
101 if (strcmp(fgFormulasName->At(i)->GetName(), name)==0){
102 return fgFormulas[i];
108 Double_t AliTPCTransformation::Eval(const char * name, const Double_t*x,const Double_t*par){
110 // Only for test purposes - very slow
112 GenFuncG fun = FindFormula(name);
118 AliTPCTransformation::AliTPCTransformation():
120 fNameX(0), // x formula name
121 fNameY(0), // y formula name
122 fNameZ(0), // z formula name
124 fBitMask(0), // bitmaps - transformation only for specified volID
125 fCoordSystem(0), // coord system of output deltas
126 fParam(0), // free parameter of transformation
127 fSigma(0), // uncertainty of the parameter
128 fSigma2Time(0), // change of the error in time - (For kalman filter)
129 fFixedParam(0), // fixed parameters of tranformation
130 fIsActive(kTRUE), // swith - On/Off
132 fInit(kFALSE), // initialization flag - set to kTRUE if corresponding formulas found
133 fFormulaX(0), // x formula - pointer to the function
134 fFormulaY(0), // y formula - pointer to the function
135 fFormulaZ(0) // z formula - pointer to the function
139 // default constructor
145 AliTPCTransformation::AliTPCTransformation(const char *name, TBits *mask, const char *fx, const char *fy, const char *fz, Int_t coordSystem):
147 fNameX(0), // x formula name
148 fNameY(0), // y formula name
149 fNameZ(0), // z formula name
150 fBitMask(mask), // bitmaps - transformation only for specified volID
151 fCoordSystem(coordSystem), // coordinate system of output deltas
152 fParam(0), // free parameter of transformation
154 fSigma2Time(0), // change of sigma in time
155 fFixedParam(0), // fixed parameters of tranformation
156 fIsActive(kTRUE), // swith - On/Off
158 fInit(kFALSE), // initialization flag - set to kTRUE if corresponding formulas found
159 fFormulaX(0), // x formula - pointer to the function
160 fFormulaY(0), // y formula - pointer to the function
161 fFormulaZ(0) // z formula - pointer to the function
164 // non default constructor
166 if (fx) fNameX= new TString(fx);
167 if (fy) fNameY= new TString(fy);
168 if (fz) fNameZ= new TString(fz);
172 AliTPCTransformation::AliTPCTransformation(const AliTPCTransformation&trafo):
174 fNameX(0), // x formula name
175 fNameY(0), // y formula name
176 fNameZ(0), // z formula name
178 fBitMask(0), // bitmaps - transformation only for specified volID
179 fCoordSystem(0), // coord system of output deltas
180 fParam(trafo.fParam), // free parameter of transformation
181 fSigma(trafo.fSigma), // uncertainty of the parameter
182 fSigma2Time(trafo.fSigma2Time), // change of the error in time - (For kalman filter)
183 fFixedParam(0), // fixed parameters of tranformation
184 fIsActive(trafo.fIsActive), // swith - On/Off
186 fInit(kFALSE), // initialization flag - set to kTRUE if corresponding formulas found
187 fFormulaX(0), // x formula - pointer to the function
188 fFormulaY(0), // y formula - pointer to the function
189 fFormulaZ(0) // z formula - pointer to the function
191 if (trafo.fNameX) fNameX = new TString(*(trafo.fNameX));
192 if (trafo.fNameY) fNameY = new TString(*(trafo.fNameY));
193 if (trafo.fNameZ) fNameZ = new TString(*(trafo.fNameZ));
194 if (trafo.fBitMask) fBitMask = new TBits(*(trafo.fBitMask));
197 AliTPCTransformation::~AliTPCTransformation(){
207 void AliTPCTransformation::SetParams(Double_t param, Double_t sigma, Double_t sigma2Time, TVectorD* fixedParams){
209 // Set parameters of transformation
213 fSigma2Time = sigma2Time;
214 if (fFixedParam) delete fFixedParam;
215 fFixedParam = new TVectorD(*fixedParams);
220 Bool_t AliTPCTransformation::Init(){
222 // associate formulas with pointer to the function
226 fFormulaX=FindFormula(fNameX->Data());
227 if (fFormulaX==0) isOK=kFALSE;
230 fFormulaY=FindFormula(fNameY->Data());
231 if (fFormulaY==0) isOK=kFALSE;
234 fFormulaZ=FindFormula(fNameZ->Data());
235 if (!fFormulaZ) isOK=kFALSE;
242 TBits * AliTPCTransformation::BitsSide(Bool_t aside){
244 TBits * bits = new TBits(72);
245 for (Int_t i=0; i<72;i++){
246 if (i%36<18 && aside) (*bits)[i]=kTRUE;
247 if (i%36<18 && (!aside)) (*bits)[i]=kFALSE;
248 if (i%36>=18 && aside) (*bits)[i]=kFALSE;
249 if (i%36>=18 && (!aside)) (*bits)[i]=kTRUE;
254 TBits * AliTPCTransformation::BitsAll(){
258 TBits * bits = new TBits(72);
259 for (Int_t i=0; i<72;i++){
265 Double_t AliTPCTransformation::GetDeltaXYZ(Int_t coord, Int_t volID, Double_t param, Double_t x, Double_t y, Double_t z){
268 // coord - type of coordinate
274 if (!fIsActive) return 0;
275 if (fBitMask && (!(*fBitMask)[volID])) return 0;
276 Double_t xyz[5]={x,y,z, param,volID};
277 if (fCoordSystem==0){
279 if (coord==0 && fFormulaX) return fFormulaX(xyz,fFixedParam->GetMatrixArray());
280 if (coord==1 && fFormulaY) return fFormulaY(xyz,fFixedParam->GetMatrixArray());
281 if (coord==2 && fFormulaZ) return fFormulaZ(xyz,fFixedParam->GetMatrixArray());
283 if (fCoordSystem==1){
284 // cylindrical system
286 if (fFormulaZ==0) return 0;
287 return fFormulaZ(xyz,fFixedParam->GetMatrixArray());
289 Double_t rrphiz[3]={0,0,0};
290 if (fFormulaX) rrphiz[0] = fFormulaX(xyz,fFixedParam->GetMatrixArray());
291 if (fFormulaY) rrphiz[1] = fFormulaY(xyz,fFixedParam->GetMatrixArray());
292 Double_t alpha = TMath::ATan2(y,x);
293 Double_t ca = TMath::Cos(alpha);
294 Double_t sa = TMath::Sin(alpha);
295 if (coord==0) return ca*rrphiz[0]-sa*rrphiz[1];
296 if (coord==1) return sa*rrphiz[0]+ca*rrphiz[1];
301 Double_t AliTPCTransformation::TPCscalingRPol(Double_t *xyz, Double_t * param){
303 // Scaling and shift of TPC radius
304 // xyz[0..2] - global xyz of point
305 // xyz[3] - scale parameter
306 // param[0] - radial scaling power
307 // param[1] - drift scaling power
308 // radius from -1(at rInner) to 1 (rOuter)
309 // driftM from -1(at 0 drift) to 1 (250 cm drift)
311 Double_t rInner=78.8;
312 Double_t rOuter=258.0;
313 Double_t deltaR = rOuter-rInner;
314 Double_t radius = (TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1])-rInner)*2./deltaR;
315 Double_t driftM = (0.5 - TMath::Abs(xyz[2]/250.))*2.0;
316 Double_t delta = TMath::Power(radius,param[0])*TMath::Power(driftM,param[1]);
321 Double_t AliTPCTransformation::TPCscalingZDr(Double_t *xyz, Double_t * param){
324 // Scaling and shift of TPC radius
325 // xyz[0..2] - global xyz of point
326 // xyz[3] - scale parameter
327 Double_t driftP = TMath::Power(1. - TMath::Abs(xyz[2]/250.), param[0]);
328 Double_t deltaZ = (xyz[2]>0) ? -driftP : driftP;
329 return deltaZ*xyz[3];
332 Double_t AliTPCTransformation::TPCscalingPhiLocal(Double_t *xyz, Double_t * param){
335 // Scaling if the local y -phi
336 // xyz[0..2] - global xyz of point
337 // xyz[3] - scale parameter
338 // value = 1 for ful drift length and parameter 1
339 Double_t alpha = TMath::ATan2(xyz[1],xyz[0]);
340 Double_t sector = TMath::Nint(9*alpha/TMath::Pi()-0.5);
341 Double_t localAlpha = (alpha-(sector+0.5)*TMath::Pi()/9.);
342 Double_t radius = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1])/250.;
344 Double_t deltaAlpha = radius*TMath::Power(2.*9.*localAlpha/TMath::Pi(),param[0]);
345 return deltaAlpha*xyz[3];
349 Double_t AliTPCTransformation::TPCscalingRIFC(Double_t *xyz, Double_t * param){
351 // inner field cage r distorion - proportinal to 1 over distance to the IFC
352 // param[0] - drift polynom order
353 // distortion at first pad row - is normalized to
354 Double_t rInner=78.8;
355 Double_t rFirst=85.2;
356 Double_t deltaR = rFirst-rInner;
357 Double_t ndistR = (TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1])-rInner)/deltaR;
358 Double_t driftM = (0.5 - TMath::Abs(xyz[2]/250.))*2.;
359 Double_t value = TMath::Power(driftM,param[0])/ndistR;
363 Double_t AliTPCTransformation::TPCscalingROFC(Double_t *xyz, Double_t * param){
365 // outer field cage r distorion - proportinal to 1 over distance to the OFC
366 // param[0] - drift polynom order
367 // driftM - from -1 to 1
369 Double_t rLast=245.8;
370 Double_t rOuter=258.0;
371 Double_t deltaR = rOuter-rLast;
372 Double_t ndistR = (rOuter-TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]))/deltaR;
373 Double_t driftM = (0.5 - TMath::Abs(xyz[2]/250.))*2.;
374 Double_t value = TMath::Power(driftM,param[0])/ndistR;
380 // TPC sector local misalignment
384 Double_t AliTPCTransformation:: TPClocaldLxdGX(Double_t *xyz, Double_t * param){
386 // xyz - [0..2] - position
387 // [3] - scale parameter
389 // param[0]= n - cos(n *alpha)
390 // param[1]= n - sin(n *alpha)
391 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
392 // return delta in global coordiante system
394 Int_t sector = TMath::Nint(xyz[4]);
395 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
396 Double_t ca = TMath::Cos(alpha);
397 // Double_t sa = TMath::Sin(alpha);
398 const Double_t xIROCOROC = 133.4;
399 Double_t factor = xyz[3];
400 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
401 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
402 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
406 Double_t AliTPCTransformation::TPClocaldLxdGY(Double_t *xyz, Double_t * param){
408 // xyz - [0..2] - position
409 // [3] - scale parameter
411 // param[0]= n - cos(n *alpha)
412 // param[1]= n - sin(n *alpha)
413 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
414 // return delta in global coordiante system
416 Int_t sector = TMath::Nint(xyz[4]);
417 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
418 //Double_t ca = TMath::Cos(alpha);
419 Double_t sa = TMath::Sin(alpha);
420 const Double_t xIROCOROC = 133.4;
421 Double_t factor = xyz[3];
422 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
423 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
424 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
428 Double_t AliTPCTransformation:: TPClocaldLydGX(Double_t *xyz, Double_t * param){
430 // xyz - [0..2] - position
431 // [3] - scale parameter
433 // param[0]= n - cos(n *alpha)
434 // param[1]= n - sin(n *alpha)
435 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
436 // return delta in global coordiante system
438 Int_t sector = TMath::Nint(xyz[4]);
439 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
440 //Double_t ca = TMath::Cos(alpha);
441 Double_t sa = TMath::Sin(alpha);
442 const Double_t xIROCOROC = 133.4;
443 Double_t factor = xyz[3];
444 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
445 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
446 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
450 Double_t AliTPCTransformation::TPClocaldLydGY(Double_t *xyz, Double_t * param){
452 // xyz - [0..2] - position
453 // [3] - scale parameter
455 // param[0]= n - cos(n *alpha)
456 // param[1]= n - sin(n *alpha)
457 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
458 // return delta in global coordiante system
460 Int_t sector = TMath::Nint(xyz[4]);
461 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
462 Double_t ca = TMath::Cos(alpha);
463 //Double_t sa = TMath::Sin(alpha);
464 const Double_t xIROCOROC = 133.4;
465 Double_t factor = xyz[3];
466 if (param[0]>0) factor*=TMath::Cos(alpha*param[0]);
467 if (param[1]>0) factor*=TMath::Sin(alpha*param[1]);
468 if (param[2]>0.5 && TMath::Sqrt(xyz[1]*xyz[1]+xyz[0]*xyz[0])>xIROCOROC) factor*=-1;
473 Double_t AliTPCTransformation::TPClocaldRzdGX(Double_t *xyz, Double_t * param){
475 // xyz - [0..2] - position
476 // [3] - scale parameter - rotation angle in mrad
478 // param[0]= n - cos(n *alpha)
479 // param[1]= n - sin(n *alpha)
480 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
481 // return delta in global coordiante system
483 Int_t sector = TMath::Nint(xyz[4]);
484 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
485 Double_t ca = TMath::Cos(alpha);
486 Double_t sa = TMath::Sin(alpha);
487 Double_t lx = xyz[0]*ca + xyz[1]*sa;
488 Double_t ly = -xyz[0]*sa + xyz[1]*ca;
490 const Double_t xIROCOROC = 133.4;
492 Double_t rot = xyz[3]*0.001; // rotation in mrad
493 if (param[0]>0) rot*=TMath::Cos(alpha*param[0]);
494 if (param[1]>0) rot*=TMath::Sin(alpha*param[1]);
495 if (param[2]>0.5 && lx>0) rot*=-1;
497 Double_t dlxR = - ly*rot;
498 Double_t dlyR = lx*rot;
499 Double_t dgxR = dlxR*ca - dlyR*sa;
500 //Double_t dgyR = dlxR*sa + dlyR*ca;
504 Double_t AliTPCTransformation::TPClocaldRzdGY(Double_t *xyz, Double_t * param){
506 // xyz - [0..2] - position
507 // [3] - scale parameter - rotation angle in mrad
509 // param[0]= n - cos(n *alpha)
510 // param[1]= n - sin(n *alpha)
511 // param[2] - indication - 0 - the same for IROC OROC 1 - opposite
512 // return delta in global coordiante system
514 Int_t sector = TMath::Nint(xyz[4]);
515 Double_t alpha = TMath::Pi()*(sector+0.5)/9;
516 Double_t ca = TMath::Cos(alpha);
517 Double_t sa = TMath::Sin(alpha);
518 Double_t lx = xyz[0]*ca + xyz[1]*sa;
519 Double_t ly = -xyz[0]*sa + xyz[1]*ca;
521 const Double_t xIROCOROC = 133.4;
523 Double_t rot = xyz[3]*0.001; // rotation in mrad
524 if (param[0]>0) rot*=TMath::Cos(alpha*param[0]);
525 if (param[1]>0) rot*=TMath::Sin(alpha*param[1]);
526 if (param[2]>0.5 && lx>0) rot*=-1;
527 Double_t dlxR = - ly*rot;
528 Double_t dlyR = lx*rot;
529 //Double_t dgxR = dlxR*ca - dlyR*sa;
530 Double_t dgyR = dlxR*sa + dlyR*ca;
535 Double_t AliTPCTransformation::TPCDeltaZ(Double_t *xyz, Double_t * param){
537 // xyz - [0..2] - position
538 // [3] - scale parameter
540 // return delta in global coordiante system
542 Int_t sector = TMath::Nint(xyz[4]);
543 Double_t signZ = (sector%36<18) ? 1: -1; // drift direction
544 return signZ*xyz[3]; // IROC shift
547 Double_t AliTPCTransformation::TPCDeltaZMediumLong(Double_t *xyz, Double_t * /*param*/){
549 // xyz - [0..2] - position
550 // [3] - scale parameter
552 // return delta in global coordinate system
554 Int_t sector = TMath::Nint(xyz[4]);
555 Double_t signZ = (sector%36<18) ? 1: -1; // drift direction
556 if (sector<36) return 0;
558 Double_t radius = (TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]));
559 const Double_t radiusLong = 198.1;
560 Double_t sign = (radius<radiusLong) ? 1:-1;
561 return xyz[3]*sign*signZ;
564 Double_t AliTPCTransformation::TPCTiltingZ(Double_t *xyz, Double_t * param){
565 // xyz - [0..2] - position
566 // [3] - scale parameter
568 // param[0] - n for cos
569 // param[1] - n for sin
570 // return delta in global coordinate system
571 Double_t radius = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
572 const Double_t rFirst=85.2;
573 const Double_t rLast =245.8;
574 Double_t radiusC = (rFirst+rLast)*0.5;
575 Double_t deltaR = 2.0*(radius-radiusC)/(rLast-rFirst);
576 Double_t alpha = TMath::ATan2(xyz[1],xyz[0]);
578 if (param[0]>0) deltaR *= TMath::Cos(param[0]*alpha);
579 if (param[1]>0) deltaR *= TMath::Sin(param[1]*alpha);
580 return deltaR*xyz[3];