1 #if !defined(__CINT__) || defined(__MAKECINT__)
4 #include <TGraphErrors.h>
5 #include <TGraphAsymmErrors.h>
12 #include <TDirectoryFile.h>
16 #include <TDatabasePDG.h>
17 #include "AliITSPIDResponse.h"
23 // Macro to extract the parameterizations of dE/dx in ITS vs. p
24 // using Phobos BB parameterization
27 Double_t BetheBlochPhobos(const Double_t *x, const Double_t *par);
28 Double_t BetheBlochPhobosBG(const Double_t *x, const Double_t *par);
29 Double_t BetheBlochAleph(const Double_t *x, const Double_t *par);
32 void ParametrizeITSBetheBloch(Bool_t optFromITSsa=kFALSE){
34 TFile *fil=new TFile("AnalysisResults.root");
36 TString dfName="PWG2SpectraITSsa";
37 TString listName="clistITSsaMult-1to-1";
38 TString hisName="fHistDEDX";
42 listName="clistITSsaTracks";
43 hisName="hdedxvsPt4clsITSpureSA";
45 TDirectoryFile* df=(TDirectoryFile*)fil->Get(dfName.Data());
47 printf("ERROR: directory file %s not found\n",dfName.Data());
50 TList* l=(TList*)df->Get(listName.Data());
52 printf("ERROR: TList %s not found\n",listName.Data());
55 hsigvsp=(TH2F*)l->FindObject(hisName.Data());
57 printf("ERROR: historgam %s not found\n",hisName.Data());
60 hsigvsp->GetXaxis()->SetTitle("momentum (GeV/c)");
61 hsigvsp->GetYaxis()->SetTitle("dE/dx (keV/300 #mum)");
63 Double_t minpPionFit=0.1;
64 Double_t maxpPionFit=0.8;
65 Double_t minbgGlobFit=0.3;
66 Double_t maxbgGlobFit=2.5;
67 Double_t minbgPions=2.;
68 Double_t maxbgPions=10.;
69 Double_t minpKaons=0.2;
70 Double_t maxpKaons=0.4;
71 Double_t maxbgKaons=0.7;
72 Double_t minpProtons=0.35;
73 Double_t maxpProtons=0.57;
74 Double_t maxbgProtons=0.7;
76 Double_t massPion=TDatabasePDG::Instance()->GetParticle(211)->Mass();
77 Double_t massKaon=TDatabasePDG::Instance()->GetParticle(321)->Mass();
78 Double_t massProton=TDatabasePDG::Instance()->GetParticle(2212)->Mass();
79 Double_t massDeuteron=1.8756;
83 Int_t nbinsX=hsigvsp->GetNbinsX();
84 printf("Total Number of bins =%d\n",nbinsX);
87 Int_t totPads=(Int_t)((Float_t)nbinsX/(Float_t)group+0.5);
88 Int_t totCanvas=totPads/16;
89 TCanvas** c0=new TCanvas*[totCanvas];
90 c0[iCanvas]=new TCanvas(Form("c0_%d",iCanvas),Form("c0_%d",iCanvas));
91 c0[iCanvas]->Divide(4,4);
92 TCanvas** c0k=new TCanvas*[totCanvas];
93 c0k[iCanvas]=new TCanvas(Form("c0k_%d",iCanvas),Form("c0k_%d",iCanvas));
94 c0k[iCanvas]->Divide(4,4);
95 TCanvas** c0p=new TCanvas*[totCanvas];
96 c0p[iCanvas]=new TCanvas(Form("c0p_%d",iCanvas),Form("c0p_%d",iCanvas));
97 c0p[iCanvas]->Divide(4,4);
99 TGraphErrors* gdedxpi=new TGraphErrors(0);
100 TGraphErrors* gdedxk=new TGraphErrors(0);
101 TGraphErrors* gdedxp=new TGraphErrors(0);
102 TGraphErrors* gdedxbg=new TGraphErrors(0);
103 gdedxbg->SetTitle("");
109 for(Int_t iBin=1; iBin<=nbinsX; iBin+=group){
112 c0[iCanvas]=new TCanvas(Form("c0_%d",iCanvas),Form("c0_%d",iCanvas));
113 c0[iCanvas]->Divide(4,4);
114 c0k[iCanvas]=new TCanvas(Form("c0k_%d",iCanvas),Form("c0k_%d",iCanvas));
115 c0k[iCanvas]->Divide(4,4);
116 c0p[iCanvas]=new TCanvas(Form("c0p_%d",iCanvas),Form("c0p_%d",iCanvas));
117 c0p[iCanvas]->Divide(4,4);
124 for(Int_t ibx=iBin; ibx<iBin+group;ibx++){
125 for(Int_t iby=1; iby<=hsigvsp->GetNbinsY();iby++){
126 sum+=hsigvsp->GetXaxis()->GetBinCenter(ibx)*hsigvsp->GetBinContent(ibx,iby);
127 sumwei+=hsigvsp->GetBinContent(ibx,iby);
130 if(sumwei>0.) pmed=sum/sumwei;
131 if(pmed<0.1) continue;
132 Int_t iPmed=(Int_t)(pmed*1000);
133 TH1D* hProj=hsigvsp->TH2F::ProjectionY(Form("proj%d",iPmed),iBin,iBin+group-1);
134 TH1D* hKaon=(TH1D*)hProj->Clone(Form("projk%d",iPmed));
135 c0[iCanvas]->cd(iPad);
136 hProj->SetLineColor(2);
139 Float_t peakpos=hProj->GetBinCenter(hProj->GetMaximumBin());
140 Float_t peaksig=0.1*peakpos;
141 hProj->Fit("gaus","LL","",peakpos-3*peaksig,peakpos+3.*peaksig);
142 TF1* fgaus=(TF1*)hProj->GetListOfFunctions()->FindObject("gaus");
143 gdedxpi->SetPoint(nPpi,sum/sumwei,fgaus->GetParameter(1));
144 gdedxpi->SetPointError(nPpi,0.,fgaus->GetParError(1));
146 if(pmed/massPion>minbgPions && pmed/massPion<maxbgPions){
147 gdedxbg->SetPoint(nPbg,pmed/massPion,fgaus->GetParameter(1));
148 gdedxbg->SetPointError(nPbg,0.,fgaus->GetParError(1));
151 for(Int_t iBinK=1; iBinK<=hKaon->GetNbinsX(); iBinK++){
152 Double_t cont=hKaon->GetBinContent(iBinK)-fgaus->Eval(hKaon->GetBinCenter(iBinK));
154 if(hKaon->GetBinCenter(iBinK)<fgaus->GetParameter(1)) cont=0;
155 hKaon->SetBinContent(iBinK,cont);
157 c0k[iCanvas]->cd(iPad);
158 hKaon->SetLineColor(4);
160 TH1D* hProton=(TH1D*)hKaon->Clone(Form("projp%d",iPmed));
162 Double_t mink=250-600*(pmed-0.2);
163 Double_t maxk=mink+mink;
164 hKaon->Fit("gaus","LL","",mink,maxk);
165 fgausk=(TF1*)hKaon->GetListOfFunctions()->FindObject("gaus");
166 if(pmed>minpKaons && pmed<maxpKaons){
167 gdedxk->SetPoint(nPk,pmed,fgausk->GetParameter(1));
168 gdedxk->SetPointError(nPk,0.,fgausk->GetParError(1));
170 if(pmed/massKaon<maxbgKaons){
171 gdedxbg->SetPoint(nPbg,pmed/massKaon,fgausk->GetParameter(1));
172 gdedxbg->SetPointError(nPbg,0.,fgausk->GetParError(1));
177 for(Int_t iBinP=1; iBinP<=hProton->GetNbinsX(); iBinP++){
178 Double_t cont=hKaon->GetBinContent(iBinP)-fgausk->Eval(hKaon->GetBinCenter(iBinP));
180 if(hProton->GetBinCenter(iBinP)<fgausk->GetParameter(1)) cont=0;
181 hProton->SetBinContent(iBinP,cont);
184 c0p[iCanvas]->cd(iPad);
185 hProton->SetLineColor(kGreen+1);
187 if(pmed>minpProtons && pmed<maxpProtons){
188 Double_t minP=300-600*(pmed-0.35);
189 Double_t maxP=minP+minP;
190 hProton->Fit("gaus","LL","",minP,maxP);
191 TF1* fgausp=(TF1*)hProton->GetListOfFunctions()->FindObject("gaus");
192 gdedxp->SetPoint(nPp,pmed,fgausp->GetParameter(1));
193 gdedxp->SetPointError(nPp,0.,fgausp->GetParError(1));
195 if(pmed/massProton<maxbgProtons){
196 gdedxbg->SetPoint(nPbg,pmed/massProton,fgausp->GetParameter(1));
197 gdedxbg->SetPointError(nPbg,0.,fgausp->GetParError(1));
204 gStyle->SetPalette(1);
205 hsigvsp->GetXaxis()->SetRangeUser(0.07,1.8);
206 hsigvsp->SetStats(0);
207 TCanvas* c1=new TCanvas("c1","Pion Fit");
209 hsigvsp->Draw("col");
210 gdedxpi->Draw("Psame");
211 gdedxk->Draw("Psame");
212 gdedxp->Draw("Psame");
214 TF1 *fPhobos=new TF1("fPhobos",BetheBlochPhobos,minpPionFit,maxpPionFit,5);
215 fPhobos->SetParLimits(0,0.,1.E9);
216 fPhobos->SetParLimits(1,0.,100.);
217 fPhobos->SetParLimits(2,0.,1.);
218 fPhobos->SetParLimits(3,0.,1.);
219 fPhobos->SetParLimits(4,0.,1.);
220 gdedxpi->Fit("fPhobos","R");
222 TCanvas* c1g=new TCanvas("c1g","Global Fit");
223 TF1 *fPhobosbg=new TF1("fPhobosbg",BetheBlochPhobosBG,minbgGlobFit,maxbgGlobFit,5);
224 fPhobosbg->SetParLimits(0,0.,1.E9);
225 fPhobosbg->SetParLimits(1,0.,100.);
226 fPhobosbg->SetParLimits(2,0.,1.);
227 fPhobosbg->SetParLimits(3,0.,1.);
228 fPhobosbg->SetParLimits(4,0.,1.);
230 gdedxbg->GetXaxis()->SetTitle("#beta#gamma");
231 gdedxbg->GetYaxis()->SetTitle("dE/dx (keV/300 #mum)");
232 gdedxbg->Fit("fPhobosbg","R");
236 AliITSPIDResponse* itsresGlobFit=new AliITSPIDResponse(kFALSE);
237 AliITSPIDResponse* itsres=new AliITSPIDResponse(kFALSE);
238 Double_t parameters[5],parametersGlob[5];
240 printf("-------- Pion Fit Parameters -----------\n");
241 for(Int_t iPar=0; iPar<5; iPar++){
242 parameters[iPar]=fPhobos->GetParameter(iPar);
243 printf("parameters[%d]=%g;\n",iPar,parameters[iPar]);
245 printf("-------- Global Fit Parameters -----------\n");
246 for(Int_t iPar=0; iPar<5; iPar++){
247 parametersGlob[iPar]=fPhobosbg->GetParameter(iPar);
248 printf("parametersGlob[%d]=%g;\n",iPar,parametersGlob[iPar]);
251 itsresGlobFit->SetBetheBlochParamsITSsa(parametersGlob);
252 itsres->SetBetheBlochParamsITSsa(parameters);
254 TGraph* gPion=new TGraph(0);
255 TGraph* gKaon=new TGraph(0);
256 TGraph* gProton=new TGraph(0);
257 TGraph* gPionGlobFit=new TGraph(0);
258 TGraph* gKaonGlobFit=new TGraph(0);
259 TGraph* gProtonGlobFit=new TGraph(0);
261 TGraphAsymmErrors* gBBpions=new TGraphAsymmErrors(0);
262 TGraphAsymmErrors* gBBkaons=new TGraphAsymmErrors(0);
263 TGraphAsymmErrors* gBBprotons=new TGraphAsymmErrors(0);
264 TGraphAsymmErrors* gBBpionsGlobFit=new TGraphAsymmErrors(0);
265 TGraphAsymmErrors* gBBkaonsGlobFit=new TGraphAsymmErrors(0);
266 TGraphAsymmErrors* gBBprotonsGlobFit=new TGraphAsymmErrors(0);
268 Double_t numberofsigmapions=2.;
270 resodedx[0]=0.0001; //default value
271 resodedx[1]=0.0001; //default value
276 for(Int_t ip=0; ip<400; ip++){
277 Double_t mom=0.1+0.02*ip;
278 Double_t dedxpions=itsres->Bethe(mom,massPion,kTRUE);
279 Double_t dedxkaons=itsres->Bethe(mom,massKaon,kTRUE);
280 Double_t dedxprotons=itsres->Bethe(mom,massProton,kTRUE);
281 Double_t dedxdeutons=itsres->Bethe(mom,massDeuteron,kTRUE);
282 Double_t dedxpionsGlobFit=itsresGlobFit->Bethe(mom,massPion,kTRUE);
283 Double_t dedxkaonsGlobFit=itsresGlobFit->Bethe(mom,massKaon,kTRUE);
284 Double_t dedxprotonsGlobFit=itsresGlobFit->Bethe(mom,massProton,kTRUE);
285 Double_t dedxdeutonsGlobFit=itsresGlobFit->Bethe(mom,massDeuteron,kTRUE);
287 gPion->SetPoint(ip,mom,dedxpions);
288 gKaon->SetPoint(ip,mom,dedxkaons);
289 gProton->SetPoint(ip,mom,dedxprotons);
290 gPionGlobFit->SetPoint(ip,mom,dedxpionsGlobFit);
291 gKaonGlobFit->SetPoint(ip,mom,dedxkaonsGlobFit);
292 gProtonGlobFit->SetPoint(ip,mom,dedxprotonsGlobFit);
294 gBBpions->SetPoint(ip,mom,dedxpions);
295 gBBpions->SetPointError(ip,0,0,(dedxpions*resodedx[3]*numberofsigmapions),TMath::Abs((dedxpions-dedxkaons)/2));
296 gBBkaons->SetPoint(ip,mom,dedxkaons);
297 gBBkaons->SetPointError(ip,0,0,TMath::Abs((dedxpions-dedxkaons)/2),TMath::Abs((dedxprotons-dedxkaons)/2));
298 gBBprotons->SetPoint(ip,mom,dedxprotons);
299 gBBprotons->SetPointError(ip,0,0,TMath::Abs((dedxprotons-dedxkaons)/2),TMath::Abs((dedxprotons-dedxdeutons)/2));
301 gBBpionsGlobFit->SetPoint(ip,mom,dedxpionsGlobFit);
302 gBBpionsGlobFit->SetPointError(ip,0,0,(dedxpionsGlobFit*resodedx[3]*numberofsigmapions),TMath::Abs((dedxpions-dedxkaonsGlobFit)/2));
303 gBBkaonsGlobFit->SetPoint(ip,mom,dedxkaonsGlobFit);
304 gBBkaonsGlobFit->SetPointError(ip,0,0,TMath::Abs((dedxpionsGlobFit-dedxkaonsGlobFit)/2),TMath::Abs((dedxprotonsGlobFit-dedxkaonsGlobFit)/2));
305 gBBprotonsGlobFit->SetPoint(ip,mom,dedxprotonsGlobFit);
306 gBBprotonsGlobFit->SetPointError(ip,0,0,TMath::Abs((dedxprotonsGlobFit-dedxkaonsGlobFit)/2),TMath::Abs((dedxprotonsGlobFit-dedxdeutonsGlobFit)/2));
310 TCanvas* c2=new TCanvas("c2","Parameterizations");
312 hsigvsp->SetMinimum(20);
313 hsigvsp->Draw("col");
314 gPion->Draw("LSAME");
315 gKaon->Draw("LSAME");
316 gProton->Draw("LSAME");
317 gPionGlobFit->SetLineColor(kRed+1);
318 gKaonGlobFit->SetLineColor(kRed+1);
319 gProtonGlobFit->SetLineColor(kRed+1);
320 gPionGlobFit->Draw("LSAME");
321 gKaonGlobFit->Draw("LSAME");
322 gProtonGlobFit->Draw("LSAME");
323 TLatex* t1=new TLatex(0.7,0.85,"Pion Fit");
326 TLatex* tG=new TLatex(0.7,0.75,"Global Fit");
328 tG->SetTextColor(kRed+1);
332 gBBpions->SetLineColor(2);
333 gBBpions->SetLineWidth(2);
334 gBBpions->SetFillColor(2);
335 gBBpions->SetFillStyle(3001);
336 gBBkaons->SetLineColor(3);
337 gBBkaons->SetLineWidth(2);
338 gBBkaons->SetFillColor(3);
339 gBBkaons->SetFillStyle(3001);
340 gBBprotons->SetLineColor(4);
341 gBBprotons->SetLineWidth(2);
342 gBBprotons->SetFillColor(4);
343 gBBprotons->SetFillStyle(3001);
345 TCanvas* c3=new TCanvas("c3","Asymm Bands, PionFit");
348 hsigvsp->SetMinimum(20);
349 hsigvsp->Draw("col");
350 gBBpions->Draw("L4same");
351 gBBkaons->Draw("L4same");
352 gBBprotons->Draw("L4same");
354 gBBpionsGlobFit->SetLineColor(2);
355 gBBpionsGlobFit->SetLineWidth(2);
356 gBBpionsGlobFit->SetFillColor(2);
357 gBBpionsGlobFit->SetFillStyle(3001);
358 gBBkaonsGlobFit->SetLineColor(3);
359 gBBkaonsGlobFit->SetLineWidth(2);
360 gBBkaonsGlobFit->SetFillColor(3);
361 gBBkaonsGlobFit->SetFillStyle(3001);
362 gBBprotonsGlobFit->SetLineColor(4);
363 gBBprotonsGlobFit->SetLineWidth(2);
364 gBBprotonsGlobFit->SetFillColor(4);
365 gBBprotonsGlobFit->SetFillStyle(3001);
367 TCanvas* c3g=new TCanvas("c3g","Asymm Bands, GlobFit");
370 hsigvsp->SetMinimum(20);
371 hsigvsp->Draw("col");
372 gBBpionsGlobFit->Draw("L4same");
373 gBBkaonsGlobFit->Draw("L4same");
374 gBBprotonsGlobFit->Draw("L4same");
383 Double_t BetheBlochPhobos(const Double_t *x, const Double_t *par){
386 // returns AliExternalTrackParam::BetheBloch normalized to
387 // fgMIP at the minimum
390 Double_t massPion=TDatabasePDG::Instance()->GetParticle(211)->Mass();
391 Double_t bg=x[0]/massPion;
392 Double_t beta = bg/TMath::Sqrt(1.+ bg*bg);
393 Double_t gamma=bg/beta;
396 eff=(bg-par[3])*(bg-par[3])+par[4];
398 eff=(par[2]-par[3])*(par[2]-par[3])+par[4];
401 if(gamma>=0. && beta>0.){
402 bb=(par[1]+2.0*TMath::Log(gamma)-beta*beta)*(par[0]/(beta*beta))*eff;
407 Double_t BetheBlochPhobosBG(const Double_t *x, const Double_t *par){
410 // returns AliExternalTrackParam::BetheBloch normalized to
411 // fgMIP at the minimum
415 Double_t beta = bg/TMath::Sqrt(1.+ bg*bg);
416 Double_t gamma=bg/beta;
419 eff=(bg-par[3])*(bg-par[3])+par[4];
421 eff=(par[2]-par[3])*(par[2]-par[3])+par[4];
424 if(gamma>=0. && beta>0.){
425 bb=(par[1]+2.0*TMath::Log(gamma)-beta*beta)*(par[0]/(beta*beta))*eff;
430 Double_t BetheBlochAleph(const Double_t *x, const Double_t *par){
433 // This is the empirical ALEPH parameterization of the Bethe-Bloch formula.
434 // It is normalized to 1 at the minimum.
438 // The default values for the kp* parameters are for ALICE TPC.
439 // The returned value is in MIP units
442 Double_t massPion=TDatabasePDG::Instance()->GetParticle(211)->Mass();
443 Double_t bg=x[0]/massPion;
444 Double_t beta = bg/TMath::Sqrt(1.+ bg*bg);
446 Double_t aa = TMath::Power(beta,par[3]);
447 Double_t bb = TMath::Power(1./bg,par[4]);
449 bb=TMath::Log(par[2]+bb);
451 return (par[1]-aa-bb)*par[0]/aa;