Bayeux  3.4.1
Core Foundation library for SuperNEMO
genbb_mgr.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2009-01-19
4  * Last modified: 2013-02-25
5  *
6  * License:
7  * Copyright 2007-2013 F. Mauger
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or (at
12  * your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  * Description:
25  *
26  * A GENBB input data file manager class using the i_genbb interface
27  *
28  * History:
29  *
30  */
31 
32 #ifndef GENBB_HELP_GENBB_MGR_H
33 #define GENBB_HELP_GENBB_MGR_H 1
34 
35 // Standard library:
36 #include <string>
37 #include <list>
38 #include <iostream>
39 #include <fstream>
40 
41 // Third party:
42 // - Bayeux/datatools:
43 #include <datatools/io_factory.h>
44 #include <datatools/properties.h>
45 
46 // This project:
47 #include <genbb_help/i_genbb.h>
49 
50 // Implementation of serialization method for the 'primary_event'
51 // class, implies also <genbb_help/primary_particle.ipp> :
52 //#include <genbb_help/primary_event.ipp>
53 
55 namespace genbb {
56 
58  class genbb_mgr : public i_genbb
59  {
60  public:
61 
62  enum format_type {
65  };
66 
67  static const std::string & format_genbb_label();
68  static const std::string & format_boost_label();
69 
70  bool is_debug () const;
71 
72  void set_debug (bool d_);
73 
74  int get_format () const;
75 
76  void set_format (int format_ = FORMAT_GENBB);
77 
78  void set_format (const std::string & format_ = "");
79 
80  bool is_format_genbb () const;
81 
82  bool is_format_boost () const;
83 
85  genbb_mgr (int format_ = FORMAT_GENBB);
86 
88  virtual ~genbb_mgr ();
89 
90  void dump (std::ostream & out_ = std::clog) const;
91 
92  void set (const std::string & filename_);
93 
94  virtual bool is_initialized () const;
95 
96  virtual void initialize (const datatools::properties & config_,
97  datatools::service_manager & service_manager_,
98  detail::pg_dict_type & dictionary_);
99 
100  virtual void reset ();
101 
102  virtual bool has_next ();
103 
104  protected:
105 
106  virtual void _load_next (primary_event & event_,
107  bool compute_classification_ = true);
108 
109  private:
110 
111  void _at_init_ ();
112 
113  void _at_reset_ ();
114 
115  void _load_next_ ();
116 
117  void _load_next_genbb_ ();
118 
119  void _load_next_boost_ ();
120 
121  private:
122 
123  bool _debug_;
124  bool _initialized_;
125  std::list<std::string> _filenames_;
126  std::string _current_filename_;
127  int _format_;
128  std::istream * _in_;
129  std::ifstream _fin_;
130  datatools::data_reader _reader_;
131  primary_event _current_;
132  double _genbb_weight_;
133 
135 
136  };
137 
138 } // end of namespace genbb
139 
140 #endif // GENBB_HELP_GENBB_MGR_H
141 
142 // Local Variables: --
143 // mode: c++ --
144 // End: --
Legacy bridge manager that reads Genbb files.
Definition: genbb_mgr.h:58
bool is_format_genbb() const
virtual ~genbb_mgr()
Destructor.
Definition: genbb_mgr.h:63
void set_format(int format_=FORMAT_GENBB)
GENBB particle generator abstract base class.
Definition: i_genbb.h:59
bool is_format_boost() const
genbb_mgr(int format_=FORMAT_GENBB)
Constructor.
void dump(std::ostream &out_=std::clog) const
virtual void reset()
Reset method.
format_type
Definition: genbb_mgr.h:62
static const std::string & format_boost_label()
#define GENBB_PG_REGISTRATION_INTERFACE(GENBB_CLASS_NAME)
Definition: genbb_macros.h:22
int get_format() const
Top-level namespace of the Bayeux/genbb_help module library.
Definition: alpha_decay.h:51
virtual bool is_initialized() const
Check initialization status.
virtual void _load_next(primary_event &event_, bool compute_classification_=true)
Protected abstract interface to be invoked by the public 'load_next' method.
void set(const std::string &filename_)
A primary event from a Monte-Carlo generator.
Definition: primary_event.h:60
void set_debug(bool d_)
Definition: genbb_mgr.h:64
static const std::string & format_genbb_label()
bool is_debug() const
std::map< std::string, pg_entry_type > pg_dict_type
Definition: pg_tools.h:134
virtual bool has_next()
Returns true if the generator can provide one more generated event.
Service management class.
Definition: service_manager.h:57
A generic data reader based on Boost/Serialization.
Definition: io_factory.h:523
virtual void initialize(const datatools::properties &config_, datatools::service_manager &service_manager_, detail::pg_dict_type &dictionary_)
Main initialization interface method.
A dictionary of arbitrary properties.
Definition: properties.h:125