#include #include #include #include "TROOT.h" #include "TChain.h" #include "TString.h" #include "THStack.h" #include "TF1.h" #include "TCanvas.h" #include "TPad.h" #include "TH1.h" #include "TH2.h" #include "TLegend.h" #include "TPaveText.h" #include "TVirtualFitter.h" #include "TMath.h" #include "TClonesArray.h" #include "TLatex.h" #include "TStyle.h" #include "TNamed.h" using namespace std; void myPadeRoot() { gROOT->Reset(); //Variables to use Double_t chi2 = 100; Double_t p0 = 0; Double_t p1 = 0; Double_t p2 = 0; Double_t p3 = 0; Double_t p4 = 0; Double_t p5 = 0; //Take data form ascii file and plot it TGraph *mygraph = new TGraph("logdata.dat"); mygraph->Draw("ALP"); //Set some Minimizer options ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit","Migrad"); // EL que viene por defecto ROOT::Math::MinimizerOptions::SetDefaultStrategy(2); // Para quee busque mejor el minimo y s eolvide de la rapidez ROOT::Math::MinimizerOptions::SetDefaultErrorDef(1); // 1 para chi^2 (default), 0.5 para log-likelihood //Start the fit to the Padé aproximants, order by order //Zeroth order [1,0] TF1 *P10 = new TF1("P10","[0]/(1-(([1]/[0])*x) )"); // Define the fit function P10->SetParameters(0,0); // Set initial parameters value mygraph->Fit("P10","EM+"); p0 = P10->GetParameter(0); p1 = P10->GetParameter(1); chi2 = P10->GetChisquare(); //First order [1,1] TF1 *P11 = new TF1("P11","[0] + ([1]*x)/(1-(([2]/[1])*x) )"); P11->SetParameters(p0,p1,0); mygraph->Fit("P11","EM+"); p0 = P11->GetParameter(0); p1 = P11->GetParameter(1); p2 = P11->GetParameter(2); chi2 = P11->GetChisquare(); //Second order [1,2] TF1 *P12 = new TF1("P12","[0] + [1]*x + ([2]*x*x)/(1-(([3]/[2])*x) )"); P12->SetParameters(p0,p1,p2,0); mygraph->Fit("P12","EM+"); p0 = P12->GetParameter(0); p1 = P12->GetParameter(1); p2 = P12->GetParameter(2); p3 = P12->GetParameter(3); chi2 = P12->GetChisquare(); //Third order [1,3] TF1 *P13 = new TF1("P13","[0] + [1]*x + [2]*x*x + ([3]*x*x*x)/(1-(([4]/[3])*x) )"); P13->SetParameters(p0,p1,p2,p3,0); mygraph->Fit("P13","EM+"); chi2 = P13->GetChisquare(); //Fourth order [1,4] TF1 *P14 = new TF1("P14","[0] + [1]*x + [2]*x*x + [3]*x*x*x + ([4]*x*x*x*x)/(1-(([5]/[4])*x) )"); P14->SetParameters(p0,p1,p2,p3,0,0); mygraph->Fit("P14","M+"); TF1 *pade14 = mygraph->GetFunction("P14"); //Graph options gStyle->SetOptFit(1111); // gStyle->SetOptFit(pcev); p=probability, c=chi2/dof, e=print errors (if v=1), v=print name/values of parameters }