LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DetectorTimingTypes.h
Go to the documentation of this file.
1 
9 #ifndef LARDATAALG_DETECTORINFO_DETECTORTIMINGTYPES_H
10 #define LARDATAALG_DETECTORINFO_DETECTORTIMINGTYPES_H
11 
12 // LArSoft libraries
16 
19 
86  template <typename Cat>
88 
92 
93  namespace details {
94 
95  template <typename Cat, typename = void>
96  struct category_of_t {
97  using type = Cat;
98  };
99 
100  template <typename Cat>
101  struct category_of_t<Cat, std::void_t<typename Cat::category_t>> {
102  using type = typename Cat::category_t;
103  };
104 
105  template <typename Cat>
107 
109  template <typename Cat, typename TimeUnit = util::quantities::microsecond>
111 
113  using category_t = Cat;
114 
117 
120 
122  using frequency_t = decltype(1.0 / std::declval<typename time_interval_t::quantity_t>());
123 
125  using tick_interval_t =
127 
129  using tick_interval_d_t =
131 
133  using tick_t =
135 
137  using tick_d_t =
139 
141  static std::string name() { return category_t::name(); }
142 
144  template <typename OC>
145  static constexpr bool same_category_as = std::is_same_v<category_of<OC>, category_t>;
146 
148  template <typename OC>
149  static constexpr bool category_compatible_with = same_category_as<category_of<OC>>;
150 
151  }; // timescale_traits_base<>
152 
153  } // namespace details
154 
155  //----------------------------------------------------------------------------
158  static std::string name() { return {"electronics time"}; }
159  }; // struct ElectronicsTimeCategory
160 
170  template <>
172  : public details::timescale_traits_base<ElectronicsTimeCategory> {};
173 
174  // ---------------------------------------------------------------------------
175 
178  static std::string name() { return {"TPC electronics time"}; }
179  }; // struct TPCelectronicsTimeCategory
180 
193  template <>
195  : public details::timescale_traits_base<TPCelectronicsTimeCategory> {};
196 
197  // ---------------------------------------------------------------------------
198 
201  static std::string name() { return {"optical electronics time"}; }
202  }; // struct OpticalTimeCategory
203 
220  template <>
222  : public details::timescale_traits_base<OpticalTimeCategory> {};
223 
224  // ---------------------------------------------------------------------------
225 
228  static std::string name() { return {"hardware trigger time"}; }
229  }; // struct TriggerTimeCategory
230 
243  template <>
245  : public details::timescale_traits_base<TriggerTimeCategory> {};
246 
247  // ---------------------------------------------------------------------------
248 
251  static std::string name() { return {"simulation time"}; }
252  }; // struct SimulationTimeCategory
253 
266  template <>
268  : public details::timescale_traits_base<SimulationTimeCategory, util::quantities::nanosecond> {
269  };
270 
271  // ---------------------------------------------------------------------------
272 
273  // --- BEGIN -- Continuous times ---------------------------------------------
276 
287 
288  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
300 
301  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
316 
317  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
328 
329  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
340 
342  // --- END -- Continuous times ---------------------------------------------
343 
344  // --- BEGIN -- Tick-based times -------------------------------------------
347 
348  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
351 
354 
357 
360 
361  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
362 
365 
368 
371 
376 
377  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
378 
382 
386 
390 
394 
395  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
396 
399 
402 
405 
408 
409  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
411  template <typename T>
412  struct is_tick_type;
413 
415  template <typename T>
416  constexpr bool is_tick_v = is_tick_type<T>();
417 
419  // --- END -- Tick-based times ---------------------------------------------
420 
421 } // namespace detinfo::timescales
422 
423 //------------------------------------------------------------------------------
424 
426 namespace detinfo::timescales {
427 
428  // ---------------------------------------------------------------------------
429  namespace details {
430 
431  // -------------------------------------------------------------------------
432  template <typename T, typename = void>
433  struct is_tick_type_impl : std::false_type {};
434 
435  template <typename Q>
437  Q,
438  std::enable_if_t<std::is_same_v<typename Q::baseunit_t, util::quantities::units::Tick>>>
439  : std::true_type {};
440 
441  // -------------------------------------------------------------------------
442 
443  // Generally undefined; suggested to derive from `timescale_traits_base`.
444  template <typename, typename = void>
446 
447  // Specialization for quantities: same traits as quantity category.
448  template <typename WC>
450  WC,
451  std::enable_if_t<util::quantities::concepts::is_interval_or_point_v<WC>>>
452  : public timescale_traits<typename WC::category_t> {};
453 
454  // -------------------------------------------------------------------------
455 
456  } // namespace details
457 
458  // ---------------------------------------------------------------------------
459 
460  // For customization, pick on `details::custom_timescale_traits`.
461  template <typename Cat>
462  struct timescale_traits : public details::custom_timescale_traits<Cat> {};
463 
464  // ---------------------------------------------------------------------------
465  template <typename T>
467 
468  // ---------------------------------------------------------------------------
469 
470 } // namespace detinfo::timescales
471 
472 //------------------------------------------------------------------------------
473 
474 #endif // LARDATAALG_DETECTORINFO_DETECTORTIMINGTYPES_H
timescale_traits< TriggerTimeCategory >::tick_d_t trigger_tick_d
A point on the trigger time scale expressed in its ticks (real).
Dimensioned variables representing frequency quantities.
timescale_traits< ElectronicsTimeCategory >::tick_t electronics_tick
A point on the electronics time scale expressed in its ticks.
microseconds_as<> microseconds
Type of time interval stored in microseconds, in double precision.
Definition: spacetime.h:274
decltype(1.0/std::declval< typename time_interval_t::quantity_t >()) frequency_t
Type of frequency for this time scale.
timescale_traits< TriggerTimeCategory >::tick_t trigger_tick
A point on the trigger time scale expressed in its ticks.
Category for electronics time scale.
util::quantities::intervals::microseconds time_interval
STL namespace.
A collection of traits for a time scale.
timescale_traits< TriggerTimeCategory >::tick_interval_d_t trigger_time_ticks_d
An interval on the trigger time scale expressed in its ticks (real).
Category for electronics time scale.
timescale_traits< OpticalTimeCategory >::tick_interval_d_t optical_time_ticks_d
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
timescale_traits< TPCelectronicsTimeCategory >::tick_d_t TPCelectronics_tick_d
A point on the TPC electronics time scale expressed in its ticks (real).
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
timescale_traits< TriggerTimeCategory >::tick_interval_t trigger_time_ticks
An interval on the trigger time scale expressed in its ticks.
timescale_traits< ElectronicsTimeCategory >::tick_interval_t electronics_time_ticks
An interval on the electronics time scale expressed in its ticks.
timescale_traits< ElectronicsTimeCategory >::tick_interval_d_t electronics_time_ticks_d
An interval on the electronics time scale expressed in its ticks (real).
timescale_traits< SimulationTimeCategory >::time_point_t simulation_time
A point in time on the simulation time scale.
timescale_traits< TPCelectronicsTimeCategory >::tick_interval_t TPCelectronics_time_ticks
An interval on the TPC electronics time scale expressed in its ticks.
constexpr bool is_tick_v
Whether the specified time T is tick-based.
Evaluates to whether the specified time T is tick-based.
timescale_traits< OpticalTimeCategory >::time_point_t optical_time
A point in time on the optical detector electronics time scale.
timescale_traits< ElectronicsTimeCategory >::tick_d_t electronics_tick_d
A point on the electronics time scale expressed in its ticks (real).
An interval (duration, length, distance) between two quantity points.
Definition: intervals.h:106
Category for trigger time scale.
A template traits for time scale of category Cat.
timescale_traits< TPCelectronicsTimeCategory >::tick_interval_d_t TPCelectronics_time_ticks_d
Category for electronics time scale.
Category for TPC electronics time scale.
Dimensioned variables related to electronics.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
An non-mandatory base class for interval and point categories.
Definition: intervals.h:48
Dimensioned variables representing space or time quantities.
typename category_of_t< Cat >::type category_of
timescale_traits< OpticalTimeCategory >::tick_d_t optical_tick_d
timescale_traits< TPCelectronicsTimeCategory >::time_point_t TPCelectronics_time
A point in time on the TPC electronics time scale.
Namespace including different time scales as defined in LArSoft.
timescale_traits< TPCelectronicsTimeCategory >::tick_t TPCelectronics_tick
A point on the TPC electronics time scale expressed in its ticks.
timescale_traits< ElectronicsTimeCategory >::time_point_t electronics_time
A point in time on the electronics time scale.
static std::string name()
Name of this time scale.