#include "TFile.h" #include "TGraphErrors.h" #include "TF1.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("effvsE.txt", "%lg %lg %lg"); TF1 *RT = new TF1("RT",Fit1,100.,1500.,7.); RT->SetParameter(0,13.); RT->SetParameter(1,-0.3); RT->FixParameter(2,0.); RT->FixParameter(3,15.); RT->SetParameter(4,5.); RT->SetParameter(5,5.); RT->SetParameter(6,10.); RT->Draw("L"); g->Fit("RT","IER"); g->SetMarkerStyle(3); g->Draw("AP"); g->SetTitle("Efficiency Vs Energy(keV);Energy;Efficiency"); gStyle->SetOptFit(0111); //showing the parameters on graph double par[7]; RT->GetChisquare(); RT->GetParameters(par); }