#include "TFile.h" #include "TGraphErrors.h" #include "TF1.h" #include "TMath.h" Double_t Fit1(Double_t *x, Double_t *par) { Double_t arg1 = TMath::Log(0.01*x[0]); // in keV Double_t arg2 = TMath::Log(0.001*x[0]); // in keV Double_t fit_val = TMath::Exp(TMath::Power((TMath::Power((par[0]+par[1]*arg1+par[2]*arg1*arg1),(-1.0*par[3]))+TMath::Power((par[4]+par[5]*arg2+par[6]*arg2*arg2),(-1.0*par[3]))),(-1.0*1/par[3])))/1000.; return fit_val; } void efficiency_R() { TGraphErrors *g = new TGraphErrors("candle_32degree.txt", "%lg %lg %lg"); ROOT::Math::MinimizerOptions::SetDefaultMaxFunctionCalls(1000000); TF1 *RT = new TF1("RT",Fit1,100.,1500.,7.); /*RT->SetParameter(0,16.); RT->SetParameter(1,7.5); RT->FixParameter(2,0.); RT->FixParameter(3,15.); RT->SetParameter(4,15.); RT->SetParameter(5,-0.78); RT->SetParameter(6,.015);*/ RT->SetParameter(0,7.); RT->SetParameter(1,2.5); RT->SetParameter(2,-1.0); RT->FixParameter(3,0.8); RT->SetParameter(4,40.); RT->SetParameter(5,8.0); RT->SetParameter(6,15); RT->Draw("L"); //g->SetMaximum(15000.);//along Y g->SetMaximum(1.5);//along Y g->Fit("RT","IER"); g->SetMarkerStyle(4); g->Draw("AP"); g->SetTitle("Efficiency Vs Energy(keV);Energy;Efficiency"); gStyle->SetOptFit(1111); //showing the parameters on graph TPaveText *pt = new TPaveText(77.6016,12857.83,971.9464,14578.31); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->AddText("Exp{[(P0+P1*X+P2*X*X)**(-P3)+(P4+P5*Y+P6*Y*Y)**(-P3)]**(-1/P3)}"); pt->AddText("WITH X = LOG (X/100) & Y = LOG (X/1000)"); pt->Draw(); /*double par[7]; RT->GetChisquare(); RT->GetParameters(par); // double a = 700.0, y; // y = RT->Eval(a); // cout << "y = "<