Bayeux  3.4.1
Core Foundation library for SuperNEMO
manager.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-03-17
4  * Last modified: 2014-04-09
5  *
6  * License:
7  *
8  * Copyright 2007-2014 F. Mauger
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or (at
13  * your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  * Description:
26  *
27  * Vertex generator factory and manager
28  *
29  */
30 
31 #ifndef GENVTX_MANAGER_H
32 #define GENVTX_MANAGER_H 1
33 
34 // Standard library:
35 #include <string>
36 #include <map>
37 #include <vector>
38 
39 // Third party:
40 // - Boost:
41 #include <boost/scoped_ptr.hpp>
42 // - Bayeux/datatools:
44 #include <datatools/i_tree_dump.h>
45 #include <datatools/logger.h>
46 // - Bayeux/geomtools:
47 #include <geomtools/utils.h>
48 // - Bayeux/mygsl:
49 #include <mygsl/rng.h>
50 #include <mygsl/random_utils.h>
51 
52 // This project:
53 #include <genvtx/detail/vg_tools.h>
55 #include <genvtx/utils.h>
56 
57 namespace datatools {
58  class service_manager;
59 }
60 
61 // namespace cuts {
62 // class cut_manager;
63 // }
64 
65 namespace genvtx {
66 
68 
82  {
83 
84  public:
85 
87  bool is_initialized() const;
88 
90  bool is_debug() const;
91 
93  void set_debug(bool);
94 
97 
99  bool has_service_manager() const;
100 
103 
106 
108  bool has_geometry_manager() const;
109 
112 
115 
117  bool has_external_random() const;
118 
121 
123  bool has_random_seed() const;
124 
126  void set_random_seed(int);
127 
129  int get_random_seed() const;
130 
132  void set_rng_id(const std::string & rng_id_);
133 
135  const std::string & get_rng_id() const;
136 
138  const mygsl::rng & get_random() const;
139 
142 
143  bool has_generator_name() const;
144 
145  void set_generator_name(const std::string & vg_name_);
146 
147  const std::string & get_generator_name() const;
148 
150  bool has_generator(const std::string &) const;
151 
153  genvtx::vg_handle_type grab_generator(const std::string & vg_name_);
154 
157 
159  virtual ~manager();
160 
162  void reset();
163 
165  void init(const datatools::properties & config_);
166 
168  void initialize(const datatools::properties & config_);
169 
170  void load_vg(const std::string & vg_name_,
171  const std::string & vg_id_,
172  const datatools::properties & vg_config_);
173 
174  virtual void create_vg(genvtx::vg_entry_type & vg_entry_);
175 
176  virtual void initialize_vg(genvtx::vg_entry_type & vg_entry_);
177 
179  void load_vgs(const datatools::multi_properties & vgs_config_);
180 
182  bool has_current_vg() const;
183 
185  void activate_current_vg(const std::string & vg_name_ = "");
186 
188  void desactivate_current_vg();
189 
191  bool can_shoot_vertex() const;
192 
194  bool is_time_generator() const;
195 
197  void shoot_vertex(geomtools::vector_3d & vertex_);
198 
200  void shoot_vertex_and_time(geomtools::vector_3d & vertex_, double & time_);
201 
203  virtual void tree_dump(std::ostream & out_ = std::clog,
204  const std::string & title_ = "",
205  const std::string & indent_ = "",
206  bool inherit_ = false) const;
207 
208  const genvtx::i_vertex_generator & get(const std::string & vg_name_) const;
209 
210  genvtx::i_vertex_generator & grab(const std::string & vg_name_);
211 
213 
215 
216  void vg_names(std::vector<std::string> & names_,
217  std::vector<std::string> & descriptions_,
218  std::string & current_) const;
219 
220  protected:
221 
222  void _load_vg(const std::string & vg_name_,
223  const std::string & vg_id_,
224  const datatools::properties & vg_config_);
225 
226  void _load_vgs(const datatools::multi_properties & vgs_config_);
227 
228  void _create_vg(genvtx::vg_entry_type & vg_entry_);
229 
230  void _initialize_vg(genvtx::vg_entry_type & vg_entry_);
231 
232  void _reset_vg(genvtx::vg_entry_type & vg_entry_);
233 
234  protected:
235 
237 
238  private:
239 
240  bool _initialized_;
241  bool _debug_vg_;
242 
243  genvtx::i_vertex_generator::factory_register_type _factory_register_;
244  bool _factory_preload_;
245  bool _factory_debug_;
246  int _random_seed_;
247  std::string _rng_id_;
248  mygsl::rng _random_;
249  mygsl::rng * _external_random_;
250 
251  datatools::service_manager * _service_manager_;
252  const geomtools::manager * _geometry_manager_;
253  genvtx::vg_dict_type _vg_store_;
254  std::string _current_vg_name_;
255  genvtx::vg_handle_type _current_vg_;
256  // boost::scoped_ptr<cuts::cut_manager> _vv_manager_; //!< Manager for vertex validators/cuts
257 
258  };
259 
260 } // end of namespace genvtx
261 
262 
263 /***************
264  * OCD support *
265  ***************/
266 #include <datatools/ocd_macros.h>
268 
269 #endif // GENVTX_MANAGER_H
270 
271 /*
272 ** Local Variables: --
273 ** mode: c++ --
274 ** c-file-style: "gnu" --
275 ** tab-width: 2 --
276 ** End: --
277 */
bool has_geometry_manager() const
Check the geometry manager.
bool is_initialized() const
Check initialization flag.
void _reset_vg(genvtx::vg_entry_type &vg_entry_)
bool is_debug() const
Check debug flag.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
void set_geometry_manager(const geomtools::manager &)
Set the geometry manager.
A container of mapped properties objects.
Definition: multi_properties.h:99
void _create_vg(genvtx::vg_entry_type &vg_entry_)
Top-level namespace of the Bayeux/genvtx module library.
Definition: box_model_vg.h:32
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print method.
void _load_vg(const std::string &vg_name_, const std::string &vg_id_, const datatools::properties &vg_config_)
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
void set_logging_priority(datatools::logger::priority)
datatools::logger::priority get_logging_priority() const
bool has_external_random() const
Check the external PRNG.
void activate_current_vg(const std::string &vg_name_="")
Activate a given vertex generator as the current one.
virtual void create_vg(genvtx::vg_entry_type &vg_entry_)
datatools::service_manager & grab_service_manager()
Return mutable reference to the service manager.
void load_vgs(const datatools::multi_properties &vgs_config_)
Load definitions of many vertex generators.
bool is_time_generator() const
Check is manager can fire vertex and time.
Vertex generator manager.
Definition: manager.h:81
genvtx::vg_handle_type grab_generator(const std::string &vg_name_)
Return a mutable reference to a generator addressed by name.
bool has_generator(const std::string &) const
Check if a generator with given name is available.
bool has_random_seed() const
Check the seed for embedded PRNG.
void set_debug(bool)
Set debug flag.
void initialize(const datatools::properties &config_)
Main initialization method.
void desactivate_current_vg()
Deactivate the current vertex generator.
void reset()
Reset.
const std::string & get_generator_name() const
int get_random_seed() const
Return the seed for embedded PRNG.
bool has_generator_name() const
bool has_current_vg() const
Check if a current vertex generator is defined.
genvtx::i_vertex_generator & grab(const std::string &vg_name_)
const mygsl::rng & get_random() const
Return the non mutable reference to the embedded PRNG.
void set_rng_id(const std::string &rng_id_)
Set the embedded PRNG's id.
void load_vg(const std::string &vg_name_, const std::string &vg_id_, const datatools::properties &vg_config_)
mygsl::rng & grab_random()
Return the mutable reference to the embedded PRNG.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
void shoot_vertex(geomtools::vector_3d &vertex_)
Main public method to randomize a 3D vertex point.
void set_random_seed(int)
Set the seed for embedded PRNG.
void set_generator_name(const std::string &vg_name_)
const geomtools::manager & get_geometry_manager() const
Return the non mutable reference to the geometry manager.
const std::string & get_rng_id() const
Return the embedded PRNG's id.
manager(datatools::logger::priority p_=datatools::logger::PRIO_WARNING)
Constructor.
virtual ~manager()
Destructor.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
datatools::logger::priority _logging_priority
Logging priority threshold.
Definition: manager.h:236
void vg_names(std::vector< std::string > &names_, std::vector< std::string > &descriptions_, std::string &current_) const
const datatools::service_manager & get_service_manager() const
Return non mutable reference to the service manager.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Utilities for logging information.
Geometry manager for virtual geometry modelling. Main geometry manager for the modelisation of variou...
Definition: manager.h:70
void set_service_manager(datatools::service_manager &)
Set the service manager.
The base interface class for all vertex generator classes.
Definition: i_vertex_generator.h:59
const genvtx::i_vertex_generator & get(const std::string &vg_name_) const
void shoot_vertex_and_time(geomtools::vector_3d &vertex_, double &time_)
Main public method to randomize a 3D vertex point/time.
bool has_service_manager() const
Check the service manager.
A warning. An operation completed with an unexpected result.
Definition: logger.h:88
void set_external_random(mygsl::rng &)
Set the external PRNG.
std::map< std::string, vg_entry_type > vg_dict_type
Definition: vg_tools.h:125
void _load_vgs(const datatools::multi_properties &vgs_config_)
virtual void initialize_vg(genvtx::vg_entry_type &vg_entry_)
void init(const datatools::properties &config_)
Main initialization method.
bool can_shoot_vertex() const
Check if manager can fire vertex :
void _initialize_vg(genvtx::vg_entry_type &vg_entry_)
Service management class.
Definition: service_manager.h:57
Pseudo random number generator.
Definition: rng.h:53
A dictionary of arbitrary properties.
Definition: properties.h:125
Definition: vg_tools.h:45