45#include "gsl/gsl_monte_vegas.h"
46#include "gsl/gsl_monte_miser.h"
47#include "gsl/gsl_monte_plain.h"
79 fResult(0),fError(0),fStatus(-1),
103 fType(MCIntegration::kDEFAULT),
108 fResult(0),fError(0),fStatus(-1),
185 assert(
fRng !=
nullptr);
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)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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
virtual void Clear()
free the workspace deleting the GSL pointer
virtual size_t NDim() const
virtual void SetOptions(const ROOT::Math::IOptions &)=0
set options
virtual MCIntegration::Type Type() const =0
virtual std::unique_ptr< ROOT::Math::IOptions > Options() const =0
retrieve option pointer corresponding to parameters create a new object to be managed by the user
virtual bool Init(size_t dim)=0
initialize the workspace creating the GSL pointer if it is not there
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.
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
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_function * GetFunc()
void SetFunction(const FuncType &f)
Fill gsl function structure from a C++ Function class.
void SetFuncPointer(GSLMonteFuncPointer f)
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)
Documentation for the abstract class IBaseFunctionMultiDim.
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.
double(* GSLMonteFuncPointer)(double *, size_t, void *)
Class for adapting any multi-dimension C++ functor class to C function pointers used by GSL MonteCarl...
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Structure collecting parameters for MISER multidimensional integration.
Structures collecting parameters for VEGAS multidimensional integration For implementation of default...