Bayeux  3.4.1
Core Foundation library for SuperNEMO
triangle_signal_shape.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2015-04-10
4  * Last modified : 2016-09-27
5  *
6  * Copyright (C) 2015 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 triangular signal shape with arbitrary polarity, rise and fall times,
26  * starting time and charge
27  *
28  * History:
29  *
30  */
31 
32 #ifndef MCTOOLS_SIGNAL_TRIANGLE_SIGNAL_SHAPE_H
33 #define MCTOOLS_SIGNAL_TRIANGLE_SIGNAL_SHAPE_H
34 
35 // Third party:
36 // - Bayeux/datatools :
37 #include <datatools/i_cloneable.h>
38 // - Bayeux/mygsl:
39 #include <mygsl/i_unary_function.h>
41 
42 // This project:
43 #include <mctools/signal/utils.h>
44 
45 namespace mctools {
46 
47  namespace signal {
48 
50 
70  : public mygsl::i_unary_function,
72  {
73  public:
74 
76  bool is_valid() const;
77 
80 
82  virtual ~triangle_signal_shape();
83 
85  virtual void initialize(const datatools::properties & config_,
86  const mygsl::unary_function_dict_type & functors_);
87 
89  virtual void reset();
90 
92  virtual bool is_initialized() const;
93 
96 
99 
101  void reset_polarity();
102 
104  void set_t0(double);
105 
107  double get_t0() const;
108 
110  void set_t1(double);
111 
113  double get_t1() const;
114 
116  void set_t2(double);
117 
119  double get_t2() const;
120 
122  void set_amplitude(double);
123 
125  double get_amplitude() const;
126 
128  virtual double get_non_zero_domain_min() const;
129 
131  virtual double get_non_zero_domain_max() const;
132 
134  double get_duration() const;
135 
137  double get_tpeak() const;
138 
140  double get_rise_time() const;
141 
143  double get_fall_time() const;
144 
146  double get_q() const;
147 
149  virtual void tree_dump(std::ostream & out_ = std::clog,
150  const std::string & title_ = "",
151  const std::string & indent_ = "",
152  bool inherit_ = false) const;
153 
154  protected:
155 
157  void _set_defaults();
158 
160  void _compute_parameters();
161 
163  double _eval(double x_) const;
164 
165  private:
166 
167  // Configuration:
168  polarity_type _polarity_ = POLARITY_UNKNOWN;
169  double _t0_;
170  double _t1_;
171  double _t2_;
172  double _amplitude_;
173 
174  // Working data:
175  double _q_;
176  mygsl::triangle_function _triangle_shape_;
177 
180 
181 
183 
184  };
185 
186  } // end of namespace signal
187 
188 } // end of namespace mctools
189 
190 #endif // MCTOOLS_SIGNAL_TRIANGLE_SIGNAL_SHAPE_H
191 
192 // Local Variables: --
193 // mode: c++ --
194 // c-file-style: "gnu" --
195 // tab-width: 2 --
196 // End: --
#define DATATOOLS_CLONEABLE_DECLARATION(Copyable)
Definition: i_cloneable.h:113
Triangular signal shape.
Definition: triangle_signal_shape.h:69
Definition: base_step_hit.h:32
virtual ~triangle_signal_shape()
Destructor.
double get_amplitude() const
Return the amplitude of the signal.
void _compute_parameters()
Automatically compute working data parameters.
double get_rise_time() const
Return the rise time of the signal.
virtual void initialize(const datatools::properties &config_, const mygsl::unary_function_dict_type &functors_)
Initialization.
double get_fall_time() const
Return the fall time of the signal.
void reset_polarity()
Reset the polarity of the signal.
virtual double get_non_zero_domain_min() const
The minimum bound of the non-zero domain (default is minus infinity)
double get_duration() const
Return the width of the signal.
double get_t0() const
Return the start time of the signal.
void _set_defaults()
Set default attributes.
void set_t0(double)
Set the start time of the signal.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart printing.
void set_polarity(polarity_type)
Set the polarity of the signal.
virtual bool is_initialized() const
Check initialization status.
Unknown polarity.
Definition: utils.h:46
double get_t1() const
Return the peak time of the signal.
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
polarity_type get_polarity() const
Return the polarity of the signal.
void set_t2(double)
Set the stop time of the signal.
A triangle function.
double _eval(double x_) const
Evaluation from parameters.
void set_t1(double)
Set the peak time of the signal.
double get_q() const
Return the charge of the signal.
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
double get_t2() const
Return the stop time of the signal.
triangle_signal_shape()
Default constructor.
virtual double get_non_zero_domain_max() const
The maximum bound of the non-zero domain (default is plus infinity)
General asymmetric triangle function.
Definition: triangle_function.h:51
bool is_valid() const
Check the validity.
void set_amplitude(double)
Set the amplitude of the signal.
polarity_type
Definition: utils.h:42
double get_tpeak() const
Return the first peak time of the signal.
A dictionary of arbitrary properties.
Definition: properties.h:125