cepgen is hosted by Hepforge, IPPP Durham
CepGen N/A
Central exclusive processes event generator
Drawer.h
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2022-2025 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_Drawer_h
20#define CepGen_Utils_Drawer_h
21
22#include <cstdint>
23
25
26namespace cepgen::utils {
27 class Graph1D;
28 class Graph2D;
29 class Hist1D;
30 class Hist2D;
31 class Drawable;
32 using DrawableColl = std::vector<const Drawable*>;
34 class Drawer : public NamedModule<Drawer> {
35 public:
37 explicit Drawer(const ParametersList& params);
38
39 class Mode {
40 public:
41 enum value_t : uint16_t {
42 none = 0,
43 logx = 1 << 0,
44 logy = 1 << 1,
45 logz = 1 << 2,
46 nostack = 1 << 3,
47 grid = 1 << 4,
48 col = 1 << 5,
49 cont = 1 << 6,
50 ratio = 1 << 7,
51 bar = 1 << 8
52 };
53 Mode() : value_(none) {}
54 Mode(int val) : value_(static_cast<value_t>(val)) {}
55 Mode(const value_t& val) : value_(val) {}
56
57 friend std::ostream& operator<<(std::ostream&, const Mode&);
58 friend bool operator&(const Mode&, const Mode::value_t&);
59
60 const value_t& value() const { return value_; }
61
62 private:
63 value_t value_;
64 };
65
66 virtual const Drawer& draw(const Graph1D&, const Mode& = Mode::none) const = 0;
67 virtual const Drawer& draw(const Graph2D&, const Mode& = Mode::none) const = 0;
69 virtual const Drawer& draw(const Hist1D&, const Mode& = Mode::none) const = 0;
71 virtual const Drawer& draw(const Hist2D&, const Mode& = Mode::none) const = 0;
72
74 virtual const Drawer& draw(const DrawableColl&,
75 const std::string& name = "",
76 const std::string& title = "",
77 const Mode& = Mode::none) const = 0;
78
80 inline virtual std::ostream& operator<<(std::ostream& os) const { return os; }
81
82 protected:
83 friend class Drawable;
84 friend class Graph1D;
85 friend class Graph2D;
86 friend class Hist1D;
87 friend class Hist2D;
88 };
89} // namespace cepgen::utils
90namespace cepgen {
93} // namespace cepgen
95
96#endif
cepgen::utils::Drawer::Mode & operator|=(cepgen::utils::Drawer::Mode &, const cepgen::utils::Drawer::Mode::value_t &)
Base runtime module object.
Definition NamedModule.h:28
const std::string & name() const
Module unique indexing name.
Definition NamedModule.h:42
A generic object which can be drawn in the standard output.
Definition Drawable.h:30
Mode(const value_t &val)
Definition Drawer.h:55
friend bool operator&(const Mode &, const Mode::value_t &)
friend std::ostream & operator<<(std::ostream &, const Mode &)
const value_t & value() const
Definition Drawer.h:60
Drawer(const ParametersList &params)
Build a drawing utility.
virtual const Drawer & draw(const Hist2D &, const Mode &=Mode::none) const =0
Draw a two-dimensional histogram.
virtual const Drawer & draw(const DrawableColl &, const std::string &name="", const std::string &title="", const Mode &=Mode::none) const =0
Draw a collection of drawables.
virtual const Drawer & draw(const Graph1D &, const Mode &=Mode::none) const =0
Draw a one-dimensional graph.
virtual std::ostream & operator<<(std::ostream &os) const
Output operator (when necessary)
Definition Drawer.h:80
virtual const Drawer & draw(const Hist1D &, const Mode &=Mode::none) const =0
virtual const Drawer & draw(const Graph2D &, const Mode &=Mode::none) const =0
Draw a two-dimensional graph Draw a one-dimensional histogram.
A one-dimensional graph object.
Definition Graph.h:28
A two-dimensional graph object.
Definition Graph.h:49
1D histogram container
Definition Histogram.h:66
2D histogram container
Definition Histogram.h:125
Collection of utilities.
std::vector< const Drawable * > DrawableColl
Collection of drawable objects A generic drawing utility.
Definition Drawer.h:32
Common namespace for this Monte Carlo generator.
Definition Handler.h:26
utils::Drawer::Mode operator|(const utils::Drawer::Mode &, const utils::Drawer::Mode::value_t &)