/*This script tests the use of ROOT's MATHMORE GSL-based integrators--syntax, function structure etc. */ #include "TObject.h" #include "TROOT.h" #include "TMath.h" #include "TH1.h" #include "TCanvas.h" #include "TLegend.h" #include "TStopwatch.h" //#include "TLabel.h" #include "Math/Functor.h" #include "Math/WrappedFunction.h" #include "Math/IFunction.h" #include "Math/Integrator.h" #include "Math/IntegratorMultiDim.h" #include "Math/GSLMCIntegrator.h" #include "Math/WrappedParamFunction.h" #include #include "Math/IParamFunction.h" #include "Math/ParamFunction.h" #include "Math/MultiDimParamFunctionAdapter.h" double funcmc(const double *x, const double *p){ // *x since arrays for multidimensional // return pow(x[0], 2.)*x[1]; double c = x[0]; double d = x[1]; double y = p[0]*pow(c+d, 2.) + p[1]; return y; } // exact answer is 1506.6667 void integratortest(){ //---Monte Carlo Multi-D------// TStopwatch time; time. Start(); double a[2] = {0., 0.}; double b[2] = {5., 2.}; double p[2] = {10., 4.}; ROOT::Math::WrappedParamFunction<> f1(&funcmc, 2, 2, p); //function object, #dims, #params, param array unsigned int calls = 1000; ROOT::Math::GSLMCIntegrator mc(ROOT::Math::MCIntegration::kVEGAS, 1E-4, 1E-5, calls); mc.SetFunction(f1); double s1 = mc.Integral(a,b); time. Stop(); cout << s1 <<" in "<