// test_integrator_limits.cpp // // Author : Jeromy Tompkins // Date : 8/6/2012 // // Purpose: Investigate the effect that the abs and rel tolerance // parameters have on the precision of the result generated by // the VEGAS MC integrator. #include "Math/IntegratorMultiDim.h" #include "Math/WrappedFunction.h" #include "TMath.h" #include "TGraph.h" #include #include Double_t func(const Double_t* x) { return TMath::Sin(x[0])*TMath::Sin(x[0])*x[1]*x[1]; } int main() { Double_t abs_tolerance = 1.0e-8; Double_t rel_tolerance = 1.0e-10; ROOT::Math::IntegratorMultiDim integ(ROOT::Math::IntegrationMultiDim::kVEGAS, abs_tolerance, rel_tolerance); ROOT::Math::WrappedMultiFunction<> f(&::func, 2); Double_t xlow[] = {-1.0, 1.0}; Double_t xhi[] = { 0, 5.0}; std::cout << std::fixed << std::setprecision(15); UInt_t npoints = 100; TGraph* gr = new TGraph(npoints); for (UInt_t i=0; iSetPoint(i,i,res); } std::cout << "\n-------------------------------------------" << std::endl; std::cout << std::scientific << std::setprecision(3); std::cout << "\nAbsTol = " << std::setw(12) << abs_tolerance; std::cout << "\nRelTol = " << std::setw(12) << rel_tolerance; std::cout << "\nMean = " << std::setw(12) << gr->GetMean(2); std::cout << "\nRMS = " << std::setw(12) << gr->GetRMS(2); std::cout << "\n" << std::endl; delete gr; return 0; }