1 // The class definition in esdClus.h has been generated automatically
2 // by the ROOT utility TTree::MakeSelector(). This class is derived
3 // from the ROOT class TSelector. For more information on the TSelector
4 // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
6 // The following methods are defined in this file:
7 // Begin(): called everytime a loop on the tree starts,
8 // a convenient place to create your histograms.
9 // SlaveBegin(): called after Begin(), when on PROOF called only on the
11 // Process(): called for each event, in this function you decide what
12 // to read and fill your histograms.
13 // SlaveTerminate: called at the end of the loop on the tree, when on PROOF
14 // called only on the slave servers.
15 // Terminate(): called at the end of the loop on the tree,
16 // a convenient place to draw/fit your histograms.
21 // Comapre the MC information with the reconstructed
25 after running analysis, read the file, and get component
26 gSystem->Load("libPWG1.so");
27 TFile f("Output.root");
28 AliComparisonDraw * comp = (AliComparisonDraw*)f.Get("AliComparisonDraw");
29 TF1 fl("fl","((min(250./(abs(x+0.000001)),250)-90))",0,2); // length function
30 TF1 fl2("fl2","[0]/((min(250./(abs(x+0.000001)),250)-90))^[1]",0,2);
31 fl2.SetParameter(1,1);
32 fl2.SetParameter(0,1);
49 #include "TTimeStamp.h"
56 #include "TProfile2D.h"
62 #include "AliTracker.h"
65 #include "AliESDEvent.h" // new container
67 #include "AliESDtrack.h"
68 #include "AliESDfriend.h"
69 #include "AliESDfriendTrack.h"
70 #include "AliTPCseed.h"
71 #include "AliTPCclusterMI.h"
73 #include "AliMathBase.h"
74 #include "AliTreeDraw.h"
75 #include "AliComparisonDraw.h"
78 ClassImp(AliComparisonDraw)
80 Bool_t AliComparisonDraw::fBDraw; //option draw temporary results
82 AliComparisonDraw::AliComparisonDraw():
90 void AliComparisonDraw::InitHisto(){
95 // Efficiency as function of pt
96 fEffTPCPt = new TProfile("Eff_pt","Eff_Pt",50,0.1,3); // physical
97 fEffTPCPtMC = new TProfile("MC_Eff_pt","MC_Eff_Pt",50,0.1,3); // MC - particles make more than 50 rowdigits
98 fEffTPCPtF = new TProfile("F_Eff_pt","F_Eff_Pt",50,0.1,3); // tracking - under condition more than 50 rdigits
100 // Efficiency as function of pt
101 fEffTPCTan = new TProfile("Eff_tan","Eff_tan",50,-2.5,2.5); // physical
102 fEffTPCTanMC = new TProfile("MC_Eff_tan","MC_Eff_tan",50,-2.5,2.5); // MC - particles make more than 50 rowdigits
103 fEffTPCTanF = new TProfile("F_Eff_tan","F_Eff_tan",50,-2.5,2.5); // tracking - under condition more than 50 rdigits
105 fEffTPCPtTan = new TProfile2D("Eff_pt","Eff_Pt",10,0.1,3,20,-2.,2.);
106 fEffTPCPtTanMC = new TProfile2D("MC_Eff_pt","MC Eff Pt",10,0.1,3,20, -2.,2.);
107 fEffTPCPtTanF = new TProfile2D("MC_Eff_pt","MC Eff Pt",10,0.1,3,20, -2.,2.);
112 fTPCSignalNormTan = new TH2F("CdEdxTan","CdEdxTan",50, -2,2, 40,30,70); // tpc signal normalized to the MC
113 fTPCSignalNormSPhi = new TH2F("CdEdxSPhi","CdEdxSPhi",10,0.0,1,40,30,70); // tpc signal normalized to the MC
114 fTPCSignalNormTPhi = new TH2F("CdEdxTPhi","CdEdxTPhi",10,0.0,2,40,30,70); // tpc signal normalized to the MC
116 fTPCSignalNormTanSPhi= new TH3F("CdEdxTanSPhi","CdEdxTanSPhi",20, -2,2, 10,0.0 ,1, 40,30,70); // tpc signal normalized to the mean signal - MC
117 fTPCSignalNormTanTPhi= new TH3F("CdEdxTanTPhi","CdEdxTanTPhi",20, -2,2, 10,0.0 ,1, 40,30,70); // tpc signal normalized to the mean signal - MC
118 fTPCSignalNormTanSPt= new TH3F("CdEdxTanSPt","CdEdxTanSPt",20, -2,2, 10,0.3 ,3, 40,30,70); // tpc signal normalized to the mean signal - MC
125 fCPtResolTan = new TH2F("C Pt resol","C pt resol",50, -2,2,200,-0.2,0.2);
126 fCPtPullTan = new TH2F("C Pt pull","C pt pull",50, -2,2,200,-5,5);
128 fCPhiResolTan = new TH2F("CPhiResolTan","CPhiResolTan",50, -2,2,200,-0.025,0.025);
129 // angular resolution - constrained
130 fCTanResolTan = new TH2F("CTanResolTan","CTanResolTan",50, -2,2,200,-0.025,0.025);
131 // angular resolution - constrained
132 fCPtResolTan=new TH2F("CPtResol","CPtResol",50, -2,2,200,-0.2,0.2);;
133 // pt resolution - constrained
134 fCPhiPullTan = new TH2F("CPhiPullTan","CPhiPullTan",50, -2,2,200,-5,5);
135 // angular resolution - constrained
136 fCTanPullTan = new TH2F("CTanPullTan","CTanPullTan",50, -2,2,200,-5,5);
137 // angular resolution - constrained
138 fCPtPullTan=new TH2F("CPtPull","CPtPull",50, -2,2,200,-5,5);
139 // pt resolution - constrained
141 fPtResolLPT = new TH2F("Pt resol","pt resol",10, 0.1,3,200,-0.2,0.2);
142 fPtResolHPT = new TH2F("Pt resol","pt resol",10, 2,100,200,-0.3,0.3);
143 fPtPullLPT = new TH2F("Pt pool","pt pool",10, 0.1,3,200,-6,6);
144 fPtPullHPT = new TH2F("Pt pool","pt pool",10, 2,100,200,-6,6);
146 fD0TanSPtB1 = new TH3F("DCAyTanSPt","DCAyTanSPt",20,1,2, 10,0.3,2, 100,-4,4);
147 fD1TanSPtB1 = new TH3F("DCAzTanSPt","DCAzTanSPt",20,1,2, 10,0.3,2, 100,-4,4);
148 fD0TanSPtL1 = new TH3F("DCAyTanSPt","DCAyTanSPt",20,0,1, 10,0.3,2, 100,-0.1,0.1);
149 fD1TanSPtL1 = new TH3F("DCAzTanSPt","DCAzTanSPt",20,0,1, 10,0.3,2, 100, -0.1,0.1);
155 void AliComparisonDraw::ProcessEff(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
157 // make efficiencies histograms
159 Float_t kptcut = 0.15;
162 Float_t mcpt = infoMC->GetParticle().Pt();
163 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
164 Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
170 if (TMath::Abs(tantheta)<ktancut){
171 fEffTPCPt->Fill(mcpt, infoRC->GetStatus(1)==3);
172 fEffTPCPtMC->Fill(mcpt, infoMC->GetRowsWithDigits()>kmincl);
173 if (infoMC->GetRowsWithDigits()>kmincl){
174 fEffTPCPtF->Fill(mcpt, infoRC->GetStatus(1)==3);
179 if (TMath::Abs(mcpt)>kptcut){
180 fEffTPCTan->Fill(tantheta, infoRC->GetStatus(1)==3);
181 fEffTPCTanMC->Fill(tantheta, infoMC->GetRowsWithDigits()>kmincl);
182 if (infoMC->GetRowsWithDigits()>kmincl){
183 fEffTPCTanF->Fill(tantheta, infoRC->GetStatus(1)==3);
189 fEffTPCPtTan->Fill(mcpt,tantheta,infoRC->GetStatus(1)==3);
190 fEffTPCPtTanMC->Fill(mcpt,tantheta,infoMC->GetRowsWithDigits()>50);
191 if (infoMC->GetRowsWithDigits()>kmincl){
192 fEffTPCPtTanF->Fill(mcpt,tantheta,infoRC->GetStatus(1)==3);
197 void AliComparisonDraw::ProcessResolConstrained(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
201 Float_t mcpt = infoMC->GetParticle().Pt();
202 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
203 Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
207 if (infoRC->GetStatus(1)!=3) return;
208 if (!infoRC->GetESDtrack()) return;
209 if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
210 if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
213 // constrained parameters resolution
215 const AliExternalTrackParam * cparam = infoRC->GetESDtrack()->GetConstrainedParam();
216 Float_t deltaCPt= (mcpt-cparam->Pt())/mcpt;
217 Float_t pullCPt= (1/mcpt-cparam->OneOverPt())/
218 TMath::Sqrt(cparam->GetSigma1Pt2());
219 Float_t deltaPhi = TMath::ATan2(cparam->Py(),cparam->Px())-
220 TMath::ATan2(infoMC->GetParticle().Py(),infoMC->GetParticle().Px());
221 Float_t pullPhi = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2());
223 Float_t deltaTan = TMath::ATan2(cparam->Pz(),cparam->Pt())-
224 TMath::ATan2(infoMC->GetParticle().Pz(),infoMC->GetParticle().Pt());
225 Float_t pullTan = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2());
227 fCPtResolTan->Fill(tantheta,deltaCPt);
228 fCPtPullTan->Fill(tantheta,pullCPt);
229 fCPhiResolTan->Fill(tantheta,deltaPhi);
230 fCPhiPullTan->Fill(tantheta,pullPhi);
231 fCTanResolTan->Fill(tantheta,deltaTan);
232 fCTanPullTan->Fill(tantheta,pullTan);
238 void AliComparisonDraw::ProcessTPCdedx(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
242 Float_t mcpt = infoMC->GetParticle().Pt();
243 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
244 Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
248 if (infoRC->GetStatus(1)!=3) return;
249 if (!infoRC->GetESDtrack()) return;
250 if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
251 if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
252 Float_t mprim = infoMC->GetPrim();
253 if (mprim>1.4) return;
254 if (mprim<0.5) return;
255 if (infoRC->GetESDtrack()->GetTPCsignalN()<50) return;
257 Float_t ratio = infoRC->GetESDtrack()->GetTPCsignal()/infoMC->GetPrim();
258 Float_t sphi = infoRC->GetESDtrack()->GetInnerParam()->GetSnp();
259 Float_t tphi = sphi/TMath::Sqrt(1-sphi*sphi);
262 if (TMath::Abs(infoMC->GetParticle().GetPdgCode())!=211) return;
264 fTPCSignalNormTan->Fill(tantheta,ratio); //only subset
266 if (TMath::Abs(tantheta)<0.5){
267 fTPCSignalNormSPhi->Fill(sphi,ratio); // only subset
268 fTPCSignalNormTPhi->Fill(tphi,ratio); // only subset
270 fTPCSignalNormTanSPhi->Fill(tantheta,sphi,ratio);
271 fTPCSignalNormTanTPhi->Fill(tantheta,tphi,ratio);
272 fTPCSignalNormTanSPt->Fill(tantheta,TMath::Sqrt(mcpt),ratio);
275 void AliComparisonDraw::ProcessDCA(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
279 Float_t mcpt = infoMC->GetParticle().Pt();
280 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
281 Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
284 if (infoRC->GetStatus(1)!=3) return;
285 if (!infoRC->GetESDtrack()) return;
286 if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
287 if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
288 Float_t spt = TMath::Sqrt(mcpt);
289 Float_t dca[2],cov[3];
290 infoRC->GetESDtrack()->GetImpactParameters(dca,cov);
291 Int_t clusterITS[100];
292 if (infoRC->GetESDtrack()->GetITSclusters(clusterITS)==0){
293 fD0TanSPtB1->Fill(tantheta,spt,dca[0]);
294 fD1TanSPtB1->Fill(tantheta,spt,dca[1]);
296 fD0TanSPtL1->Fill(tantheta,spt,dca[0]);
297 fD1TanSPtL1->Fill(tantheta,spt,dca[1]);
303 void AliComparisonDraw::Process(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
307 ProcessEff(infoMC,infoRC);
308 ProcessResolConstrained(infoMC,infoRC);
309 ProcessTPCdedx(infoMC, infoRC);
310 ProcessDCA(infoMC, infoRC);
312 Float_t mcpt = infoMC->GetParticle().Pt();
313 Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
319 if (infoRC->GetStatus(1)==0) return;
320 if (!infoRC->GetESDtrack()) return;
321 if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
322 // printf("Pt\t%f\t%f\n",mcpt, infoRC->GetESDtrack()->Pt());
324 Float_t deltaPt= (mcpt-infoRC->GetESDtrack()->Pt())/mcpt;
325 Float_t poolPt= (1/mcpt-infoRC->GetESDtrack()->OneOverPt())/
326 TMath::Sqrt(infoRC->GetESDtrack()->GetSigma1Pt2());
328 fPtResolLPT->Fill(mcpt,deltaPt);
329 fPtResolHPT->Fill(mcpt,deltaPt);
330 fPtPullLPT->Fill(mcpt,poolPt);
331 fPtPullHPT->Fill(mcpt,poolPt);
336 TH1F* AliComparisonDraw::MakeResol(TH2F * his, Int_t integ, Bool_t type){
338 if (!gPad) new TCanvas;
339 hisr = AliTreeDraw::CreateResHistoI(his,&hism,integ);
340 if (type) return hism;
346 TGraph2D * AliComparisonDraw::MakeStat2D(TH3 * his, Int_t delta0, Int_t delta1, Int_t type){
350 // delta - number of bins to integrate
351 // type - 0 - mean value
353 TAxis * xaxis = his->GetXaxis();
354 TAxis * yaxis = his->GetYaxis();
355 // TAxis * zaxis = his->GetZaxis();
356 Int_t nbinx = xaxis->GetNbins();
357 Int_t nbiny = yaxis->GetNbins();
360 TGraph2D *graph = new TGraph2D(nbinx*nbiny);
362 for (Int_t ix=0; ix<nbinx;ix++)
363 for (Int_t iy=0; iy<nbiny;iy++){
364 Float_t xcenter = xaxis->GetBinCenter(ix);
365 Float_t ycenter = yaxis->GetBinCenter(iy);
366 sprintf(name,"%s_%d_%d",his->GetName(), ix,iy);
367 TH1 *projection = his->ProjectionZ(name,ix-delta0,ix+delta0,iy-delta1,iy+delta1);
369 if (type==0) stat = projection->GetMean();
370 if (type==1) stat = projection->GetRMS();
371 if (type==2 || type==3){
373 AliMathBase::LTM((TH1F*)projection,&vec,0.7);
374 if (type==2) stat= vec[1];
375 if (type==3) stat= vec[0];
377 if (type==4|| type==5){
378 projection->Fit(&f1);
379 if (type==4) stat= f1.GetParameter(1);
380 if (type==5) stat= f1.GetParameter(2);
382 //printf("%d\t%f\t%f\t%f\n", icount,xcenter, ycenter, stat);
383 graph->SetPoint(icount,xcenter, ycenter, stat);
389 TGraph * AliComparisonDraw::MakeStat1D(TH3 * his, Int_t delta1, Int_t type){
393 // delta - number of bins to integrate
394 // type - 0 - mean value
396 TAxis * xaxis = his->GetXaxis();
397 TAxis * yaxis = his->GetYaxis();
398 // TAxis * zaxis = his->GetZaxis();
399 Int_t nbinx = xaxis->GetNbins();
400 Int_t nbiny = yaxis->GetNbins();
403 TGraph *graph = new TGraph(nbinx);
405 for (Int_t ix=0; ix<nbinx;ix++){
406 Float_t xcenter = xaxis->GetBinCenter(ix);
407 // Float_t ycenter = yaxis->GetBinCenter(iy);
408 sprintf(name,"%s_%d",his->GetName(), ix);
409 TH1 *projection = his->ProjectionZ(name,ix-delta1,ix+delta1,0,nbiny);
411 if (type==0) stat = projection->GetMean();
412 if (type==1) stat = projection->GetRMS();
413 if (type==2 || type==3){
415 AliMathBase::LTM((TH1F*)projection,&vec,0.7);
416 if (type==2) stat= vec[1];
417 if (type==3) stat= vec[0];
419 if (type==4|| type==5){
420 projection->Fit(&f1);
421 if (type==4) stat= f1.GetParameter(1);
422 if (type==5) stat= f1.GetParameter(2);
424 //printf("%d\t%f\t%f\t%f\n", icount,xcenter, ycenter, stat);
425 graph->SetPoint(icount,xcenter, stat);
432 // Make derived plots
435 void AliComparisonDraw::MakePlots(){
439 AliComparisonDraw * comp=this;
441 TFile *fp = new TFile("picutures.root","recreate");
442 TH1F *hiss=0, *hism=0;
443 TGraph2D * gr=0, gr2=0;
445 TCanvas * c = new TCanvas("Phi resol Tan","Phi resol Tan");
449 hiss = comp->MakeResol(comp->fCPtResolTan,1,0);
450 hiss->SetXTitle("Tan(#theta)");
451 hiss->SetYTitle("#sigmap_{t}/p_{t}");
453 hiss->Write("CptResolTan");
456 hiss = comp->MakeResol(comp->fCPhiResolTan,1,0);
458 hiss->SetXTitle("Tan(#theta)");
459 hiss->SetYTitle("#sigma#phi (rad)");
462 hiss->Write("PhiResolTan");
464 hiss = comp->MakeResol(comp->fCTanResolTan,1,0);
466 hiss->SetXTitle("Tan(#theta)");
467 hiss->SetYTitle("#sigma#theta (rad)");
470 hiss->Write("ThetaResolTan");
473 hiss = comp->MakeResol(comp->fCTanResolTan,1,0);
475 hiss->SetXTitle("Tan(#theta)");
476 hiss->SetYTitle("#sigmap_{t}/p_{t} ");
482 hiss = comp->MakeResol(comp->fTPCSignalNormTan,4,0);
483 hiss->SetXTitle("Tan(#theta)");
484 hiss->SetYTitle("#sigma_{dEdx}");
487 hiss->Write("TPCdEdxResolTan");
491 hiss = comp->MakeResol(comp->fTPCSignalNormTan,4,1);
492 hiss->SetXTitle("Tan(#theta)");
493 hiss->SetYTitle("<dEdx>");
495 hiss->Write("TPCdEdxMeanTan");
498 gr = comp->MakeStat2D(comp->fTPCSignalNormTanSPt,3,1,4);
499 gr->GetXaxis()->SetTitle("Tan(#theta)");
500 gr->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
501 gr->GetZaxis()->SetTitle("<dEdx>");
503 gr->GetHistogram()->Write("TPCdEdxMeanTanPt");
506 gr = comp->MakeStat2D(comp->fTPCSignalNormTanSPt,3,1,5);
507 gr->GetXaxis()->SetTitle("Tan(#theta)");
508 gr->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
509 gr->GetZaxis()->SetTitle("#sigma_{dEdx}");
511 gr->GetHistogram()->Write("TPCdEdxMeanTanPt");
515 comp->fEffTPCTanF->SetXTitle("Tan(#theta)");
516 comp->fEffTPCTanF->SetYTitle("eff_{findable}");
517 comp->fEffTPCTanF->Draw();
518 comp->fEffTPCTanF->Write("EffTanFindable");
521 comp->fEffTPCTan->SetXTitle("Tan(#theta)");
522 comp->fEffTPCTan->SetYTitle("eff_{all}");
523 comp->fEffTPCTan->Draw();
524 comp->fEffTPCTan->Write("EffTanAll");
528 gr0 = comp->MakeStat1D(comp->fD0TanSPtB1,2,5);
529 gr0->GetXaxis()->SetTitle("Tan(#theta)");
530 gr0->GetYaxis()->SetTitle("#sigmaDCA (cm)");
533 gr->GetHistogram()->Write("DCAResolTan");
537 gr = comp->MakeStat2D(comp->fD0TanSPtB1,4,2,5);
538 gr0->GetXaxis()->SetTitle("Tan(#theta)");
539 gr0->GetYaxis()->SetTitle("#sigmaDCA (cm)");
542 gr->GetHistogram()->Write("DCAResolSPTTan");