Bayeux  3.4.1
Core Foundation library for SuperNEMO
histogram_pool.h
Go to the documentation of this file.
1 
3 #ifndef MYGSL_HISTOGRAM_POOL_H
4 #define MYGSL_HISTOGRAM_POOL_H 1
5 
6 // Standard library:
7 #include <iostream>
8 #include <string>
9 #include <map>
10 #include <vector>
11 
12 // Third party:
13 // - Bayeux/datatools :
15 #include <datatools/properties.h>
17 #include <datatools/handle.h>
18 #include <datatools/logger.h>
19 
20 // This project:
21 #include <mygsl/histogram.h>
22 #include <mygsl/histogram_2d.h>
23 #include <mygsl/histogram_utils.h>
24 
25 namespace mygsl {
26 
31  {
32  public:
33 
36  {
40  };
41 
44 
47 
50  {
51  std::string name;
52  std::string title;
53  std::string group;
54  int32_t dimension;
57 
58  public:
62  virtual ~histogram_entry_type();
64  virtual void tree_dump(std::ostream & out_ = std::clog,
65  const std::string & title_ = "",
66  const std::string & indent_ = "",
67  bool inherit_ = false) const;
68 
69 
71  };
72 
74  typedef std::map<std::string, histogram_entry_type> dict_type;
75 
77  const std::string & get_description() const;
78 
80  void set_description(const std::string & desc_);
81 
83  const datatools::properties & get_auxiliaries() const;
84 
87 
90 
92  histogram_pool(const std::string & desc_);
93 
95  virtual ~histogram_pool();
96 
98  static void init_histo_1d(histogram_1d & h1_,
99  const datatools::properties & h1_setups_,
100  const histogram_pool * histo_pool_ = 0);
101 
103  static void init_histo_2d(histogram_2d & h2_,
104  const datatools::properties & h2_setups_,
105  const histogram_pool * histo_pool_ = 0);
106 
108  void load(const std::string & histo_setups_filename_);
109 
111  void load(const datatools::multi_properties & histo_setups_);
112 
114  bool is_initialized() const;
115 
117  void initialize(const datatools::properties & setup_);
118 
120  void reset();
121 
123  void remove_all();
124 
126  bool empty() const;
127 
129  size_t size() const;
130 
132  void clear_auxiliaries();
133 
135  bool has(const std::string & name_, int dim_ = 0) const;
136 
138  bool has_1d(const std::string & name_) const ;
139 
141  bool has_2d(const std::string & name_) const;
142 
144  histogram_1d & grab_1d(const std::string & name_);
145 
147  const histogram_1d & get_1d(const std::string & name_) const;
148 
150  histogram_2d & grab_2d(const std::string & name_);
151 
153  const histogram_2d & get_2d(const std::string & name_) const;
154 
156  void remove(const std::string & name_);
157 
159  void rename(const std::string & name_, const std::string & new_name_);
160 
162  void set_title(const std::string & name_, const std::string & title_);
163 
165  const std::string & get_title(const std::string & name_) const;
166 
168  void set_group(const std::string & name_, const std::string & group_);
169 
171  const std::string & get_group(const std::string & name_) const;
172 
174  void names(std::vector<std::string> &names_, const std::string & filter_ = "", bool reverse_ = false) const;
175 
177  histogram_1d & add_1d(const std::string & name_,
178  const std::string & title_ = "",
179  const std::string & group_ = "");
180 
182  histogram_2d & add_2d(const std::string & name_,
183  const std::string & title_ = "",
184  const std::string & group_ = "");
185 
187  virtual void tree_dump(std::ostream & out = std::clog,
188  const std::string & title = "",
189  const std::string & indent = "",
190  bool inherit = false) const;
191 
194 
197 
198  private:
199 
200  static const std::string _INITIALIZED_FLAG_KEY_;
201 
202  datatools::logger::priority _logging_priority_;
203  std::string _description_;
204  dict_type _dict_;
205  datatools::properties _auxiliaries_;
206 
208 
209  };
210 
211 } // end of namespace mygsl
212 
213 /***************
214  * OCD support *
215  ***************/
216 #include <datatools/ocd_macros.h>
220 
221 #endif // MYGSL_HISTOGRAM_POOL_H
222 
223 /* Local Variables: */
224 /* mode: c++ */
225 /* coding: utf-8 */
226 /* End: */
bool is_initialized() const
Check histogram pool initialization.
histogram_pool()
Constructor.
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
A container of mapped properties objects.
Definition: multi_properties.h:99
datatools::logger::priority get_logging_priority() const
Get logging priority.
virtual void tree_dump(std::ostream &out=std::clog, const std::string &title="", const std::string &indent="", bool inherit=false) const
Smart print.
void clear_auxiliaries()
Clear auxiliairies.
virtual ~histogram_entry_type()
Destructor.
void rename(const std::string &name_, const std::string &new_name_)
Rename an histogram.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Simple structure related to histogram attributes.
Definition: histogram_pool.h:49
histogram_entry_type()
Constructor.
histogram_2d & add_2d(const std::string &name_, const std::string &title_="", const std::string &group_="")
Add 2D histogram.
std::map< std::string, histogram_entry_type > dict_type
Alias to histogram dictionnary.
Definition: histogram_pool.h:74
const histogram_1d & get_1d(const std::string &name_) const
Get a non-mutable reference to 1D histogram given its name.
std::string name
Definition: histogram_pool.h:51
hh1d_type hh1d
Definition: histogram_pool.h:55
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
static void init_histo_1d(histogram_1d &h1_, const datatools::properties &h1_setups_, const histogram_pool *histo_pool_=0)
Static method to initialize 1D histogram.
void remove_all()
Clen histogram dictionnary.
void set_group(const std::string &name_, const std::string &group_)
Assign a group to an histogram.
bool has(const std::string &name_, int dim_=0) const
Check histogram presence given an histogram name.
void remove(const std::string &name_)
Remove an histogram given its name.
const datatools::properties & get_auxiliaries() const
Get a non-mutable reference to auxiliaries.
const std::string & get_group(const std::string &name_) const
Get group of an histogram.
hh2d_type hh2d
Definition: histogram_pool.h:56
const histogram_2d & get_2d(const std::string &name_) const
Get a non-mutable reference to 2D histogram given its name.
histogram_2d & grab_2d(const std::string &name_)
Get a mutable reference to 2D histogram given its name.
bool has_1d(const std::string &name_) const
Check for 1D histogram given its name.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
void set_logging_priority(datatools::logger::priority)
Set logging priority.
A pool of histograms.
Definition: histogram_pool.h:28
void initialize(const datatools::properties &setup_)
Initialization.
int32_t dimension
Definition: histogram_pool.h:54
datatools::handle< histogram_2d > hh2d_type
Typedef to handle of 2D histogram.
Definition: histogram_pool.h:46
const std::string & get_title(const std::string &name_) const
Get histogram title.
bool has_2d(const std::string &name_) const
Check for 2D histogram given its name.
Definition: histogram_pool.h:37
static void init_histo_2d(histogram_2d &h2_, const datatools::properties &h2_setups_, const histogram_pool *histo_pool_=0)
Static method to initialize 2D histogram.
void names(std::vector< std::string > &names_, const std::string &filter_="", bool reverse_=false) const
Build an array containing the names of the histograms stored in the pool :
datatools::handle< histogram_1d > hh1d_type
Typedef to handle of 1D histogram.
Definition: histogram_pool.h:43
One dimensional histogram.
Definition: histogram.h:30
histogram_1d & grab_1d(const std::string &name_)
Get a mutable reference to 1D histogram given its name.
Definition: histogram_pool.h:38
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
Definition: histogram_pool.h:39
Utilities for logging information.
void set_description(const std::string &desc_)
Set histogram poool description.
void load(const std::string &histo_setups_filename_)
Load histograms given a setup filename.
histogram_dim_type
Histogram dimensionality.
Definition: histogram_pool.h:35
size_t size() const
Return the number of histrogrmas stored.
histogram_1d & add_1d(const std::string &name_, const std::string &title_="", const std::string &group_="")
Add 1D histogram.
virtual ~histogram_pool()
Destructor.
void set_title(const std::string &name_, const std::string &title_)
Set histogram title.
std::string title
Definition: histogram_pool.h:52
datatools::properties & grab_auxiliaries()
Get a mutable reference to auxiliaries.
bool empty() const
Check dictionnary emptiness.
const std::string & get_description() const
Return histogram pool description.
std::string group
Definition: histogram_pool.h:53
A dictionary of arbitrary properties.
Definition: properties.h:125
Two dimensional histogram.
Definition: histogram_2d.h:29