small changes in analysing macros
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / QAPlotsBoth.C
CommitLineData
88d02ae4 1Float_t QAPlotsBoth( AliSpectraBothHistoManager* hman_data, AliSpectraBothHistoManager* hman_mc,
2 AliSpectraBothEventCuts* ecuts_data, AliSpectraBothEventCuts* ecuts_mc,
3 AliSpectraBothTrackCuts* tcuts_data, AliSpectraBothTrackCuts* tcuts_mc,
33d374d5 4 TList * flistqa,TList * flistcanvas)
88d02ae4 5{
6TString pidmethods[3]={"TPC","TOF","TPCTOF"};
7 Double_t neventsdata = ecutsdata->NumberOfPhysSelEvents();
8 Double_t neventsmc = ecutsmc->NumberOfPhysSelEvents();
9
10 for(Int_t ipart=0;ipart<3;ipart++)
11 {
12 for(Int_t imethod=0;imethod<3;imethod++)
13 {
14 TH2F *nsig_data = (TH2F*)((TH2F*)hman_data->GetNSigHistogram(Form("hHistNSig%sPt%s",Particle[ipart].Data(),pidmethods[imethod].Data())))->Clone();
15 // nsig_data->RebinX(20);
16 // nsig_data->RebinY(4);
17 // nsig_data->Sumw2();
18
19 TH2F *nsig_mc = (TH2F*)((TH2F*)hman_mc->GetNSigHistogram(Form("hHistNSig%sPt%s",Particle[ipart].Data(),pidmethods[imethod].Data())))->Clone();
20 //nsig_mc->RebinX(20);
21 // nsig_mc->RebinY(4);
22 // nsig_mc->Sumw2();
23
24 Int_t ibin=1;
25 Float_t binsize=nsig_mc->GetXaxis()->GetBinWidth(1);
26 while (ibin*binsize<3.0)
27 {
28 // TCanvas* c=new TCanvas(Form("canvas%s%s%d",Particle[ipart].Data(),pidmethods[imethod].Data(),ibin),Form("canvas%s%s%d",Particle[ipart].Data(),pidmethods[imethod].Data(),ibin),700,500);
29
30 TH1F *nsig_data_Proj1=(TH1F*)nsig_data->ProjectionY(Form("%s%sdata[%.2f,%.2f]",Particle[ipart].Data(),pidmethods[imethod].Data(),nsig_data->GetXaxis()->GetBinLowEdge(ibin),nsig_data->GetXaxis()->GetBinUpEdge(ibin)),ibin,ibin));
31 TH1F *nsig_mc_Proj1=(TH1F*)nsig_mc->ProjectionY(Form("%s%smc[%.2f,%.2f]",Particle[ipart].Data(),pidmethods[imethod].Data(),nsig_mc->GetXaxis()->GetBinLowEdge(ibin),nsig_mc->GetXaxis()->GetBinUpEdge(ibin)),ibin,ibin));
32 nsig_data_Proj1->GetXaxis()->SetRangeUser(-3,3);
33 nsig_data_Proj1->SetLineColor(kRed);
34 if(nsig_data_Proj1->Integral()<1&&nsig_mc_Proj1->Integral()<1)
35 {
36 ibin++;
37 continue;
38 }
39 nsig_data_Proj1->Scale(1.0/neventsdata);
40 nsig_mc_Proj1->Scale(1.0/neventsmc);
41 // nsig_data_Proj1->Sumw2();
42 // nsig_mc_Proj1->Sumw2();
43 //nsig_data_Proj1->GetXaxis()->SetRangeUser(-5,5);
44
45 //c->cd()->SetLogy();
46 //nsig_data_Proj1->Draw();
47 //nsig_mc_Proj1->Draw("same");
33d374d5 48 flistqa->Add(nsig_data_Proj1);
49 flistqa->Add(nsig_mc_Proj1);
88d02ae4 50 ibin++;
51 }
52 }
53 }
54 TH1F* fHistoVtxAftSeldata=(TH1F*)ecuts_data->GetHistoVtxAftSel();
55 TH1F* fHistoVtxAftSelmc=(TH1F*)ecuts_mc->GetHistoVtxAftSel();
33d374d5 56 flistcanvas->Add(plot_on_canvas("vertex",fHistoVtxAftSeldata,fHistoVtxAftSelmc));
88d02ae4 57 TF1* fdata=new TF1("dataveretxfit","gausn");
58 TF1* fmc=new TF1("mcveretxfit","gausn");
59 fHistoVtxAftSeldata->Fit("dataveretxfit","0");
60 fHistoVtxAftSelmc->Fit("mcveretxfit","0");
61 Float_t datavertexratio=fHistoVtxAftSeldata->Integral(-1,-1,"width")/fdata->GetParameter(0);
62 Float_t mcvertexratio=fHistoVtxAftSelmc->Integral(-1,-1,"width")/fmc->GetParameter(0);
63
64
65 TH1F* fHistoEtaAftSeldata=(TH1F*)ecuts_data->GetHistoEtaAftSel();
66 TH1F* fHistoEtaAftSelmc=(TH1F*)ecuts_mc->GetHistoEtaAftSel();
33d374d5 67 flistcanvas->Add(plot_on_canvas("ETA",fHistoEtaAftSeldata,fHistoEtaAftSelmc));
88d02ae4 68
69
70 TH1F* fITSclustershistdata=(TH1F*)tcuts_data->GetHistoNclustersITS();
71 TH1F* fITSclustershistmc=(TH1F*)tcuts_mc->GetHistoNclustersITS();
72
33d374d5 73 flistcanvas->Add(plot_on_canvas("NITS",fITSclustershistdata,fITSclustershistmc));
88d02ae4 74 cout<<" data "<<datavertexratio<<" mc "<<mcvertexratio<<endl;
75
76 TH2F* hmul=(TH2F*)hman_mc->GetGenMulvsRawMulHistogram("hHistGenMulvsRawMul");
77 hmul->Sumw2();
78 TCanvas* cbc=new TCanvas("broken chunks","broken chunks",1200,600);
79 cbc->Divide(2,1);
80 cbc->cd(1);
81 hmul->Draw();
82 cbc->cd(2);
83 TH1F* nonzero=(TH1F*)hmul->ProjectionX("nonzerotracks",2,-1);
84 nonzero->SetMarkerColor(kRed);
85 nonzero->SetMarkerStyle(21);
86 TH1F* binzero=(TH1F*)hmul->ProjectionX("binzerotracks",1,1);
87 binzero->SetMarkerColor(kBlack);
88 binzero->SetMarkerStyle(22);
89 binzero->Sumw2();
90 nonzero->Sumw2();
91 binzero->Divide(nonzero);
92 TF1* badchunk=new TF1("badchunkfit","pol0",10,40);
93 binzero->Fit("badchunkfit","R");
94 Float_t badchunksfraction=badchunk->GetParameter(0);
95 binzero->Draw("E1");
33d374d5 96 flistcanvas->Add(cbc);
88d02ae4 97
98 return (1.0-badchunksfraction)*mcvertexratio/datavertexratio;
99
100}
101TCanvas* plot_on_canvas(TString name, TH1* h1,TH1* h2)
102{
103 TCanvas* cvrt=new TCanvas(name.Data(),name.Data(),600,600);
104 cvrt->cd();
105 h1->SetLineColor(kRed);
106 h2->SetLineColor(kBlue);
107 h1->Sumw2();
108 h2->Sumw2();
109 TLegend *lvtr=new TLegend(0.2,0.2,0.5,0.3,"","NDC");
110 lvtr->SetLineColor(kWhite);
111 lvtr->AddEntry(h1,"data","l");
112 lvtr->AddEntry(h2,"MC","l");
113 h1->Scale(1.0/h1->GetBinContent(h1->GetXaxis()->FindBin(0.0)));
114 h2->Scale(1.0/h2->GetBinContent(h2->GetXaxis()->FindBin(0.0)));
115 h1->DrawCopy("L");
116 h2->DrawCopy("Lsame");
117 lvtr->Draw();
118 return cvrt;
119}
120