Bayeux  3.4.1
Core Foundation library for SuperNEMO
simulated_data_reader.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2013-06-22
4  * Last modified: 2013-06-22
5  *
6  * License:
7  *
8  * Description:
9  * Simulation data reader.
10  *
11  */
12 
13 #ifndef MCTOOLS_SIMULATED_DATA_READER_H
14 #define MCTOOLS_SIMULATED_DATA_READER_H 1
15 
16 // Standard library:
17 #include <string>
18 #include <vector>
19 
20 // Third party:
21 // - Boost :
22 #include <boost/scoped_ptr.hpp>
23 // - Bayeux/datatools :
24 #include <datatools/logger.h>
26 #include <datatools/utils.h>
27 
28 namespace datatools {
29  class properties;
30  class data_reader;
31 }
32 
33 namespace brio {
34  class reader;
35 }
36 
37 namespace mctools {
38 
39  class simulated_data;
40 
44  {
45  public:
46 
49  LOAD_OK = 0,
52  };
53 
55  void set_max_files (int max_files_);
56 
58  void set_max_record_total (int max_record_total_);
59 
61  void set_max_record_per_file (int max_record_per_file_);
62 
64  int get_max_record_per_file() const;
65 
67  int get_max_record_total() const;
68 
70  int get_max_files() const;
71 
73  void set_filenames (const datatools::properties & setup_);
74 
77 
80 
83 
85  virtual ~simulated_data_reader();
86 
88  bool is_initialized() const;
89 
91  void initialize(const std::string & filename_);
92 
94  void initialize(const std::vector<std::string> & filenames_);
95 
97  void initialize(const std::string & path_,
98  const std::string & prefix_,
99  const std::string & extension_,
100  unsigned int stop_,
101  unsigned int start_ = 0,
102  int increment_ = 1);
103 
105  void initialize(const datatools::properties & setup_);
106 
108  void reset();
109 
111  bool is_terminated () const;
112 
114  bool has_next() const;
115 
117  int load_next(simulated_data & sd_);
118 
120  bool has_run_header() const;
121 
123  const datatools::properties & get_run_header() const;
124 
126  bool has_run_footer() const;
127 
129  const datatools::properties & get_run_footer() const;
130 
132  bool file_has_changed() const;
133 
135  int get_file_index() const;
136 
138  int get_file_record_counter() const;
139 
141  int get_record_counter() const;
142 
144  virtual void tree_dump(std::ostream & out_ = std::clog,
145  const std::string & title_ = "",
146  const std::string & indent_ = "",
147  bool inherit_ = false) const;
148 
149  protected:
150 
151  void _initialize();
152 
153  int _check_input();
154 
155  int _load(simulated_data & sd_);
156 
157  void _set_defaults();
158 
159  private:
160 
161  bool _initialized_;
162  datatools::logger::priority _logging_;
163  datatools::smart_filename _filenames_;
164  int _max_record_per_file_;
165  int _max_record_total_;
166  int _max_files_;
167 
168  /* Running/dynamic attributes: */
169  bool _terminated_;
170  int _file_record_counter_;
171  int _record_counter_;
172  int _file_index_;
173  bool _file_has_changed_;
174  boost::scoped_ptr<datatools::data_reader> _bio_reader_;
175  boost::scoped_ptr<brio::reader> _brio_reader_;
176  boost::scoped_ptr<datatools::properties> _run_header_;
177  boost::scoped_ptr<datatools::properties> _run_footer_;
178  };
179 
180 
181 } // end of namespace mctools
182 
183 // Object configuration description (OCD) support :
184 #include <datatools/ocd_macros.h>
186 
187 #endif // MCTOOLS_SIMULATED_DATA_READER_H
188 
189 // Local Variables: --
190 // mode: c++ --
191 // c-file-style: "gnu" --
192 // tab-width: 2 --
193 // End: --
bool has_run_footer() const
Check if run footer exists.
void set_logging_priority(datatools::logger::priority logging_)
Set logging priority threshold.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
void set_filenames(const datatools::properties &setup_)
Set the input filenames.
bool is_terminated() const
Check if the reader is terminated.
load_status_type
Loading errors.
Definition: simulated_data_reader.h:48
void set_max_record_per_file(int max_record_per_file_)
Set the maximum number of simulated data records per file to be used.
Definition: base_step_hit.h:32
int get_max_record_total() const
Get the maximum number of simulated data records to be used.
The container of collections of MC hits.
Definition: simulated_data.h:43
Definition: simulated_data_reader.h:51
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
A fatal error. The application will most likely terminate. This is the highest priority.
Definition: logger.h:85
Reader class for simulated data record.
Definition: simulated_data_reader.h:42
int get_file_record_counter() const
Return the current input file record counter.
bool file_has_changed() const
Check if the input file has changed after loading a simulated data record.
bool has_run_header() const
Check if run header exists.
datatools::logger::priority get_logging_priority() const
Get logging priority threshold.
void set_max_files(int max_files_)
Set the maximum number of files to be used.
int get_file_index() const
Return the current input file index.
int _load(simulated_data &sd_)
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
int get_max_files() const
Get the maximum number of files to be used.
simulated_data_reader(datatools::logger::priority logging_=datatools::logger::PRIO_FATAL)
Constructor.
int get_max_record_per_file() const
Get the maximum number of simulated data records per file to be used.
virtual ~simulated_data_reader()
Destructor.
bool has_next() const
Check if the reader has next record.
void set_max_record_total(int max_record_total_)
Set the maximum number of simulated data records to be used.
int load_next(simulated_data &sd_)
Load next reader.
Definition: simulated_data_reader.h:49
A class that builds an arbitrary list of filenames on user request. Supported modes are:
Definition: smart_filename.h:52
bool is_initialized() const
Check if reader is initialized.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Utilities for logging information.
void initialize(const std::string &filename_)
Initialize the reader from an unique filename.
int get_record_counter() const
Return the record counter.
const datatools::properties & get_run_footer() const
Get footer header.
void reset()
Reset the reader.
Definition: simulated_data_reader.h:50
Top-level namespace of the Bayeux/brio module library.
Definition: base_io.h:37
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
const datatools::properties & get_run_header() const
Get run header.
A dictionary of arbitrary properties.
Definition: properties.h:125