ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_maker.hpp
Go to the documentation of this file.
1 #ifndef H_PLOT_MAKER
2 #define H_PLOT_MAKER
3 
4 #include <vector>
5 #include <set>
6 #include <memory>
7 #include <utility>
8 
9 #include "core/plot_opt.hpp"
10 #include "core/figure.hpp"
11 
12 class Process;
13 
14 class PlotMaker{
15 public:
16  PlotMaker();
17  PlotMaker(const PlotMaker &) = default;
18  PlotMaker& operator=(const PlotMaker &) = default;
19  PlotMaker(PlotMaker &&) = default;
20  PlotMaker& operator=(PlotMaker &&) = default;
21  ~PlotMaker() = default;
22 
23  template<typename FigureType, typename... Args>
24  FigureType & Push(Args&&... args){
25  figures_.emplace_back(static_cast<Figure*>(new FigureType(args...)));
26  return *static_cast<FigureType*>(figures_.back().get());
27  }
28 
29  void MakePlots(double luminosity,
30  const std::string &subdir = "");
31 
32  const std::vector<std::unique_ptr<Figure> > & Figures() const;
33  template<typename FigureType>
34  FigureType * GetLast(){
35  FigureType *out = nullptr;
36  for(auto f = figures_.crbegin(); f != figures_.crend(); ++f){
37  if((out = dynamic_cast<FigureType*>(f->get()))) return out;
38  }
39  return nullptr;
40  }
41  void Clear();
42 
44  bool min_print_;
45 
46 private:
47  std::vector<std::unique_ptr<Figure> > figures_;
48 
49  void GetYields();
50  long GetYield(Baby *baby_ptr);
51 
52  std::set<Baby*> GetBabies() const;
53  std::set<const Process *> GetProcesses() const;
54  std::set<Figure::FigureComponent*> GetComponents(const Process *process) const;
55 };
56 
57 #endif
~PlotMaker()=default
std::vector< std::unique_ptr< Figure > > figures_
Figures to be produced.
Definition: plot_maker.hpp:47
Abstract base class for access to ntuple variables.
Definition: baby.hpp:16
const std::vector< std::unique_ptr< Figure > > & Figures() const
Definition: plot_maker.cpp:63
tuple args
Definition: compile.py:193
bool multithreaded_
Definition: plot_maker.hpp:43
FigureType & Push(Args &&...args)
Definition: plot_maker.hpp:24
std::set< Figure::FigureComponent * > GetComponents(const Process *process) const
Definition: plot_maker.cpp:206
bool min_print_
Definition: plot_maker.hpp:44
Organizes efficient production of plots with single loop over each process.
Definition: plot_maker.hpp:14
PlotMaker()
Standard constructor.
Definition: plot_maker.cpp:44
PlotMaker & operator=(const PlotMaker &)=default
void Clear()
Empties list of plots to be produced at next PlotMaker::MakePlots call.
Definition: plot_maker.cpp:69
std::set< Baby * > GetBabies() const
Definition: plot_maker.cpp:186
FigureType * GetLast()
Definition: plot_maker.hpp:34
std::set< const Process * > GetProcesses() const
Definition: plot_maker.cpp:196
long GetYield(Baby *baby_ptr)
Definition: plot_maker.cpp:120
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
Definition: plot_maker.cpp:54
void GetYields()
Definition: plot_maker.cpp:73