7 #include <AliHFMassFitter.h>
9 //root[0] .L plotHFMassFitterOutput.C+
10 //root[1] plotHFMassFitterOutput(2)
12 //input: pt bin you want to plot; path of the HFMassFitterOutput.root file
15 //grey= background with parameters from the fit on the side-bands
16 //red= background with parameters from the total fit
19 void plotHFMassFitterOutput(Int_t ptbin, TString path="./"){
20 TString stdfilename="HFMassFitterOutput.root";
21 stdfilename.Prepend(path);
23 cout<<"Opening "<<stdfilename<<endl;
24 TFile *fin=new TFile(stdfilename.Data());
26 cout<<"File "<<stdfilename<<" not found"<<endl;
29 TString histoname="histMass_";
32 TH1F *h=(TH1F*)fin->Get(histoname);
34 cout<<histoname<<" is not here, sorry!"<<endl;
35 histoname="fhistoInvMass";
36 h=(TH1F*)fin->Get(histoname);
38 cout<<histoname<<" is not here, sorry!"<<endl;
39 cout<<"Write the name of the histo required (e.g. histMassSum<factor>_<ptbin>): ";
41 h=(TH1F*)fin->Get(histoname);
43 cout<<histoname<<" is not in "<<stdfilename<<" check it, please!"<<endl;
48 h->SetName(histoname);
54 cout<<histoname<<" will be drawn!"<<endl;
55 TCanvas *c1=new TCanvas("c1",histoname);
56 //funcbkgfullrange_faint
58 (h->GetFunction("funcbkgFullRange"))->SetLineColor(14);
59 (h->GetFunction("funcbkgFullRange"))->SetLineStyle(4);
62 (h->GetFunction("funcbkgFullRange"))->GetRange(xmin,xmax);
63 Int_t nfreepar=h->GetFunction("funcbkgFullRange")->GetNumberFreeParameters();
64 cout<<"nfreepar = "<<nfreepar<<endl;
66 cout<<"Range = ("<<xmin<<", "<<xmax<<")"<<endl;
67 cout<<"Bin Width "<<h->GetBinWidth(3)<<endl;
68 cout<<"Initial parameters:\n";
69 cout<<"par0= "<<h->GetFunction("funcbkgFullRange")->GetParameter(0)<<endl;
70 cout<<"par1= "<<h->GetFunction("funcbkgFullRange")->GetParameter(1)<<endl;
71 cout<<"par2= "<<h->GetFunction("funcbkgFullRange")->GetParameter(2)<<endl;
72 cout<<"Formula= "<<h->GetFunction("funcbkgFullRange")->GetExpFormula()<<endl;
74 TF1 *fmass=h->GetFunction("funcmass");
75 cout<<"Parametri massa input:\n";
76 cout<<"par0= "<<h->GetFunction("funcmass")->GetParameter(0)-h->GetFunction("funcmass")->GetParameter(nfreepar)<<endl;
77 cout<<"par1= "<<h->GetFunction("funcmass")->GetParameter(1)<<endl;
78 cout<<"par2= "<<h->GetFunction("funcmass")->GetParameter(2)<<endl;
81 AliHFMassFitter *fitter=new AliHFMassFitter(h,xmin,xmax,1,2,0);
82 fitter->SetSideBands(kFALSE);
84 //funcbkgfullrange_deep
86 TF1 *fbkgfullrange_deep=new TF1("fbkgfullrange_deep",fitter,&AliHFMassFitter::FitFunction4Bkg,xmin,xmax,nfreepar,"AliHFMassFitter","FitFunction4Bkg");
89 fbkgfullrange_deep->SetParameter(0,(fmass->GetParameter(0)-fmass->GetParameter(nfreepar))); //lin exp pol2 no-bkg
90 if(nfreepar>=2) fbkgfullrange_deep->SetParameter(1,fmass->GetParameter(1)); //lin exp pol2
91 if(nfreepar==3) fbkgfullrange_deep->SetParameter(2,fmass->GetParameter(2)); //pol2
93 fbkgfullrange_deep->SetMinimum(0);
95 cout<<"Final parameters:\n";
96 cout<<"par0= "<<fbkgfullrange_deep->GetParameter(0)<<"\tcompare with "<<fbkgfullrange_deep->Integral(xmin,xmax)<<endl;
97 cout<<"par1= "<<fbkgfullrange_deep->GetParameter(1)<<endl;
98 cout<<"par2= "<<fbkgfullrange_deep->GetParameter(2)<<endl;
101 fbkgfullrange_deep->SetLineStyle(1);
102 fbkgfullrange_deep->SetLineColor(2);
104 fbkgfullrange_deep->Draw("sames");
105 fmass->Draw("sames");
108 cout<<histoname<<" is not here, sorry!"<<endl;