Bayeux  3.4.1
Core Foundation library for SuperNEMO
from_file_vg.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-13
4  * Last modified: 2014-04-09
5  *
6  * License:
7  *
8  * Description:
9  * Generate vertex from a file
10  *
11  * History:
12  *
13  */
14 
15 #ifndef GENVTX_FROM_FILE_VG_H
16 #define GENVTX_FROM_FILE_VG_H 1
17 
18 // Standard library:
19 #include <fstream>
20 #include <string>
21 
22 // This project:
24 
25 namespace genvtx {
26 
29  {
30  public:
31 
32  static double default_length_unit();
33 
34  static double default_time_unit();
35 
36  bool is_open() const;
37 
38  const std::string & get_filename() const;
39 
40  void set_filename(const std::string &);
41 
42  void set_length_unit(double lu_);
43 
44  double get_length_unit() const;
45 
46  void set_time_unit(double tu_);
47 
48  double get_time_unit() const;
49 
51  from_file_vg();
52 
54  virtual ~from_file_vg();
55 
57  virtual void initialize(const ::datatools::properties &,
60 
62  virtual void reset();
63 
65  virtual bool is_initialized() const;
66 
68  virtual bool has_next_vertex() const;
69 
70  protected :
71 
73  virtual void _shoot_vertex(::mygsl::rng & random_, ::geomtools::vector_3d & vertex_);
74 
76  virtual void _shoot_vertex_and_time(::mygsl::rng & random_, ::geomtools::vector_3d & vertex_, double & time_);
77 
79  void _open_source();
80 
82  void _close_source();
83 
85  void _read_next();
86 
88  bool _has_next();
89 
90  private:
91 
92  // Configuration:
93  std::string _filename_;
94  double _length_unit_; // default length unit (default == 1);
95  double _time_unit_; // default time unit (default == 1);
96 
97  // Working:
98  bool _open_;
99  std::ifstream _source_;
100  geomtools::vector_3d _next_;
101  double _next_time_;
102 
106 
107  };
108 
110 
111 } // end of namespace genvtx
112 
113 #endif // GENVTX_FROM_FILE_VG_H
114 
115 /*
116 ** Local Variables: --
117 ** mode: c++ --
118 ** c-file-style: "gnu" --
119 ** tab-width: 2 --
120 ** End: --
121 */
virtual bool has_next_vertex() const
Check if at least one more vertex is available.
const std::string & get_filename() const
Generate vertex from a file storing precomputed vertexes.
Definition: from_file_vg.h:28
Top-level namespace of the Bayeux/genvtx module library.
Definition: box_model_vg.h:32
void _open_source()
Open the source file.
static double default_time_unit()
void set_length_unit(double lu_)
double get_length_unit() const
virtual void _shoot_vertex(::mygsl::rng &random_, ::geomtools::vector_3d &vertex_)
Load vertex from the source.
bool is_open() const
void set_time_unit(double tu_)
virtual void _shoot_vertex_and_time(::mygsl::rng &random_, ::geomtools::vector_3d &vertex_, double &time_)
Load vertex/time from the source.
virtual ~from_file_vg()
Destructor.
virtual void initialize(const ::datatools::properties &, ::datatools::service_manager &, ::genvtx::vg_dict_type &)
Initialization.
double get_time_unit() const
void _close_source()
Close the source file.
virtual void reset()
Reset.
virtual bool is_initialized() const
Check initialization status.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
from_file_vg from_file_vertex_generator
Definition: from_file_vg.h:109
from_file_vg()
Constructor.
The base interface class for all vertex generator classes.
Definition: i_vertex_generator.h:59
void _read_next()
Read the next vertex[/time] entry.
#define GENVTX_VG_REGISTRATION_INTERFACE(GENVTX_CLASS_NAME)
Definition: vg_macros.h:46
bool _has_next()
Check for a next vertex[/time] entry.
void set_filename(const std::string &)
std::map< std::string, vg_entry_type > vg_dict_type
Definition: vg_tools.h:125
Service management class.
Definition: service_manager.h:57
static double default_length_unit()
Pseudo random number generator.
Definition: rng.h:53