Bayeux  3.4.1
Core Foundation library for SuperNEMO
histogram_service.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2012-10-23
4  * Last modified : 2013-02-16
5  *
6  * Copyright (C) 2012-2013 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * Histogram service.
26  *
27  */
28 
29 #ifndef DPP_HISTOGRAM_SERVICE_H
30 #define DPP_HISTOGRAM_SERVICE_H 1
31 
32 // Standard library:
33 #include <string>
34 #include <vector>
35 
36 // Third party:
37 // - Bayeux/datatools:
38 #include <datatools/base_service.h>
40 // - Bayeux/mygsl:
41 #include <mygsl/histogram_pool.h>
42 
43 // This project:
44 #include <dpp/dpp_config.h>
45 
46 class TH1D;
47 class TH2D;
48 
49 namespace datatools {
50  class properties;
51 }
52 
53 namespace dpp {
54 
58  {
59  public:
60 
61  bool has_output_files () const;
62 
63  const std::vector<std::string> & get_output_files () const;
64 
65  std::vector<std::string> & grab_output_files ();
66 
67  void add_output_file (const std::string & fn_);
68 
69  const mygsl::histogram_pool & get_pool () const;
70 
72 
74 
75  virtual ~histogram_service ();
76 
77  virtual bool is_initialized () const;
78 
79  virtual int initialize (const datatools::properties & config_,
80  datatools::service_dict_type & service_dict_);
81 
82  virtual int reset ();
83 
84  void load_from_boost_file (const std::string & filename_);
85 
86  void store_as_boost_file (const std::string & filename_) const;
87 
88  void store_as_root_file (const std::string & filename_) const;
89 
90  virtual void tree_dump (std::ostream & out_ = std::clog,
91  const std::string & title_ = "",
92  const std::string & indent_ = "",
93  bool inherit_ = false) const;
94 
95  static void export_to_root (const mygsl::histogram_1d & h1d_,
96  const std::string & name_,
97  const std::string & title_,
98  TH1D & rh1d_, bool stats_ = false);
99 
100  static void export_to_root (const mygsl::histogram_2d & h2d_,
101  const std::string & name_,
102  const std::string & title_,
103  TH2D & rh2d_, bool stats_ = false);
104 
105  protected:
106 
107  void _at_init ();
108 
109  void _at_reset ();
110 
111  private:
112 
113  bool _initialized_;
114  mygsl::histogram_pool _pool_;
115  std::vector<std::string> _output_files_;
116  bool _root_export_stats_;
117  std::string _root_export_title_prefix_;
118  std::string _root_export_name_suffix_;
119  // Registration :
121 
122  };
123 
124 } // end of namespace dpp
125 
126 /***************
127  * OCD support *
128  ***************/
129 #include <datatools/ocd_macros.h>
131 
132 #endif // DPP_HISTOGRAM_SERVICE_H
133 
134 // Local Variables: --
135 // mode: c++ --
136 // c-file-style: "gnu" --
137 // tab-width: 2 --
138 // End: --
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
mygsl::histogram_pool & grab_pool()
virtual int initialize(const datatools::properties &config_, datatools::service_dict_type &service_dict_)
Initialize the service using a list of properties with access to a dictionary of other services.
Top-level namespace of the Bayeux/dpp module library.
Definition: base_module.h:56
std::map< std::string, service_entry_ptr > service_dict_type
Type alias for a flat dictionary of service entries.
Definition: service_tools.h:196
The base service class.
Definition: base_service.h:68
virtual bool is_initialized() const
Check if service is initialized.
void add_output_file(const std::string &fn_)
void load_from_boost_file(const std::string &filename_)
#define DATATOOLS_SERVICE_REGISTRATION_INTERFACE(SERVICE_CLASS_NAME)
Definition: base_service.h:152
void store_as_root_file(const std::string &filename_) const
static void export_to_root(const mygsl::histogram_1d &h1d_, const std::string &name_, const std::string &title_, TH1D &rh1d_, bool stats_=false)
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
A pool of histograms.
Definition: histogram_pool.h:28
std::vector< std::string > & grab_output_files()
void store_as_boost_file(const std::string &filename_) const
const mygsl::histogram_pool & get_pool() const
A service for managing 1D and 2D histograms.
Definition: histogram_service.h:56
One dimensional histogram.
Definition: histogram.h:30
virtual int reset()
Reset the service.
header file
const std::vector< std::string > & get_output_files() const
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
bool has_output_files() const
virtual ~histogram_service()
A dictionary of arbitrary properties.
Definition: properties.h:125
Two dimensional histogram.
Definition: histogram_2d.h:29