Bayeux  3.4.1
Core Foundation library for SuperNEMO
simple_linear_adc.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2016-10-01
4  * Last modified : 2016-10-02
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  * Simple linear ADC (Analog/Digital Converter).
26  *
27  */
28 
29 #ifndef MCTOOLS_DIGITIZATION_SIMPLE_LINEAR_ADC_H
30 #define MCTOOLS_DIGITIZATION_SIMPLE_LINEAR_ADC_H
31 
32 // Standard library:
33 #include <limits>
34 
35 // Third party:
36 // - Bayeux/datatools:
37 #include <datatools/properties.h>
38 #include <datatools/i_tree_dump.h>
39 
40 // This project:
42 
43 namespace mctools {
44 
45  namespace digitization {
46 
49  : public i_adc
51  {
52  public:
53 
54  static const int32_t INVALID_CHANNEL = std::numeric_limits<int32_t>::min();
55 
58 
60  virtual ~simple_linear_adc();
61 
63  void set_v_ref_low(const double);
64 
66  double get_v_ref_low() const;
67 
69  void set_v_ref_high(const double);
70 
72  double get_v_ref_high() const;
73 
75  void set_nbits(const uint16_t);
76 
78  uint16_t get_nbits()const;
79 
81  void set_signed(bool);
82 
84  void set_no_underflow(bool n_);
85 
87  bool is_no_underflow() const;
88 
90  void set_no_overflow(bool n_);
91 
93  bool is_no_overflow() const;
94 
96  void set_underflow_channel(int32_t);
97 
99  int32_t get_underflow_channel() const;
100 
102  void set_overflow_channel(int32_t);
103 
105  int32_t get_overflow_channel() const;
106 
108  bool is_signed() const;
109 
111  bool is_initialized() const;
112 
114  void initialize_simple();
115 
117  void initialize(const datatools::properties & config_);
118 
120  void reset();
121 
123  double compute_sampled_voltage(int32_t channel_, bool ignore_out_ = false) const;
124 
126  virtual int32_t quantize(const double vinput_) const;
127 
129  int32_t get_min_channel() const;
130 
132  int32_t get_max_channel() const;
133 
135  uint32_t get_number_of_voltage_intervals() const;
136 
138  double get_voltage_resolution() const;
139 
141  virtual void tree_dump(std::ostream & out_ = std::clog,
142  const std::string & title_ = "",
143  const std::string & indent_ = "",
144  bool inherit_ = false) const;
145 
147  DR_CLASS_RTTI()
148 
149  protected:
150 
152  void _set_defaults();
153 
155  void _compute_working_data();
156 
157  private:
158 
159  // Management
160  bool _initialized_ = false;
161 
162  // Configuration parameters:
163  double _v_ref_low_;
164  double _v_ref_high_;
165  uint16_t _nbits_ = 0;
166  bool _signed_ = false;
167  bool _no_underflow_ = false;
168  bool _no_overflow_ = false;
169  int32_t _underflow_channel_;
170  int32_t _overflow_channel_;
171 
172  // Working data:
173  int32_t _min_channel_;
174  int32_t _max_channel_;
175  uint32_t _number_of_voltage_intervals_;
176  double _efsr_;
177  double _q_;
178  double _v0_;
179 
180  };
181 
182  } // end of namespace digitization
183 
184 } // end of namespace mctools
185 
186 // Activate reflection layer :
187 DR_CLASS_INIT(::mctools::digitization::simple_linear_adc)
188 
189 #endif // MCTOOLS_DIGITIZATION_SIMPLE_LINEAR_ADC_H
190 
191 // Local Variables: --
192 // mode: c++ --
193 // c-file-style: "gnu" --
194 // tab-width: 2 --
195 // End: --
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
double compute_sampled_voltage(int32_t channel_, bool ignore_out_=false) const
Compute the sampled voltage associated to a channel.
virtual int32_t quantize(const double vinput_) const
Quantize.
int32_t get_min_channel() const
Return the minimum channel.
uint16_t get_nbits() const
Return the number of encoding bits.
Definition: base_step_hit.h:32
double get_voltage_resolution() const
Return the voltage resolution.
double get_v_ref_low() const
Return the low voltage reference value.
void set_v_ref_high(const double)
Set the high voltage reference value.
void set_underflow_channel(int32_t)
Set the underflow channel.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
void _compute_working_data()
Compute working data.
A simple linear ADC (Analog Digital Converter).
Definition: i_adc.h:39
int32_t get_max_channel() const
Return the maximum channel.
int32_t get_overflow_channel() const
Return the overflow code.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
double get_v_ref_high() const
Return the high voltage reference value.
void initialize(const datatools::properties &config_)
Initialization.
static const int32_t INVALID_CHANNEL
Definition: simple_linear_adc.h:54
void set_nbits(const uint16_t)
Set the number of encoding bits.
A simple linear ADC (Analog/Digital Converter)
Definition: simple_linear_adc.h:48
void set_no_overflow(bool n_)
Set the no overflow flag.
void set_no_underflow(bool n_)
Set the no underflow flag.
bool is_no_overflow() const
Check the no overflow flag.
int32_t get_underflow_channel() const
Return the underflow code.
void set_overflow_channel(int32_t)
Set the overflow channel.
bool is_no_underflow() const
Check the no underflow flag.
void _set_defaults()
Reflection interface.
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
bool is_signed() const
Check the signed codes flag.
void set_v_ref_low(const double)
Set the low voltage reference value.
bool is_initialized() const
Check the initialization flag.
uint32_t get_number_of_voltage_intervals() const
Return the number of voltage intervals.
A dictionary of arbitrary properties.
Definition: properties.h:125
void set_signed(bool)
Set the signed codes flag.