cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Drawable.h
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
19#ifndef CepGen_Utils_Drawable_h
20#define CepGen_Utils_Drawable_h
21
22#include <map>
23#include <string>
24
25#include "CepGen/Utils/Limits.h"
26#include "CepGen/Utils/Value.h"
27
28namespace cepgen {
29 namespace utils {
31 class Drawable {
32 public:
33 explicit Drawable(const std::string& name = "", const std::string& title = "") : name_(name), title_(title) {}
34 virtual ~Drawable() {}
35
37 const std::string& name() const { return name_; }
39 void setName(const std::string& name) { name_ = name; }
40
42 const std::string& title() const { return title_; }
44 void setTitle(const std::string& title) { title_ = title; }
45
47 class AxisInfo {
48 public:
50 AxisInfo& setLabel(const std::string& label) {
51 label_ = label;
52 return *this;
53 }
55 const std::string& label() const { return label_; }
57 AxisInfo& setMinimum(double min) {
58 lim_.min() = min;
59 return *this;
60 }
62 AxisInfo& setMaximum(double max) {
63 lim_.max() = max;
64 return *this;
65 }
67 AxisInfo& setRange(const Limits& lim) {
68 lim_ = lim;
69 return *this;
70 }
72 const Limits& range() const { return lim_; }
73
74 private:
75 std::string label_;
76 Limits lim_;
77 };
78
79 AxisInfo& xAxis() { return xaxis_; }
80 const AxisInfo& xAxis() const { return xaxis_; }
81 AxisInfo& yAxis() { return yaxis_; }
82 const AxisInfo& yAxis() const { return yaxis_; }
83 AxisInfo& zAxis() { return zaxis_; }
84 const AxisInfo& zAxis() const { return zaxis_; }
85
87 struct coord_t {
89 bool operator<(const coord_t& oth) const { return value < oth.value; }
90 double value{0.};
91 double value_unc = 0.;
92 std::string label = "";
93 };
95 typedef std::map<coord_t, Value> axis_t;
98 bool operator()(const std::pair<coord_t, Value>& lhs, const std::pair<coord_t, Value>& rhs) {
99 return lhs.second < rhs.second;
100 }
101 };
103 typedef std::map<coord_t, axis_t> dualaxis_t;
104
105 virtual bool isHist1D() const { return false; }
106 virtual bool isHist2D() const { return false; }
107 virtual bool isGraph1D() const { return false; }
108 virtual bool isGraph2D() const { return false; }
109
110 protected:
111 std::string name_;
112 std::string title_;
116 };
117 } // namespace utils
118} // namespace cepgen
119
120#endif
Validity interval for a variable.
Definition Limits.h:28
double min() const
Lower limit to apply on the variable.
Definition Limits.h:52
double max() const
Upper limit to apply on the variable.
Definition Limits.h:54
Metadata for an axis.
Definition Drawable.h:47
const std::string & label() const
Axis title.
Definition Drawable.h:55
AxisInfo & setMinimum(double min)
Set the minimum range.
Definition Drawable.h:57
AxisInfo & setLabel(const std::string &label)
Set the axis title.
Definition Drawable.h:50
AxisInfo & setRange(const Limits &lim)
Set the full axis range.
Definition Drawable.h:67
AxisInfo & setMaximum(double max)
Set the maximum range.
Definition Drawable.h:62
const Limits & range() const
Axis range.
Definition Drawable.h:72
A generic object which can be drawn in the standard output.
Definition Drawable.h:31
std::map< coord_t, Value > axis_t
Metadata for an axis (coordinates and bins value)
Definition Drawable.h:95
Drawable(const std::string &name="", const std::string &title="")
Definition Drawable.h:33
const std::string & name() const
Drawable name.
Definition Drawable.h:37
const AxisInfo & xAxis() const
Definition Drawable.h:80
AxisInfo & yAxis()
Definition Drawable.h:81
AxisInfo & zAxis()
Definition Drawable.h:83
const std::string & title() const
Drawable name.
Definition Drawable.h:42
std::string name_
Computer-readable name.
Definition Drawable.h:111
AxisInfo yaxis_
y-axis metadata
Definition Drawable.h:114
virtual bool isGraph2D() const
Is this drawable a two-dimensional graph?
Definition Drawable.h:108
AxisInfo & xAxis()
Definition Drawable.h:79
const AxisInfo & yAxis() const
Definition Drawable.h:82
std::string title_
Human-readable title.
Definition Drawable.h:112
void setName(const std::string &name)
Set the drawable name.
Definition Drawable.h:39
virtual bool isHist1D() const
Is this drawable a one-dimensional histogram?
Definition Drawable.h:105
virtual bool isGraph1D() const
Is this drawable a one-dimensional graph?
Definition Drawable.h:107
virtual bool isHist2D() const
Is this drawable a two-dimensional histogram?
Definition Drawable.h:106
const AxisInfo & zAxis() const
Definition Drawable.h:84
void setTitle(const std::string &title)
Set the drawable title.
Definition Drawable.h:44
std::map< coord_t, axis_t > dualaxis_t
Metadata for a two-dimensional axis definition (coordinates and bins values)
Definition Drawable.h:103
AxisInfo xaxis_
x-axis metadata
Definition Drawable.h:113
AxisInfo zaxis_
z-axis metadata
Definition Drawable.h:115
Common namespace for this Monte Carlo generator.
Comparator of an axis by the values it holds.
Definition Drawable.h:97
bool operator()(const std::pair< coord_t, Value > &lhs, const std::pair< coord_t, Value > &rhs)
Definition Drawable.h:98
Generic bin coordinate and its human-readable label.
Definition Drawable.h:87
bool operator<(const coord_t &oth) const
Sorting helper for axis coordinates.
Definition Drawable.h:89
std::string label
Human-readable description of the bin.
Definition Drawable.h:92
double value_unc
Bin uncertainty.
Definition Drawable.h:91
double value
Bin central value.
Definition Drawable.h:90