45#include "gsl/gsl_monte_vegas.h"
46#include "gsl/gsl_monte_miser.h"
47#include "gsl/gsl_monte_plain.h"
185 assert(
fRng !=
nullptr);
186 gsl_rng* fr =
fRng->Rng();
187 assert(fr !=
nullptr);
197 assert(ws !=
nullptr);
203 assert(ws !=
nullptr);
209 assert(ws !=
nullptr);
219 std::cerr <<
"GSLIntegrator - Error: Unknown integration type" << std::endl;
220 throw std::exception();
299 MATH_WARN_MSG(
"GSLMCIntegration",
"Invalid integration type : use Vegas as default");
309 std::string typeName = (
type!=
nullptr) ?
type :
"VEGAS";
310 if (
type ==
nullptr)
MATH_INFO_MSG(
"GSLMCIntegration::SetTypeName",
"use default Vegas integrator method");
311 std::transform(typeName.begin(), typeName.end(), typeName.begin(), (
int(*)(
int)) toupper );
315 if (typeName ==
"PLAIN") {
318 else if (typeName ==
"MISER") {
321 else if (typeName !=
"VEGAS") {
322 MATH_WARN_MSG(
"GSLMCIntegration::SetTypeName",
"Invalid integration type : use Vegas as default");
337 assert(ws !=
nullptr);
338 assert(ws->
GetWS() !=
nullptr);
344 else std::cerr <<
"Mode not matching integration type";
368 MATH_WARN_MSG(
"GSLMCIntegrator::SetOptions",
"Invalid options set for the chosen integration type - ignore them");
380 assert(ws !=
nullptr);
384 MATH_ERROR_MSG(
"GSLIntegrator::SetParameters",
" Parameters not matching integration type");
393 assert(ws !=
nullptr);
397 MATH_ERROR_MSG(
"GSLIntegrator::SetParameters",
" Parameters not matching integration type");
425 assert (ws !=
nullptr);
426 return ws->
GetWS()->sigma;
430 std::cerr <<
"Parameter not matching integration type";
445 assert(ws !=
nullptr);
446 return ws->
GetWS()->chisq;
450 std::cerr <<
"Parameter not matching integration type";
462 MATH_ERROR_MSG(
"GSLMCIntegrator::CheckFunction",
"Function has not been specified");
#define MATH_INFO_MSG(loc, str)
Pre-processor macro to report messages which can be configured to use ROOT error or simply an std::io...
#define MATH_ERROR_MSG(loc, str)
#define MATH_WARN_MSG(loc, str)
void SetAbsTolerance(double tol)
non-static methods for setting options
double RelTolerance() const
absolute tolerance
void SetRelTolerance(double tol)
set the relative tolerance
double AbsTolerance() const
non-static methods for retrieving options
void SetWKSize(unsigned int size)
set workspace size
IOptions * ExtraOptions() const
return extra options
void SetExtraOptions(const ROOT::Math::IOptions &opt)
Set the extra options for Vegas and Miser.
double Result() const override
return the type of the integration used
GSLMonteFunctionWrapper * fFunction
GSLMCIntegrator(MCIntegration::Type type=MCIntegration::kVEGAS, double absTol=-1, double relTol=-1, unsigned int calls=0)
constructor of GSL MCIntegrator using all the default options
ROOT::Math::IntegratorMultiDimOptions Options() const override
get the option used for the integration
double Integral(const GSLMonteFuncPointer &f, unsigned int dim, double *a, double *b, void *p=nullptr)
evaluate the Integral of a function f over the defined hypercube (a,b)
const char * GetTypeName() const
return the name
GSLMCIntegrator & operator=(const GSLMCIntegrator &)
void SetFunction(const IMultiGenFunction &f) override
method to set the a generic integration function
~GSLMCIntegrator() override
destructor
double(* GSLMonteFuncPointer)(double *, size_t, void *)
void SetRelTolerance(double relTolerance) override
set the desired relative Error
void SetOptions(const ROOT::Math::IntegratorMultiDimOptions &opt) override
set the integration options
void SetParameters(const VegasParameters &p)
set default parameters for VEGAS method
void SetGenerator(GSLRandomEngine &r)
set random number generator
void SetAbsTolerance(double absTolerance) override
set the desired absolute Error
GSLMCIntegrationWorkspace * fWorkspace
void SetMode(MCIntegration::Mode mode)
set integration mode for VEGAS method The possible MODE are : MCIntegration::kIMPORTANCE (default) : ...
void SetTypeName(const char *typeName)
set integration method using a name instead of an enumeration
double Sigma()
set parameters for PLAIN method
double ChiSqr()
returns chi-squared per degree of freedom for the estimate of the integral in the Vegas algorithm
double Error() const override
return the estimate of the absolute Error of the last Integral calculation
int Status() const override
return the Error Status of the last Integral calculation
void SetType(MCIntegration::Type type)
set integration method
std::unique_ptr< ROOT::Math::IOptions > ExtraOptions() const
get the specific options (for Vegas or Miser) in term of string- name.
MCIntegration::Type fType
gsl_monte_miser_state * GetWS()
void SetParameters(const MiserParameters &p)
wrapper to a multi-dim function withtout derivatives for Monte Carlo multi-dimensional integration al...
gsl_monte_plain_state * GetWS()
GSLRandomEngine Base class for all GSL random engines, normally user instantiate the derived classes ...
GSLRngWrapper class to wrap gsl_rng structure.
gsl_monte_vegas_state * GetWS()
void SetParameters(const struct VegasParameters &p)
Generic interface for defining configuration options of a numerical algorithm.
Numerical multi dimensional integration options.
static ROOT::Math::IOptions * FindDefault(const char *name)
find specific options - return 0 if not existing
void SetIntegrator(const char *name)
set multi-dim integrator name
void SetNCalls(unsigned int calls)
set maximum number of function calls
std::string Integrator() const override
name of multi-dim integrator
unsigned int NCalls() const
maximum number of function calls
Interface (abstract) class for multi numerical integration It must be implemented by the concrete Int...
Type
enumeration specifying the integration types.
IMultiGenFunctionTempl< double > IMultiGenFunction
Structure collecting parameters for MISER multidimensional integration.
Structures collecting parameters for VEGAS multidimensional integration For implementation of default...