2 gROOT->Macro("~/rootlogon.C")
3 gSystem->AddIncludePath("-I$ALICE_ROOT/STAT")
4 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC")
5 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros")
6 gSystem->Load("libANALYSIS");
7 gSystem->Load("libTPCcalib");
9 .L $ALICE_ROOT/TPC/CalibMacros/MakeGlobalFit.C+
13 aliroot -b -q $ALICE_ROOT/TPC/CalibMacros/MakeGlobalFit.C | tee globalFit.log
17 #if !defined(__CINT__) || defined(__MAKECINT__)
18 #include "THnSparse.h"
28 #include "TProfile3D.h"
32 #include "TStatToolkit.h"
33 #include "TTreeStream.h"
34 #include "AliExternalTrackParam.h"
35 #include "AliESDfriend.h"
36 #include "AliTPCcalibTime.h"
38 #include "AliXRDPROOFtoolkit.h"
39 #include "AliTPCCorrection.h"
40 #include "AliTPCExBTwist.h"
41 #include "AliTPCGGVoltError.h"
42 #include "AliTPCComposedCorrection.h"
43 #include "AliTPCExBConical.h"
44 #include "TPostScript.h"
46 #include "AliTrackerBase.h"
47 #include "AliTPCCalibGlobalMisalignment.h"
48 #include "AliTPCExBEffective.h"
49 #include "TEntryList.h"
52 const char* chDetName[5]={"ITS","TRD", "Vertex", "TOF","Laser"};
53 const char* chParName[5]={"rphi","z", "snp", "tan","1/pt"};
54 const char* chSideName[2]={"A side","C side"};
55 Bool_t enableDet[5]={1,1,1,1,1}; // detector for fit ITS=0, TRD=1, Vertex=2, Laser=4
56 Bool_t enableParam[5]={1,0,1,0,1}; //
57 Bool_t enableSign=kFALSE;
58 Bool_t useEff0=kFALSE;
59 Bool_t useEffD=kFALSE;
60 Bool_t useEffR=kFALSE;
64 Bool_t printMatrix=kFALSE;
75 void MakeFit(TCut cutCustom);
76 TCanvas* DrawFitITS(const char *name);
77 TCanvas* DrawFitVertex(const char *name);
78 TCanvas* DrawFitLaser(const char *cname);
79 TCanvas* DrawCorrdY();
80 TCanvas* DrawCorrdSnp();
81 TCanvas * DrawFitdY(const char *name);
82 TCanvas * DrawFitdSnp(const char *name);
84 TCanvas * MakeComposedCorrection(const char * name);
87 chain->SetAlias("isITS","(dtype==0||dtype==2)");
88 chain->SetAlias("isTRD","(dtype==1)");
89 chain->SetAlias("isLaser","(dtype==4)");
90 chain->SetAlias("r","sqrt(gx*gx+gy*gy)");
91 chain->SetAlias("r250","(sqrt(gx*gx+gy*gy)/250.)");
92 chain->SetAlias("weight","((dtype==4)*rms*10+rms)"); // downscale laser
93 chain->SetAlias("side","(1+(theta>0)*2)");
94 chain->SetAlias("mdelta","(mean-R.mean-isLaser*((dRrec-R.dRrec)*tan(asin(snp))))");
95 chain->SetAlias("drift","(1-abs(gz/250))");
96 chain->SetAlias("r0","(r-160)/80");
97 chain->SetAlias("delta","(0*gx)");
101 void MakeGlobalFit(){
105 gROOT->Macro("~/rootlogon.C");
106 gROOT->Macro("NimStyle.C");
107 gSystem->AddIncludePath("-I$ALICE_ROOT/STAT");
108 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC");
109 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
110 gSystem->Load("libANALYSIS");
111 gSystem->Load("libTPCcalib");
115 TPostScript *ps = new TPostScript("matching.ps", 112);
116 gStyle->SetOptTitle(1);
117 gStyle->SetOptStat(0);
119 useEff0=kFALSE; useEffD=kFALSE; useEffR=kFALSE;
122 DrawFitdY("dY-Physical")->Draw();
124 DrawFitdSnp("dSnp-Physical")->Draw();
126 DrawFitITS("ITS Physical")->Draw();
128 DrawFitVertex("Vertex Physical")->Draw();
130 DrawFitLaser("Laser Physical")->Draw();
132 MakeComposedCorrection("Correction physical")->Draw();
137 useEff0=kTRUE; useEffD=kTRUE; useEffR=kTRUE; enableSign=kFALSE;
141 DrawFitdY("dY-Physical+Effective ")->Draw();
143 DrawFitdSnp("dSnp-Physical+Effective ")->Draw();
145 DrawFitITS("ITS Physical+Effective")->Draw();
147 DrawFitVertex("Vertex Physical+Effective")->Draw();
149 DrawFitLaser("Laser Physical +Effective ")->Draw();
151 MakeComposedCorrection("Correction physical+Effective")->Draw();
153 useEff0=kTRUE; useEffD=kTRUE; useEffR=kTRUE; enableSign=kTRUE;
157 DrawFitdY("dY-Physical+Effective Sign")->Draw();
159 DrawFitdSnp("dSnp-Physical+Effective Sign")->Draw();
161 DrawFitITS("ITS Physical+Effective Sign")->Draw();
163 DrawFitVertex("Vertex Physical+Effective Sign")->Draw();
165 DrawFitLaser("Laser Physical +Effective Sign")->Draw();
167 MakeComposedCorrection("Correction physical+Effective Sign")->Draw();
177 TH1::AddDirectory(0);
182 chain = new TChain("fit","fit");
183 chainRef = new TChain("fit","fit");
184 for (Int_t idet=0; idet<5; idet++){
185 for (Int_t ipar=0; ipar<5; ipar++){
187 f= TFile::Open(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
189 tree = (TTree*)f->Get("fit");
190 f= TFile::Open(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
191 if (f && ipar!=4 &&ipar!=3 &&ipar!=1){
192 treeF = (TTree*)f->Get("fit");
194 if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
195 printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
196 chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
197 chainRef->Add(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
200 f= TFile::Open(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
202 treeF = (TTree*)f->Get("fit");
204 if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
205 printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
206 chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
207 chainRef->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
212 f= TFile::Open(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
214 tree = (TTree*)f->Get("fit");
215 f= TFile::Open(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
217 treeF = (TTree*)f->Get("fit");
219 if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
220 printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
221 chain->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
222 chainRef->Add(Form("../mergeField0/distortion%d_%d.root",idet,ipar));
226 f= TFile::Open(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
227 if (f && ipar!=4&&ipar!=3 &&ipar!=1){
228 treeF = (TTree*)f->Get("fit");
230 if (tree->GetEntries()>0 &&(tree->GetEntries()==treeF->GetEntries())){
231 printf("%d\t%d\n",Int_t(tree->GetEntries()),Int_t(treeF->GetEntries()));
232 chain->Add(Form("../mergePlus/distortion%d_%d.root",idet,ipar));
233 chainRef->Add(Form("../mergeMinus/distortion%d_%d.root",idet,ipar));
240 chain->AddFriend(chainRef,"R");
250 TCut cutS="((rms>0&&R.rms>0&&entries>0&&R.entries>0))"; // statistic cuts
251 TCut cutType="((dtype==R.dtype)&&(ptype==R.ptype))"; // corresponding types
252 TCut cutOut="(ptype==0)*abs(mdelta)<(0.3+rms)||(ptype==0&&abs(mdelta*85)<(0.3+rms*85))"; // corresponding types
255 chain->Draw(">>outList",cutS+cutType+cutOut+"abs(snp)<0.5","entryList");
256 TEntryList *elistOut = (TEntryList*)gDirectory->Get("outList");
257 chain->SetEntryList(elistOut);
263 TMatrixD * MakeCorrelation(TMatrixD &matrix){
267 Int_t nrows = matrix.GetNrows();
268 TMatrixD * mat = new TMatrixD(nrows,nrows);
269 for (Int_t irow=0; irow<nrows; irow++)
270 for (Int_t icol=0; icol<nrows; icol++){
271 (*mat)(irow,icol)= matrix(irow,icol)/TMath::Sqrt(matrix(irow,irow)*matrix(icol,icol));
277 cutD=Form("((dtype==%d)||(dtype==%d)||(dtype==%d)||(dtype==%d)||(dtype==%d))",enableDet[0]?0:0,enableDet[1]?1:0,enableDet[2]?2:0,enableDet[3]?3:0,enableDet[4]?4:0);
278 cutD+=Form("((ptype==%d)||(ptype==%d)||(ptype==%d)||(ptype==%d)||(ptype==%d))",enableParam[0]?0:0,enableParam[1]?1:0,enableParam[2]?2:0,enableParam[3]?3:0,enableParam[4]?4:0);
281 void MakeFit(TCut cutCustom){
283 Int_t npointsMax=30000000;
284 TStatToolkit toolkit;
290 TString fstring=""; // magnetic part
291 fstring+="(tX1-R.tX1)++"; // twist X
292 fstring+="(tY1-R.tY1)++"; // twist Y
293 fstring+="(sign(bz)*(tX1-R.tX1))++"; // twist X
294 fstring+="(sign(bz)*(tY1-R.tY1))++"; // twist Y
295 fstring+="(exbT1-exb11-(R.exbT1-R.exb11))++"; // T1 adjustment
296 fstring+="(exbT2-exb11-(R.exbT2-R.exb11))++"; // T2 adjustment
299 fstring+="(isITS*shiftX)++"; // shift X - ITS
300 fstring+="(isITS*shiftY)++"; // shift Y - ITS
301 fstring+="(isITS*sign(bz)*shiftX)++"; // shift X - ITS
302 fstring+="(isITS*sign(bz)*shiftY)++"; // shift Y - ITS
305 fstring+="(isTRD*shiftX)++"; // shift X - TRD
306 fstring+="(isTRD*shiftY)++"; // shift Y - TRD
307 fstring+="(isTRD*sign(bz)*shiftX)++"; // shift X - TRD
308 fstring+="(isTRD*sign(bz)*shiftY)++"; // shift Y - TRD
313 TString fstringCustom="";
315 fstringCustom+="(eff0_0_0-R.eff0_0_0)++"; // effective correction constant part
316 fstringCustom+="(eff1_0_0-R.eff1_0_0)++"; //
319 fstringCustom+="(eff0_0_1-R.eff0_0_1)++"; // effective correction drift part
320 fstringCustom+="(eff1_0_1-R.eff1_0_1)++"; //
321 fstringCustom+="(eff0_0_2-R.eff0_0_2)++"; // effective correction drift part
322 fstringCustom+="(eff1_0_2-R.eff1_0_2)++"; //
325 fstringCustom+="(eff0_1_0-R.eff0_1_0)++"; // effective correction radial part
326 fstringCustom+="(eff1_1_0-R.eff1_1_0)++"; //
327 fstringCustom+="(eff0_1_1-R.eff0_1_1)++"; // effective correction radial part
328 fstringCustom+="(eff1_1_1-R.eff1_1_1)++"; //
329 fstringCustom+="(eff0_1_2-R.eff0_1_2)++"; // effective correction radial part
330 fstringCustom+="(eff1_1_2-R.eff1_1_2)++"; //
331 fstringCustom+="(eff0_2_0-R.eff0_2_0)++"; // effective correction radial part
332 fstringCustom+="(eff1_2_0-R.eff1_2_0)++"; //
333 fstringCustom+="(eff0_2_1-R.eff0_2_1)++"; // effective correction radial part
334 fstringCustom+="(eff1_2_1-R.eff1_2_1)++"; //
335 fstringCustom+="(eff0_2_2-R.eff0_2_2)++"; // effective correction radial part
336 fstringCustom+="(eff1_2_2-R.eff1_2_2)++"; //
340 fstringCustom+="sign(bz)*(eff0_0_0-R.eff0_0_0)++"; // effective correction constant part
341 fstringCustom+="sign(bz)*(eff1_0_0-R.eff1_0_0)++"; //
344 fstringCustom+="sign(bz)*(eff0_0_1-R.eff0_0_1)++"; // effective correction drift part
345 fstringCustom+="sign(bz)*(eff1_0_1-R.eff1_0_1)++"; //
346 fstringCustom+="sign(bz)*(eff0_0_2-R.eff0_0_2)++"; // effective correction drift part
347 fstringCustom+="sign(bz)*(eff1_0_2-R.eff1_0_2)++"; //
350 fstringCustom+="sign(bz)*(eff0_1_0-R.eff0_1_0)++"; // effective correction radial part
351 fstringCustom+="sign(bz)*(eff1_1_0-R.eff1_1_0)++"; //
352 fstringCustom+="sign(bz)*(eff0_1_1-R.eff0_1_1)++"; // effective correction radial part
353 fstringCustom+="sign(bz)*(eff1_1_1-R.eff1_1_1)++"; //
354 fstringCustom+="sign(bz)*(eff0_1_2-R.eff0_1_2)++"; // effective correction radial part
355 fstringCustom+="sign(bz)*(eff1_1_2-R.eff1_1_2)++"; //
356 fstringCustom+="sign(bz)*(eff0_2_0-R.eff0_2_0)++"; // effective correction radial part
357 fstringCustom+="sign(bz)*(eff1_2_0-R.eff1_2_0)++"; //
358 fstringCustom+="sign(bz)*(eff0_2_1-R.eff0_2_1)++"; // effective correction radial part
359 fstringCustom+="sign(bz)*(eff1_2_1-R.eff1_2_1)++"; //
360 fstringCustom+="sign(bz)*(eff0_2_2-R.eff0_2_2)++"; // effective correction radial part
361 fstringCustom+="sign(bz)*(eff1_2_2-R.eff1_2_2)++"; //
365 fstring+=fstringCustom;
367 TString *strDelta = TStatToolkit::FitPlane(chain,"mdelta:weight", fstring.Data(),cut+cutD+cutCustom, chi2,npoints,param,covar,-1,0, npointsMax, kTRUE);
368 if (printMatrix) MakeCorrelation(covar)->Print();
369 chain->SetAlias("delta",strDelta->Data());
370 strDelta->Tokenize("++")->Print();
371 fitString = strDelta;
381 // Print detector matching info
383 for (Int_t ipar=0; ipar<5; ipar++){
384 for (Int_t idet=0; idet<5; idet++){
385 Double_t mean0,rms0,mean1,rms1;
386 Int_t entries = chain->Draw("delta-mdelta",cut+Form("dtype==%d&&ptype==%d",idet,ipar),"");
387 if (entries==0) continue;
388 TH1 * his = (TH1*)(chain->GetHistogram()->Clone());
389 mean1=his->GetMean();
393 entries = chain->Draw("mdelta",cut+Form("dtype==%d&&ptype==%d",idet,ipar),"");
394 if (entries==0) continue;
395 his = (TH1*)(chain->GetHistogram()->Clone());
397 mean0=his->GetMean();
400 printf("ptype==%s\tdtype==%s\tMean=%f -> %f\tRMS=%f -> %f\n",chParName[ipar],chDetName[idet], mean0,mean1,rms0,rms1);
409 TCanvas* DrawFitITS(const char *name){
414 TCanvas *canvas = new TCanvas(name,name,800,800);
417 const char * grname[10]={"A side (B=0.5T)","A side (B=-0.5T)", "C side (B=0.5T)", "C side (B=-0.5T)",0};
419 TGraph *graphsdyITS[10];
420 TGraph *graphsdyITSc[10];
421 entries=chain->Draw("mdelta:phi",cut+"ptype==0&&dtype==0&&bz>0&&theta>0","goff");
422 graphsdyITS[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
423 entries=chain->Draw("mdelta:phi",cut+cut+"ptype==0&&dtype==0&&bz<0&&theta>0","goff");
424 graphsdyITS[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
425 entries=chain->Draw("mdelta:phi",cut+cut+"ptype==0&&dtype==0&&bz>0&&theta<0","goff");
426 graphsdyITS[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
427 entries=chain->Draw("mdelta:phi",cut+cut+"ptype==0&&dtype==0&&bz<0&&theta<0","goff");
428 graphsdyITS[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
430 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==0&&bz>0&&theta>0","goff");
431 graphsdyITSc[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
432 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==0&&bz<0&&theta>0","goff");
433 graphsdyITSc[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
434 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==0&&bz>0&&theta<0","goff");
435 graphsdyITSc[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
436 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==0&&bz<0&&theta<0","goff");
437 graphsdyITSc[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
440 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta R#phi TPC-ITS");
441 for (Int_t i=0; i<4; i++){
442 graphsdyITS[i]->SetMaximum(0.5);
443 graphsdyITS[i]->SetMinimum(-0.5);
444 graphsdyITS[i]->SetMarkerColor(i+1);
445 graphsdyITS[i]->SetMarkerStyle(25+i);
446 // graphsdyITS[i]->SetName(grname[i]);
447 graphsdyITS[i]->GetXaxis()->SetTitle("#phi");
448 graphsdyITS[i]->GetYaxis()->SetTitle("#Delta R#Phi (cm)");
449 if (i==0) graphsdyITS[i]->Draw("ap");
450 graphsdyITS[i]->Draw("p");
451 legend->AddEntry(graphsdyITS[i],grname[i]);
455 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta R#phi TPC-ITS corrected");
456 for (Int_t i=0; i<4; i++){
457 graphsdyITSc[i]->SetMaximum(0.5);
458 graphsdyITSc[i]->SetMinimum(-0.5);
459 graphsdyITSc[i]->SetMarkerColor(i+1);
460 graphsdyITSc[i]->SetMarkerStyle(25+i);
461 // graphsdyITS[i]->SetName(grname[i]);
462 graphsdyITSc[i]->GetXaxis()->SetTitle("#phi");
463 graphsdyITSc[i]->GetYaxis()->SetTitle("#Delta R#Phi (cm)");
464 if (i==0) graphsdyITS[i]->Draw("ap");
465 graphsdyITSc[i]->Draw("p");
466 legend->AddEntry(graphsdyITSc[i],grname[i]);
473 TCanvas* DrawFitLaser(const char *cname){
477 TH1::AddDirectory(0);
478 TCut cutLaser=cut+"isLaser&&bz<0";
479 TCanvas *canvas= new TCanvas(cname, cname,800,800);
485 {for (Int_t icorr=0; icorr<2; icorr++){
486 for (Int_t iside=0; iside<2; iside++){
488 for (Int_t ib=0; ib<4; ib++){
490 if (iside==0) cutB=Form("(id==%d&&gz>0)",ib);
491 if (iside==1) cutB=Form("(id==%d&&gz<0)",ib);
493 if (icorr==0) chain->Draw("10*mdelta:r",cutLaser+cutB,"prof");
494 if (icorr==1) chain->Draw("10*(mdelta-delta):r",cutLaser+cutB,"prof");
495 his[icorr*8+iside*4+ib] = (TH1*)(chain->GetHistogram()->Clone());
496 his[icorr*8+iside*4+ib]->SetName(Form("B%d%d%d",icorr,iside,ib));
497 his[icorr*8+iside*4+ib]->SetTitle(Form("Bundle %d",ib));
498 his[icorr*8+iside*4+ib]->SetMarkerColor(ib+1);
499 his[icorr*8+iside*4+ib]->SetMarkerStyle(ib+25);
500 his[icorr*8+iside*4+ib]->SetMarkerSize(0.4);
501 his[icorr*8+iside*4+ib]->SetMaximum(3);
502 his[icorr*8+iside*4+ib]->SetMinimum(-3);
503 his[icorr*8+iside*4+ib]->GetXaxis()->SetTitle("r (cm)");
504 his[icorr*8+iside*4+ib]->GetYaxis()->SetTitle("#Delta r#phi (mm)");
509 for (Int_t icorr=0; icorr<2; icorr++){
510 for (Int_t iside=0; iside<2; iside++){
511 canvas->cd(icorr*2+iside+1);
512 legend = new TLegend(0.6,0.6,1.0,1.0,Form("#Delta R#phi Laser-%s",chSideName[iside]));
513 for (Int_t ib=0; ib<4; ib++){
514 if (ib==0) his[icorr*2+iside*4+ib]->Draw();
515 his[icorr*8+iside*4+ib]->Draw("same");
516 legend->AddEntry(his[icorr*8+iside*4+ib]);
534 TCanvas* DrawFitVertex(const char *name){
539 TCanvas *canvas = new TCanvas(name,name,800,800);
542 const char * grname[10]={"A side (B=0.5T)","A side (B=-0.5T)", "C side (B=0.5T)", "C side (B=-0.5T)",0};
544 TGraph *graphsdyVertex[10];
545 TGraph *graphsdyVertexc[10];
546 entries=chain->Draw("mdelta:phi",cut+cut+"ptype==0&&dtype==2&&bz>0&&theta>0","goff");
547 graphsdyVertex[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
548 entries=chain->Draw("mdelta:phi",cut+cut+"ptype==0&&dtype==2&&bz<0&&theta>0","goff");
549 graphsdyVertex[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
550 entries=chain->Draw("mdelta:phi",cut+cut+"ptype==0&&dtype==2&&bz>0&&theta<0","goff");
551 graphsdyVertex[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
552 entries=chain->Draw("mdelta:phi",cut+cut+"ptype==0&&dtype==2&&bz<0&&theta<0","goff");
553 graphsdyVertex[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
555 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==2&&bz>0&&theta>0","goff");
556 graphsdyVertexc[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
557 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==2&&bz<0&&theta>0","goff");
558 graphsdyVertexc[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
559 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==2&&bz>0&&theta<0","goff");
560 graphsdyVertexc[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
561 entries=chain->Draw("mdelta-delta:phi",cut+cut+"ptype==0&&dtype==2&&bz<0&&theta<0","goff");
562 graphsdyVertexc[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
565 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta R#phi TPC-Vertex");
566 for (Int_t i=0; i<4; i++){
567 graphsdyVertex[i]->SetMaximum(1);
568 graphsdyVertex[i]->SetMinimum(-1);
569 graphsdyVertex[i]->SetMarkerColor(i+1);
570 graphsdyVertex[i]->SetMarkerStyle(25+i);
571 // graphsdyVertex[i]->SetName(grname[i]);
572 graphsdyVertex[i]->GetXaxis()->SetTitle("#phi");
573 graphsdyVertex[i]->GetYaxis()->SetTitle("#Delta R#Phi (cm)");
574 if (i==0) graphsdyVertex[i]->Draw("ap");
575 graphsdyVertex[i]->Draw("p");
576 legend->AddEntry(graphsdyVertex[i],grname[i]);
580 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta R#phi TPC-Vertex corrected");
581 for (Int_t i=0; i<4; i++){
582 graphsdyVertexc[i]->SetMaximum(1);
583 graphsdyVertexc[i]->SetMinimum(-1);
584 graphsdyVertexc[i]->SetMarkerColor(i+1);
585 graphsdyVertexc[i]->SetMarkerStyle(25+i);
586 // graphsdyVertex[i]->SetName(grname[i]);
587 graphsdyVertexc[i]->GetXaxis()->SetTitle("#phi");
588 graphsdyVertexc[i]->GetYaxis()->SetTitle("#Delta R#Phi (cm)");
589 if (i==0) graphsdyVertex[i]->Draw("ap");
590 graphsdyVertexc[i]->Draw("p");
591 legend->AddEntry(graphsdyVertexc[i],grname[i]);
602 TCanvas* DrawCorrdY(){
605 TCanvas *canvas = new TCanvas("Corrections","Corrections",800,800);
608 TGraph *graphsITS[10];
609 TGraph *graphsTRD[10];
610 TGraph *graphsVertex[10];
612 const char * grname[10]={"X twist (1 mrad)","Y twist (1 mrad)", "X shift (1 mm)", "Y shift (1 mm)", "drPhi (1 mm)"};
614 entries=chain->Draw("tX1:phi",cut+cut+"ptype==0&&dtype==0&&bz>0","goff");
615 graphsITS[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
616 entries=chain->Draw("tY1:phi",cut+cut+"ptype==0&&dtype==0&&bz>0","goff");
617 graphsITS[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
618 entries=chain->Draw("shiftX:phi",cut+cut+"ptype==0&&dtype==0&&bz>0","goff");
619 graphsITS[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
620 entries=chain->Draw("shiftY:phi",cut+cut+"ptype==0&&dtype==0&&bz>0","goff");
621 graphsITS[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
622 entries=chain->Draw("drPhiA+drPhiC:phi",cut+cut+"ptype==0&&dtype==0&&bz>0","goff");
623 graphsITS[4]=new TGraph(entries,chain->GetV2(), chain->GetV1());
625 entries=chain->Draw("tX1:phi",cut+cut+"ptype==0&&dtype==1&&bz>0","goff");
626 graphsTRD[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
627 entries=chain->Draw("tY1:phi",cut+cut+"ptype==0&&dtype==1&&bz>0","goff");
628 graphsTRD[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
629 entries=chain->Draw("shiftX:phi",cut+cut+"ptype==0&&dtype==1&&bz>0","goff");
630 graphsTRD[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
631 entries=chain->Draw("shiftY:phi",cut+cut+"ptype==0&&dtype==1&&bz>0","goff");
632 graphsTRD[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
633 entries=chain->Draw("drPhiA+drPhiC:phi",cut+cut+"ptype==0&&dtype==1&&bz>0","goff");
634 graphsTRD[4]=new TGraph(entries,chain->GetV2(), chain->GetV1());
636 entries=chain->Draw("tX1:phi",cut+cut+"ptype==0&&dtype==2&&bz>0","goff");
637 graphsVertex[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
638 entries=chain->Draw("tY1:phi",cut+cut+"ptype==0&&dtype==2&&bz>0","goff");
639 graphsVertex[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
640 entries=chain->Draw("shiftX:phi",cut+cut+"ptype==0&&dtype==2&&bz>0","goff");
641 graphsVertex[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
642 entries=chain->Draw("shiftY:phi",cut+cut+"ptype==0&&dtype==2&&bz>0","goff");
643 graphsVertex[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
644 entries=chain->Draw("drPhiA+drPhiC:phi",cut+cut+"ptype==0&&dtype==2&&bz>0","goff");
645 graphsVertex[4]=new TGraph(entries,chain->GetV2(), chain->GetV1());
649 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta R#Phi TPC-Vertex");
650 for (Int_t i=0; i<5; i++){
651 graphsVertex[i]->SetMaximum(0.2);
652 graphsVertex[i]->SetMinimum(-0.2);
653 graphsVertex[i]->SetMarkerColor(i+1);
654 graphsVertex[i]->SetMarkerStyle(25+i);
655 graphsVertex[i]->SetName(grname[i]);
656 graphsVertex[i]->GetXaxis()->SetTitle("#phi");
657 graphsVertex[i]->GetYaxis()->SetTitle("#DeltaR#Phi (cm)");
658 if (i==0) graphsVertex[i]->Draw("ap");
659 graphsVertex[i]->Draw("p");
660 legend->AddEntry(graphsITS[i],grname[i]);
665 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta R#Phi ITS-TPC");
666 for (Int_t i=0; i<5; i++){
667 graphsITS[i]->SetMaximum(0.2);
668 graphsITS[i]->SetMinimum(-0.2);
669 graphsITS[i]->SetMarkerColor(i+1);
670 graphsITS[i]->SetMarkerStyle(25+i);
671 graphsITS[i]->SetName(grname[i]);
672 graphsITS[i]->GetXaxis()->SetTitle("#phi");
673 graphsITS[i]->GetYaxis()->SetTitle("#Delta R#Phi (cm)");
674 if (i==0) graphsITS[i]->Draw("ap");
675 graphsITS[i]->Draw("p");
676 legend->AddEntry(graphsITS[i],grname[i]);
681 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta R#Phi TPC-TRD");
682 for (Int_t i=0; i<5; i++){
683 graphsTRD[i]->SetMaximum(0.2);
684 graphsTRD[i]->SetMinimum(-0.2);
685 graphsTRD[i]->SetMarkerColor(i+1);
686 graphsTRD[i]->SetMarkerStyle(25+i);
687 graphsTRD[i]->SetName(grname[i]);
688 graphsTRD[i]->GetXaxis()->SetTitle("#phi");
689 graphsTRD[i]->GetYaxis()->SetTitle("#DeltaR#Phi (cm)");
690 if (i==0) graphsTRD[i]->Draw("ap");
691 graphsTRD[i]->Draw("p");
692 legend->AddEntry(graphsITS[i],grname[i]);
699 TCanvas * DrawCorrdSnp(){
702 TCanvas *canvas = new TCanvas("Corrections dSnp","Corrections dSnp",800,800);
705 TGraph *graphsITS[10];
706 TGraph *graphsTRD[10];
707 TGraph *graphsVertex[10];
709 const char * grname[10]={"X twist (1 mrad)","Y twist (1 mrad)", "X shift (1 mm)", "Y shift (1 mm)",0};
711 entries=chain->Draw("1000*tX1:phi",cut+cut+"ptype==2&&dtype==0&&bz>0","goff");
712 graphsITS[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
713 entries=chain->Draw("1000*tY1:phi",cut+cut+"ptype==2&&dtype==0&&bz>0","goff");
714 graphsITS[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
715 entries=chain->Draw("1000*shiftX:phi",cut+cut+"ptype==2&&dtype==0&&bz>0","goff");
716 graphsITS[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
717 entries=chain->Draw("1000*shiftY:phi",cut+cut+"ptype==2&&dtype==0&&bz>0","goff");
718 graphsITS[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
720 entries=chain->Draw("1000*tX1:phi",cut+cut+"ptype==2&&dtype==1&&bz>0","goff");
721 graphsTRD[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
722 entries=chain->Draw("1000*tY1:phi",cut+cut+"ptype==2&&dtype==1&&bz>0","goff");
723 graphsTRD[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
724 entries=chain->Draw("1000*shiftX:phi",cut+cut+"ptype==2&&dtype==1&&bz>0","goff");
725 graphsTRD[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
726 entries=chain->Draw("1000*shiftY:phi",cut+cut+"ptype==2&&dtype==1&&bz>0","goff");
727 graphsTRD[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
729 entries=chain->Draw("1000*tX1:phi",cut+cut+"ptype==2&&dtype==2&&bz>0","goff");
730 graphsVertex[0]=new TGraph(entries,chain->GetV2(), chain->GetV1());
731 entries=chain->Draw("1000*tY1:phi",cut+cut+"ptype==2&&dtype==2&&bz>0","goff");
732 graphsVertex[1]=new TGraph(entries,chain->GetV2(), chain->GetV1());
733 entries=chain->Draw("1000*shiftX:phi",cut+cut+"ptype==2&&dtype==2&&bz>0","goff");
734 graphsVertex[2]=new TGraph(entries,chain->GetV2(), chain->GetV1());
735 entries=chain->Draw("1000*shiftY:phi",cut+cut+"ptype==2&&dtype==2&&bz>0","goff");
736 graphsVertex[3]=new TGraph(entries,chain->GetV2(), chain->GetV1());
740 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta sin(#phi) TPC-Vertex");
741 for (Int_t i=0; i<4; i++){
742 graphsVertex[i]->SetMaximum(2);
743 graphsVertex[i]->SetMinimum(2);
744 graphsVertex[i]->SetMarkerColor(i+1);
745 graphsVertex[i]->SetMarkerStyle(25+i);
746 graphsVertex[i]->SetName(grname[i]);
747 graphsVertex[i]->GetXaxis()->SetTitle("#phi");
748 graphsVertex[i]->GetYaxis()->SetTitle("#Deltasin(#phi) (mrad)");
749 if (i==0) graphsVertex[i]->Draw("ap");
750 graphsVertex[i]->Draw("p");
751 legend->AddEntry(graphsITS[i],grname[i]);
756 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta sin(#phi) ITS-TPC");
757 for (Int_t i=0; i<4; i++){
758 graphsITS[i]->SetMaximum(1);
759 graphsITS[i]->SetMinimum(-1);
760 graphsITS[i]->SetMarkerColor(i+1);
761 graphsITS[i]->SetMarkerStyle(25+i);
762 graphsITS[i]->SetName(grname[i]);
763 graphsITS[i]->GetXaxis()->SetTitle("#phi");
764 graphsITS[i]->GetYaxis()->SetTitle("#Delta sin(#phi) (mrad)");
765 if (i==0) graphsITS[i]->Draw("ap");
766 graphsITS[i]->Draw("p");
767 legend->AddEntry(graphsITS[i],grname[i]);
772 legend = new TLegend(0.6,0.6,1.0,1.0,"#Delta sin(#phi) TPC-TRD");
773 for (Int_t i=0; i<4; i++){
774 graphsTRD[i]->SetMaximum(1);
775 graphsTRD[i]->SetMinimum(-1);
776 graphsTRD[i]->SetMarkerColor(i+1);
777 graphsTRD[i]->SetMarkerStyle(25+i);
778 graphsTRD[i]->SetName(grname[i]);
779 graphsTRD[i]->GetXaxis()->SetTitle("#phi");
780 graphsTRD[i]->GetYaxis()->SetTitle("#Deltasin(#phi) (mrad)");
781 if (i==0) graphsTRD[i]->Draw("ap");
782 graphsTRD[i]->Draw("p");
783 legend->AddEntry(graphsITS[i],grname[i]);
790 TCanvas * DrawFitdY(const char *name){
794 TH1::AddDirectory(0);
795 TCanvas *canvas = new TCanvas(name,name,800,800);
797 for (Int_t idet=0; idet<5; idet++){
798 chain->SetMarkerColor(4);
799 chain->SetMarkerStyle(25);
800 chain->SetMarkerSize(0.3);
801 chain->SetLineColor(2);
803 canvas->cd(idet*3+1);
804 chain->Draw("mdelta:delta",cut+Form("ptype==0&&dtype==%d",idet),"");
806 canvas->cd(idet*3+2);
807 chain->SetLineColor(2);
808 chain->Draw("mdelta-delta",cut+Form("ptype==0&&dtype==%d",idet),"");
809 chain->SetLineColor(1);
810 chain->Draw("mdelta",cut+Form("ptype==0&&dtype==%d",idet),"same");
812 canvas->cd(idet*3+3);
813 chain->SetMarkerColor(1);
814 chain->Draw("mdelta:phi",cut+Form("ptype==0&&dtype==%d&&theta>0&&bz>0",idet),"");
815 chain->SetMarkerColor(2);
816 chain->Draw("mdelta-delta:phi",cut+Form("ptype==0&&dtype==%d&&theta>0&&bz>0",idet),"same");
822 TCanvas * DrawFitdSnp(const char *name){
826 TH1::AddDirectory(0);
827 TCanvas *canvas = new TCanvas(name,name,800,800);
829 {for (Int_t idet=0; idet<5; idet++){
830 chain->SetMarkerColor(4);
831 chain->SetMarkerStyle(25);
832 chain->SetMarkerSize(0.3);
833 chain->SetLineColor(2);
835 canvas->cd(idet*3+1);
836 chain->Draw("1000*mdelta:1000*delta",cut+Form("ptype==2&&dtype==%d",idet),"");
838 canvas->cd(idet*3+2);
839 chain->SetLineColor(2);
840 chain->Draw("1000*(mdelta-delta)",cut+Form("ptype==2&&dtype==%d",idet),"");
841 chain->SetLineColor(1);
842 chain->Draw("1000*mdelta",cut+Form("ptype==2&&dtype==%d",idet),"same");
844 canvas->cd(idet*3+3);
845 chain->SetMarkerColor(1);
846 chain->Draw("1000*(mdelta):phi",cut+Form("ptype==2&&dtype==%d&&theta>0&&bz>0",idet),"");
847 chain->SetMarkerColor(2);
848 chain->Draw("1000*(mdelta-delta):phi",cut+Form("ptype==2&&dtype==%d&&theta>0&&bz>0",idet),"same");
853 TCanvas * MakeComposedCorrection(const char *name){
855 TString fit = chain->GetAlias("delta");
856 TObjArray * array = fit.Tokenize("++");
857 Int_t nfun=array->GetEntries();
862 // sign independent correction
864 AliTPCExBEffective *eff = new AliTPCExBEffective;
865 AliTPCCalibGlobalMisalignment *shiftITS = new AliTPCCalibGlobalMisalignment;
866 AliTPCExBTwist *twist = new AliTPCExBTwist;
868 // sign dependent correction
870 AliTPCExBEffective *effS = new AliTPCExBEffective;
871 AliTPCCalibGlobalMisalignment *shiftITSS = new AliTPCCalibGlobalMisalignment;
872 AliTPCExBTwist *twistS = new AliTPCExBTwist;
874 TMatrixD polA(100,4);
875 TMatrixD polC(100,4);
876 TMatrixD valA(100,1);
877 TMatrixD valC(100,1);
882 for (Int_t i=1; i<nfun;i++){
883 TObjString fitName=array->At(i)->GetName();
884 TObjString fitVal= &(fitName.String()[1+fitName.String().Last('(')]);
885 Double_t value= fitVal.String().Atof();
886 if (fitName.String().Contains("sign")) continue;
887 if (fitName.String().Contains("tX1")){
888 twist->SetXTwist(value*0.001);
890 if (fitName.String().Contains("tY1")){
891 twist->SetYTwist(value*0.001);
894 if (fitName.String().Contains("shiftX")&&fitName.String().Contains("isITS")){
895 shiftITS->SetXShift(value*0.1);
897 if (fitName.String().Contains("shiftY")&&fitName.String().Contains("isITS")){
898 shiftITS->SetYShift(value*0.1);
901 if (fitName.String().Contains("eff")){
902 Int_t index=fitName.String().First("_")-1;
903 Int_t side=atoi(&(fitName.String()[index]));
904 Int_t px =atoi(&(fitName.String()[index+2]));
905 Int_t pd =atoi(&(fitName.String()[index+4]));
907 //printf("%s\t%d\t%d\t%d\t%d\t%f\n",fitName.GetName(),side,px,pd,pp, value);
913 valA(counterA,0)=value*0.1;
921 valC(counterC,0)=value*0.1;
927 polA.ResizeTo(counterA,4);
928 polC.ResizeTo(counterC,4);
929 valA.ResizeTo(counterA,1);
930 valC.ResizeTo(counterC,1);
931 eff->SetPolynoms(&polA,&polC);
932 eff->SetCoeficients(&valA,&valC);
933 eff->SetOmegaTauT1T2(wt,T1,T2);
934 shiftITS->SetOmegaTauT1T2(wt,T1,T2);
935 twist->SetOmegaTauT1T2(wt,T1,T2);
942 for (Int_t i=1; i<nfun;i++){
943 TObjString fitName=array->At(i)->GetName();
944 TObjString fitVal= &(fitName.String()[1+fitName.String().Last('(')]);
945 if (!fitName.String().Contains("sign")) continue;
946 Double_t value= fitVal.String().Atof();
947 if (fitName.String().Contains("tX1")){
948 twistS->SetXTwist(value*0.001);
950 if (fitName.String().Contains("tY1")){
951 twistS->SetYTwist(value*0.001);
954 if (fitName.String().Contains("shiftX")&&fitName.String().Contains("isITS")){
955 shiftITSS->SetXShift(value*0.1);
957 if (fitName.String().Contains("shiftY")&&fitName.String().Contains("isITS")){
958 shiftITSS->SetYShift(value*0.1);
961 if (fitName.String().Contains("eff")){
962 Int_t index=fitName.String().First("_")-1;
963 Int_t side=atoi(&(fitName.String()[index]));
964 Int_t px =atoi(&(fitName.String()[index+2]));
965 Int_t pd =atoi(&(fitName.String()[index+4]));
967 //printf("%s\t%d\t%d\t%d\t%d\t%f\n",fitName.GetName(),side,px,pd,pp, value);
973 valA(counterA,0)=value*0.1;
981 valC(counterC,0)=value*0.1;
987 polA.ResizeTo(counterA,4);
988 polC.ResizeTo(counterC,4);
989 valA.ResizeTo(counterA,1);
990 valC.ResizeTo(counterC,1);
991 effS->SetPolynoms(&polA,&polC);
992 effS->SetCoeficients(&valA,&valC);
993 effS->SetOmegaTauT1T2(wt,T1,T2);
994 shiftITSS->SetOmegaTauT1T2(wt,T1,T2);
995 twistS->SetOmegaTauT1T2(wt,T1,T2);
1000 TCanvas *c = new TCanvas(name,name,800,800);
1003 shiftITS->CreateHistoDRPhiinXY()->Draw("surf2");
1005 twist->CreateHistoDRPhiinXY()->Draw("surf2");
1007 eff->CreateHistoDRPhiinZR()->Draw("surf2");
1009 shiftITSS->CreateHistoDRPhiinXY()->Draw("surf2");
1011 twistS->CreateHistoDRPhiinXY()->Draw("surf2");
1013 effS->CreateHistoDRPhiinZR()->Draw("surf2");
1014 TObjArray * corr = new TObjArray;