cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
VegasIntegrator.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 VegasIntegrator : public Integrator {
29 public:
30 explicit VegasIntegrator(const ParametersList& params)
31 : Integrator(params),
32 nstart_(steer<int>("NStart")),
33 nincrease_(steer<int>("NIncrease")),
34 nbatch_(steer<int>("NBatch")),
35 gridno_(steer<int>("GridNo")) {
36 CG_DEBUG("Integrator:build") << "Cuba-VEGAS integrator built.";
37 }
38
40 auto desc = Integrator::description();
41 desc.setDescription("Cuba implementation of the VEGAS algorithm");
42 desc.add<int>("NStart", 1000).setDescription("number of integrand evaluations per iteration to start with");
43 desc.add<int>("NIncrease", 500).setDescription("increase in the number of integrand evaluations per iteration");
44 desc.add<int>("NBatch", 1000)
45 .setDescription("number of points sent in one MathLink packet to be sampled by Mathematica");
46 desc.add<int>("GridNo", 0).setDescription("slot in the internal grid table");
47 return desc;
48 }
49
50 Value integrate() override {
51 int neval, fail;
52 double integral, error, prob;
53
54 Vegas(gIntegrand->size(),
55 ncomp_,
57 nullptr,
58 nvec_,
59 epsrel_,
60 epsabs_,
62 rnd_gen_->parameters().get<unsigned long long>("seed"),
65 nstart_,
66 nincrease_,
67 nbatch_,
68 gridno_,
69 nullptr,
70 nullptr,
71 &neval,
72 &fail,
73 &integral,
74 &error,
75 &prob);
76 return Value{integral, error};
77 }
78
79 private:
80 const int nstart_, nincrease_, nbatch_;
81 const int gridno_;
82 };
83 } // namespace cuba
84} // 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 VEGAS integration algorithm.
VegasIntegrator(const ParametersList &params)
static ParametersDescription description()
int cuba_integrand(const int *ndim, const double xx[], const int *, double ff[], void *)
Common namespace for this Monte Carlo generator.