AliEveEventManager
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibAlign.cxx
CommitLineData
9318a5b4 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17///////////////////////////////////////////////////////////////////////////////
18// //
19// Class to make a internal alignemnt of TPC chambers //
20//
967eae0d 21// Requierements - Warnings:
22// 1. Before using this componenent the magnetic filed has to be set properly //
1c1a1176 23// 2. The systematic effects - unlinearities has to be understood
967eae0d 24//
1c1a1176 25// If systematic and unlinearities are not under control
26// the alignment is just effective alignment. Not second order corrction
27// are calculated.
28//
29// The histograming of the edge effects and unlineratities integral part
30// of the component (currently only in debug stream)
31//
32// 3 general type of linear transformation investigated (see bellow)
33//
34// By default only 6 parameter alignment to be used - other just for QA purposes
f8a2dcfb 35
1c1a1176 36// Different linear tranformation investigated
972cf6f2 37// 12 parameters - arbitrary linear transformation
f8a2dcfb 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]
41//
9318a5b4 42// 9 parameters - scaling fixed to 1
f8a2dcfb 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]
46//
972cf6f2 47// 6 parameters - x-y rotation x-z, y-z tiliting
f8a2dcfb 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]
51//
1c1a1176 52//
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
57// stored there
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
67
68//
8f74ae77 69//
70/*
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);
75 chain->Lookup();
76*/
1c1a1176 77
9318a5b4 78////
79////
80
81#include "TLinearFitter.h"
82#include "AliTPCcalibAlign.h"
83#include "AliExternalTrackParam.h"
e4042305 84#include "AliTPCTracklet.h"
85#include "TH1D.h"
7eaa723e 86#include "TVectorD.h"
e149f26d 87#include "TTreeStream.h"
7eaa723e 88#include "TFile.h"
e81dc112 89#include "TF1.h"
8b3c60d8 90#include "TGraphErrors.h"
967eae0d 91#include "AliTPCclusterMI.h"
92#include "AliTPCseed.h"
93#include "AliTracker.h"
94#include "TClonesArray.h"
9318a5b4 95
8b3c60d8 96
97#include "TTreeStream.h"
9318a5b4 98#include <iostream>
e4042305 99#include <sstream>
9318a5b4 100using namespace std;
101
102ClassImp(AliTPCcalibAlign)
103
104AliTPCcalibAlign::AliTPCcalibAlign()
e4042305 105 : fDphiHistArray(72*72),
106 fDthetaHistArray(72*72),
107 fDyHistArray(72*72),
108 fDzHistArray(72*72),
109 fFitterArray12(72*72),
110 fFitterArray9(72*72),
111 fFitterArray6(72*72)
9318a5b4 112{
113 //
114 // Constructor
115 //
116 for (Int_t i=0;i<72*72;++i) {
117 fPoints[i]=0;
118 }
119}
120
e149f26d 121AliTPCcalibAlign::AliTPCcalibAlign(const Text_t *name, const Text_t *title)
122 :AliTPCcalibBase(),
123 fDphiHistArray(72*72),
124 fDthetaHistArray(72*72),
125 fDyHistArray(72*72),
126 fDzHistArray(72*72),
127 fFitterArray12(72*72),
128 fFitterArray9(72*72),
129 fFitterArray6(72*72)
130{
131 //
132 // Constructor
133 //
134 SetName(name);
135 SetTitle(title);
136 for (Int_t i=0;i<72*72;++i) {
137 fPoints[i]=0;
138 }
139}
140
9318a5b4 141AliTPCcalibAlign::~AliTPCcalibAlign() {
142 //
143 // destructor
144 //
145}
146
e4042305 147void AliTPCcalibAlign::Process(AliTPCseed *seed) {
148 TObjArray tracklets=
149 AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kKalman,
150 kFALSE,20,2);
cbc19295 151 // TObjArray trackletsL=
152// AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kLinear,
153// kFALSE,20,2);
154// TObjArray trackletsQ=
155// AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kQuadratic,
156// kFALSE,20,2);
157// TObjArray trackletsR=
158// AliTPCTracklet::CreateTracklets(seed,AliTPCTracklet::kRiemann,
159// kFALSE,20,2);
e4042305 160 tracklets.SetOwner();
cbc19295 161 // trackletsL.SetOwner();
162// trackletsQ.SetOwner();
163// trackletsR.SetOwner();
e4042305 164 if (tracklets.GetEntries()==2) {
165 AliTPCTracklet *t1=static_cast<AliTPCTracklet*>(tracklets[0]);
166 AliTPCTracklet *t2=static_cast<AliTPCTracklet*>(tracklets[1]);
167 if (t1->GetSector()>t2->GetSector()) {
168 AliTPCTracklet* tmp=t1;
169 t1=t2;
170 t2=tmp;
171 }
172 AliExternalTrackParam *common1=0,*common2=0;
173 if (AliTPCTracklet::PropagateToMeanX(*t1,*t2,common1,common2))
967eae0d 174 ProcessTracklets(*common1,*common2,seed, t1->GetSector(),t2->GetSector());
e4042305 175 delete common1;
176 delete common2;
177 }
cbc19295 178
e4042305 179}
180
7eaa723e 181void AliTPCcalibAlign::Analyze(){
182 //
183 // Analyze function
184 //
185 EvalFitters();
186}
187
188
189void AliTPCcalibAlign::Terminate(){
190 //
191 // Terminate function
192 // call base terminate + Eval of fitters
193 //
967eae0d 194 if (GetDebugLevel()>0) Info("AliTPCcalibAlign","Terminate");
7eaa723e 195 EvalFitters();
196 AliTPCcalibBase::Terminate();
197}
198
199
200
201
e4042305 202void AliTPCcalibAlign::ProcessTracklets(const AliExternalTrackParam &tp1,
203 const AliExternalTrackParam &tp2,
967eae0d 204 const AliTPCseed * seed,
e4042305 205 Int_t s1,Int_t s2) {
206
972cf6f2 207 //
208 //
209 //
8b3c60d8 210 //
9318a5b4 211 //
212 // Process function to fill fitters
213 //
214 Double_t t1[5],t2[5];
215 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
7eaa723e 216 Double_t &x2=t2[0], &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
9318a5b4 217 x1 =tp1.GetX();
218 y1 =tp1.GetY();
219 z1 =tp1.GetZ();
220 Double_t snp1=tp1.GetSnp();
221 dydx1=snp1/TMath::Sqrt(1.-snp1*snp1);
222 Double_t tgl1=tp1.GetTgl();
223 // dz/dx = 1/(cos(theta)*cos(phi))
7eaa723e 224 dzdx1=tgl1/TMath::Sqrt(1.-snp1*snp1);
225 x2 =tp2.GetX();
9318a5b4 226 y2 =tp2.GetY();
227 z2 =tp2.GetZ();
228 Double_t snp2=tp2.GetSnp();
229 dydx2=snp2/TMath::Sqrt(1.-snp2*snp2);
230 Double_t tgl2=tp2.GetTgl();
7eaa723e 231 dzdx2=tgl2/TMath::Sqrt(1.-snp2*snp2);
7eaa723e 232 //
233 //
234 //
235 if (fStreamLevel>1){
236 TTreeSRedirector *cstream = GetDebugStreamer();
237 if (cstream){
238 static TVectorD vec1(5);
239 static TVectorD vec2(5);
240 vec1.SetElements(t1);
241 vec2.SetElements(t2);
242 AliExternalTrackParam *p1 = &((AliExternalTrackParam&)tp1);
243 AliExternalTrackParam *p2 = &((AliExternalTrackParam&)tp2);
244 (*cstream)<<"Tracklet"<<
245 "tp1.="<<p1<<
246 "tp2.="<<p2<<
247 "v1.="<<&vec1<<
248 "v2.="<<&vec2<<
249 "s1="<<s1<<
250 "s2="<<s2<<
251 "\n";
252 }
253 }
8b3c60d8 254 //
255 // Aplly cut selection
256 /*
ae0ac7be 257 TChain * chainalign = tool.MakeChain("align.txt","Tracklet",0,1000000)
258 chainalign->Lookup();
259
8b3c60d8 260 // Cuts to be justified with the debug streamer
261 //
7b18d067 262 TCut c1pt("abs((tp1.fP[4]+tp2.fP[4])*0.5)<3"); // pt cut - OK
263 TCut cdy("abs(tp1.fP[0]-tp2.fP[0])<2");
264 TCut cdz("abs(tp1.fP[1]-tp2.fP[1])<2");
265 TCut cdphi("abs(tp1.fP[2]-tp2.fP[2])<0.02");
266 TCut cdt("abs(tp1.fP[3]-tp2.fP[3])<0.02");
267 TCut cd1pt("abs(tp1.fP[4]-tp2.fP[4])<0.3"); // delta 1/pt cut -OK
8b3c60d8 268 //
269 //
7b18d067 270 TCut acut = c1pt+cdy+cdz+cdphi+cdt+cd1pt;
ae0ac7be 271
8b3c60d8 272 */
273 // 1. pt cut
7b18d067 274 // 2. dy
275 // 3. dz
276 // 4. dphi
277 // 5. dtheta
278 // 6. d1pt
ae0ac7be 279 printf("Process track\n");
7b18d067 280 if (TMath::Abs(tp1.GetParameter()[0]-tp2.GetParameter()[0])>2) return;
281 if (TMath::Abs(tp1.GetParameter()[1]-tp2.GetParameter()[1])>2) return;
282 if (TMath::Abs(tp1.GetParameter()[2]-tp2.GetParameter()[2])>0.02) return;
283 if (TMath::Abs(tp1.GetParameter()[3]-tp2.GetParameter()[3])>0.02) return;
284 if (TMath::Abs(tp1.GetParameter()[4]-tp2.GetParameter()[4])>0.3) return;
ae0ac7be 285 if (TMath::Abs((tp1.GetParameter()[4]+tp2.GetParameter()[4])*0.5)>3) return;
286 if (TMath::Abs((tp1.GetParameter()[0]-tp2.GetParameter()[0]))<0.000000001) return;
287 printf("Filling track\n");
8b3c60d8 288 //
289 // fill resolution histograms - previous cut included
290 FillHisto(tp1,tp2,s1,s2);
291 //
9318a5b4 292 Process12(t1,t2,GetOrMakeFitter12(s1,s2));
7eaa723e 293 Process9(t1,t2,GetOrMakeFitter9(s1,s2));
294 Process6(t1,t2,GetOrMakeFitter6(s1,s2));
967eae0d 295 ProcessDiff(tp1,tp2, seed,s1,s2);
e81dc112 296 ++fPoints[GetIndex(s1,s2)];
9318a5b4 297}
298
967eae0d 299void AliTPCcalibAlign::ProcessDiff(const AliExternalTrackParam &t1,
300 const AliExternalTrackParam &t2,
301 const AliTPCseed *seed,
302 Int_t s1,Int_t s2)
303{
304 //
305 // Process local residuals function
306 //
307 TVectorD vecX(160);
308 TVectorD vecY(160);
309 TVectorD vecZ(160);
310 TVectorD vecClY(160);
311 TVectorD vecClZ(160);
312 TClonesArray arrCl("AliTPCclusterMI",160);
313 arrCl.ExpandCreateFast(160);
314 Int_t count1=0, count2=0;
315 for (Int_t i=0;i<160;++i) {
316 AliTPCclusterMI *c=seed->GetClusterPointer(i);
317 vecX[i]=0;
318 vecY[i]=0;
319 vecZ[i]=0;
320 if (!c) continue;
321 AliTPCclusterMI & cl = (AliTPCclusterMI&) (*arrCl[i]);
322 if (c->GetDetector()!=s1 && c->GetDetector()!=s2) continue;
323 vecClY[i] = c->GetY();
324 vecClZ[i] = c->GetZ();
325 cl=*c;
326 const AliExternalTrackParam *par = (c->GetDetector()==s1)? &t1:&t2;
327 if (c->GetDetector()==s1) ++count1;
328 if (c->GetDetector()==s2) ++count2;
329 Double_t gxyz[3],xyz[3];
330 t1.GetXYZ(gxyz);
331 Float_t bz = AliTracker::GetBz(gxyz);
332 par->GetYAt(c->GetX(), bz, xyz[1]);
333 par->GetZAt(c->GetX(), bz, xyz[2]);
334 vecX[i] = c->GetX();
335 vecY[i]= xyz[1];
336 vecZ[i]= xyz[2];
337 }
338 //
339 //
340 if (fStreamLevel>5){
341 //
342 // huge output - cluster residuals to be investigated
343 //
344 TTreeSRedirector *cstream = GetDebugStreamer();
345 AliTPCseed * t = (AliTPCseed*) seed;
346 //AliExternalTrackParam *p0 = &((AliExternalTrackParam&)seed);
347 AliExternalTrackParam *p1 = &((AliExternalTrackParam&)t1);
348 AliExternalTrackParam *p2 = &((AliExternalTrackParam&)t2);
1c1a1176 349 /*
350
351 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");
352
353 */
354
967eae0d 355 if (cstream){
356 (*cstream)<<"Track"<<
357 "Cl.="<<&arrCl<<
358 //"tp0.="<<p0<<
359 "tp1.="<<p1<<
360 "tp2.="<<p2<<
361 "vtX.="<<&vecX<<
362 "vtY.="<<&vecY<<
363 "vtZ.="<<&vecZ<<
364 "vcY.="<<&vecClY<<
365 "vcZ.="<<&vecClZ<<
366 "s1="<<s1<<
367 "s2="<<s2<<
368 "c1="<<count1<<
369 "c2="<<count2<<
370 "\n";
371 }
372 }
373}
374
375
376
377
7eaa723e 378void AliTPCcalibAlign::Process12(const Double_t *t1,
379 const Double_t *t2,
9318a5b4 380 TLinearFitter *fitter) {
381 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
382 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
383 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
384 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
385 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
386 //
f8a2dcfb 387 // a00 a01 a02 a03 p[0] p[1] p[2] p[9]
388 // a10 a11 a12 a13 ==> p[3] p[4] p[5] p[10]
389 // a20 a21 a22 a23 p[6] p[7] p[8] p[11]
390
391
392
7eaa723e 393 const Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
394 const Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
9318a5b4 395
396 // TODO:
7eaa723e 397 Double_t sy = 0.1;
398 Double_t sz = 0.1;
399 Double_t sdydx = 0.001;
400 Double_t sdzdx = 0.001;
9318a5b4 401
402 Double_t p[12];
403 Double_t value;
404
405 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
406 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
407 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
408 for (Int_t i=0; i<12;i++) p[i]=0.;
409 p[3+0] = x1; // a10
410 p[3+1] = y1; // a11
411 p[3+2] = z1; // a12
412 p[9+1] = 1.; // a13
413 p[0+1] = y1*dydx2; // a01
414 p[0+2] = z1*dydx2; // a02
415 p[9+0] = dydx2; // a03
416 value = y2;
417 fitter->AddPoint(p,value,sy);
418
419 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
420 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
421 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
422 for (Int_t i=0; i<12;i++) p[i]=0.;
423 p[6+0] = x1; // a20
424 p[6+1] = y1; // a21
425 p[6+2] = z1; // a22
426 p[9+2] = 1.; // a23
427 p[0+1] = y1*dzdx2; // a01
428 p[0+2] = z1*dzdx2; // a02
429 p[9+0] = dzdx2; // a03
430 value = z2;
431 fitter->AddPoint(p,value,sz);
432
433 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
434 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
435 for (Int_t i=0; i<12;i++) p[i]=0.;
436 p[3+0] = 1.; // a10
437 p[3+1] = dydx1; // a11
438 p[3+2] = dzdx1; // a12
439 p[0+0] = -dydx2; // a00
440 p[0+1] = -dydx1*dydx2; // a01
441 p[0+2] = -dzdx1*dydx2; // a02
442 value = 0.;
443 fitter->AddPoint(p,value,sdydx);
444
445 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
446 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
447 for (Int_t i=0; i<12;i++) p[i]=0.;
448 p[6+0] = 1; // a20
449 p[6+1] = dydx1; // a21
450 p[6+2] = dzdx1; // a22
451 p[0+0] = -dzdx2; // a00
452 p[0+1] = -dydx1*dzdx2; // a01
453 p[0+2] = -dzdx1*dzdx2; // a02
454 value = 0.;
455 fitter->AddPoint(p,value,sdzdx);
456}
457
458void AliTPCcalibAlign::Process9(Double_t *t1,
459 Double_t *t2,
460 TLinearFitter *fitter) {
461 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
462 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
463 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
464 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
465 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
466 //
f8a2dcfb 467 // a00 a01 a02 a03 1 p[0] p[1] p[6]
468 // a10 a11 a12 a13 ==> p[2] 1 p[3] p[7]
469 // a20 a21 a21 a23 p[4] p[5] 1 p[8]
470
471
9318a5b4 472 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
cec17745 473 Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
9318a5b4 474
475 // TODO:
f8a2dcfb 476 Double_t sy = 0.1;
477 Double_t sz = 0.1;
478 Double_t sdydx = 0.001;
479 Double_t sdzdx = 0.001;
480 //
9318a5b4 481 Double_t p[12];
482 Double_t value;
483
484 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
485 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
f8a2dcfb 486 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
9318a5b4 487 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 488 p[2] += x1; // a10
489 //p[] +=1; // a11
490 p[3] += z1; // a12
491 p[7] += 1; // a13
492 p[0] += y1*dydx2; // a01
493 p[1] += z1*dydx2; // a02
494 p[6] += dydx2; // a03
495 value = y2-y1; //-a11
9318a5b4 496 fitter->AddPoint(p,value,sy);
f8a2dcfb 497 //
9318a5b4 498 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
499 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
f8a2dcfb 500 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
9318a5b4 501 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 502 p[4] += x1; // a20
503 p[5] += y1; // a21
504 //p[] += z1; // a22
505 p[8] += 1.; // a23
506 p[0] += y1*dzdx2; // a01
507 p[1] += z1*dzdx2; // a02
508 p[6] += dzdx2; // a03
509 value = z2-z1; //-a22
9318a5b4 510 fitter->AddPoint(p,value,sz);
511
512 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
513 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
514 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 515 p[2] += 1.; // a10
516 //p[] += dydx1; // a11
517 p[3] += dzdx1; // a12
518 //p[] += -dydx2; // a00
519 p[0] += -dydx1*dydx2; // a01
520 p[1] += -dzdx1*dydx2; // a02
521 value = -dydx1+dydx2; // -a11 + a00
9318a5b4 522 fitter->AddPoint(p,value,sdydx);
523
524 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
525 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
526 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 527 p[4] += 1; // a20
528 p[5] += dydx1; // a21
529 //p[] += dzdx1; // a22
530 //p[] += -dzdx2; // a00
531 p[0] += -dydx1*dzdx2; // a01
532 p[1] += -dzdx1*dzdx2; // a02
533 value = -dzdx1+dzdx2; // -a22 + a00
9318a5b4 534 fitter->AddPoint(p,value,sdzdx);
535}
536
537void AliTPCcalibAlign::Process6(Double_t *t1,
538 Double_t *t2,
539 TLinearFitter *fitter) {
540 // x2 = 1 *x1 +-a01*y1 + 0 +a03
541 // y2 = a01*x1 + 1 *y1 + 0 +a13
542 // z2 = a20*x1 + a21*y1 + 1 *z1 +a23
543 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
544 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/(a00 + a01*dydx1 + a02*dzdx1)
545 //
f8a2dcfb 546 // a00 a01 a02 a03 1 -p[0] 0 p[3]
547 // a10 a11 a12 a13 ==> p[0] 1 0 p[4]
548 // a20 a21 a21 a23 p[1] p[2] 1 p[5]
549
9318a5b4 550 Double_t &x1=t1[0], &y1=t1[1], &z1=t1[2], &dydx1=t1[3], &dzdx1=t1[4];
cec17745 551 Double_t /*&x2=t2[0],*/ &y2=t2[1], &z2=t2[2], &dydx2=t2[3], &dzdx2=t2[4];
9318a5b4 552
553 // TODO:
7eaa723e 554 Double_t sy = 0.1;
555 Double_t sz = 0.1;
556 Double_t sdydx = 0.001;
557 Double_t sdzdx = 0.001;
9318a5b4 558
559 Double_t p[12];
560 Double_t value;
f8a2dcfb 561 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
562 // y2 = a10*x1 + a11*y1 + a12*z1 + a13
9318a5b4 563 // y2' = a10*x1 + a11*y1 + a12*z1 + a13 + (a01*y1 + a02*z1 + a03)*dydx2
564 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 565 p[0] += x1; // a10
566 //p[] +=1; // a11
567 //p[] += z1; // a12
568 p[4] += 1; // a13
569 p[0] += -y1*dydx2; // a01
570 //p[] += z1*dydx2; // a02
571 p[3] += dydx2; // a03
572 value = y2-y1; //-a11
9318a5b4 573 fitter->AddPoint(p,value,sy);
f8a2dcfb 574 //
575 // x2 = a00*x1 + a01*y1 + a02*z1 + a03
576 // z2 = a20*x1 + a21*y1 + a22*z1 + a23
577 // z2' = a20*x1 + a21*y1 + a22*z1 + a23 + (a01*y1 + a02*z1 + a03)*dzdx2;
9318a5b4 578 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 579 p[1] += x1; // a20
580 p[2] += y1; // a21
581 //p[] += z1; // a22
582 p[5] += 1.; // a23
583 p[0] += -y1*dzdx2; // a01
584 //p[] += z1*dzdx2; // a02
585 p[3] += dzdx2; // a03
586 value = z2-z1; //-a22
9318a5b4 587 fitter->AddPoint(p,value,sz);
588
589 // dydx2 = (a10 + a11*dydx1 + a12*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
590 // (a10 + a11*dydx1 + a12*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dydx2 = 0
591 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 592 p[0] += 1.; // a10
593 //p[] += dydx1; // a11
594 //p[] += dzdx1; // a12
595 //p[] += -dydx2; // a00
596 p[0] += dydx1*dydx2; // a01
597 //p[] += -dzdx1*dydx2; // a02
598 value = -dydx1+dydx2; // -a11 + a00
9318a5b4 599 fitter->AddPoint(p,value,sdydx);
600
601 // dzdx2 = (a20 + a21*dydx1 + a22*dzdx1)/( a00 + a01*dydx1 + a02*dzdx1)
602 // (a20 + a21*dydx1 + a22*dzdx1) - (a00 + a01*dydx1 + a02*dzdx1)*dzdx2 = 0
603 for (Int_t i=0; i<12;i++) p[i]=0.;
f8a2dcfb 604 p[1] += 1; // a20
605 p[2] += dydx1; // a21
606 //p[] += dzdx1; // a22
607 //p[] += -dzdx2; // a00
608 p[0] += dydx1*dzdx2; // a01
609 //p[] += -dzdx1*dzdx2; // a02
610 value = -dzdx1+dzdx2; // -a22 + a00
9318a5b4 611 fitter->AddPoint(p,value,sdzdx);
612}
613
7eaa723e 614
615
616
617void AliTPCcalibAlign::EvalFitters() {
618 //
619 // Analyze function
620 //
621 // Perform the fitting using linear fitters
622 //
623 Int_t kMinPoints =50;
9318a5b4 624 TLinearFitter *f;
7eaa723e 625 TFile fff("alignDebug.root","recreate");
9318a5b4 626 for (Int_t s1=0;s1<72;++s1)
7eaa723e 627 for (Int_t s2=0;s2<72;++s2){
e81dc112 628 if ((f=GetFitter12(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
629 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
0ebabeb6 630 if (f->Eval()!=0) {
9318a5b4 631 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
7eaa723e 632 f->Write(Form("f12_%d_%d",s1,s2));
633 }else{
634 f->Write(Form("f12_%d_%d",s1,s2));
9318a5b4 635 }
636 }
e81dc112 637 if ((f=GetFitter9(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
638 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
0ebabeb6 639 if (f->Eval()!=0) {
7eaa723e 640 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
641 }else{
642 f->Write(Form("f9_%d_%d",s1,s2));
643 }
644 }
e81dc112 645 if ((f=GetFitter6(s1,s2))&&fPoints[GetIndex(s1,s2)]>kMinPoints) {
646 // cerr<<s1<<","<<s2<<": "<<fPoints[GetIndex(s1,s2)]<<endl;
972cf6f2 647 if (f->Eval()!=0) {
7eaa723e 648 cerr<<"Evaluation failed for "<<s1<<","<<s2<<endl;
649 }else{
650 f->Write(Form("f6_%d_%d",s1,s2));
651 }
652 }
653 }
0ebabeb6 654 this->Write("align");
9318a5b4 655 /*
656
657 fitter->Eval();
658 fitter->Eval();
659 chi212 = align->GetChisquare()/(4.*entries);
660
661 TMatrixD mat(13,13);
662 TVectorD par(13);
663 align->GetParameters(par);
664 align->GetCovarianceMatrix(mat);
665
666 //
667 //
668 for (Int_t i=0; i<12;i++){
669 palign12(i)= par(i+1);
670 for (Int_t j=0; j<12;j++){
671 pcovar12(i,j) = mat(i+1,j+1);
672 pcovar12(i,j) *= chi212;
673 }
674 }
675 //
676 for (Int_t i=0; i<12;i++){
677 psigma12(i) = TMath::Sqrt(pcovar12(i,i));
678 palignR12(i) = palign12(i)/TMath::Sqrt(pcovar12(i,i));
679 for (Int_t j=0; j<12;j++){
680 pcovarN12(i,j) = pcovar12(i,j)/TMath::Sqrt(pcovar12(i,i)*pcovar12(j,j));
681 }
682 }
683 */
684}
685
972cf6f2 686TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter12(Int_t s1,Int_t s2) {
687 //
688 // get or make fitter - general linear transformation
689 //
e81dc112 690 static Int_t counter12=0;
691 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]");
972cf6f2 692 TLinearFitter * fitter = GetFitter12(s1,s2);
693 if (fitter) return fitter;
e81dc112 694 // 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]");
695 fitter =new TLinearFitter(&f12,"");
972cf6f2 696 fitter->StoreData(kFALSE);
e81dc112 697 fFitterArray12.AddAt(fitter,GetIndex(s1,s2));
698 counter12++;
699 if (GetDebugLevel()>0) cerr<<"Creating fitter12 "<<s1<<","<<s2<<" : "<<counter12<<endl;
972cf6f2 700 return fitter;
701}
702
703TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter9(Int_t s1,Int_t s2) {
704 //
705 //get or make fitter - general linear transformation - no scaling
706 //
e81dc112 707 static Int_t counter9=0;
708 static TF1 f9("f9","x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]");
972cf6f2 709 TLinearFitter * fitter = GetFitter9(s1,s2);
710 if (fitter) return fitter;
e81dc112 711 // fitter =new TLinearFitter(9,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]++x[6]++x[7]++x[8]");
712 fitter =new TLinearFitter(&f9,"");
972cf6f2 713 fitter->StoreData(kFALSE);
714 fFitterArray9.AddAt(fitter,GetIndex(s1,s2));
e81dc112 715 counter9++;
716 if (GetDebugLevel()>0) cerr<<"Creating fitter12 "<<s1<<","<<s2<<" : "<<counter9<<endl;
972cf6f2 717 return fitter;
718}
719
720TLinearFitter* AliTPCcalibAlign::GetOrMakeFitter6(Int_t s1,Int_t s2) {
721 //
722 // get or make fitter - 6 paramater linear tranformation
723 // - no scaling
724 // - rotation x-y
725 // - tilting x-z, y-z
e81dc112 726 static Int_t counter6=0;
727 static TF1 f6("f6","x[0]++x[1]++x[2]++x[3]++x[4]++x[5]");
972cf6f2 728 TLinearFitter * fitter = GetFitter6(s1,s2);
729 if (fitter) return fitter;
e81dc112 730 // fitter=new TLinearFitter(6,"x[0]++x[1]++x[2]++x[3]++x[4]++x[5]");
731 fitter=new TLinearFitter(&f6,"");
972cf6f2 732 fitter->StoreData(kFALSE);
733 fFitterArray6.AddAt(fitter,GetIndex(s1,s2));
e81dc112 734 counter6++;
735 if (GetDebugLevel()>0) cerr<<"Creating fitter6 "<<s1<<","<<s2<<" : "<<counter6<<endl;
972cf6f2 736 return fitter;
737}
738
739
740
741
742
9318a5b4 743Bool_t AliTPCcalibAlign::GetTransformation12(Int_t s1,Int_t s2,TMatrixD &a) {
972cf6f2 744 //
745 // GetTransformation matrix - 12 paramaters - generael linear transformation
746 //
9318a5b4 747 if (!GetFitter12(s1,s2))
748 return false;
749 else {
750 TVectorD p(12);
9318a5b4 751 GetFitter12(s1,s2)->GetParameters(p);
9318a5b4 752 a.ResizeTo(4,4);
972cf6f2 753 a[0][0]=p[0]; a[0][1]=p[1]; a[0][2]=p[2]; a[0][3]=p[9];
754 a[1][0]=p[3]; a[1][1]=p[4]; a[1][2]=p[5]; a[1][3]=p[10];
755 a[2][0]=p[6]; a[2][1]=p[7]; a[2][2]=p[8]; a[2][3]=p[11];
756 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
9318a5b4 757 return true;
758 }
759}
760
761Bool_t AliTPCcalibAlign::GetTransformation9(Int_t s1,Int_t s2,TMatrixD &a) {
972cf6f2 762 //
763 // GetTransformation matrix - 9 paramaters - general linear transformation
764 // No scaling
765 //
9318a5b4 766 if (!GetFitter9(s1,s2))
767 return false;
768 else {
769 TVectorD p(9);
770 GetFitter9(s1,s2)->GetParameters(p);
771 a.ResizeTo(4,4);
f8a2dcfb 772 a[0][0]=1; a[0][1]=p[0]; a[0][2]=p[1]; a[0][3]=p[6];
773 a[1][0]=p[2]; a[1][1]=1; a[1][2]=p[3]; a[1][3]=p[7];
774 a[2][0]=p[4]; a[2][1]=p[5]; a[2][2]=1; a[2][3]=p[8];
972cf6f2 775 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
9318a5b4 776 return true;
777 }
778}
779
780Bool_t AliTPCcalibAlign::GetTransformation6(Int_t s1,Int_t s2,TMatrixD &a) {
972cf6f2 781 //
782 // GetTransformation matrix - 6 paramaters
783 // 3 translation
784 // 1 rotation -x-y
785 // 2 tilting x-z y-z
9318a5b4 786 if (!GetFitter6(s1,s2))
787 return false;
788 else {
789 TVectorD p(6);
9318a5b4 790 GetFitter6(s1,s2)->GetParameters(p);
9318a5b4 791 a.ResizeTo(4,4);
f8a2dcfb 792 a[0][0]=1; a[0][1]=-p[0];a[0][2]=0; a[0][3]=p[3];
793 a[1][0]=p[0]; a[1][1]=1; a[1][2]=0; a[1][3]=p[4];
794 a[2][0]=p[1]; a[2][1]=p[2]; a[2][2]=1; a[2][3]=p[5];
972cf6f2 795 a[3][0]=0.; a[3][1]=0.; a[3][2]=0.; a[3][3]=1.;
9318a5b4 796 return true;
797 }
798}
972cf6f2 799
800void AliTPCcalibAlign::FillHisto(const AliExternalTrackParam &tp1,
801 const AliExternalTrackParam &tp2,
802 Int_t s1,Int_t s2) {
803 //
804 // Fill residual histograms
8b3c60d8 805 // Innner-Outer
806 // Left right - x-y
807 // A-C side
808 if (TMath::Abs(s2%36-s1%36)<2 || TMath::Abs(s2%18-s1%18)==0) {
972cf6f2 809 GetHisto(kPhi,s1,s2,kTRUE)->Fill(TMath::ASin(tp1.GetSnp())-TMath::ASin(tp2.GetSnp()));
810 GetHisto(kTheta,s1,s2,kTRUE)->Fill(TMath::ATan(tp1.GetTgl())-TMath::ATan(tp2.GetTgl()));
811 GetHisto(kY,s1,s2,kTRUE)->Fill(tp1.GetY()-tp2.GetY());
812 GetHisto(kZ,s1,s2,kTRUE)->Fill(tp1.GetZ()-tp2.GetZ());
813 }
814}
815
816
817
818TH1 * AliTPCcalibAlign::GetHisto(HistoType type, Int_t s1, Int_t s2, Bool_t force)
819{
820 //
821 // return specified residual histogram - it is only QA
822 // if force specified the histogram and given histogram is not existing
823 // new histogram is created
824 //
825 if (GetIndex(s1,s2)>=72*72) return 0;
826 TObjArray *histoArray=0;
827 switch (type) {
828 case kY:
829 histoArray = &fDyHistArray; break;
830 case kZ:
831 histoArray = &fDzHistArray; break;
832 case kPhi:
833 histoArray = &fDphiHistArray; break;
834 case kTheta:
835 histoArray = &fDthetaHistArray; break;
836 }
837 TH1 * histo= (TH1*)histoArray->At(GetIndex(s1,s2));
838 if (histo) return histo;
839 if (force==kFALSE) return 0;
840 //
841 stringstream name;
842 stringstream title;
843 switch (type) {
844 case kY:
845 name<<"hist_y_"<<s1<<"_"<<s2;
846 title<<"Y Missalignment for sectors "<<s1<<" and "<<s2;
847 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
848 break;
849 case kZ:
850 name<<"hist_z_"<<s1<<"_"<<s2;
851 title<<"Z Missalignment for sectors "<<s1<<" and "<<s2;
852 histo = new TH1D(name.str().c_str(),title.str().c_str(),512,-0.3,0.3); // +/- 3 mm
853 break;
854 case kPhi:
855 name<<"hist_phi_"<<s1<<"_"<<s2;
856 title<<"Phi Missalignment for sectors "<<s1<<" and "<<s2;
857 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
858 break;
859 case kTheta:
860 name<<"hist_theta_"<<s1<<"_"<<s2;
861 title<<"Theta Missalignment for sectors "<<s1<<" and "<<s2;
862 histo =new TH1D(name.str().c_str(),title.str().c_str(),512,-0.01,0.01); // +/- 10 mrad
863 break;
864 }
865 histo->SetDirectory(0);
866 histoArray->AddAt(histo,GetIndex(s1,s2));
867 return histo;
868}
8b3c60d8 869
870TGraphErrors * AliTPCcalibAlign::MakeGraph(Int_t sec0, Int_t sec1, Int_t dsec,
871 Int_t i0, Int_t i1, FitType type)
872{
873 //
874 //
875 //
876 TMatrixD mat;
877 TObjArray *fitArray=0;
878 Double_t xsec[1000];
879 Double_t ysec[1000];
880 Int_t npoints=0;
881 for (Int_t isec = sec0; isec<=sec1; isec++){
882 Int_t isec2 = (isec+dsec)%72;
883 switch (type) {
884 case k6:
885 GetTransformation6(isec,isec2,mat);break;
886 case k9:
887 GetTransformation9(isec,isec2,mat);break;
888 case k12:
889 GetTransformation12(isec,isec2,mat);break;
890 }
891 xsec[npoints]=isec;
892 ysec[npoints]=mat(i0,i1);
893 ++npoints;
894 }
895 TGraphErrors *gr = new TGraphErrors(npoints,xsec,ysec,0,0);
896 Char_t name[1000];
897 sprintf(name,"Mat[%d,%d] Type=%d",i0,i1,type);
898 gr->SetName(name);
899 return gr;
900}
901
902void AliTPCcalibAlign::MakeTree(const char *fname){
903 //
904 // make tree with alignment cosntant -
905 // For QA visualization
906 //
ae0ac7be 907 /*
908 TFile f("CalibObjects.root");
909 TObjArray *array = (TObjArray*)f.Get("TPCCalib");
910 AliTPCcalibAlign *alignTPC = (AliTPCcalibAlign *)array->At(0);
911 alignTPC->MakeTree("alignTree.root");
912 TFile falign("alignTree.root");
913 Align->Draw("dy")
914 */
8b3c60d8 915 const Int_t kMinPoints=50;
916 TTreeSRedirector cstream(fname);
917 for (Int_t s1=0;s1<72;++s1)
918 for (Int_t s2=0;s2<72;++s2){
919 if (fPoints[GetIndex(s1,s2)]<kMinPoints) continue;
920 TMatrixD m6;
921 TMatrixD m9;
922 TMatrixD m12;
923 GetTransformation6(s1,s2,m6);
924 GetTransformation9(s1,s2,m9);
925 GetTransformation12(s1,s2,m12);
926 Double_t dy=0, dz=0, dphi=0,dtheta=0;
927 Double_t sy=0, sz=0, sphi=0,stheta=0;
928 Double_t ny=0, nz=0, nphi=0,ntheta=0;
929 TH1 * his=0;
930 his = GetHisto(kY,s1,s2);
931 if (his) { dy = his->GetMean(); sy = his->GetRMS(); ny = his->GetEntries();}
932 his = GetHisto(kZ,s1,s2);
933 if (his) { dz = his->GetMean(); sz = his->GetRMS(); nz = his->GetEntries();}
934 his = GetHisto(kPhi,s1,s2);
935 if (his) { dphi = his->GetMean(); sphi = his->GetRMS(); nphi = his->GetEntries();}
936 his = GetHisto(kTheta,s1,s2);
937 if (his) { dtheta = his->GetMean(); stheta = his->GetRMS(); ntheta = his->GetEntries();}
938 //
939 cstream<<"Align"<<
940 "s1="<<s1<< // reference sector
941 "s2="<<s2<< // sector to align
942 "m6.="<<&m6<< // tranformation matrix
943 "m9.="<<&m9<< //
944 "m12.="<<&m12<<
967eae0d 945 // histograms mean RMS and entries
946 "dy="<<dy<<
8b3c60d8 947 "sy="<<sy<<
948 "ny="<<ny<<
949 "dz="<<dz<<
950 "sz="<<sz<<
951 "nz="<<nz<<
952 "dphi="<<dphi<<
953 "sphi="<<sphi<<
954 "nphi="<<nphi<<
955 "dtheta="<<dtheta<<
956 "stheta="<<stheta<<
957 "ntheta="<<ntheta<<
958 "\n";
959 }
960
961}
ae0ac7be 962
963
964//_____________________________________________________________________
965Long64_t AliTPCcalibAlign::Merge(TCollection* list) {
966 //
967 // merge function
968 //
969 if (GetDebugLevel()>0) Info("AliTPCcalibAlign","Merge");
970 if (!list)
971 return 0;
972 if (list->IsEmpty())
973 return 1;
974
975 TIterator* iter = list->MakeIterator();
976 TObject* obj = 0;
977 iter->Reset();
978 Int_t count=0;
979 while((obj = iter->Next()) != 0)
980 {
981 AliTPCcalibAlign* entry = dynamic_cast<AliTPCcalibAlign*>(obj);
982 if (entry == 0) continue;
983 Add(entry);
984 count++;
985 }
986 return count;
987}
988
989
990void AliTPCcalibAlign::Add(AliTPCcalibAlign * align){
991 //
992 // Add entry
993 //
994
995 for (Int_t i=0; i<72;i++){
996 for (Int_t j=0; j<72;j++){
997 fPoints[GetIndex(i,j)]+=align->fPoints[GetIndex(i,j)];
998
999 //
1000 // dy
1001 TH1* hdy0 = GetHisto(kY,i,j);
1002 TH1* hdy1 = align->GetHisto(kY,i,j);
1003 if (hdy1){
1004 if (hdy0) hdy0->Add(hdy1);
1005 else {
1006 hdy0 = GetHisto(kY,i,j,kTRUE);
1007 hdy0->Add(hdy1);
1008 }
1009 }
1010 //
1011 // dz
1012 TH1* hdz0 = GetHisto(kZ,i,j);
1013 TH1* hdz1 = align->GetHisto(kZ,i,j);
1014 if (hdz1){
1015 if (hdz0) hdz0->Add(hdz1);
1016 else {
1017 hdz0 = GetHisto(kZ,i,j,kTRUE);
1018 hdz0->Add(hdz1);
1019 }
1020 }
1021 //
1022 // dphi
1023 TH1* hdphi0 = GetHisto(kPhi,i,j);
1024 TH1* hdphi1 = align->GetHisto(kPhi,i,j);
1025 if (hdphi1){
1026 if (hdphi0) hdphi0->Add(hdphi1);
1027 else {
1028 hdphi0 = GetHisto(kPhi,i,j,kTRUE);
1029 hdphi0->Add(hdphi1);
1030 }
1031 }
1032 //
1033 // dtheta
1034 TH1* hdTheta0 = GetHisto(kTheta,i,j);
1035 TH1* hdTheta1 = align->GetHisto(kTheta,i,j);
1036 if (hdTheta1){
1037 if (hdTheta0) hdTheta0->Add(hdTheta1);
1038 else {
1039 hdTheta0 = GetHisto(kTheta,i,j,kTRUE);
1040 hdTheta0->Add(hdTheta1);
1041 }
1042 }
1043 }
1044 }
1045 TLinearFitter *f0=0;
1046 TLinearFitter *f1=0;
1047 for (Int_t i=0; i<72;i++){
1048 for (Int_t j=0; j<72;j++){
1049 //
1050 // fitter12
1051 f0 = GetFitter12(i,j);
1052 f1 = GetFitter12(i,j);
1053 if (f1){
1054 if (f0) f0->Add(f1);
1055 else {
1056 f0 = GetOrMakeFitter12(i,j);
1057 f0->Add(f1);
1058 }
1059 }
1060 //
1061 // fitter9
1062 f0 = GetFitter9(i,j);
1063 f1 = GetFitter9(i,j);
1064 if (f1){
1065 if (f0) f0->Add(f1);
1066 else {
1067 f0 = GetOrMakeFitter9(i,j);
1068 f0->Add(f1);
1069 }
1070 }
1071 f0 = GetFitter6(i,j);
1072 f1 = GetFitter6(i,j);
1073 if (f1){
1074 if (f0) f0->Add(f1);
1075 else {
1076 f0 = GetOrMakeFitter6(i,j);
1077 f0->Add(f1);
1078 }
1079 }
1080 }
1081 }
1082}