Bayeux  3.4.1
Core Foundation library for SuperNEMO
base_electromagnetic_field.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2012-04-24
4  * Last modified: 2012-05-22
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Base class for all electro-magnetic fields
11  *
12  * History:
13  *
14  */
15 
16 #ifndef EMFIELD_BASE_ELECTROMAGNETIC_FIELD_H
17 #define EMFIELD_BASE_ELECTROMAGNETIC_FIELD_H 1
18 
19 // Standard library:
20 #include <iostream>
21 #include <string>
22 #include <map>
23 
24 // Third party:
25 // - Boost:
26 #include <boost/cstdint.hpp>
27 // - Bayeux/datatools:
29 #include <datatools/handle.h>
30 #include <datatools/bit_mask.h>
31 #include <datatools/i_tree_dump.h>
32 // - Bayeux/geomtools:
33 #include <geomtools/utils.h>
34 
35 namespace datatools {
36  class properties;
37  class service_manager;
38 }
39 
40 namespace emfield {
41 
44  {
45 
46  public:
47 
49  typedef std::map<std::string, handle_type> field_dict_type;
50 
52  enum flag_type {
60  };
61 
63  enum status_type {
70  };
71 
72  static const char ELECTRIC_FIELD_LABEL = 'E';
73  static const char MAGNETIC_FIELD_LABEL = 'B';
74 
77 
80 
82  bool is_initialized() const;
83 
85  void set_name(const std::string &);
86 
88  const std::string & get_name() const;
89 
91  bool is_debug() const;
92 
94  void set_debug(bool debug_);
95 
97  bool is_electric_field() const;
98 
100  bool is_magnetic_field() const;
101 
103  bool electric_field_can_be_combined() const;
104 
106  bool magnetic_field_can_be_combined() const;
107 
110 
113 
115  base_electromagnetic_field(uint32_t flags_ = 0);
116 
118  virtual ~base_electromagnetic_field();
119 
121  virtual int compute_electromagnetic_field(const geomtools::vector_3d & position_,
122  double time_,
123  geomtools::vector_3d & electric_field_,
124  geomtools::vector_3d & magnetic_field_) const;
125 
127  virtual int compute_field(char label_,
128  const geomtools::vector_3d & position_,
129  double time_,
130  geomtools::vector_3d & field_) const;
131 
133  virtual void initialize_simple();
134 
136  virtual void initialize_standalone(const datatools::properties & setup_);
137 
139  virtual void initialize_with_service_only(const datatools::properties & setup_,
140  datatools::service_manager & service_manager_);
141 
143  virtual void initialize_with_dictionary_only(const datatools::properties & setup_,
144  field_dict_type & dictionary_);
145 
147  virtual void initialize(const datatools::properties & setup_,
148  datatools::service_manager & service_manager_,
149  field_dict_type & dictionary_) = 0;
150 
152  virtual void reset() = 0;
153 
155  virtual std::string get_class_id() const = 0;
156 
158  virtual bool position_and_time_are_valid(const geomtools::vector_3d & position_,
159  double time_) const;
160 
162  virtual int compute_electric_field(const geomtools::vector_3d & position_,
163  double time_,
164  geomtools::vector_3d & electric_field_) const;
165 
167  virtual int compute_magnetic_field(const geomtools::vector_3d & position_,
168  double time_,
169  geomtools::vector_3d & magnetic_field_) const;
170 
172  virtual void tree_dump(std::ostream & out_ = std::clog,
173  const std::string & title_ = "",
174  const std::string & indent_ = "",
175  bool inherit_ = false) const;
176 
177  protected:
178 
179  void _set_initialized(bool initialized_);
180 
181  void _set_electric_field(bool = true);
182 
183  void _set_magnetic_field(bool = true);
184 
185  void _set_electric_field_can_be_combined(bool = true);
186 
187  void _set_magnetic_field_can_be_combined(bool = true);
188 
189  void _set_electric_field_is_time_dependent(bool = true);
190 
191  void _set_magnetic_field_is_time_dependent(bool = true);
192 
194  datatools::service_manager & service_manager_,
195  field_dict_type & dictionary_);
196 
197  protected:
198 
200  void _set_defaults();
201 
202  private:
203 
204  std::string _name_;
205  bool _initialized_;
206  datatools::logger::priority _logging_priority_;
207  bool _electric_field_;
208  bool _magnetic_field_;
209  bool _electric_field_can_be_combined_;
210  bool _magnetic_field_can_be_combined_;
211  bool _electric_field_is_time_dependent_;
212  bool _magnetic_field_is_time_dependent_;
213 
214  // Factory stuff :
216 
217  };
218 
219 } // end of namespace emfield
220 
222 
223 #endif // EMFIELD_BASE_ELECTROMAGNETIC_FIELD_H
224 
225 // Local Variables: --
226 // mode: c++ --
227 // c-file-style: "gnu" --
228 // tab-width: 2 --
229 // End: --
status_type
Status at field computation.
Definition: base_electromagnetic_field.h:63
Definition: base_electromagnetic_field.h:53
virtual void initialize_standalone(const datatools::properties &setup_)
Standalone initialization, no external resources are needed, only a set of parameters.
datatools::logger::priority get_logging_priority() const
Set the logging priority.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
base_electromagnetic_field(uint32_t flags_=0)
Constructor.
static const uint32_t bit07
Definition: bit_mask.h:34
virtual void initialize_simple()
Naked initialization.
void _set_magnetic_field_can_be_combined(bool=true)
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
static const uint32_t bit01
Definition: bit_mask.h:28
virtual int compute_field(char label_, const geomtools::vector_3d &position_, double time_, geomtools::vector_3d &field_) const
Compute the coordinates of the electric or magnetic field at given position and time.
static const uint32_t bit03
Definition: bit_mask.h:30
static const uint32_t bit04
Definition: bit_mask.h:31
void set_logging_priority(datatools::logger::priority priority_)
Return the logging priority.
virtual int compute_electric_field(const geomtools::vector_3d &position_, double time_, geomtools::vector_3d &electric_field_) const
Compute the coordinates of the electric field at given position and time.
static const uint32_t bit06
Definition: bit_mask.h:33
virtual int compute_magnetic_field(const geomtools::vector_3d &position_, double time_, geomtools::vector_3d &magnetic_field_) const
Compute the coordinates of the magnetic field at given position and time.
void _set_electric_field_can_be_combined(bool=true)
std::map< std::string, handle_type > field_dict_type
Definition: base_electromagnetic_field.h:49
void set_name(const std::string &)
Set the name of the field.
void set_debug(bool debug_)
Set debug status.
flag_type
Initialization flags.
Definition: base_electromagnetic_field.h:52
virtual int compute_electromagnetic_field(const geomtools::vector_3d &position_, double time_, geomtools::vector_3d &electric_field_, geomtools::vector_3d &magnetic_field_) const
Compute the coordinates of the electric and magnetic fields at given position and time.
bool electric_field_is_time_dependent() const
Check if the electric field depends on time.
bool magnetic_field_is_time_dependent() const
Check if the magnetic field depends on time.
virtual void initialize_with_service_only(const datatools::properties &setup_, datatools::service_manager &service_manager_)
Initialization using a set of parameters and a service manager.
void _set_magnetic_field_is_time_dependent(bool=true)
void _set_initialized(bool initialized_)
virtual bool position_and_time_are_valid(const geomtools::vector_3d &position_, double time_) const
Check if position and time are valid for this field.
Definition: base_electromagnetic_field.h:54
Abstract base class for all electromagnetic field.
Definition: base_electromagnetic_field.h:43
virtual void initialize_with_dictionary_only(const datatools::properties &setup_, field_dict_type &dictionary_)
Initialization using a set of parameters and an external dictionary of EM fields.
static const char MAGNETIC_FIELD_LABEL
Definition: base_electromagnetic_field.h:73
Definition: base_electromagnetic_field.h:65
Definition: base_electromagnetic_field.h:55
static const uint32_t bit02
Definition: bit_mask.h:29
void _parse_basic_parameters(const datatools::properties &setup_, datatools::service_manager &service_manager_, field_dict_type &dictionary_)
virtual std::string get_class_id() const =0
Return the class string identifier.
Definition: base_electromagnetic_field.h:66
bool magnetic_field_can_be_combined() const
Check if the magnetic field can be combined.
void _set_electric_field_is_time_dependent(bool=true)
static const uint32_t bit05
Definition: bit_mask.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.
bool is_electric_field() const
Check if the field is an electric field.
Definition: base_electromagnetic_field.h:68
Top-level namespace of the Bayeux/emfield module library.
Definition: base_electromagnetic_field.h:40
bool is_magnetic_field() const
Check if the field is a magnetic field.
const std::string & get_name() const
Return the name of the field.
bool electric_field_can_be_combined() const
Check if the electric field can be combined.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
Definition: base_electromagnetic_field.h:64
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
static const char ELECTRIC_FIELD_LABEL
Definition: base_electromagnetic_field.h:72
virtual ~base_electromagnetic_field()
Destructor.
virtual void initialize(const datatools::properties &setup_, datatools::service_manager &service_manager_, field_dict_type &dictionary_)=0
Main initialization.
virtual void reset()=0
Reset the field.
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE(BaseType)
Declaration of a system (allocator/functor) factory register as a static member of a base class and s...
Definition: factory_macros.h:52
Definition: base_electromagnetic_field.h:69
Macros to automatically generate some parts of the electromagnetic fields interface.
datatools::handle< base_electromagnetic_field > handle_type
Definition: base_electromagnetic_field.h:48
bool is_debug() const
Check debug status.
void _set_defaults()
Set default attributes values.
Service management class.
Definition: service_manager.h:57
bool is_initialized() const
Check initialization status.
A dictionary of arbitrary properties.
Definition: properties.h:125