cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
DivonneIntegrator.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2021-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 <cuba.h>
20
21
#include "
CepGen/Core/Exception.h
"
22
#include "
CepGen/Integration/Integrand.h
"
23
#include "
CepGen/Modules/IntegratorFactory.h
"
24
#include "
CepGenAddOns/CubaWrapper/Integrator.h
"
25
26
namespace
cepgen
{
27
namespace
cuba {
29
class
DivonneIntegrator
:
public
Integrator
{
30
public
:
31
explicit
DivonneIntegrator
(
const
ParametersList
& params)
32
:
Integrator
(params),
33
key1_(
steer
<int>(
"Key1"
)),
34
key2_(
steer
<int>(
"Key2"
)),
35
key3_(
steer
<int>(
"Key3"
)),
36
maxpass_(
steer
<int>(
"MaxPass"
)),
37
border_(
steer
<double>(
"Border"
)),
38
maxchisq_(
steer
<double>(
"MaxChisq"
)),
39
mindeviation_(
steer
<double>(
"MinDeviation"
)),
40
given_(
steer
<std::vector<std::vector<double> > >(
"Given"
)),
41
ldxgiven_(
steer
<int>(
"LDXGiven"
)),
42
nextra_(
steer
<int>(
"NExtra"
)) {
43
CG_DEBUG
(
"Integrator:build"
) <<
"Cuba-Divonne integrator built."
;
44
}
45
46
static
ParametersDescription
description
() {
47
auto
desc =
Integrator::description
();
48
desc.setDescription(
"Cuba implementation of the Divonne algorithm"
);
49
desc.add<
int
>(
"Key1"
, 47).setDescription(
"sampling rule in the partitioning phase"
);
50
desc.add<
int
>(
"Key2"
, 1).setDescription(
"sampling rule in the final integration phase"
);
51
desc.add<
int
>(
"Key3"
, 1).setDescription(
52
"strategy for the refinement phase"
53
"(0 = do not treat the subregion any further, 1 = split the subregion up once more)"
);
54
desc.add<
int
>(
"MaxPass"
, 5).setDescription(
"thoroughness parameter of the partitioning phase"
);
55
desc.add<
double
>(
"Border"
, 0.).setDescription(
"border width of the integration region"
);
56
desc.add<
double
>(
"MaxChisq"
, 10.)
57
.setDescription(
58
"maximum chi-square value a single subregion is allowed to have in the final integration phase"
);
59
desc.add<
double
>(
"MinDeviation"
, 0.25)
60
.setDescription(
61
"fraction of the requested error of the entire integral, which determines whether it is worthwhile "
62
"further "
63
"examining a region that failed the chi-square test"
);
64
desc.add<std::vector<std::vector<double> > >(
"Given"
, {})
65
.setDescription(
"list of points where the integrand might have peaks"
);
66
desc.add<
int
>(
"LDXGiven"
, 0)
67
.setDescription(
"leading dimension of xgiven, i.e. the offset between one point and the next in memory"
);
68
desc.add<
int
>(
"NExtra"
, 0)
69
.setDescription(
"maximum number of extra points the peak-finder subroutine will return"
);
70
return
desc;
71
}
72
73
Value
integrate
()
override
{
74
int
nregions, neval, fail;
75
double
integral, error, prob;
76
int
ngiven = given_.size();
77
std::vector<double*> given_arr;
78
std::transform(
79
given_.begin(), given_.end(), std::back_inserter(given_arr), [](
auto
& point) { return point.data(); });
80
81
Divonne(
gIntegrand
->
size
(),
82
ncomp_
,
83
cuba_integrand
,
84
nullptr
,
85
nvec_
,
86
epsrel_
,
87
epsabs_
,
88
verbose_
,
89
rnd_gen_
->parameters().get<
unsigned
long
long
>(
"seed"
),
90
mineval_
,
91
maxeval_
,
92
key1_,
93
key2_,
94
key3_,
95
maxpass_,
96
border_,
97
maxchisq_,
98
mindeviation_,
99
ngiven,
100
ldxgiven_,
101
!given_arr.empty() ? *given_arr.data() :
nullptr
,
// cubareal xgiven[]
102
nextra_,
103
nullptr
,
// peakfinder_t peakfinder
104
nullptr
,
// const char *statefile
105
nullptr
,
// void *spin
106
&nregions,
107
&neval,
108
&fail,
109
&integral,
110
&error,
111
&prob);
112
113
return
Value
{integral, error};
114
}
115
116
private
:
117
const
int
key1_, key2_, key3_;
118
const
int
maxpass_;
119
const
double
border_, maxchisq_, mindeviation_;
120
std::vector<std::vector<double> > given_;
121
const
int
ldxgiven_;
122
const
int
nextra_;
123
};
124
}
// namespace cuba
125
}
// namespace cepgen
126
using
DivonneIntegratorCuba
=
cepgen::cuba::DivonneIntegrator
;
127
REGISTER_INTEGRATOR
(
"cuba_divonne"
,
DivonneIntegratorCuba
);
Exception.h
Integrand.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::Integrand::size
virtual size_t size() const =0
Phase space dimension.
cepgen::Integrator::rnd_gen_
const std::unique_ptr< utils::RandomGenerator > rnd_gen_
Definition
Integrator.h:56
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::cuba::DivonneIntegrator
Cuba implementation of the Divonne integration algorithm.
Definition
DivonneIntegrator.cpp:29
cepgen::cuba::DivonneIntegrator::description
static ParametersDescription description()
Definition
DivonneIntegrator.cpp:46
cepgen::cuba::DivonneIntegrator::DivonneIntegrator
DivonneIntegrator(const ParametersList ¶ms)
Definition
DivonneIntegrator.cpp:31
cepgen::cuba::DivonneIntegrator::integrate
Value integrate() override
Definition
DivonneIntegrator.cpp:73
cepgen::cuba::Integrator
Cuba integration algorithm.
Definition
Integrator.h:29
cepgen::cuba::Integrator::mineval_
int mineval_
Definition
Integrator.h:43
cepgen::cuba::Integrator::nvec_
int nvec_
Definition
Integrator.h:41
cepgen::cuba::Integrator::maxeval_
int maxeval_
Definition
Integrator.h:43
cepgen::cuba::Integrator::ncomp_
int ncomp_
Definition
Integrator.h:41
cepgen::cuba::Integrator::verbose_
int verbose_
Definition
Integrator.h:44
cepgen::cuba::Integrator::epsrel_
double epsrel_
Definition
Integrator.h:42
cepgen::cuba::Integrator::description
static ParametersDescription description()
Definition
Integrator.cpp:42
cepgen::cuba::Integrator::gIntegrand
static Integrand * gIntegrand
Definition
Integrator.h:34
cepgen::cuba::Integrator::epsabs_
double epsabs_
Definition
Integrator.h:42
Integrator.h
cepgen::cuba::cuba_integrand
int cuba_integrand(const int *ndim, const double xx[], const int *, double ff[], void *)
Definition
Integrator.cpp:55
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
CepGenAddOns
CubaWrapper
DivonneIntegrator.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7