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
25
26namespace cepgen {
27 namespace cuba {
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
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_,
84 nullptr,
85 nvec_,
86 epsrel_,
87 epsabs_,
89 rnd_gen_->parameters().get<unsigned long long>("seed"),
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
#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 implementation of the Divonne integration algorithm.
static ParametersDescription description()
DivonneIntegrator(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.