1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Class to make a internal alignemnt of TPC chambers //
21 // Requierements - Warnings:
22 // 1. Before using this componenent the magnetic filed has to be set properly //
23 // 2. The systematic effects - unlinearities has to be understood
25 // If systematic and unlinearities are not under control
26 // the alignment is just effective alignment. Not second order corrction
29 // The histograming of the edge effects and unlineratities integral part
30 // of the component (currently only in debug stream)
32 // 3 general type of linear transformation investigated (see bellow)
34 // By default only 6 parameter alignment to be used - other just for QA purposes
36 // Different linear tranformation investigated
37 // 12 parameters - arbitrary linear transformation
38 // a00 a01 a02 a03 p[0] p[1] p[2] p[9]
39 // a10 a11 a12 a13 ==> p[3] p[4] p[5] p[10]
40 // a20 a21 a22 a23 p[6] p[7] p[8] p[11]
42 // 9 parameters - scaling fixed to 1
43 // a00 a01 a02 a03 1 p[0] p[1] p[6]
44 // a10 a11 a12 a13 ==> p[2] 1 p[3] p[7]
45 // a20 a21 a22 a23 p[4] p[5] 1 p[8]
47 // 6 parameters - x-y rotation x-z, y-z tiliting
48 // a00 a01 a02 a03 1 -p[0] 0 p[3]
49 // a10 a11 a12 a13 ==> p[0] 1 0 p[4]
50 // a20 a21 a22 a23 p[1] p[2] 1 p[5]
53 // Debug stream supported
54 // 0. Align - The main output of the Alignment component
55 // - Used for visualization of the misalignment between sectors
56 // - Results of the missalignment fit and the mean and sigmas of histograms
58 // 1. Tracklet - StreamLevel >1
59 // - Dump all information about tracklet match from sector1 to sector 2
60 // - Default histogram residulas created in parallel
61 // - Check this streamer in case of suspicious content of these histograms
62 // 2. Track - StreamLevel>5
63 // - For debugging of the edge effects
64 // - All information - extrapolation inside of one sectors
65 // - Created in order to distinguish between unlinearities inside of o
66 // sector and missalignment
73 #include "TLinearFitter.h"
74 #include "AliTPCcalibAlign.h"
75 #include "AliExternalTrackParam.h"
76 #include "AliTPCTracklet.h"
79 #include "TTreeStream.h"
82 #include "TGraphErrors.h"
83 #include "AliTPCclusterMI.h"
84 #include "AliTPCseed.h"
85 #include "AliTracker.h"
86 #include "TClonesArray.h"
89 #include "TTreeStream.h"
94 ClassImp(AliTPCcalibAlign)
96 AliTPCcalibAlign::AliTPCcalibAlign()
97 : fDphiHistArray(72*72),
98 fDthetaHistArray(72*72),
101 fFitterArray12(72*72),
102 fFitterArray9(72*72),
108 for (Int_t i=0;i<72*72;++i) {
113 AliTPCcalibAlign::AliTPCcalibAlign(const Text_t *name, const Text_t *title)
115 fDphiHistArray(72*72),
116 fDthetaHistArray(72*72),
119 fFitterArray12(72*72),
120 fFitterArray9(72*72),
128 for (Int_t i=0;i<72*72;++i) {
133 AliTPCcalibAlign::~AliTPCcalibAlign() {
139 void AliTPCcalibAlign::Process(AliTPCseed *seed) {
141 AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kKalman,
143 // TObjArray trackletsL=
144 // AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kLinear,
146 // TObjArray trackletsQ=
147 // AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kQuadratic,
149 // TObjArray trackletsR=
150 // AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kRiemann,
152 tracklets.SetOwner();
153 // trackletsL.SetOwner();
154 // trackletsQ.SetOwner();
155 // trackletsR.SetOwner();
156 if (tracklets.GetEntries()==2) {
157 AliTPCTracklet *t1=static_cast<AliTPCTracklet*>(tracklets[0]);
158 AliTPCTracklet *t2=static_cast<AliTPCTracklet*>(tracklets[1]);
159 if (t1->GetSector()>t2->GetSector()) {
160 AliTPCTracklet* tmp=t1;
164 AliExternalTrackParam *common1=0,*common2=0;
165 if (AliTPCTracklet::PropagateToMeanX(*t1,*t2,common1,common2))
166 ProcessTracklets(*common1,*common2,seed, t1->GetSector(),t2->GetSector());
173 void AliTPCcalibAlign::Analyze(){
181 void AliTPCcalibAlign::Terminate(){
183 // Terminate function
184 // call base terminate + Eval of fitters
186 if (GetDebugLevel()>0) Info("AliTPCcalibAlign","Terminate");
188 AliTPCcalibBase::Terminate();
194 void AliTPCcalibAlign::ProcessTracklets(const AliExternalTrackParam &tp1,
195 const AliExternalTrackParam &tp2,
196 const AliTPCseed * seed,
204 // Process function to fill fitters
206 Double_t t1[5],t2[5];
207 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
208 Double_t &x2=t2[0], &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
212 Double_t snp1=tp1.GetSnp();
213 dydx1=snp1/TMath::Sqrt(1.-snp1*snp1);
214 Double_t tgl1=tp1.GetTgl();
215 // dz/dx = 1/(cos(theta)*cos(phi))
216 dzdx1=tgl1/TMath::Sqrt(1.-snp1*snp1);
220 Double_t snp2=tp2.GetSnp();
221 dydx2=snp2/TMath::Sqrt(1.-snp2*snp2);
222 Double_t tgl2=tp2.GetTgl();
223 dzdx2=tgl2/TMath::Sqrt(1.-snp2*snp2);
228 TTreeSRedirector *cstream = GetDebugStreamer();
230 static TVectorD vec1(5);
231 static TVectorD vec2(5);
232 vec1.SetElements(t1);
233 vec2.SetElements(t2);
234 AliExternalTrackParam *p1 = &((AliExternalTrackParam&)tp1);
235 AliExternalTrackParam *p2 = &((AliExternalTrackParam&)tp2);
236 (*cstream)<<"Tracklet"<<
247 // Aplly cut selection
249 // Cuts to be justified with the debug streamer
251 TCut c1pt("abs((tp1.fP[4]+tp2.fP[4])*0.5)<5"); // pt cut
252 TCut cd1pt("abs(tp1.fP[4]-tp2.fP[4])<0.5");
253 TCut c1ptpull("abs((tp1.fP[4]-tp2.fP[4])/sqrt(tp1.fC[14]+tp2.fC[14]))<5");
254 TCut csy("sqrt(tp1.fC[0]+tp2.fC[0])<0.5");
255 TCut csz("sqrt(tp1.fC[2]+tp2.fC[2])<0.3");
256 TCut cphi("abs(v1.fElements[3])<1")
257 TCut ctheta("abs(v1.fElements[4])<1")
260 TCut acut = c1ptpull+c1pt+cd1pt+csy+csz+cphi+ctheta;
263 // 2. delta in curvature
269 Double_t sigma1pt = TMath::Sqrt(tp1.GetSigma1Pt2()+tp1.GetSigma1Pt2());
270 Double_t delta1pt = (tp1.GetParameter()[4]-tp2.GetParameter()[4]);
271 Double_t pull1pt = delta1pt/sigma1pt;
272 if (0.5*TMath::Abs(tp1.GetParameter()[4]+tp2.GetParameter()[4])>5) return;
273 if (TMath::Abs(delta1pt)>0.5) return;
274 if (TMath::Abs(pull1pt)>5) return;
275 if (TMath::Sqrt(tp1.GetSigmaY2()+tp2.GetSigmaY2())>0.5) return;
276 if (TMath::Sqrt(tp1.GetSigmaZ2()+tp2.GetSigmaZ2())>0.3) return;
277 if (TMath::Abs(dydx1)>1.) return;
278 if (TMath::Abs(dzdx1)>1.) return;
280 // fill resolution histograms - previous cut included
281 FillHisto(tp1,tp2,s1,s2);
283 Process12(t1,t2,GetOrMakeFitter12(s1,s2));
284 Process9(t1,t2,GetOrMakeFitter9(s1,s2));
285 Process6(t1,t2,GetOrMakeFitter6(s1,s2));
286 ProcessDiff(tp1,tp2, seed,s1,s2);
287 ++fPoints[GetIndex(s1,s2)];
290 void AliTPCcalibAlign::ProcessDiff(const AliExternalTrackParam &t1,
291 const AliExternalTrackParam &t2,
292 const AliTPCseed *seed,
296 // Process local residuals function
301 TVectorD vecClY(160);
302 TVectorD vecClZ(160);
303 TClonesArray arrCl("AliTPCclusterMI",160);
304 arrCl.ExpandCreateFast(160);
305 Int_t count1=0, count2=0;
306 for (Int_t i=0;i<160;++i) {
307 AliTPCclusterMI *c=seed->GetClusterPointer(i);
312 AliTPCclusterMI & cl = (AliTPCclusterMI&) (*arrCl[i]);
313 if (c->GetDetector()!=s1 && c->GetDetector()!=s2) continue;
314 vecClY[i] = c->GetY();
315 vecClZ[i] = c->GetZ();
317 const AliExternalTrackParam *par = (c->GetDetector()==s1)? &t1:&t2;
318 if (c->GetDetector()==s1) ++count1;
319 if (c->GetDetector()==s2) ++count2;
320 Double_t gxyz[3],xyz[3];
322 Float_t bz = AliTracker::GetBz(gxyz);
323 par->GetYAt(c->GetX(), bz, xyz[1]);
324 par->GetZAt(c->GetX(), bz, xyz[2]);
333 // huge output - cluster residuals to be investigated
335 TTreeSRedirector *cstream = GetDebugStreamer();
336 AliTPCseed * t = (AliTPCseed*) seed;
337 //AliExternalTrackParam *p0 = &((AliExternalTrackParam&)seed);
338 AliExternalTrackParam *p1 = &((AliExternalTrackParam&)t1);
339 AliExternalTrackParam *p2 = &((AliExternalTrackParam&)t2);
342 Track->Draw("Cl[].fY-vtY.fElements:vtY.fElements-vtX.fElements*tan(pi/18.)>>his(100,-10,0)","Cl.fY!=0&&abs(Cl.fY-vtY.fElements)<1","prof");
347 (*cstream)<<"Track"<<
369 void AliTPCcalibAlign::Process12(const Double_t *t1,
371 TLinearFitter *fitter) {
372 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
373 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
374 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
375 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
376 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
378 // a00 a01 a02 a03 p[0] p[1] p[2] p[9]
379 // a10 a11 a12 a13 ==> p[3] p[4] p[5] p[10]
380 // a20 a21 a22 a23 p[6] p[7] p[8] p[11]
384 const Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
385 const Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
390 Double_t sdydx = 0.001;
391 Double_t sdzdx = 0.001;
396 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
397 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
398 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
399 for (Int_t i=0; i<12;i++) p[i]=0.;
404 p[0+1] = y1*dydx2; // a01
405 p[0+2] = z1*dydx2; // a02
406 p[9+0] = dydx2; // a03
408 fitter->AddPoint(p,value,sy);
410 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
411 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
412 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
413 for (Int_t i=0; i<12;i++) p[i]=0.;
418 p[0+1] = y1*dzdx2; // a01
419 p[0+2] = z1*dzdx2; // a02
420 p[9+0] = dzdx2; // a03
422 fitter->AddPoint(p,value,sz);
424 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
425 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
426 for (Int_t i=0; i<12;i++) p[i]=0.;
428 p[3+1] = dydx1; // a11
429 p[3+2] = dzdx1; // a12
430 p[0+0] = -dydx2; // a00
431 p[0+1] = -dydx1*dydx2; // a01
432 p[0+2] = -dzdx1*dydx2; // a02
434 fitter->AddPoint(p,value,sdydx);
436 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
437 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
438 for (Int_t i=0; i<12;i++) p[i]=0.;
440 p[6+1] = dydx1; // a21
441 p[6+2] = dzdx1; // a22
442 p[0+0] = -dzdx2; // a00
443 p[0+1] = -dydx1*dzdx2; // a01
444 p[0+2] = -dzdx1*dzdx2; // a02
446 fitter->AddPoint(p,value,sdzdx);
449 void AliTPCcalibAlign::Process9(Double_t *t1,
451 TLinearFitter *fitter) {
452 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
453 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
454 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
455 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
456 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
458 // a00 a01 a02 a03 1 p[0] p[1] p[6]
459 // a10 a11 a12 a13 ==> p[2] 1 p[3] p[7]
460 // a20 a21 a21 a23 p[4] p[5] 1 p[8]
463 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
464 Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
469 Double_t sdydx = 0.001;
470 Double_t sdzdx = 0.001;
475 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
476 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
477 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
478 for (Int_t i=0; i<12;i++) p[i]=0.;
483 p[0] += y1*dydx2; // a01
484 p[1] += z1*dydx2; // a02
485 p[6] += dydx2; // a03
486 value = y2-y1; //-a11
487 fitter->AddPoint(p,value,sy);
489 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
490 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
491 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
492 for (Int_t i=0; i<12;i++) p[i]=0.;
497 p[0] += y1*dzdx2; // a01
498 p[1] += z1*dzdx2; // a02
499 p[6] += dzdx2; // a03
500 value = z2-z1; //-a22
501 fitter->AddPoint(p,value,sz);
503 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
504 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
505 for (Int_t i=0; i<12;i++) p[i]=0.;
507 //p[] += dydx1; // a11
508 p[3] += dzdx1; // a12
509 //p[] += -dydx2; // a00
510 p[0] += -dydx1*dydx2; // a01
511 p[1] += -dzdx1*dydx2; // a02
512 value = -dydx1+dydx2; // -a11 + a00
513 fitter->AddPoint(p,value,sdydx);
515 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
516 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
517 for (Int_t i=0; i<12;i++) p[i]=0.;
519 p[5] += dydx1; // a21
520 //p[] += dzdx1; // a22
521 //p[] += -dzdx2; // a00
522 p[0] += -dydx1*dzdx2; // a01
523 p[1] += -dzdx1*dzdx2; // a02
524 value = -dzdx1+dzdx2; // -a22 + a00
525 fitter->AddPoint(p,value,sdzdx);
528 void AliTPCcalibAlign::Process6(Double_t *t1,
530 TLinearFitter *fitter) {
531 // x2 = 1 *x1 +-a01*y1 + 0 +a03
532 // y2 = a01*x1 + 1 *y1 + 0 +a13
533 // z2 = a20*x1 + a21*y1 + 1 *z1 +a23
534 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
535 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
537 // a00 a01 a02 a03 1 -p[0] 0 p[3]
538 // a10 a11 a12 a13 ==> p[0] 1 0 p[4]
539 // a20 a21 a21 a23 p[1] p[2] 1 p[5]
541 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
542 Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
547 Double_t sdydx = 0.001;
548 Double_t sdzdx = 0.001;
552 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
553 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
554 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
555 for (Int_t i=0; i<12;i++) p[i]=0.;
560 p[0] += -y1*dydx2; // a01
561 //p[] += z1*dydx2; // a02
562 p[3] += dydx2; // a03
563 value = y2-y1; //-a11
564 fitter->AddPoint(p,value,sy);
566 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
567 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
568 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
569 for (Int_t i=0; i<12;i++) p[i]=0.;
574 p[0] += -y1*dzdx2; // a01
575 //p[] += z1*dzdx2; // a02
576 p[3] += dzdx2; // a03
577 value = z2-z1; //-a22
578 fitter->AddPoint(p,value,sz);
580 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
581 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
582 for (Int_t i=0; i<12;i++) p[i]=0.;
584 //p[] += dydx1; // a11
585 //p[] += dzdx1; // a12
586 //p[] += -dydx2; // a00
587 p[0] += dydx1*dydx2; // a01
588 //p[] += -dzdx1*dydx2; // a02
589 value = -dydx1+dydx2; // -a11 + a00
590 fitter->AddPoint(p,value,sdydx);
592 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
593 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
594 for (Int_t i=0; i<12;i++) p[i]=0.;
596 p[2] += dydx1; // a21
597 //p[] += dzdx1; // a22
598 //p[] += -dzdx2; // a00
599 p[0] += dydx1*dzdx2; // a01
600 //p[] += -dzdx1*dzdx2; // a02
601 value = -dzdx1+dzdx2; // -a22 + a00
602 fitter->AddPoint(p,value,sdzdx);
608 void AliTPCcalibAlign::EvalFitters() {
612 // Perform the fitting using linear fitters
614 Int_t kMinPoints =50;
616 TFile fff("alignDebug.root","recreate");
617 for (Int_t s1=0;s1<72;++s1)
618 for (Int_t s2=0;s2<72;++s2){
619 if ((f=GetFitter12(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
620 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
622 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
623 f->Write(Form("f12_%d_%d",s1,s2));
625 f->Write(Form("f12_%d_%d",s1,s2));
628 if ((f=GetFitter9(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
629 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
631 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
633 f->Write(Form("f9_%d_%d",s1,s2));
636 if ((f=GetFitter6(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
637 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
639 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
641 f->Write(Form("f6_%d_%d",s1,s2));
645 this->Write("align");
650 chi212 = align->GetChisquare()/(4.*entries);
654 align->GetParameters(par);
655 align->GetCovarianceMatrix(mat);
659 for (Int_t i=0; i<12;i++){
660 palign12(i)= par(i+1);
661 for (Int_t j=0; j<12;j++){
662 pcovar12(i,j) = mat(i+1,j+1);
663 pcovar12(i,j) *= chi212;
667 for (Int_t i=0; i<12;i++){
668 psigma12(i) = TMath::Sqrt(pcovar12(i,i));
669 palignR12(i) = palign12(i)/TMath::Sqrt(pcovar12(i,i));
670 for (Int_t j=0; j<12;j++){
671 pcovarN12(i,j) = pcovar12(i,j)/TMath::Sqrt(pcovar12(i,i)*pcovar12(j,j));
677 TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter12(Int_t s1,Int_t s2) {
679 // get or make fitter - general linear transformation
681 static Int_t counter12=0;
682 static TF1 f12("f12","x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]++x[9]++x[10]++x[11]");
683 TLinearFitter * fitter = GetFitter12(s1,s2);
684 if (fitter) return fitter;
685 // fitter =new TLinearFitter(12,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]++x[9]++x[10]++x[11]");
686 fitter =new TLinearFitter(&f12,"");
687 fitter->StoreData(kFALSE);
688 fFitterArray12.AddAt(fitter,GetIndex(s1,s2));
690 if (GetDebugLevel()>0) cerr<<"Creating fitter12 "<<s1<<","<<s2<<" : "<<counter12<<endl;
694 TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter9(Int_t s1,Int_t s2) {
696 //get or make fitter - general linear transformation - no scaling
698 static Int_t counter9=0;
699 static TF1 f9("f9","x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]");
700 TLinearFitter * fitter = GetFitter9(s1,s2);
701 if (fitter) return fitter;
702 // fitter =new TLinearFitter(9,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]");
703 fitter =new TLinearFitter(&f9,"");
704 fitter->StoreData(kFALSE);
705 fFitterArray9.AddAt(fitter,GetIndex(s1,s2));
707 if (GetDebugLevel()>0) cerr<<"Creating fitter12 "<<s1<<","<<s2<<" : "<<counter9<<endl;
711 TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter6(Int_t s1,Int_t s2) {
713 // get or make fitter - 6 paramater linear tranformation
716 // - tilting x-z, y-z
717 static Int_t counter6=0;
718 static TF1 f6("f6","x[0]++x[1]++x[2]++x[3]++x[4]++x[5]");
719 TLinearFitter * fitter = GetFitter6(s1,s2);
720 if (fitter) return fitter;
721 // fitter=new TLinearFitter(6,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]");
722 fitter=new TLinearFitter(&f6,"");
723 fitter->StoreData(kFALSE);
724 fFitterArray6.AddAt(fitter,GetIndex(s1,s2));
726 if (GetDebugLevel()>0) cerr<<"Creating fitter6 "<<s1<<","<<s2<<" : "<<counter6<<endl;
734 Bool_t AliTPCcalibAlign::GetTransformation12(Int_t s1,Int_t s2,TMatrixD &a) {
736 // GetTransformation matrix - 12 paramaters - generael linear transformation
738 if (!GetFitter12(s1,s2))
742 GetFitter12(s1,s2)->GetParameters(p);
744 a[0][0]=p[0]; a[0][1]=p[1]; a[0][2]=p[2]; a[0][3]=p[9];
745 a[1][0]=p[3]; a[1][1]=p[4]; a[1][2]=p[5]; a[1][3]=p[10];
746 a[2][0]=p[6]; a[2][1]=p[7]; a[2][2]=p[8]; a[2][3]=p[11];
747 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
752 Bool_t AliTPCcalibAlign::GetTransformation9(Int_t s1,Int_t s2,TMatrixD &a) {
754 // GetTransformation matrix - 9 paramaters - general linear transformation
757 if (!GetFitter9(s1,s2))
761 GetFitter9(s1,s2)->GetParameters(p);
763 a[0][0]=1; a[0][1]=p[0]; a[0][2]=p[1]; a[0][3]=p[6];
764 a[1][0]=p[2]; a[1][1]=1; a[1][2]=p[3]; a[1][3]=p[7];
765 a[2][0]=p[4]; a[2][1]=p[5]; a[2][2]=1; a[2][3]=p[8];
766 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
771 Bool_t AliTPCcalibAlign::GetTransformation6(Int_t s1,Int_t s2,TMatrixD &a) {
773 // GetTransformation matrix - 6 paramaters
777 if (!GetFitter6(s1,s2))
781 GetFitter6(s1,s2)->GetParameters(p);
783 a[0][0]=1; a[0][1]=-p[0];a[0][2]=0; a[0][3]=p[3];
784 a[1][0]=p[0]; a[1][1]=1; a[1][2]=0; a[1][3]=p[4];
785 a[2][0]=p[1]; a[2][1]=p[2]; a[2][2]=1; a[2][3]=p[5];
786 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
791 void AliTPCcalibAlign::FillHisto(const AliExternalTrackParam &tp1,
792 const AliExternalTrackParam &tp2,
795 // Fill residual histograms
799 if (TMath::Abs(s2%36-s1%36)<2 || TMath::Abs(s2%18-s1%18)==0) {
800 GetHisto(kPhi,s1,s2,kTRUE)->Fill(TMath::ASin(tp1.GetSnp())-TMath::ASin(tp2.GetSnp()));
801 GetHisto(kTheta,s1,s2,kTRUE)->Fill(TMath::ATan(tp1.GetTgl())-TMath::ATan(tp2.GetTgl()));
802 GetHisto(kY,s1,s2,kTRUE)->Fill(tp1.GetY()-tp2.GetY());
803 GetHisto(kZ,s1,s2,kTRUE)->Fill(tp1.GetZ()-tp2.GetZ());
809 TH1 * AliTPCcalibAlign::GetHisto(HistoType type, Int_t s1, Int_t s2, Bool_t force)
812 // return specified residual histogram - it is only QA
813 // if force specified the histogram and given histogram is not existing
814 // new histogram is created
816 if (GetIndex(s1,s2)>=72*72) return 0;
817 TObjArray *histoArray=0;
820 histoArray = &fDyHistArray; break;
822 histoArray = &fDzHistArray; break;
824 histoArray = &fDphiHistArray; break;
826 histoArray = &fDthetaHistArray; break;
828 TH1 * histo= (TH1*)histoArray->At(GetIndex(s1,s2));
829 if (histo) return histo;
830 if (force==kFALSE) return 0;
836 name<<"hist_y_"<<s1<<"_"<<s2;
837 title<<"Y Missalignment for sectors "<<s1<<" and "<<s2;
838 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
841 name<<"hist_z_"<<s1<<"_"<<s2;
842 title<<"Z Missalignment for sectors "<<s1<<" and "<<s2;
843 histo = new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
846 name<<"hist_phi_"<<s1<<"_"<<s2;
847 title<<"Phi Missalignment for sectors "<<s1<<" and "<<s2;
848 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
851 name<<"hist_theta_"<<s1<<"_"<<s2;
852 title<<"Theta Missalignment for sectors "<<s1<<" and "<<s2;
853 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
856 histo->SetDirectory(0);
857 histoArray->AddAt(histo,GetIndex(s1,s2));
861 TGraphErrors * AliTPCcalibAlign::MakeGraph(Int_t sec0, Int_t sec1, Int_t dsec,
862 Int_t i0, Int_t i1, FitType type)
868 TObjArray *fitArray=0;
872 for (Int_t isec = sec0; isec<=sec1; isec++){
873 Int_t isec2 = (isec+dsec)%72;
876 GetTransformation6(isec,isec2,mat);break;
878 GetTransformation9(isec,isec2,mat);break;
880 GetTransformation12(isec,isec2,mat);break;
883 ysec[npoints]=mat(i0,i1);
886 TGraphErrors *gr = new TGraphErrors(npoints,xsec,ysec,0,0);
888 sprintf(name,"Mat[%d,%d] Type=%d",i0,i1,type);
893 void AliTPCcalibAlign::MakeTree(const char *fname){
895 // make tree with alignment cosntant -
896 // For QA visualization
898 const Int_t kMinPoints=50;
899 TTreeSRedirector cstream(fname);
900 for (Int_t s1=0;s1<72;++s1)
901 for (Int_t s2=0;s2<72;++s2){
902 if (fPoints[GetIndex(s1,s2)]<kMinPoints) continue;
906 GetTransformation6(s1,s2,m6);
907 GetTransformation9(s1,s2,m9);
908 GetTransformation12(s1,s2,m12);
909 Double_t dy=0, dz=0, dphi=0,dtheta=0;
910 Double_t sy=0, sz=0, sphi=0,stheta=0;
911 Double_t ny=0, nz=0, nphi=0,ntheta=0;
913 his = GetHisto(kY,s1,s2);
914 if (his) { dy = his->GetMean(); sy = his->GetRMS(); ny = his->GetEntries();}
915 his = GetHisto(kZ,s1,s2);
916 if (his) { dz = his->GetMean(); sz = his->GetRMS(); nz = his->GetEntries();}
917 his = GetHisto(kPhi,s1,s2);
918 if (his) { dphi = his->GetMean(); sphi = his->GetRMS(); nphi = his->GetEntries();}
919 his = GetHisto(kTheta,s1,s2);
920 if (his) { dtheta = his->GetMean(); stheta = his->GetRMS(); ntheta = his->GetEntries();}
923 "s1="<<s1<< // reference sector
924 "s2="<<s2<< // sector to align
925 "m6.="<<&m6<< // tranformation matrix
928 // histograms mean RMS and entries