cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
CuhreIntegrator.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2022-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
25
26namespace cepgen {
27 namespace cuba {
29 class CuhreIntegrator final : public Integrator {
30 public:
31 explicit CuhreIntegrator(const ParametersList& params) : Integrator(params), key_(steer<int>("key")) {
32 CG_DEBUG("Integrator:build") << "Cuba-Cuhre integrator built.";
33 }
34
36 auto desc = Integrator::description();
37 desc.setDescription("Cuba implementation of the Cuhre algorithm");
38 desc.add<int>("key", 0).setDescription(
39 "basic integration rule:\n"
40 "key = 7, 9, 11, 13 selects the cubature rule of degree key. Note that the degree-11\n"
41 "rule is available only in 3 dimensions, the degree-13 rule only in 2 dimensions.\n"
42 "For other values, the default rule is taken, which is the degree-13 rule in 2 dimensions,\n"
43 "the degree-11 rule in 3 dimensions, and the degree-9 rule otherwise.");
44 return desc;
45 }
46
47 Value integrate() override {
48 int nregions, neval, fail;
49 double integral, error, prob;
50
51 Cuhre(gIntegrand->size(),
52 ncomp_,
54 nullptr,
55 nvec_,
56 epsrel_,
57 epsabs_,
61 key_,
62 nullptr, // statefile
63 nullptr, // spin
64 &nregions,
65 &neval,
66 &fail,
67 &integral,
68 &error,
69 &prob);
70
71 CG_DEBUG("CuhreIntegrator:integrate")
72 << "Number of regions needed: " << nregions << ".\nNumber of function evaluations: " << neval
73 << "\nError flag: " << fail << ".";
74
75 return Value{integral, error};
76 }
77
78 private:
79 const int key_;
80 };
81 } // namespace cuba
82} // namespace cepgen
#define REGISTER_INTEGRATOR(name, obj)
Add a generic process definition to the list of handled processes.
#define CG_DEBUG(mod)
Definition Message.h:220
virtual size_t size() const =0
Phase space dimension.
A description object for parameters collection.
T steer(const std::string &key) const
Retrieve a parameters as previously steered.
Definition Steerable.h:39
A scalar value with its uncertainty.
Definition Value.h:26
Cuba implementation of the VEGAS integration algorithm.
static ParametersDescription description()
CuhreIntegrator(const ParametersList &params)
Cuba integration algorithm.
Definition Integrator.h:29
static ParametersDescription description()
static Integrand * gIntegrand
Definition Integrator.h:34
int cuba_integrand(const int *ndim, const double xx[], const int *, double ff[], void *)
Common namespace for this Monte Carlo generator.