cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
GluonGrid.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2018-2023 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 <cmath>
20#include <fstream>
21
24#include "CepGen/Utils/Timer.h"
25
26namespace kmr {
28 static GluonGrid instance(!params.empty() ? params : description().parameters());
29 return instance;
30 }
31
33 : cepgen::GridHandler<3, 1>(cepgen::GridType::linear /*grid is already logarithmic*/),
34 SteeredObject(params),
35 grid_path_(steerPath("path")) {
36 CG_INFO("GluonGrid") << "Building the KMR grid evaluator.";
37
39 { // file readout part
40 std::ifstream file(grid_path_, std::ios::in);
41 if (!file.is_open())
42 throw CG_FATAL("GluonGrid") << "Failed to load grid file \"" << grid_path_ << "\"!";
43
44 std::string x, kt2, mu2, fg;
45 while (file >> x >> kt2 >> mu2 >> fg)
46 insert({std::stod(x), std::stod(kt2), std::stod(mu2)}, {std::stod(fg)});
47 file.close();
48 initialise(); // initialise the grid after filling its nodes
49 }
50 const auto limits = boundaries();
51 CG_INFO("GluonGrid") << "KMR grid evaluator built in " << tmr.elapsed() << " s.\n\t"
52 << " log(x) in range " << limits.at(0) << ",\t"
53 << "x in range " << limits.at(0).compute(std::exp) << "\n\t"
54 << " log(kt^2) in range " << limits.at(1) << ",\t"
55 << "kt^2 in range " << limits.at(1).compute(std::exp) << "\n\t"
56 << " log(mu^2) in range " << limits.at(2) << ",\t"
57 << "mu^2 in range " << limits.at(2).compute(std::exp) << ".";
58 }
59
60 double GluonGrid::operator()(double x, double kt2, double mu2) const {
61 return cepgen::GridHandler<3, 1>::eval({std::log10(x), std::log10(kt2), std::log10(mu2)}).at(0);
62 }
63
66 desc.add<std::string>("path", DEFAULT_KMR_GRID_PATH);
67 return desc;
68 }
69} // namespace kmr
#define CG_FATAL(mod)
Definition Exception.h:61
#define DEFAULT_KMR_GRID_PATH
Definition GluonGrid.h:25
#define CG_INFO(mod)
Definition Message.h:216
void initialise()
Initialise the grid and all useful interpolators/accelerators.
void insert(coord_t coord, values_t value)
Insert a new value in the grid.
std::array< Limits, D > boundaries() const
Grid boundaries (collection of (min,max))
values_t eval(coord_t in_coords) const
Interpolate a point to a given coordinate.
A description object for parameters collection.
ParametersList & parameters()
List of parameters associated to this description object.
bool empty() const
Is the list empty?
A generic timer to extract the processing time between two steps in this software's flow.
Definition Timer.h:30
double elapsed() const
Time elapsed since the last reset call (or class construction)
Definition Timer.h:37
A KMR unintegrated gluon densities grid interpolator.
Definition GluonGrid.h:30
GluonGrid(const GluonGrid &)=delete
double operator()(double x, double kt2, double mu2) const
Compute the gluon flux.
Definition GluonGrid.cpp:60
static GluonGrid & get(const cepgen::ParametersList &params={})
Retrieve the grid interpolator (singleton)
Definition GluonGrid.cpp:27
static cepgen::ParametersDescription description()
Definition GluonGrid.cpp:64
Common namespace for this Monte Carlo generator.
Kimber-Martin-Ryskin unintegrated gluon densities.
Definition GluonGrid.cpp:26