#include "TF2.h" #include "TF12.h" #include "TCanvas.h" #include "TF1.h" TF2 *f = new TF2("f", "[0]*[0]*(x^2+y^2)+[1]*(x^2+y^2)", -1, 1, -1, 1); TF12 *sl; TF1 *sli; Int_t np = 20; double *x1=new double[np]; double *w=new double[np]; Double_t slice(Double_t *x, Double_t *par) { f->SetParameters(par[0], par[1]); if(sl!=NULL) delete sl; sl = new TF12("sl", f, x[0], "y"); sl->CalcGaussLegendreSamplingPoints(np,x1,w,1e-10); return sl->IntegralFast(np, x1, w, -1, 1); // return sl->Integral(-1, 1); } Double_t intg(Double_t *x, Double_t *par) { if(sli!=NULL) delete sli; sli = new TF1("sli", slice, -1, 1, 2); sli->SetParameters(x[0], x[1]); sli->CalcGaussLegendreSamplingPoints(np,x1,w,1e-10); return sli->IntegralFast(np, x1, w, -1, 1); // return sli->Integral(-1, 1); } void par2() { sl=NULL; f->SetNpx(100); f->SetNpy(100); f->SetParameters(2, 1); f->Draw("colz"); new TCanvas(); TF2 *ires = new TF2("ires", intg, -1, 1, -1, 1, 0); ires->SetNpx(100); ires->SetNpy(100); ires->Draw("colz"); }