Canvas.hh
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "TCanvas.h"
7 
8 #include "boca/math/Rectangle.hh"
9 #include "boca/generic/Debug.hh"
10 
11 namespace boca
12 {
13 
14 class Canvas
15 {
16 
17 public:
18 
19  Canvas();
20 
21  Canvas(std::string const& path, std::string const& name, bool show_title = false);
22 
23  TCanvas const& canvas() const;
24 
25  TCanvas& canvas();
26 
27  template<typename Value>
28  bool SetLog(Range<Value> const& range) {
29  if(debug_) Debug("min: ", range.Min(), "max: ", range.Max());
30  if (range.Min() < Value(0) || range.Min() / range.Max() > 50_mU) return false;
31  if(debug_) Debug("set log", true);
32  canvas_.SetLogy();
33  return true;
34  }
35 
36 // template<typename Value>
37 // void SetLog(Rectangle<Value> const& range) {
38 // if (range.XMin() > Value(0) && range.XMin() / range.XMax() < 0.02) canvas_.SetLogx();
39 // if (range.YMin() > Value(0) && range.YMin() / range.YMax() < 0.02) canvas_.SetLogy();
40 // }
41 
42  void SetLog();
43 
44  std::string SaveAs(std::string const& name);
45 
46  std::string FileName() const;
47 
48  virtual std::string FileBaseName() const;
49 
50  Canvas(Canvas const&) = default;
51 
52  Canvas(Canvas &&) = default;
53 
54  Canvas &operator=(Canvas const&) & = default;
55 
56  Canvas &operator=(Canvas &&) & = default;
57 
58 protected :
59 
60  ~Canvas() {}
61 
62  std::string const& Title() const;
63 
64  std::string Path() const;
65 
66 private:
67 
72  void Initialize();
73 
74  void SetMargins(bool show_title);
75 
76  TCanvas canvas_;
77 
78  std::string title_;
79 
80  std::string path_;
81 
82  bool debug_ = true;
83 
84 };
85 
86 }
Value_ Min() const
Definition: Range.hh:91
void Debug(bool final=true)
Definition: Debug.cpp:60
TCanvas const & canvas() const
Definition: Canvas.cpp:92
Value_ Max() const
Definition: Range.hh:95
std::string SaveAs(std::string const &name)
Definition: Canvas.cpp:85
Canvas & operator=(Canvas const &)&=default
std::string FileName() const
Definition: Canvas.cpp:59
~Canvas()
Definition: Canvas.hh:60
Canvas()
Definition: Canvas.cpp:28
Boosted Collider Analysis.
Definition: Analysis.hh:15
Definition: Canvas.hh:14
bool SetLog(Range< Value > const &range)
Definition: Canvas.hh:28
std::string const & Title() const
Definition: Canvas.cpp:104
std::string Path() const
Definition: Canvas.cpp:71
virtual std::string FileBaseName() const
Definition: Canvas.cpp:65
void SetLog()
Definition: Canvas.cpp:110