LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
electronics.h
Go to the documentation of this file.
1 
16 #ifndef LARDATAALG_UTILITIES_QUANTITIES_ELECTRONICS_H
17 #define LARDATAALG_UTILITIES_QUANTITIES_ELECTRONICS_H
18 
19 // LArSoft libraries
22 
23 // C/C++ standard libraries
24 #include <cstddef> // std::ptrdiff_t
25 #include <ratio>
26 #include <string_view>
27 
28 //------------------------------------------------------------------------------
29 namespace util::quantities {
30 
31  namespace units {
32 
33  using namespace std::string_view_literals; // for operator""sv()
34 
35  struct Tick : public concepts::UnitBase {
36  static constexpr auto symbol = "#"sv;
37  static constexpr auto name = "tick"sv;
38  };
39 
40  struct Counts : public concepts::UnitBase {
41  static constexpr auto symbol = "#"sv;
42  static constexpr auto name = "counts"sv;
43  };
44 
45  } // namespace units
46 
47  // -- BEGIN Ticks ------------------------------------------------------------
62 
65  template <typename T = std::ptrdiff_t>
67 
69  template <typename T = tick_as<>::value_t>
71 
73  using tick = tick_as<>;
74 
76  using ticks = tick;
77 
80 
82  using ticks_f = tick_f;
83 
86 
88  using ticks_d = tick_d;
89 
91  // -- END Ticks --------------------------------------------------------------
92 
93  // -- BEGIN ADC counts -------------------------------------------------------
105 
108  template <typename T = signed short int>
110 
113 
116 
117  // -- END ADC counts ---------------------------------------------------------
118 
135  namespace electronics_literals {
136 
137  // @{
139  constexpr tick operator""_tick(long double v)
140  {
141  return tick::castFrom(v);
142  }
143  constexpr tick operator""_tick(unsigned long long int v)
144  {
145  return tick::castFrom(v);
146  }
147  // @}
148 
149  // @{
151  constexpr tick_d operator""_tickd(long double v)
152  {
153  return tick_d::castFrom(v);
154  }
155  constexpr tick_d operator""_tickd(unsigned long long int v)
156  {
157  return tick_d::castFrom(v);
158  }
159  // @}
160 
161  // @{
163  constexpr counts operator""_ADC(long double v)
164  {
165  return counts{static_cast<signed short int>(v)};
166  }
167  constexpr counts operator""_ADC(unsigned long long int v)
168  {
169  return counts{static_cast<signed short int>(v)};
170  }
171  // @}
172 
173  // @{
175  constexpr counts_f operator""_ADCf(long double v)
176  {
177  return counts_f{static_cast<float>(v)};
178  }
179  constexpr counts_f operator""_ADCf(unsigned long long int v)
180  {
181  return counts_f{static_cast<float>(v)};
182  }
183  // @}
184 
185  } // electronics_literals
186 
187  // --- BEGIN Tick intervals --------------------------------------------------
188 
189  namespace intervals {
190 
192  template <typename T = util::quantities::tick_as<>::value_t>
194 
196  using ticks = ticks_as<>;
197 
200 
203 
204  } // namespace intervals
205 
206  // --- END Time intervals ----------------------------------------------------
207 
208  // --- BEGIN Time points -----------------------------------------------------
209 
210  namespace points {
211 
213  template <typename T = util::quantities::tick_as<>::value_t, typename Cat = NoCategory>
215 
217  using tick = tick_as<>;
218 
221 
224 
225  } // namespace points
226 
227  // --- END Tick points -------------------------------------------------------
228 
230 
231 } // namespace util::quantities
232 
233 //------------------------------------------------------------------------------
234 
235 #endif // LARDATAALG_UTILITIES_QUANTITIES_ELECTRONICS_H
static constexpr quantity_t castFrom(U value)
Returns a new quantity initialized with the specified value.
Definition: quantities.h:816
tick_as< double > tick_d
Tick number, represented by double.
Definition: electronics.h:85
Defines point and interval variables based on quantities.
A value measured in the specified unit.
Definition: quantities.h:554
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:73
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:106
Numeric variable proxies with embedded unit of measurement.
Types of variables with a unit.
Definition: intervals.h:20
tick_as< float > tick_f
Tick number, represented by float.
Definition: electronics.h:79