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 **************************************************************************/
16 // Draw corrections of secondaries
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
19 #if !defined(__CINT__) || defined(__MAKECINT__)
31 Int_t GetNumberCols(Int_t lowbin, Int_t hibin);
33 TCanvas* DrawMC(TH1D** hData, TH1D** hPrim, TH1D** hMat, TH1D** hFdwn, Int_t lowbin, Int_t hibin, const TString& name, const TString& title, const TH1D* hPt, Double_t dcaxyMin, Double_t dcaxyMax);
35 TCanvas* DrawFit(TH1D** hData, TH1D** hDataFit, TH1D** hPrim, TH1D** hMat, TH1D** hFdwn, Int_t lowbin, Int_t hibin, const TString& name, const TString& title, const TH1D* hPt, Double_t dcaxyMin, Double_t dcaxyMax);
37 TCanvas* DrawGoF(TH1D** hData, TH1D** hDataFit, Int_t lowbin, Int_t hibin, const TString& name, const TString& title, const TH1D* hPt, Double_t dcaxyMin, Double_t dcaxyMax);
39 void DrawSec(const TString& inputFile="debug.root", const TString& tag="test", const TString& particle="Proton", Double_t ptmin=0.5, Double_t ptmax=3., Double_t dcaxyMin=-1.5, Double_t dcaxyMax=1.5)
42 // draw corrections of secondaries
44 gStyle->SetPadTickX(1);
45 gStyle->SetPadTickY(1);
46 gStyle->SetOptStat(0);
47 gStyle->SetOptTitle(1);
49 const Int_t kNBin = 50;
51 TFile* finput = new TFile(inputFile.Data());
52 if (finput->IsZombie()) exit(1);
64 TH1D* hDataFit[kNBin];
65 TH1D* hPrimFit[kNBin];
67 TH1D* hFdwnFit[kNBin];
69 TH1D* hPidPt = FindObj<TH1D>(finput, tag, particle + "_PID_Pt");
71 Int_t lowbin = hPidPt->GetXaxis()->FindFixBin(ptmin);
72 Int_t hibin = hPidPt->GetXaxis()->FindFixBin(ptmax);
74 for(Int_t i=lowbin; i<hibin && i<kNBin; ++i)
77 hData[i] = FindObj<TH1D>(finput, tag, particle + Form("_Data_DCAxy_%02d",i));
78 hDataMC[i] = FindObj<TH1D>(finput, tag, particle + Form("_SimData_DCAxy_%02d",i));
79 hPrim[i] = FindObj<TH1D>(finput, tag, particle + Form("_Prim_DCAxy_%02d",i));
80 hMat[i] = FindObj<TH1D>(finput, tag, particle + Form("_Mat_DCAxy_%02d",i));
82 if(particle.Contains("Proton"))
84 hFdwn[i] = FindObj<TH1D>(finput, tag, particle + Form("_Fdwn_DCAxy_%02d",i));
92 hDataFit[i] = FindObj<TH1D>(finput, tag, particle + Form("_Fit_Data_DCAxy_%02d",i));
93 hPrimFit[i] = FindObj<TH1D>(finput, tag, particle + Form("_Fit_Prim_DCAxy_%02d",i));
94 hMatFit[i] = FindObj<TH1D>(finput, tag, particle + Form("_Fit_Mat_DCAxy_%02d",i));
96 if(particle.Contains("Proton"))
98 hFdwnFit[i] = FindObj<TH1D>(finput, tag, particle + Form("_Fit_Fdwn_DCAxy_%02d",i));
110 if(hDataMC[lowbin]!=0)
112 c0 = DrawMC(hDataMC, hPrim, hMat, hFdwn, lowbin, hibin, particle + ".MC", Form("MC simulation for %s",particle.Data()), hPidPt, dcaxyMin, dcaxyMax);
118 if(hDataFit[lowbin]!=0)
120 c1 = DrawFit(hData, hDataFit, hPrimFit, hMatFit, hFdwnFit, lowbin, hibin, particle + ".Fit", Form("Fitted DCA for %s",particle.Data()), hPidPt, dcaxyMin, dcaxyMax);
126 if(hDataFit[lowbin]!=0)
128 c2 = DrawGoF(hData, hDataFit, lowbin, hibin, particle + ".GoF", Form("GoF for %s",particle.Data()), hPidPt, dcaxyMin, dcaxyMax);
133 Int_t GetNumberCols(Int_t lowbin, Int_t hibin)
136 // number of rows and cols for plotting the slices
137 // square matrix (cols = rows)
139 return TMath::CeilNint(TMath::Sqrt(TMath::Abs(hibin - lowbin)));
142 TCanvas* DrawMC(TH1D** hData, TH1D** hPrim, TH1D** hMat, TH1D** hFdwn, Int_t lowbin, Int_t hibin, const TString& name, const TString& title, const TH1D* hPt, Double_t dcaxyMin, Double_t dcaxyMax)
145 // Draw MC DCA distributions for each pt bin
147 Int_t ncol = GetNumberCols(lowbin, hibin);
149 TCanvas* c0 = new TCanvas(name.Data(), title.Data());
150 c0->Divide(ncol, ncol);
152 for(Int_t i=lowbin; i < hibin; ++i)
158 hData[i]->SetTitle(Form("%0.2f < p_{T} < %0.2f GeV/c", hPt->GetBinLowEdge(i), hPt->GetBinLowEdge(i)+hPt->GetBinWidth(i)));
159 hData[i]->SetMinimum(0.2);
161 hData[i]->SetAxisRange(dcaxyMin, dcaxyMax, "X");
163 hData[i]->SetMarkerStyle(kFullCircle);
168 hPrim[i]->SetLineColor(9);
169 hPrim[i]->Draw("sameHist");
174 hMat[i]->SetLineColor(46);
175 hMat[i]->Draw("sameHist");
181 hFdwn[i]->SetLineColor(8);
182 hFdwn[i]->Draw("sameHist");
189 TCanvas* DrawFit(TH1D** hData, TH1D** hDataFit, TH1D** hPrim, TH1D** hMat, TH1D** hFdwn, Int_t lowbin, Int_t hibin, const TString& name, const TString& title, const TH1D* hPt, Double_t dcaxyMin, Double_t dcaxyMax)
192 // Draw DCA fitted model for each pt bin in current canvas
194 Int_t ncol = GetNumberCols(lowbin, hibin);
196 TCanvas* c0 = new TCanvas(name.Data(), title.Data());
197 c0->Divide(ncol, ncol);
199 for(Int_t i=lowbin; i < hibin && i < ncol*ncol; ++i)
205 hData[i]->SetTitle(Form("%0.2f < #it{p}_{T} < %0.2f GeV/c", hPt->GetBinLowEdge(i), hPt->GetBinLowEdge(i)+hPt->GetBinWidth(i)));
206 hData[i]->SetMinimum(0.2);
208 hData[i]->SetAxisRange(dcaxyMin, dcaxyMax, "X");
210 hData[i]->SetMarkerStyle(kFullCircle);
213 hDataFit[i]->SetLineColor(2);
214 hDataFit[i]->Draw("sameHist");
218 hPrim[i]->SetLineColor(9);
219 hPrim[i]->Draw("sameHist");
224 hMat[i]->SetLineColor(46);
225 hMat[i]->Draw("sameHist");
231 hFdwn[i]->SetLineColor(8);
232 hFdwn[i]->Draw("sameHist");
239 TCanvas* DrawGoF(TH1D** hData, TH1D** hDataFit, Int_t lowbin, Int_t hibin, const TString& name, const TString& title, const TH1D* hPt, Double_t dcaxyMin, Double_t dcaxyMax)
242 // Draw a goodness of fit for each pt bin consisting of data/fit
244 Int_t ncol = GetNumberCols(lowbin, hibin);
246 TCanvas* c0 = new TCanvas(name.Data(), title.Data());
247 c0->Divide(ncol, ncol);
249 for(Int_t i=lowbin; i < hibin; ++i)
253 TH1D* hDiv = (TH1D*)hData[i]->Clone("_Div_Data_Fit_");
255 hDiv->Divide(hDataFit[i]);
257 hDiv->SetTitle(Form("%0.2f < p_{T} < %0.2f GeV/c", hPt->GetBinLowEdge(i), hPt->GetBinLowEdge(i)+hPt->GetBinWidth(i)));
258 hDiv->SetAxisRange(dcaxyMin, dcaxyMax, "X");
259 hDiv->SetAxisRange(0,3,"Y");
260 hDiv->SetMarkerStyle(kFullCircle);