cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
MISERIntegrator.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2013-2024 Laurent Forthomme
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#include <gsl/gsl_monte_miser.h>
20
21
#include "
CepGen/Core/Exception.h
"
22
#include "
CepGen/Integration/GSLIntegrator.h
"
23
#include "
CepGen/Modules/IntegratorFactory.h
"
24
25
namespace
cepgen
{
27
class
MISERIntegrator
final :
public
GSLIntegrator
{
28
public
:
29
explicit
MISERIntegrator
(
const
ParametersList
& params)
30
:
GSLIntegrator
(params), ncvg_(
steer
<int>(
"numFunctionCalls"
)) {}
31
32
static
ParametersDescription
description
() {
33
auto
desc =
GSLIntegrator::description
();
34
desc.setDescription(
"MISER adaptive importance sampling integrator"
);
35
desc.add<
int
>(
"numFunctionCalls"
, 50'000)
36
.setDescription(
"Number of function calls per phase space point evaluation"
);
37
desc.add<
double
>(
"estimateFraction"
, 0.1);
38
desc.add<
int
>(
"minCalls"
, 16 * 10);
39
desc.add<
int
>(
"minCallsPerBisection"
, 32 * 16 * 10);
40
desc.add<
double
>(
"alpha"
, 2.);
41
desc.add<
double
>(
"dither"
, 0.1);
42
return
desc;
43
}
44
45
Value
integrate
(
Integrand
& integrand)
override
{
46
setIntegrand
(integrand);
47
std::unique_ptr<gsl_monte_miser_state,
decltype
(&gsl_monte_miser_free)> miser_state(
48
gsl_monte_miser_alloc(
function_
->dim), gsl_monte_miser_free);
49
miser_state->verbose =
verbosity_
;
50
gsl_monte_miser_params_get(miser_state.get(), &miser_params_);
51
miser_params_.estimate_frac = steer<double>(
"estimateFraction"
);
52
miser_params_.min_calls = steer<int>(
"minCalls"
);
53
miser_params_.min_calls_per_bisection = steer<int>(
"minCallsPerBisection"
);
54
miser_params_.alpha = steer<double>(
"alpha"
);
55
miser_params_.dither = steer<double>(
"dither"
);
56
gsl_monte_miser_params_set(miser_state.get(), &miser_params_);
57
58
CG_DEBUG
(
"Integrator:build"
) <<
"MISER parameters:\n\t"
59
<<
"Number of calls: "
<< miser_params_.min_calls <<
", "
60
<<
"per bisection: "
<< miser_params_.min_calls_per_bisection <<
",\n\t"
61
<<
"Estimate fraction: "
<< miser_params_.estimate_frac <<
",\n\t"
62
<<
"α-value: "
<< miser_params_.alpha <<
",\n\t"
63
<<
"Dither: "
<< miser_params_.dither <<
"."
;
64
65
// launch the full integration
66
double
result, abserr;
67
int
res = gsl_monte_miser_integrate(
function_
.get(),
68
&
xlow_
[0],
69
&
xhigh_
[0],
70
function_
->dim,
71
ncvg_,
72
rnd_gen_
->engine<gsl_rng>(),
73
miser_state.get(),
74
&result,
75
&abserr);
76
77
if
(res != GSL_SUCCESS)
78
throw
CG_FATAL
(
"Integrator:integrate"
) <<
"Error while performing the integration!\n\t"
79
<<
"GSL error: "
<< gsl_strerror(res) <<
"."
;
80
81
return
Value
{result, abserr};
82
}
83
84
private
:
85
const
int
ncvg_;
86
gsl_monte_miser_params miser_params_{};
87
};
88
89
}
// namespace cepgen
90
REGISTER_INTEGRATOR
(
"MISER"
, MISERIntegrator);
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
GSLIntegrator.h
IntegratorFactory.h
REGISTER_INTEGRATOR
#define REGISTER_INTEGRATOR(name, obj)
Add a generic process definition to the list of handled processes.
Definition
IntegratorFactory.h:25
CG_DEBUG
#define CG_DEBUG(mod)
Definition
Message.h:220
cepgen::GSLIntegrator
Definition
GSLIntegrator.h:28
cepgen::GSLIntegrator::xhigh_
std::vector< double > xhigh_
Definition
GSLIntegrator.h:43
cepgen::GSLIntegrator::xlow_
std::vector< double > xlow_
Definition
GSLIntegrator.h:43
cepgen::GSLIntegrator::setIntegrand
void setIntegrand(Integrand &)
Definition
GSLIntegrator.cpp:30
cepgen::GSLIntegrator::function_
std::unique_ptr< gsl_monte_function > function_
GSL structure storing the function to be integrated by this integrator instance (along with its param...
Definition
GSLIntegrator.h:42
cepgen::GSLIntegrator::description
static ParametersDescription description()
Definition
GSLIntegrator.cpp:54
cepgen::Integrand
An integrand wrapper placeholder.
Definition
Integrand.h:27
cepgen::Integrator::verbosity_
int verbosity_
Integrator verbosity.
Definition
Integrator.h:57
cepgen::Integrator::rnd_gen_
const std::unique_ptr< utils::RandomGenerator > rnd_gen_
Definition
Integrator.h:56
cepgen::MISERIntegrator
MISER integration algorithm developed by W.H. Press and G.R. Farrar, as documented in .
Definition
MISERIntegrator.cpp:27
cepgen::MISERIntegrator::MISERIntegrator
MISERIntegrator(const ParametersList ¶ms)
Definition
MISERIntegrator.cpp:29
cepgen::MISERIntegrator::integrate
Value integrate(Integrand &integrand) override
Perform the multidimensional Monte Carlo integration.
Definition
MISERIntegrator.cpp:45
cepgen::MISERIntegrator::description
static ParametersDescription description()
Definition
MISERIntegrator.cpp:32
cepgen::ParametersDescription
A description object for parameters collection.
Definition
ParametersDescription.h:26
cepgen::ParametersList
Definition
ParametersList.h:52
cepgen::Steerable::steer
T steer(const std::string &key) const
Retrieve a parameters as previously steered.
Definition
Steerable.h:39
cepgen::Value
A scalar value with its uncertainty.
Definition
Value.h:26
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
CepGen
Integration
MISERIntegrator.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7