#include "TF2.h" #include "TF12.h" #include "Math/Integrator.h" #include struct FitFunction { std::shared_ptr main; std::shared_ptr part; std::shared_ptr f12A; std::shared_ptr ig; FitFunction() { main = std::make_shared("main","[0]*TMath::Factorial(x)*(exp(-y)/exp([1]*pow(y,2)+[2]*pow(y,3)))"); f12A = std::make_shared("f12A",main.get(),0.,"y"); // it seems to me deno is a function of only one variable part = std::make_shared("deno","exp([1]*pow(x,2)+[2]*pow(x,3))" ); ig = std::make_shared(ROOT::Math::IntegrationOneDim::kADAPTIVESINGULAR); } double operator() (double *x, double *p) { main->SetParameters(p[0],p[1],p[2],p[3]); f12A->SetXY(x[0]); ig->SetFunction(*f12A); double mainsum = ig->IntegralUp(0.); part->SetParameters(p[1],p[2],p[3]); ig->SetFunction(*part); double deno = ig->IntegralUp(0.); return mainsum/deno; } }; void TestFitFunction() { FitFunction f; TF1 func("f",f,270, 340, 4); func.DrawClone(); }