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
71 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
72 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
73 AliXRDPROOFtoolkit tool;
74 TChain * chain = tool.MakeChain("align.txt","Track",0,10200);
76 TCut cutA("abs(tp1.fP[1]-tp2.fP[1])<0.3&&abs(tp1.fP[0]-tp2.fP[0])<0.15&&abs(tp1.fP[3]-tp2.fP[3])<0.01&&abs(tp1.fP[2]-tp2.fP[2])<0.01");
77 TCut cutS("s1%36==s2%36");
80 .x $ALICE_ROOT/macros/loadlibsREC.C
82 gSystem->Load("$ROOTSYS/lib/libXrdClient.so");
83 gSystem->Load("libProof");
84 gSystem->Load("libANALYSIS");
85 gSystem->Load("libSTAT");
86 gSystem->Load("libTPCcalib");
89 TFile fcalib("CalibObjects.root");
90 TObjArray * array = (TObjArray*)fcalib.Get("TPCCalib");
92 AliTPCcalibAlign * align = ( AliTPCcalibAlign *)array->FindObject("alignTPC");
96 align->MakeTree("alignTree.root");
97 TFile falignTree("alignTree.root");
98 TTree * treeAlign = (TTree*)falignTree.Get("Align");
106 #include "TLinearFitter.h"
107 #include "AliTPCcalibAlign.h"
108 #include "AliExternalTrackParam.h"
109 #include "AliTPCTracklet.h"
112 #include "TVectorD.h"
113 #include "TTreeStream.h"
117 #include "TGraphErrors.h"
118 #include "AliTPCclusterMI.h"
119 #include "AliTPCseed.h"
120 #include "AliTracker.h"
121 #include "TClonesArray.h"
124 #include "TTreeStream.h"
129 AliTPCcalibAlign* AliTPCcalibAlign::fgInstance = 0;
130 ClassImp(AliTPCcalibAlign)
135 AliTPCcalibAlign* AliTPCcalibAlign::Instance()
138 // Singleton implementation
139 // Returns an instance of this class, it is created if neccessary
141 if (fgInstance == 0){
142 fgInstance = new AliTPCcalibAlign();
150 AliTPCcalibAlign::AliTPCcalibAlign()
152 fDphiHistArray(72*72),
153 fDthetaHistArray(72*72),
157 fDyPhiHistArray(72*72), // array of residual histograms y -kYPhi
158 fDzThetaHistArray(72*72), // array of residual histograms z-z -kZTheta
159 fDphiZHistArray(72*72), // array of residual histograms phi -kPhiz
160 fDthetaZHistArray(72*72), // array of residual histograms theta -kThetaz
161 fDyZHistArray(72*72), // array of residual histograms y -kYz
162 fDzZHistArray(72*72), // array of residual histograms z -kZz
163 fFitterArray12(72*72),
164 fFitterArray9(72*72),
165 fFitterArray6(72*72),
166 fMatrixArray12(72*72),
167 fMatrixArray9(72*72),
173 for (Int_t i=0;i<72*72;++i) {
178 AliTPCcalibAlign::AliTPCcalibAlign(const Text_t *name, const Text_t *title)
180 fDphiHistArray(72*72),
181 fDthetaHistArray(72*72),
184 fDyPhiHistArray(72*72), // array of residual histograms y -kYPhi
185 fDzThetaHistArray(72*72), // array of residual histograms z-z -kZTheta
186 fDphiZHistArray(72*72), // array of residual histograms phi -kPhiz
187 fDthetaZHistArray(72*72), // array of residual histograms theta -kThetaz
188 fDyZHistArray(72*72), // array of residual histograms y -kYz
189 fDzZHistArray(72*72), // array of residual histograms z -kZz //
190 fFitterArray12(72*72),
191 fFitterArray9(72*72),
192 fFitterArray6(72*72),
193 fMatrixArray12(72*72),
194 fMatrixArray9(72*72),
203 for (Int_t i=0;i<72*72;++i) {
209 AliTPCcalibAlign::AliTPCcalibAlign(const AliTPCcalibAlign &align)
210 :AliTPCcalibBase(align),
211 fDphiHistArray(align.fDphiHistArray),
212 fDthetaHistArray(align.fDthetaHistArray),
213 fDyHistArray(align.fDyHistArray),
214 fDzHistArray(align.fDzHistArray),
215 fDyPhiHistArray(align.fDyPhiHistArray), // array of residual histograms y -kYPhi
216 fDzThetaHistArray(align.fDzThetaHistArray), // array of residual histograms z-z -kZTheta
217 fDphiZHistArray(align.fDphiZHistArray), // array of residual histograms phi -kPhiz
218 fDthetaZHistArray(align.fDthetaZHistArray), // array of residual histograms theta -kThetaz
219 fDyZHistArray(align.fDyZHistArray), // array of residual histograms y -kYz
220 fDzZHistArray(align.fDzZHistArray), // array of residual histograms z -kZz
222 fFitterArray12(align.fFitterArray12),
223 fFitterArray9(align.fFitterArray9),
224 fFitterArray6(align.fFitterArray6),
226 fMatrixArray12(align.fMatrixArray12),
227 fMatrixArray9(align.fMatrixArray9),
228 fMatrixArray6(align.fMatrixArray6)
232 // copy constructor - copy also the content
236 const TObjArray *arr1=0;
237 for (Int_t index =0; index<72*72; index++){
238 for (Int_t iarray=0;iarray<10; iarray++){
240 arr0 = &fDyHistArray;
241 arr1 = &align.fDyHistArray;
244 arr0 = &fDzHistArray;
245 arr1 = &align.fDzHistArray;
248 arr0 = &fDphiHistArray;
249 arr1 = &align.fDphiHistArray;
252 arr0 = &fDthetaHistArray;
253 arr1 = &align.fDthetaHistArray;
256 arr0 = &fDyZHistArray;
257 arr1 = &align.fDyZHistArray;
260 arr0 = &fDzZHistArray;
261 arr1 = &align.fDzZHistArray;
264 arr0 = &fDphiZHistArray;
265 arr1 = &align.fDphiZHistArray;
267 if (iarray==kThetaZ){
268 arr0 = &fDthetaZHistArray;
269 arr1 = &align.fDthetaZHistArray;
273 arr0 = &fDyPhiHistArray;
274 arr1 = &align.fDyPhiHistArray;
276 if (iarray==kZTheta){
277 arr0 = &fDzThetaHistArray;
278 arr1 = &align.fDzThetaHistArray;
281 if (arr1->At(index)) {
282 his = (TH1*)arr1->At(index)->Clone();
283 his->SetDirectory(0);
284 arr0->AddAt(his,index);
291 AliTPCcalibAlign::~AliTPCcalibAlign() {
297 void AliTPCcalibAlign::Process(AliTPCseed *seed) {
303 AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kKalman,
305 // TObjArray trackletsL=
306 // AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kLinear,
308 // TObjArray trackletsQ=
309 // AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kQuadratic,
311 // TObjArray trackletsR=
312 // AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kRiemann,
314 tracklets.SetOwner();
315 // trackletsL.SetOwner();
316 // trackletsQ.SetOwner();
317 // trackletsR.SetOwner();
318 if (tracklets.GetEntries()==2) {
319 AliTPCTracklet *t1=static_cast<AliTPCTracklet*>(tracklets[0]);
320 AliTPCTracklet *t2=static_cast<AliTPCTracklet*>(tracklets[1]);
321 if (t1->GetSector()>t2->GetSector()) {
322 AliTPCTracklet* tmp=t1;
326 AliExternalTrackParam *common1=0,*common2=0;
327 if (AliTPCTracklet::PropagateToMeanX(*t1,*t2,common1,common2))
328 ProcessTracklets(*common1,*common2,seed, t1->GetSector(),t2->GetSector());
335 void AliTPCcalibAlign::Analyze(){
343 void AliTPCcalibAlign::Terminate(){
345 // Terminate function
346 // call base terminate + Eval of fitters
348 Info("AliTPCcalibAlign","Terminate");
350 AliTPCcalibBase::Terminate();
356 void AliTPCcalibAlign::ProcessTracklets(const AliExternalTrackParam &tp1,
357 const AliExternalTrackParam &tp2,
358 const AliTPCseed * seed,
366 // Process function to fill fitters
368 Double_t t1[5],t2[5];
369 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
370 Double_t &x2=t2[0], &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
374 Double_t snp1=tp1.GetSnp();
375 dydx1=snp1/TMath::Sqrt(1.-snp1*snp1);
376 Double_t tgl1=tp1.GetTgl();
377 // dz/dx = 1/(cos(theta)*cos(phi))
378 dzdx1=tgl1/TMath::Sqrt(1.-snp1*snp1);
382 Double_t snp2=tp2.GetSnp();
383 dydx2=snp2/TMath::Sqrt(1.-snp2*snp2);
384 Double_t tgl2=tp2.GetTgl();
385 dzdx2=tgl2/TMath::Sqrt(1.-snp2*snp2);
386 Bool_t accept = AcceptTracklet(tp1,tp2);
391 TTreeSRedirector *cstream = GetDebugStreamer();
393 static TVectorD vec1(5);
394 static TVectorD vec2(5);
395 vec1.SetElements(t1);
396 vec2.SetElements(t2);
397 AliExternalTrackParam *p1 = &((AliExternalTrackParam&)tp1);
398 AliExternalTrackParam *p2 = &((AliExternalTrackParam&)tp2);
399 (*cstream)<<"Tracklet"<<
400 "run="<<fRun<< // run number
401 "event="<<fEvent<< // event number
402 "time="<<fTime<< // time stamp of event
403 "trigger="<<fTrigger<< // trigger
404 "mag="<<fMagF<< // magnetic field
405 "isOK="<<accept<< // flag - used for alignment
417 if (GetDebugLevel()>50) printf("Process track\n");
418 if (GetDebugLevel()>50) printf("Filling track\n");
420 // fill resolution histograms - previous cut included
421 ProcessDiff(tp1,tp2, seed,s1,s2);
422 FillHisto(tp1,tp2,s1,s2);
423 ProcessAlign(t1,t2,s1,s2);
426 void AliTPCcalibAlign::ProcessAlign(Double_t * t1,
430 // Do intersector alignment
432 Process12(t1,t2,GetOrMakeFitter12(s1,s2));
433 Process9(t1,t2,GetOrMakeFitter9(s1,s2));
434 Process6(t1,t2,GetOrMakeFitter6(s1,s2));
435 ++fPoints[GetIndex(s1,s2)];
438 void AliTPCcalibAlign::ProcessTree(TTree * chainTracklet){
440 // Process the debug streamer tree
441 // Possible to modify selection criteria
442 // Used with entry list
444 TTreeSRedirector * cstream = new TTreeSRedirector("aligndump.root");
446 AliTPCcalibAlign *align = this;
450 AliExternalTrackParam * tp1 = new AliExternalTrackParam;
451 AliExternalTrackParam * tp2 = new AliExternalTrackParam;
455 Int_t entries=chainTracklet->GetEntries();
456 for (Int_t i=0; i< entries; i++){
457 chainTracklet->GetBranch("tp1.")->SetAddress(&tp1);
458 chainTracklet->GetBranch("tp2.")->SetAddress(&tp2);
459 chainTracklet->GetBranch("v1.")->SetAddress(&vec1);
460 chainTracklet->GetBranch("v2.")->SetAddress(&vec2);
461 chainTracklet->GetBranch("s1")->SetAddress(&s1);
462 chainTracklet->GetBranch("s2")->SetAddress(&s2);
463 chainTracklet->GetEntry(i);
464 if (s1==s2) continue;
465 if (i%100==0) printf("%d\t%d\t%d\t\n",i, s1,s2);
466 Bool_t accept = AcceptTracklet(tp1,tp2);
467 if (!accept) continue;
468 if (vec1->GetMatrixArray()){
469 align->FillHisto(*tp1,*tp2,s1,s2);
470 align->ProcessAlign(vec1->GetMatrixArray(),vec2->GetMatrixArray(),s1,s2);
471 (*cstream)<<"Tracklet"<<
486 Bool_t AliTPCcalibAlign::AcceptTracklet(const AliExternalTrackParam &p1,
487 const AliExternalTrackParam &p2){
490 // Accept pair of tracklets?
494 TCut cutS0("sqrt(tp2.fC[0]+tp2.fC[0])<0.2");
495 TCut cutS1("sqrt(tp2.fC[2]+tp2.fC[2])<0.2");
496 TCut cutS2("sqrt(tp2.fC[5]+tp2.fC[5])<0.01");
497 TCut cutS3("sqrt(tp2.fC[9]+tp2.fC[9])<0.01");
498 TCut cutS4("sqrt(tp2.fC[14]+tp2.fC[14])<0.5");
499 TCut cutS=cutS0+cutS1+cutS2+cutS3+cutS4;
501 // parameters matching cuts
502 TCut cutP0("abs(tp1.fP[0]-tp2.fP[0])<0.6");
503 TCut cutP1("abs(tp1.fP[1]-tp2.fP[1])<0.6");
504 TCut cutP2("abs(tp1.fP[2]-tp2.fP[2])<0.03");
505 TCut cutP3("abs(tp1.fP[3]-tp2.fP[3])<0.03");
506 TCut cutP=cutP0+cutP1+cutP2+cutP3;
510 const Double_t *cp1 = p1.GetCovariance();
511 const Double_t *cp2 = p2.GetCovariance();
512 if (TMath::Abs(cp1[0]+cp2[0])>0.2) return kFALSE;
513 if (TMath::Abs(cp1[2]+cp2[2])>0.2) return kFALSE;
514 if (TMath::Abs(cp1[5]+cp2[5])>0.01) return kFALSE;
515 if (TMath::Abs(cp1[9]+cp2[9])>0.01) return kFALSE;
516 if (TMath::Abs(cp1[14]+cp2[14])>0.5) return kFALSE;
518 //parameters difference
519 const Double_t *tp1 = p1.GetParameter();
520 const Double_t *tp2 = p2.GetParameter();
521 if (TMath::Abs(tp1[0]-tp2[0])>0.6) return kFALSE;
522 if (TMath::Abs(tp1[1]-tp2[1])>0.6) return kFALSE;
523 if (TMath::Abs(tp1[2]-tp2[2])>0.03) return kFALSE;
524 if (TMath::Abs(tp1[3]-tp2[3])>0.03) return kFALSE;
526 if (TMath::Abs(tp2[1])>235) return kFALSE;
532 void AliTPCcalibAlign::ProcessDiff(const AliExternalTrackParam &t1,
533 const AliExternalTrackParam &t2,
534 const AliTPCseed *seed,
538 // Process local residuals function
543 TVectorD vecClY(160);
544 TVectorD vecClZ(160);
545 TClonesArray arrCl("AliTPCclusterMI",160);
546 arrCl.ExpandCreateFast(160);
547 Int_t count1=0, count2=0;
548 for (Int_t i=0;i<160;++i) {
549 AliTPCclusterMI *c=seed->GetClusterPointer(i);
554 AliTPCclusterMI & cl = (AliTPCclusterMI&) (*arrCl[i]);
555 if (c->GetDetector()!=s1 && c->GetDetector()!=s2) continue;
556 vecClY[i] = c->GetY();
557 vecClZ[i] = c->GetZ();
559 const AliExternalTrackParam *par = (c->GetDetector()==s1)? &t1:&t2;
560 if (c->GetDetector()==s1) ++count1;
561 if (c->GetDetector()==s2) ++count2;
562 Double_t gxyz[3],xyz[3];
564 Float_t bz = AliTracker::GetBz(gxyz);
565 par->GetYAt(c->GetX(), bz, xyz[1]);
566 par->GetZAt(c->GetX(), bz, xyz[2]);
575 // huge output - cluster residuals to be investigated
577 TTreeSRedirector *cstream = GetDebugStreamer();
578 //AliTPCseed * t = (AliTPCseed*) seed;
579 //AliExternalTrackParam *p0 = &((AliExternalTrackParam&)seed);
580 AliExternalTrackParam *p1 = &((AliExternalTrackParam&)t1);
581 AliExternalTrackParam *p2 = &((AliExternalTrackParam&)t2);
584 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");
589 (*cstream)<<"Track"<<
590 "run="<<fRun<< // run number
591 "event="<<fEvent<< // event number
592 "time="<<fTime<< // time stamp of event
593 "trigger="<<fTrigger<< // trigger
594 "mag="<<fMagF<< // magnetic field
616 void AliTPCcalibAlign::Process12(const Double_t *t1,
618 TLinearFitter *fitter) {
619 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
620 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
621 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
622 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
623 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
625 // a00 a01 a02 a03 p[0] p[1] p[2] p[9]
626 // a10 a11 a12 a13 ==> p[3] p[4] p[5] p[10]
627 // a20 a21 a22 a23 p[6] p[7] p[8] p[11]
631 const Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
632 const Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
637 Double_t sdydx = 0.001;
638 Double_t sdzdx = 0.001;
643 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
644 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
645 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
646 for (Int_t i=0; i<12;i++) p[i]=0.;
651 p[0+1] = y1*dydx2; // a01
652 p[0+2] = z1*dydx2; // a02
653 p[9+0] = dydx2; // a03
655 fitter->AddPoint(p,value,sy);
657 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
658 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
659 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
660 for (Int_t i=0; i<12;i++) p[i]=0.;
665 p[0+1] = y1*dzdx2; // a01
666 p[0+2] = z1*dzdx2; // a02
667 p[9+0] = dzdx2; // a03
669 fitter->AddPoint(p,value,sz);
671 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
672 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
673 for (Int_t i=0; i<12;i++) p[i]=0.;
675 p[3+1] = dydx1; // a11
676 p[3+2] = dzdx1; // a12
677 p[0+0] = -dydx2; // a00
678 p[0+1] = -dydx1*dydx2; // a01
679 p[0+2] = -dzdx1*dydx2; // a02
681 fitter->AddPoint(p,value,sdydx);
683 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
684 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
685 for (Int_t i=0; i<12;i++) p[i]=0.;
687 p[6+1] = dydx1; // a21
688 p[6+2] = dzdx1; // a22
689 p[0+0] = -dzdx2; // a00
690 p[0+1] = -dydx1*dzdx2; // a01
691 p[0+2] = -dzdx1*dzdx2; // a02
693 fitter->AddPoint(p,value,sdzdx);
696 void AliTPCcalibAlign::Process9(Double_t *t1,
698 TLinearFitter *fitter) {
699 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
700 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
701 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
702 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
703 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
705 // a00 a01 a02 a03 1 p[0] p[1] p[6]
706 // a10 a11 a12 a13 ==> p[2] 1 p[3] p[7]
707 // a20 a21 a21 a23 p[4] p[5] 1 p[8]
710 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
711 Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
716 Double_t sdydx = 0.001;
717 Double_t sdzdx = 0.001;
722 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
723 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
724 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
725 for (Int_t i=0; i<12;i++) p[i]=0.;
730 p[0] += y1*dydx2; // a01
731 p[1] += z1*dydx2; // a02
732 p[6] += dydx2; // a03
733 value = y2-y1; //-a11
734 fitter->AddPoint(p,value,sy);
736 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
737 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
738 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
739 for (Int_t i=0; i<12;i++) p[i]=0.;
744 p[0] += y1*dzdx2; // a01
745 p[1] += z1*dzdx2; // a02
746 p[6] += dzdx2; // a03
747 value = z2-z1; //-a22
748 fitter->AddPoint(p,value,sz);
750 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
751 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
752 for (Int_t i=0; i<12;i++) p[i]=0.;
754 //p[] += dydx1; // a11
755 p[3] += dzdx1; // a12
756 //p[] += -dydx2; // a00
757 p[0] += -dydx1*dydx2; // a01
758 p[1] += -dzdx1*dydx2; // a02
759 value = -dydx1+dydx2; // -a11 + a00
760 fitter->AddPoint(p,value,sdydx);
762 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
763 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
764 for (Int_t i=0; i<12;i++) p[i]=0.;
766 p[5] += dydx1; // a21
767 //p[] += dzdx1; // a22
768 //p[] += -dzdx2; // a00
769 p[0] += -dydx1*dzdx2; // a01
770 p[1] += -dzdx1*dzdx2; // a02
771 value = -dzdx1+dzdx2; // -a22 + a00
772 fitter->AddPoint(p,value,sdzdx);
775 void AliTPCcalibAlign::Process6(Double_t *t1,
777 TLinearFitter *fitter) {
778 // x2 = 1 *x1 +-a01*y1 + 0 +a03
779 // y2 = a01*x1 + 1 *y1 + 0 +a13
780 // z2 = a20*x1 + a21*y1 + 1 *z1 +a23
781 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
782 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
784 // a00 a01 a02 a03 1 -p[0] 0 p[3]
785 // a10 a11 a12 a13 ==> p[0] 1 0 p[4]
786 // a20 a21 a21 a23 p[1] p[2] 1 p[5]
788 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
789 Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
794 Double_t sdydx = 0.001;
795 Double_t sdzdx = 0.001;
799 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
800 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
801 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
802 for (Int_t i=0; i<12;i++) p[i]=0.;
807 p[0] += -y1*dydx2; // a01
808 //p[] += z1*dydx2; // a02
809 p[3] += dydx2; // a03
810 value = y2-y1; //-a11
811 fitter->AddPoint(p,value,sy);
813 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
814 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
815 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
816 for (Int_t i=0; i<12;i++) p[i]=0.;
821 p[0] += -y1*dzdx2; // a01
822 //p[] += z1*dzdx2; // a02
823 p[3] += dzdx2; // a03
824 value = z2-z1; //-a22
825 fitter->AddPoint(p,value,sz);
827 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
828 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
829 for (Int_t i=0; i<12;i++) p[i]=0.;
831 //p[] += dydx1; // a11
832 //p[] += dzdx1; // a12
833 //p[] += -dydx2; // a00
834 p[0] += dydx1*dydx2; // a01
835 //p[] += -dzdx1*dydx2; // a02
836 value = -dydx1+dydx2; // -a11 + a00
837 fitter->AddPoint(p,value,sdydx);
839 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
840 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
841 for (Int_t i=0; i<12;i++) p[i]=0.;
843 p[2] += dydx1; // a21
844 //p[] += dzdx1; // a22
845 //p[] += -dzdx2; // a00
846 p[0] += dydx1*dzdx2; // a01
847 //p[] += -dzdx1*dzdx2; // a02
848 value = -dzdx1+dzdx2; // -a22 + a00
849 fitter->AddPoint(p,value,sdzdx);
855 void AliTPCcalibAlign::EvalFitters() {
859 // Perform the fitting using linear fitters
861 Int_t kMinPoints =50;
863 TFile fff("alignDebug.root","recreate");
864 for (Int_t s1=0;s1<72;++s1)
865 for (Int_t s2=0;s2<72;++s2){
866 if ((f=GetFitter12(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
867 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
869 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
870 f->Write(Form("f12_%d_%d",s1,s2));
872 f->Write(Form("f12_%d_%d",s1,s2));
875 if ((f=GetFitter9(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
876 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
878 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
880 f->Write(Form("f9_%d_%d",s1,s2));
883 if ((f=GetFitter6(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
884 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
886 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
888 f->Write(Form("f6_%d_%d",s1,s2));
893 for (Int_t s1=0;s1<72;++s1)
894 for (Int_t s2=0;s2<72;++s2){
895 if (GetTransformation12(s1,s2,mat)){
896 fMatrixArray12.AddAt(mat.Clone(), GetIndex(s1,s2));
898 if (GetTransformation9(s1,s2,mat)){
899 fMatrixArray9.AddAt(mat.Clone(), GetIndex(s1,s2));
901 if (GetTransformation6(s1,s2,mat)){
902 fMatrixArray6.AddAt(mat.Clone(), GetIndex(s1,s2));
905 //this->Write("align");
909 TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter12(Int_t s1,Int_t s2) {
911 // get or make fitter - general linear transformation
913 static Int_t counter12=0;
914 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]");
915 TLinearFitter * fitter = GetFitter12(s1,s2);
916 if (fitter) return fitter;
917 // 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]");
918 fitter =new TLinearFitter(&f12,"");
919 fitter->StoreData(kFALSE);
920 fFitterArray12.AddAt(fitter,GetIndex(s1,s2));
922 if (GetDebugLevel()>0) cerr<<"Creating fitter12 "<<s1<<","<<s2<<" : "<<counter12<<endl;
926 TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter9(Int_t s1,Int_t s2) {
928 //get or make fitter - general linear transformation - no scaling
930 static Int_t counter9=0;
931 static TF1 f9("f9","x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]");
932 TLinearFitter * fitter = GetFitter9(s1,s2);
933 if (fitter) return fitter;
934 // fitter =new TLinearFitter(9,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]");
935 fitter =new TLinearFitter(&f9,"");
936 fitter->StoreData(kFALSE);
937 fFitterArray9.AddAt(fitter,GetIndex(s1,s2));
939 if (GetDebugLevel()>0) cerr<<"Creating fitter12 "<<s1<<","<<s2<<" : "<<counter9<<endl;
943 TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter6(Int_t s1,Int_t s2) {
945 // get or make fitter - 6 paramater linear tranformation
948 // - tilting x-z, y-z
949 static Int_t counter6=0;
950 static TF1 f6("f6","x[0]++x[1]++x[2]++x[3]++x[4]++x[5]");
951 TLinearFitter * fitter = GetFitter6(s1,s2);
952 if (fitter) return fitter;
953 // fitter=new TLinearFitter(6,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]");
954 fitter=new TLinearFitter(&f6,"");
955 fitter->StoreData(kTRUE);
956 fFitterArray6.AddAt(fitter,GetIndex(s1,s2));
958 if (GetDebugLevel()>0) cerr<<"Creating fitter6 "<<s1<<","<<s2<<" : "<<counter6<<endl;
966 Bool_t AliTPCcalibAlign::GetTransformation12(Int_t s1,Int_t s2,TMatrixD &a) {
968 // GetTransformation matrix - 12 paramaters - generael linear transformation
970 if (!GetFitter12(s1,s2))
974 GetFitter12(s1,s2)->GetParameters(p);
976 a[0][0]=p[0]; a[0][1]=p[1]; a[0][2]=p[2]; a[0][3]=p[9];
977 a[1][0]=p[3]; a[1][1]=p[4]; a[1][2]=p[5]; a[1][3]=p[10];
978 a[2][0]=p[6]; a[2][1]=p[7]; a[2][2]=p[8]; a[2][3]=p[11];
979 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
984 Bool_t AliTPCcalibAlign::GetTransformation9(Int_t s1,Int_t s2,TMatrixD &a) {
986 // GetTransformation matrix - 9 paramaters - general linear transformation
989 if (!GetFitter9(s1,s2))
993 GetFitter9(s1,s2)->GetParameters(p);
995 a[0][0]=1; a[0][1]=p[0]; a[0][2]=p[1]; a[0][3]=p[6];
996 a[1][0]=p[2]; a[1][1]=1; a[1][2]=p[3]; a[1][3]=p[7];
997 a[2][0]=p[4]; a[2][1]=p[5]; a[2][2]=1; a[2][3]=p[8];
998 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
1003 Bool_t AliTPCcalibAlign::GetTransformation6(Int_t s1,Int_t s2,TMatrixD &a) {
1005 // GetTransformation matrix - 6 paramaters
1008 // 2 tilting x-z y-z
1009 if (!GetFitter6(s1,s2))
1013 GetFitter6(s1,s2)->GetParameters(p);
1015 a[0][0]=1; a[0][1]=-p[0];a[0][2]=0; a[0][3]=p[3];
1016 a[1][0]=p[0]; a[1][1]=1; a[1][2]=0; a[1][3]=p[4];
1017 a[2][0]=p[1]; a[2][1]=p[2]; a[2][2]=1; a[2][3]=p[5];
1018 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
1023 void AliTPCcalibAlign::FillHisto(const AliExternalTrackParam &tp1,
1024 const AliExternalTrackParam &tp2,
1025 Int_t s1,Int_t s2) {
1027 // Fill residual histograms
1031 if (TMath::Abs(s2%36-s1%36)<2 || TMath::Abs(s2%18-s1%18)==0) {
1032 GetHisto(kPhi,s1,s2,kTRUE)->Fill(TMath::ASin(tp1.GetSnp())-TMath::ASin(tp2.GetSnp()));
1033 GetHisto(kTheta,s1,s2,kTRUE)->Fill(TMath::ATan(tp1.GetTgl())-TMath::ATan(tp2.GetTgl()));
1034 GetHisto(kY,s1,s2,kTRUE)->Fill(tp1.GetY()-tp2.GetY());
1035 GetHisto(kZ,s1,s2,kTRUE)->Fill(tp1.GetZ()-tp2.GetZ());
1037 GetHisto(kPhiZ,s1,s2,kTRUE)->Fill(tp1.GetZ(),TMath::ASin(tp1.GetSnp())-TMath::ASin(tp2.GetSnp()));
1038 GetHisto(kThetaZ,s1,s2,kTRUE)->Fill(tp1.GetZ(),TMath::ATan(tp1.GetTgl())-TMath::ATan(tp2.GetTgl()));
1039 GetHisto(kYz,s1,s2,kTRUE)->Fill(tp1.GetZ(),tp1.GetY()-tp2.GetY());
1040 GetHisto(kZz,s1,s2,kTRUE)->Fill(tp1.GetZ(),tp1.GetZ()-tp2.GetZ());
1042 GetHisto(kYPhi,s1,s2,kTRUE)->Fill(tp1.GetSnp(),tp1.GetY()-tp2.GetY());
1043 GetHisto(kZTheta,s1,s2,kTRUE)->Fill(tp1.GetTgl(),tp1.GetZ()-tp2.GetZ());
1051 TH1 * AliTPCcalibAlign::GetHisto(HistoType type, Int_t s1, Int_t s2, Bool_t force)
1054 // return specified residual histogram - it is only QA
1055 // if force specified the histogram and given histogram is not existing
1056 // new histogram is created
1058 if (GetIndex(s1,s2)>=72*72) return 0;
1059 TObjArray *histoArray=0;
1062 histoArray = &fDyHistArray; break;
1064 histoArray = &fDzHistArray; break;
1066 histoArray = &fDphiHistArray; break;
1068 histoArray = &fDthetaHistArray; break;
1070 histoArray = &fDyPhiHistArray; break;
1072 histoArray = &fDzThetaHistArray; break;
1074 histoArray = &fDyZHistArray; break;
1076 histoArray = &fDzZHistArray; break;
1078 histoArray = &fDphiZHistArray; break;
1080 histoArray = &fDthetaZHistArray; break;
1082 TH1 * histo= (TH1*)histoArray->At(GetIndex(s1,s2));
1083 if (histo) return histo;
1084 if (force==kFALSE) return 0;
1090 name<<"hist_y_"<<s1<<"_"<<s2;
1091 title<<"Y Missalignment for sectors "<<s1<<" and "<<s2;
1092 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
1095 name<<"hist_z_"<<s1<<"_"<<s2;
1096 title<<"Z Missalignment for sectors "<<s1<<" and "<<s2;
1097 histo = new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
1100 name<<"hist_phi_"<<s1<<"_"<<s2;
1101 title<<"Phi Missalignment for sectors "<<s1<<" and "<<s2;
1102 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
1105 name<<"hist_theta_"<<s1<<"_"<<s2;
1106 title<<"Theta Missalignment for sectors "<<s1<<" and "<<s2;
1107 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
1112 name<<"hist_yphi_"<<s1<<"_"<<s2;
1113 title<<"Y Missalignment for sectors Phi"<<s1<<" and "<<s2;
1114 histo =new TH2F(name.str().c_str(),title.str().c_str(),20,-1,1,128,-0.3,0.3); // +/- 3 mm
1117 name<<"hist_ztheta_"<<s1<<"_"<<s2;
1118 title<<"Z Missalignment for sectors Theta"<<s1<<" and "<<s2;
1119 histo = new TH2F(name.str().c_str(),title.str().c_str(),128,20,-1,1,-0.3,0.3); // +/- 3 mm
1125 name<<"hist_yz_"<<s1<<"_"<<s2;
1126 title<<"Y Missalignment for sectors Z"<<s1<<" and "<<s2;
1127 histo =new TH2F(name.str().c_str(),title.str().c_str(),20,-250,250,128,-0.3,0.3); // +/- 3 mm
1130 name<<"hist_zz_"<<s1<<"_"<<s2;
1131 title<<"Z Missalignment for sectors Z"<<s1<<" and "<<s2;
1132 histo = new TH2F(name.str().c_str(),title.str().c_str(),20,-250,250,128,-0.3,0.3); // +/- 3 mm
1135 name<<"hist_phiz_"<<s1<<"_"<<s2;
1136 title<<"Phi Missalignment for sectors Z"<<s1<<" and "<<s2;
1137 histo =new TH2F(name.str().c_str(),title.str().c_str(),20,-250,250,128,-0.01,0.01); // +/- 10 mrad
1140 name<<"hist_thetaz_"<<s1<<"_"<<s2;
1141 title<<"Theta Missalignment for sectors Z"<<s1<<" and "<<s2;
1142 histo =new TH2F(name.str().c_str(),title.str().c_str(),20,-250,250,128,-0.01,0.01); // +/- 10 mrad
1147 histo->SetDirectory(0);
1148 histoArray->AddAt(histo,GetIndex(s1,s2));
1152 TGraphErrors * AliTPCcalibAlign::MakeGraph(Int_t sec0, Int_t sec1, Int_t dsec,
1153 Int_t i0, Int_t i1, FitType type)
1159 //TObjArray *fitArray=0;
1160 Double_t xsec[1000];
1161 Double_t ysec[1000];
1163 for (Int_t isec = sec0; isec<=sec1; isec++){
1164 Int_t isec2 = (isec+dsec)%72;
1167 GetTransformation6(isec,isec2,mat);break;
1169 GetTransformation9(isec,isec2,mat);break;
1171 GetTransformation12(isec,isec2,mat);break;
1174 ysec[npoints]=mat(i0,i1);
1177 TGraphErrors *gr = new TGraphErrors(npoints,xsec,ysec,0,0);
1179 sprintf(name,"Mat[%d,%d] Type=%d",i0,i1,type);
1184 void AliTPCcalibAlign::MakeTree(const char *fname){
1186 // make tree with alignment cosntant -
1187 // For QA visualization
1190 TFile f("CalibObjects.root");
1191 TObjArray *array = (TObjArray*)f.Get("TPCCalib");
1192 AliTPCcalibAlign *alignTPC = (AliTPCcalibAlign *)array->At(0);
1193 alignTPC->MakeTree("alignTree.root");
1194 TFile falign("alignTree.root");
1197 const Int_t kMinPoints=50;
1198 TTreeSRedirector cstream(fname);
1199 for (Int_t s1=0;s1<72;++s1)
1200 for (Int_t s2=0;s2<72;++s2){
1204 Double_t dy=0, dz=0, dphi=0,dtheta=0;
1205 Double_t sy=0, sz=0, sphi=0,stheta=0;
1206 Double_t ny=0, nz=0, nphi=0,ntheta=0;
1207 Double_t chi2v12=0, chi2v9=0, chi2v6=0;
1209 if (fPoints[GetIndex(s1,s2)]>kMinPoints){
1213 TLinearFitter * fitter = 0;
1214 fitter = GetFitter12(s1,s2);
1215 npoints = fitter->GetNpoints();
1216 chi2v12 = TMath::Sqrt(fitter->GetChisquare()/npoints);
1218 fitter = GetFitter9(s1,s2);
1219 npoints = fitter->GetNpoints();
1220 chi2v9 = TMath::Sqrt(fitter->GetChisquare()/npoints);
1222 fitter = GetFitter6(s1,s2);
1223 npoints = fitter->GetNpoints();
1224 chi2v6 = TMath::Sqrt(fitter->GetChisquare()/npoints);
1226 GetTransformation6(s1,s2,m6);
1227 GetTransformation9(s1,s2,m9);
1228 GetTransformation12(s1,s2,m12);
1230 his = GetHisto(kY,s1,s2);
1231 if (his) { dy = his->GetMean(); sy = his->GetRMS(); ny = his->GetEntries();}
1232 his = GetHisto(kZ,s1,s2);
1233 if (his) { dz = his->GetMean(); sz = his->GetRMS(); nz = his->GetEntries();}
1234 his = GetHisto(kPhi,s1,s2);
1235 if (his) { dphi = his->GetMean(); sphi = his->GetRMS(); nphi = his->GetEntries();}
1236 his = GetHisto(kTheta,s1,s2);
1237 if (his) { dtheta = his->GetMean(); stheta = his->GetRMS(); ntheta = his->GetEntries();}
1241 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
1242 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
1243 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
1244 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1245 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1247 // a00 a01 a02 a03 p[0] p[1] p[2] p[9]
1248 // a10 a11 a12 a13 ==> p[3] p[4] p[5] p[10]
1249 // a20 a21 a22 a23 p[6] p[7] p[8] p[11]
1253 // dy:-(134*m6.fElements[4]+m6.fElements[7])
1255 // dphi:-(m6.fElements[4])
1257 // dz:134*m6.fElements[8]+m6.fElements[11]
1259 // dtheta:m6.fElements[8]
1262 "s1="<<s1<< // reference sector
1263 "s2="<<s2<< // sector to align
1264 "m6.="<<&m6<< // tranformation matrix
1267 "chi2v12="<<chi2v12<<
1270 // histograms mean RMS and entries
1289 //_____________________________________________________________________
1290 Long64_t AliTPCcalibAlign::Merge(TCollection* list) {
1294 if (GetDebugLevel()>0) Info("AliTPCcalibAlign","Merge");
1297 if (list->IsEmpty())
1300 TIterator* iter = list->MakeIterator();
1305 TString str1(GetName());
1306 while((obj = iter->Next()) != 0)
1308 AliTPCcalibAlign* entry = dynamic_cast<AliTPCcalibAlign*>(obj);
1309 if (entry == 0) continue;
1310 if (str1.CompareTo(entry->GetName())!=0) continue;
1318 void AliTPCcalibAlign::Add(AliTPCcalibAlign * align){
1320 // Add entry - used for merging of compoents
1322 for (Int_t i=0; i<72;i++){
1323 for (Int_t j=0; j<72;j++){
1324 if (align->fPoints[GetIndex(i,j)]<10) continue;
1325 fPoints[GetIndex(i,j)]+=align->fPoints[GetIndex(i,j)];
1329 for (Int_t itype=0; itype<10; itype++){
1330 TH1 * his0=0, *his1=0;
1331 his0 = GetHisto((HistoType)itype,i,j);
1332 his1 = align->GetHisto((HistoType)itype,i,j);
1334 if (his0) his0->Add(his1);
1336 his0 = GetHisto(kY,i,j,kTRUE);
1343 TLinearFitter *f0=0;
1344 TLinearFitter *f1=0;
1345 for (Int_t i=0; i<72;i++){
1346 for (Int_t j=0; j<72;j++){
1347 if (align->fPoints[GetIndex(i,j)]<20) continue;
1351 f0 = GetFitter12(i,j);
1352 f1 = align->GetFitter12(i,j);
1353 if (f1 &&f1->Eval()){
1354 if (f0&&f0->GetNpoints()>10) f0->Add(f1);
1356 fFitterArray12.AddAt(f1->Clone(),GetIndex(i,j));
1361 f0 = GetFitter9(i,j);
1362 f1 = align->GetFitter9(i,j);
1363 if (f1&&f1->Eval()){
1364 if (f0&&f0->GetNpoints()>10) f0->Add(f1);
1366 fFitterArray9.AddAt(f1->Clone(),GetIndex(i,j));
1369 f0 = GetFitter6(i,j);
1370 f1 = align->GetFitter6(i,j);
1371 if (f1 &&f1->Eval()){
1372 if (f0&&f0->GetNpoints()>10) f0->Add(f1);
1374 fFitterArray6.AddAt(f1->Clone(),GetIndex(i,j));
1381 Double_t AliTPCcalibAlign::Correct(Int_t type, Int_t value, Int_t s1, Int_t s2, Double_t x1, Double_t y1, Double_t z1, Double_t dydx1,Double_t dzdx1){
1383 // GetTransformed value
1386 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
1387 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
1388 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
1389 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1390 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1393 const TMatrixD * mat = GetTransformation(s1,s2,type);
1395 if (value==0) return x1;
1396 if (value==1) return y1;
1397 if (value==2) return z1;
1398 if (value==3) return dydx1;
1399 if (value==4) return dzdx1;
1401 if (value==5) return dydx1;
1402 if (value==6) return dzdx1;
1408 valT = (*mat)(0,0)*x1+(*mat)(0,1)*y1+(*mat)(0,2)*z1+(*mat)(0,3);
1412 valT = (*mat)(1,0)*x1+(*mat)(1,1)*y1+(*mat)(1,2)*z1+(*mat)(1,3);
1415 valT = (*mat)(2,0)*x1+(*mat)(2,1)*y1+(*mat)(2,2)*z1+(*mat)(2,3);
1418 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1419 valT = (*mat)(1,0) +(*mat)(1,1)*dydx1 +(*mat)(1,2)*dzdx1;
1420 valT/= ((*mat)(0,0) +(*mat)(0,1)*dydx1 +(*mat)(0,2)*dzdx1);
1424 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1425 valT = (*mat)(2,0) +(*mat)(2,1)*dydx1 +(*mat)(2,2)*dzdx1;
1426 valT/= ((*mat)(0,0) +(*mat)(0,1)*dydx1 +(*mat)(0,2)*dzdx1);
1430 // onlys shift in angle
1431 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1432 valT = (*mat)(1,0) +(*mat)(1,1)*dydx1;
1436 // only shift in angle
1437 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
1438 valT = (*mat)(2,0) +(*mat)(2,1)*dydx1;
1449 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
1450 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
1451 AliXRDPROOFtoolkit tool;
1452 TChain * chainTr = tool.MakeChain("align.txt","Track",0,10200);
1454 TChain * chainTracklet = tool.MakeChain("align.txt","Tracklet",0,20);
1455 chainTracklet->Lookup();
1458 TCut cutS0("sqrt(tp2.fC[0]+tp2.fC[0])<0.6");
1459 TCut cutS1("sqrt(tp2.fC[2]+tp2.fC[2])<0.6");
1460 TCut cutS2("sqrt(tp2.fC[5]+tp2.fC[5])<0.04");
1461 TCut cutS3("sqrt(tp2.fC[9]+tp2.fC[9])<0.02");
1462 TCut cutS4("sqrt(tp2.fC[14]+tp2.fC[14])<0.5");
1464 TCut cutS=cutS0+cutS1+cutS2+cutS3+cutS4;
1466 TCut cutP0("abs(tp1.fP[0]-tp2.fP[0])<0.6");
1467 TCut cutP1("abs(tp1.fP[1]-tp2.fP[1])<0.6");
1468 TCut cutP2("abs(tp1.fP[2]-tp2.fP[2])<0.02");
1469 TCut cutP3("abs(tp1.fP[3]-tp2.fP[3])<0.01");
1470 TCut cutE("abs(tp2.fP[1])<235");
1471 TCut cutP=cutP0+cutP1+cutP2+cutP3+cutE;
1476 TCut cutA = cutP+cutS;
1477 chainTr->Draw(">>listEL",cutA,"entryList");
1478 TEntryList *elist = (TEntryList*)gDirectory->Get("listEL");
1479 chainTr->SetEntryList(elist);
1486 TCut cutS("s1%36==s2%36");
1488 TCut cutN("c1>32&&c2>60");
1489 TCut cutC0("sqrt(tp2.fC[0])<1");
1491 TCut cutX("abs(tp2.fX-133.6)<2");
1493 TCut cutA = cutP+cutN;
1496 TCut cutY("abs(vcY.fElements-vtY.fElements)<0.3&&vcY.fElements!=0")
1497 TCut cutZ("abs(vcZ.fElements-vtZ.fElements)<0.3&&vcZ.fElements!=0")
1504 TCut cutA = cutP+cutS;
1505 chainTracklet->Draw(">>listEL",cutA,"entryList");
1506 TEntryList *elist = (TEntryList*)gDirectory->Get("listEL");
1507 chainTracklet->SetEntryList(elist);
1510 TVectorD * vec1 = 0;
1511 TVectorD * vec2 = 0;
1512 AliExternalTrackParam * tp1 = 0;
1513 AliExternalTrackParam * tp2 = 0;
1517 chainTracklet->GetBranch("v1.")->SetAddress(&vec1);
1518 chainTracklet->GetBranch("v2.")->SetAddress(&vec2);
1519 chainTracklet->GetBranch("s1")->SetAddress(&s1);
1520 chainTracklet->GetBranch("s2")->SetAddress(&s2);
1523 AliTPCcalibAlign align;
1525 for (Int_t i=0; i< elist->GetN(); i++){
1526 //for (Int_t i=0; i<100000; i++){
1527 chainTracklet->GetBranch("tp1.")->SetAddress(&tp1);
1528 chainTracklet->GetBranch("tp2.")->SetAddress(&tp2);
1529 chainTracklet->GetBranch("v1.")->SetAddress(&vec1);
1530 chainTracklet->GetBranch("v2.")->SetAddress(&vec2);
1531 chainTracklet->GetBranch("s1")->SetAddress(&s1);
1532 chainTracklet->GetBranch("s2")->SetAddress(&s2);
1534 chainTracklet->GetEntry(i);
1535 if (i%100==0) printf("%d\t%d\t%d\t%d\t\n",i,tentry, s1,s2);
1537 TLinearFitter * fitter = align.GetOrMakeFitter6(s1,s2);
1538 if (fitter) align.Process6(vec1->GetMatrixArray(),vec2->GetMatrixArray(),fitter);