cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
GridDrawer.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2013-2022 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
20#include "CepGen/Utils/Graph.h"
23#include "CepGen/Utils/String.h"
24
25namespace cepgen {
26 namespace utils {
27 GridDrawer::GridDrawer(const ParametersList& params)
28 : SteeredObject(params), drawer_(DrawerFactory::get().build(params_)) {}
29
30 template <size_t N>
31 void GridDrawer::draw(const GridHandler<1, N>& grid, const Drawer::Mode& mode) {
32 auto gd = GridDrawer(ParametersList());
33 // first prepare the array of plots to generate
34 std::array<Graph1D, N> plots;
35 for (size_t i = 0; i < N; ++i) {
36 plots[i].xAxis().setLabel("x");
37 plots[i].yAxis().setLabel(utils::format("var%d", i));
38 }
39 for (const auto& val : grid.values()) {
40 for (size_t i = 0; i < N; ++i)
41 plots[i].addPoint(val.first[0], val.second[i]);
42 }
43 for (size_t i = 0; i < N; ++i)
44 gd.drawer_->draw(plots[i], mode);
45 }
46
47 template <size_t N>
48 void GridDrawer::draw(const GridHandler<2, N>& grid, const Drawer::Mode& mode) {
49 auto gd = GridDrawer(ParametersList());
50 // first prepare the array of plots to generate
51 std::array<Graph2D, N> plots;
52 for (size_t i = 0; i < N; ++i) {
53 plots[i].xAxis().setLabel("x0");
54 plots[i].yAxis().setLabel("x1");
55 plots[i].zAxis().setLabel(utils::format("var%d", i));
56 }
57 for (const auto& val : grid.values()) {
58 for (size_t i = 0; i < N; ++i)
59 plots[i].addPoint(val.first[0], val.first[1], val.second[i]);
60 }
61 for (size_t i = 0; i < N; ++i)
62 gd.drawer_->draw(plots[i], mode);
63 }
64
65 template <size_t N>
66 void GridDrawer::draw(const GridHandler<3, N>& grid, const Drawer::Mode& mode) {
67 auto gd = GridDrawer(ParametersList());
68 // first prepare the array of plots to generate
69 std::array<std::array<Graph2D, 3>, N> plots;
70 for (size_t i = 0; i < N; ++i) {
71 plots[i][0].xAxis().setLabel("x0");
72 plots[i][0].yAxis().setLabel("x1");
73 plots[i][0].zAxis().setLabel(utils::format("var%d", i));
74 plots[i][1].xAxis().setLabel("x0");
75 plots[i][1].yAxis().setLabel("x2");
76 plots[i][1].zAxis().setLabel(utils::format("var%d", i));
77 plots[i][2].xAxis().setLabel("x1");
78 plots[i][2].yAxis().setLabel("x2");
79 plots[i][2].zAxis().setLabel(utils::format("var%d", i));
80 }
81 for (const auto& val : grid.values())
82 for (size_t i = 0; i < N; ++i) {
83 plots[i][0].addPoint(val.first[0], val.first[1], val.second[i]);
84 plots[i][1].addPoint(val.first[0], val.first[2], val.second[i]);
85 plots[i][2].addPoint(val.first[1], val.first[2], val.second[i]);
86 }
87 DrawableColl coll;
88 for (size_t i = 0; i < N; ++i)
89 for (size_t j = 0; j < 3; ++j)
90 coll.emplace_back(&plots[i][j]);
91 gd.drawer_->draw(coll, "", "", mode);
92 }
93
94 ParametersDescription GridDrawer::description() {
95 auto desc = ParametersDescription();
96 desc.setName("root");
97 return desc;
98 }
99
100 template void GridDrawer::draw(const GridHandler<1, 1>&, const Drawer::Mode&);
101 template void GridDrawer::draw(const GridHandler<1, 2>&, const Drawer::Mode&);
102 template void GridDrawer::draw(const GridHandler<2, 2>&, const Drawer::Mode&);
103 template void GridDrawer::draw(const GridHandler<3, 1>&, const Drawer::Mode&);
104 } // namespace utils
105} // namespace cepgen
A generic class for grid interpolation.
Definition GridHandler.h:44
std::map< coord_t, values_t > values() const
List of values in the grid.
Definition GridHandler.h:56
A description object for parameters collection.
Utility object to draw a grid values mapping.
Definition GridDrawer.h:32
std::string get(const std::string &var, const std::string &def)
Get an environment variable.
std::vector< const Drawable * > DrawableColl
A collection of drawable objects.
Definition Drawer.h:34
Common namespace for this Monte Carlo generator.