2 * Test script to fit the energy loss spectra
5 * This is a simple test script
7 * @ingroup pwg2_forward_analysis_scripts
10 # include "AliForwardUtil.h"
15 # include <TFitResult.h>
28 //____________________________________________________________________
40 * This is a simple test script
42 * @ingroup pwg2_forward_analysis_scripts
44 TH1* GetEDist(TList* ef, UShort_t d, Char_t r, UShort_t etabin)
46 TList* dL = static_cast<TList*>(ef->FindObject(Form("FMD%d%c",d,r)));
48 Error("GetEDist", "Couldn't find list FMD%d%c",d,r);
53 TH1* hist = static_cast<TH1*>(dL->FindObject(Form("FMD%d%c_edist",d,r)));
55 Error("GetEDist", "Couldn't find EDists histogram for FMD%d%c",d,r);
60 TList* edL = static_cast<TList*>(dL->FindObject("EDists"));
62 Error("GetEDist", "Couldn't find list EDists for FMD%d%c",d,r);
66 TH1* hist = static_cast<TH1*>(edL->FindObject(Form("FMD%d%c_etabin%03d",
69 Error("GetEDist", "Couldn't find histogra FMD%d%c_etabin%03d",
77 //____________________________________________________________________
89 * This is a simple test script
91 * @ingroup pwg2_forward_analysis_scripts
93 TH1* GetEDist(TList* ef, UShort_t d, Char_t r, Float_t eta)
96 Error("GetEDist", "EF not set");
99 TAxis* etaAxis = static_cast<TAxis*>(ef->FindObject("etaAxis"));
101 Error("GetEDist", "Couldn't find eta axis in list");
105 UShort_t bin = etaAxis->FindBin(eta);
106 if (bin <= 0 || bin > etaAxis->GetNbins()) {
107 Error("GetEDist", "eta=%f out of range [%f,%f] - getting ring histo",
108 eta, etaAxis->GetXmin(), etaAxis->GetXmax());
109 return GetEDist(ef, d, r, UShort_t(1000));
112 return GetEDist(ef, d, r, bin);
115 //____________________________________________________________________
124 * This is a simple test script
126 * @ingroup pwg2_forward_analysis_scripts
128 TList* GetEF(TFile* file)
130 TList* forward = static_cast<TList*>(file->Get("PWG2forwardDnDeta/Forward"));
132 Error("GetEF", "Failed to get list PWG2forwardDnDeta/Forward from file");
135 TList* ef = static_cast<TList*>(forward->FindObject("fmdEnergyFitter"));
137 Error("GetEF", "Failed to get energy fitter list");
144 //____________________________________________________________________
147 //____________________________________________________________________
155 * This is a simple test script
157 * @ingroup pwg2_forward_analysis_scripts
163 TFile* file = TFile::Open("AnalysisResults.root", "READ");
165 Error("Fit1", "Failed to open file");
171 //____________________________________________________________________
174 //____________________________________________________________________
182 * This is a simple test script
184 * @ingroup pwg2_forward_analysis_scripts
190 gStyle->SetOptFit(1111);
191 gStyle->SetCanvasColor(0);
192 gStyle->SetCanvasBorderSize(0);
193 gStyle->SetCanvasBorderMode(0);
194 gStyle->SetCanvasDefW(800);
195 gStyle->SetCanvasDefH(800);
196 gStyle->SetPadTopMargin(0.05);
197 gStyle->SetPadRightMargin(0.05);
198 gStyle->SetTitleBorderSize(0);
199 gStyle->SetTitleFillColor(0);
200 gStyle->SetTitleStyle(0);
201 gStyle->SetStatBorderSize(1);
202 gStyle->SetStatColor(0);
203 gStyle->SetStatStyle(0);
204 gStyle->SetStatX(0.95);
205 gStyle->SetStatY(0.95);
206 gStyle->SetStatW(0.15);
207 gStyle->SetStatH(0.15);
209 c = new TCanvas("c", "c");
215 //____________________________________________________________________
222 * This is a simple test script
224 * @ingroup pwg2_forward_analysis_scripts
226 void PrintFit(TF1* f)
228 Int_t nu = f->GetNDF();
229 Double_t chi2 = f->GetChisquare();
230 Double_t chi2nu = (nu > 0 ? chi2/nu : 0);
231 Printf("%s: chi^2/nu=%f/%d=%f [%f,%f]",
232 f->GetName(), chi2, nu, chi2nu,
233 f->GetXmin(), f->GetXmax());
234 for (Int_t i = 0; i < f->GetNpar(); i++) {
235 Double_t v = f->GetParameter(i);
236 Double_t e = f->GetParError(i);
237 Double_t r = 100*(v == 0 ? 1 : e / v);
238 Printf("%32s = %14.7f +/- %14.7f (%5.1f%%)",f->GetParName(i),v,e,r);
242 //____________________________________________________________________
252 * This is a simple test script
254 * @ingroup pwg2_forward_analysis_scripts
256 void FitELoss(Int_t n, UShort_t d, Char_t r, Float_t eta)
258 TList* ef1 = CheckEF();
259 TCanvas* c1 = CheckC();
263 TH1* dist = GetEDist(ef1, d, r, eta);
266 AliForwardUtil::ELossFitter f(0.4, 10, 4);
267 TF1* landau1 = new TF1(*f.Fit1Particle(dist, 0));
268 landau1->SetName("Landau1");
270 TF1* landaun = new TF1(*f.FitNParticle(dist, n, 0));
271 landau1->SetName(Form("Landau%d", n));
273 landau1->SetRange(0,10);
274 landaun->SetRange(0,10);
275 landau1->SetLineWidth(4);
276 landaun->SetLineWidth(4);
277 landau1->SetLineColor(kBlack);
278 landaun->SetLineColor(kBlack);
280 dist->GetListOfFunctions()->Clear();
281 dist->GetListOfFunctions()->Add(landau1);
282 dist->GetListOfFunctions()->Add(landaun);
283 dist->GetListOfFunctions()->ls();
285 landau1->Draw("same");
286 landaun->Draw("same");
288 Double_t mp = landaun->GetParameter(1);
289 Double_t xi = landaun->GetParameter(2);
290 for (Int_t i = 1; i <= n; i++) {
291 Double_t x = i * (mp + xi * TMath::Log(i));
292 Double_t y = landaun->Eval(x);
293 Double_t y1 = y < 0.05 ? 1 : 0.01;
294 TArrow* a = new TArrow(x,y1,x,y,0.03,"|>");
295 Info("FitSteer", "Delta_{p,%d}=%f", i, x);