#include "TF1.h" #include "TCanvas.h" #include "TLegend.h" #include "TAxis.h" TF1 *Gks, *Gkf, *eLst, *fInt; double fint(double *x, double *par) { double tp = x[0]; double lambda = par[0]; double t = par[1]; return lambda*Gkf->Eval(tp)*eLst->Eval(tp)*Gks->Eval(t-tp); } double gkcalc(double *x, double * /*par*/) { double t = x[0]; fInt->SetParameter(1,t); return eLst->Eval(t)*Gkf->Eval(t) +fInt->Integral(0,t); } void gks() { //Calculate Gks //parameter[0] = alpha_k //parameter[1] = gamma Gks = new TF1("Gks","[0]+(1-[0])*exp(-[1]*x)",0,15); Gks->SetParameters(0.221243,0.4); //Calculate Gkf //parameter[0] = lambda_k //parameter[1] = tau_c Gkf = new TF1("Gkf","(1-[0]*[1])*exp(-[0]*x)",0,15); Gkf->SetParameters(0.172,0.5); //Calculate expLamba*t double Lambdas = 0.0345; //parameter[0] = 1 //parameter[1] = Lambda* eLst = new TF1("eLst","[0]*exp(-[1]*x)",0,15); eLst->SetParameters(1.,Lambdas); //calculate teh function to be integrated fInt = new TF1("fInt",fint,0,15,2); fInt->SetParameter(0,Lambdas); //Combine Gks and Gkf to for Gkcalc //TF1 *Gkcalc = new TF1("Gkcalc","Gkf*eLst*[0]*[1]",0,15); // This is the bit I can't get!!!!!!!! TF1 *Gkcalc = new TF1("Gkcalc",gkcalc,0,15,1); // This is the bit I can't get!!!!!!!! //Create a canvas to draw Gkcalc TCanvas *Gkcalc1 = new TCanvas("Gkcalc1","Gkcalc1",10,10,1400,1200); //Draw and format Gkcalc Gkcalc->Draw(); Gkcalc->SetLineWidth(2); Gkcalc->SetLineColor(kBlue); Gkcalc->GetXaxis()->SetTitle("time"); Gkcalc->GetYaxis()->SetTitle("G_{k}(t)"); Gkcalc->SetTitle("G_{k}(t) = e^{-#Lambda^{*} t}G_{k}^{(fluct.)}(t)+ #int_{0}^{t} #Lambda^{*} G_{k}^{(fluct.)}(t').e^{-#Lambda^{*} t'}G_{k}^{(stat.)} (t-t')dt' "); Gkcalc->GetYaxis()->SetLabelFont(22); Gkcalc->GetYaxis()->SetTitleFont(22); Gkcalc->GetXaxis()->SetLabelFont(22); Gkcalc->GetXaxis()->SetTitleFont(22); //Add other lines Gks->Draw("same"); Gks->SetLineWidth(2); Gks->SetLineColor(kRed); Gkf->Draw("same"); Gkf->SetLineWidth(2); Gkf->SetLineColor(kGreen); eLst->Draw("same"); eLst->SetLineWidth(2); eLst->SetLineColor(kMagenta); TLegend *legend = new TLegend(.75,.80,.95,.95); legend->AddEntry(Gkcalc,"G_{k}(t)"); legend->AddEntry(Gks,"G_{k}^{(stat)}(t)"); legend->AddEntry(Gkf,"G_{k}^{(fluct)}(t)"); legend->AddEntry(Gks,"e^{-#Lambda^{*} t}"); legend->Draw(); }