cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
SuaveIntegrator.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
23#include "cuba.h"
24
25namespace cepgen {
26 namespace cuba {
28 class SuaveIntegrator : public Integrator {
29 public:
30 explicit SuaveIntegrator(const ParametersList& params)
31 : Integrator(params),
32 nnew_(steer<int>("NNew")),
33 nmin_(steer<int>("NMin")),
34 flatness_(steer<double>("Flatness")) {
35 CG_DEBUG("Integrator:build") << "Cuba-Suave integrator built.";
36 }
37
39 auto desc = Integrator::description();
40 desc.setDescription("Cuba implementation of the Suave algorithm");
41 desc.add<int>("NNew", 1000).setDescription("number of new integrand evaluations in each subdivision");
42 desc.add<int>("NMin", 2).setDescription(
43 "minimum number of samples a former pass must contribute to a subregion to be considered in that region’s "
44 "compound integral value");
45 desc.add<double>("Flatness", 50.).setDescription("type of norm used to compute the fluctuation of a sample");
46 return desc;
47 }
48
49 Value integrate() override {
50 int neval, fail, nregions;
51 double integral, error, prob;
52
53 Suave(gIntegrand->size(),
54 ncomp_,
56 nullptr,
57 nvec_,
58 epsrel_,
59 epsabs_,
61 rnd_gen_->parameters().get<unsigned long long>("seed"),
64 nnew_,
65 nmin_,
66 flatness_,
67 nullptr, // const char* statefile
68 nullptr, // void* spin
69 &nregions,
70 &neval,
71 &fail,
72 &integral,
73 &error,
74 &prob);
75 return Value{integral, error};
76 }
77
78 private:
79 const int nnew_, nmin_;
80 const double flatness_;
81 };
82 } // namespace cuba
83} // 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.
const std::unique_ptr< utils::RandomGenerator > rnd_gen_
Definition Integrator.h:56
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 integration algorithm.
Definition Integrator.h:29
static ParametersDescription description()
static Integrand * gIntegrand
Definition Integrator.h:34
Cuba implementation of the Suave integration algorithm.
static ParametersDescription description()
SuaveIntegrator(const ParametersList &params)
int cuba_integrand(const int *ndim, const double xx[], const int *, double ff[], void *)
Common namespace for this Monte Carlo generator.