ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
table.hpp
Go to the documentation of this file.
1 #ifndef H_TABLE
2 #define H_TABLE
3 
4 #include <memory>
5 #include <vector>
6 #include <string>
7 #include <fstream>
8 
9 #include "core/figure.hpp"
10 #include "core/table_row.hpp"
11 #include "core/process.hpp"
12 #include "core/gamma_params.hpp"
13 #include "core/plot_opt.hpp"
14 
15 class Table final: public Figure{
16 public:
17  class TableColumn final: public Figure::FigureComponent{
18  public:
19  TableColumn(const Table &table,
20  const std::shared_ptr<Process> &process);
21  ~TableColumn() = default;
22 
23  void RecordEvent(const Baby &baby) final;
24 
25  std::vector<double> sumw_, sumw2_;
26 
27  private:
28  TableColumn() = delete;
29  TableColumn(const TableColumn &) = delete;
30  TableColumn& operator=(const TableColumn &) = delete;
31  TableColumn(TableColumn &&) = delete;
32  TableColumn& operator=(TableColumn &&) = delete;
33 
34  std::vector<NamedFunc> proc_and_table_cut_;
36  };
37 
38  Table(const std::string &name,
39  const std::vector<TableRow> &rows,
40  const std::vector<std::shared_ptr<Process> > &processes,
41  bool do_zbi=true,
42  bool print_table=true,
43  bool print_pie=false);
44  Table(Table &&) = default;
45  Table& operator=(Table &&) = default;
46  ~Table() = default;
47 
48  void Print(double luminosity,
49  const std::string &subdir) final;
50 
51  std::vector<GammaParams> Yield(const Process *process, double luminosity) const;
52  std::vector<GammaParams> BackgroundYield(double luminosity) const;
53  std::vector<GammaParams> DataYield() const;
54 
55  std::set<const Process*> GetProcesses() const final;
56 
57  FigureComponent * GetComponent(const Process *process) final;
58 
59  std::string name_;
60  std::vector<TableRow> rows_;
61  bool do_zbi_;
63  bool print_pie_;
65 
66 private:
67  std::vector<std::unique_ptr<TableColumn> > backgrounds_;
68  std::vector<std::unique_ptr<TableColumn> > signals_;
69  std::vector<std::unique_ptr<TableColumn> > datas_;
70 
71  Table(const Table &) = delete;
72  Table& operator=(const Table &) = delete;
73  Table() = delete;
74 
75  const std::vector<std::unique_ptr<TableColumn> >& GetComponentList(const Process *process) const;
76 
77  void PrintHeader(std::ofstream &file) const;
78  void PrintRow(std::ofstream &file, std::size_t irow, double luminosity) const;
79  void PrintPie(std::size_t irow, double luminosity) const;
80  void PrintFooter(std::ofstream &file) const;
81 
82  std::size_t NumColumns() const;
83 
84  static double GetYield(const std::vector<std::unique_ptr<TableColumn> > &columns,
85  std::size_t irow);
86  static double GetError(const std::vector<std::unique_ptr<TableColumn> > &columns,
87  std::size_t irow);
88 };
89 
90 #endif
void PrintRow(std::ofstream &file, std::size_t irow, double luminosity) const
Definition: table.cpp:306
Table()=delete
std::vector< ScalarType > VectorType
Definition: named_func.hpp:16
std::vector< GammaParams > Yield(const Process *process, double luminosity) const
Definition: table.cpp:158
std::set< const Process * > GetProcesses() const final
Definition: table.cpp:201
std::vector< double > sumw2_
Definition: table.hpp:25
Abstract base class for access to ntuple variables.
Definition: baby.hpp:16
std::vector< std::unique_ptr< TableColumn > > signals_
Signal components of the figure.
Definition: table.hpp:68
~TableColumn()=default
STL namespace.
TableColumn & operator=(const TableColumn &)=delete
std::vector< std::unique_ptr< TableColumn > > datas_
Data components of the figure.
Definition: table.hpp:69
std::size_t NumColumns() const
Definition: table.cpp:451
void PrintPie(std::size_t irow, double luminosity) const
Definition: table.cpp:361
NamedFunc::VectorType val_vector_
Definition: table.hpp:35
bool print_table_
Definition: table.hpp:62
std::vector< PlotOpt > plot_options_
Styles with which to draw pie chart.
Definition: table.hpp:64
std::vector< GammaParams > BackgroundYield(double luminosity) const
Definition: table.cpp:175
bool print_pie_
Definition: table.hpp:63
FigureComponent * GetComponent(const Process *process) final
Definition: table.cpp:215
const std::vector< std::unique_ptr< TableColumn > > & GetComponentList(const Process *process) const
Definition: table.cpp:226
std::vector< std::unique_ptr< TableColumn > > backgrounds_
Background components of the figure.
Definition: table.hpp:67
void PrintFooter(std::ofstream &file) const
Definition: table.cpp:415
~Table()=default
NamedFunc::VectorType cut_vector_
Definition: table.hpp:35
std::vector< TableRow > rows_
Definition: table.hpp:60
std::vector< GammaParams > DataYield() const
Definition: table.cpp:188
Definition: table.hpp:15
static double GetYield(const std::vector< std::unique_ptr< TableColumn > > &columns, std::size_t irow)
Definition: table.cpp:458
bool do_zbi_
Definition: table.hpp:61
void PrintHeader(std::ofstream &file) const
Definition: table.cpp:239
std::vector< NamedFunc > proc_and_table_cut_
Definition: table.hpp:34
std::vector< double > sumw_
Definition: table.hpp:25
std::string name_
Definition: table.hpp:59
void Print(double luminosity, const std::string &subdir) final
Definition: table.cpp:139
void RecordEvent(const Baby &baby) final
Definition: table.cpp:53
static double GetError(const std::vector< std::unique_ptr< TableColumn > > &columns, std::size_t irow)
Definition: table.cpp:467
NamedFunc::VectorType wgt_vector_
Definition: table.hpp:35