Bayeux  3.4.1
Core Foundation library for SuperNEMO
multi_signal_shape.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2016-11-30
4  * Last modified : 2016-11-30
5  *
6  * Copyright (C) 2016 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * A class representing a signal shape made of the superposition of
26  * other signal shapes, arbitrarily scaled and shifted.
27  *
28  */
29 
30 #ifndef MCTOOLS_SIGNAL_MULTI_SIGNAL_SHAPE_H
31 #define MCTOOLS_SIGNAL_MULTI_SIGNAL_SHAPE_H
32 
33 // Standard library:
34 #include <vector>
35 
36 // Third party:
37 // - Bayeux/datatools :
38 #include <datatools/i_cloneable.h>
39 // - Bayeux/mygsl:
40 #include <mygsl/i_unary_function.h>
42 
43 // This project:
44 #include <mctools/signal/utils.h>
45 
46 namespace mctools {
47 
48  namespace signal {
49 
53  , public datatools::i_cloneable
54  {
55  public:
56 
59 
61  virtual ~multi_signal_shape();
62 
64  bool is_valid() const;
65 
67  virtual bool is_initialized() const;
68 
70  virtual void initialize(const datatools::properties & config_,
71  const mygsl::unary_function_dict_type & functors_);
72 
74  virtual void reset();
75 
77  void remove(const std::size_t index_);
78 
80  std::size_t add(const std::string & key_,
82  double time_shift_ = 0.0,
83  double scaling_ = 1.0);
84 
86  std::size_t add(const std::string & key_,
87  const mygsl::i_unary_function & shape_,
88  double time_shift_ = 0.0,
89  double scaling_ = 1.0);
90 
92  std::size_t get_number_of_components() const;
93 
95  virtual bool has_explicit_domain_of_definition() const;
96 
98  virtual bool is_in_domain_of_definition(double x_) const;
99 
101  virtual double get_non_zero_domain_min() const;
102 
104  virtual double get_non_zero_domain_max() const;
105 
107  virtual void tree_dump(std::ostream & out_ = std::clog,
108  const std::string & title_ = "",
109  const std::string & indent_ = "",
110  bool inherit_ = false) const;
111 
112  protected:
113 
115  void _set_defaults();
116 
118  double _eval(double x_) const;
119 
120  private:
121 
123  void _init_();
124 
126  void _reset_();
127 
129  void _recompute_();
130 
131  private:
132 
133  // Management:
134  bool _initialized_ = false;
135 
136  // Working data:
137  bool _explicit_domain_of_definition_ = false;
138  double _non_zero_domain_min_;
139  double _non_zero_domain_max_;
140 
141  struct component_record;
142  std::vector<component_record> _components_;
143 
146 
147 
149 
150  };
151 
152  } // end of namespace signal
153 
154 } // end of namespace mctools
155 
156 #endif // MCTOOLS_SIGNAL_MULTI_SIGNAL_SHAPE_H
157 
158 // Local Variables: --
159 // mode: c++ --
160 // c-file-style: "gnu" --
161 // tab-width: 2 --
162 // End: --
#define DATATOOLS_CLONEABLE_DECLARATION(Copyable)
Definition: i_cloneable.h:113
double _eval(double x_) const
Evaluation from parameters.
virtual bool is_initialized() const
Check initialization status.
Definition: base_step_hit.h:32
virtual double get_non_zero_domain_min() const
The minimum bound of the non-zero domain (default is minus infinity)
bool is_valid() const
Check the validity.
std::size_t add(const std::string &key_, const mygsl::const_unary_function_handle_type &shape_, double time_shift_=0.0, double scaling_=1.0)
Add a component signal.
virtual void initialize(const datatools::properties &config_, const mygsl::unary_function_dict_type &functors_)
Initialization.
virtual double get_non_zero_domain_max() const
The maximum bound of the non-zero domain (default is plus infinity)
virtual bool has_explicit_domain_of_definition() const
Check if the function has an explicit domain of definition (default: false)
virtual ~multi_signal_shape()
Destructor.
A signal shape made of the superposition of other signal shapes, arbitrarily scaled and shifted.
Definition: multi_signal_shape.h:51
void remove(const std::size_t index_)
Remove a component signal by index.
std::size_t get_number_of_components() const
Return the number of components.
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart printing.
A triangle function.
A pure abstract class (interface) for inherited cloneable classes.
Definition: i_cloneable.h:75
std::map< std::string, unary_function_handle_type > unary_function_dict_type
Alias for dictionary of handles to unary function objects.
Definition: unary_function_utils.h:30
#define MYGSL_UNARY_FUNCTOR_REGISTRATION_INTERFACE(UnaryFunctorClass)
Definition: i_unary_function.h:206
multi_signal_shape()
Default constructor.
virtual bool is_in_domain_of_definition(double x_) const
Check if a value is in the explicit domain of definition (default: true)
void _set_defaults()
Set default attributes.
A dictionary of arbitrary properties.
Definition: properties.h:125