9 #ifndef LARDATAALG_DETECTORINFO_DETECTORTIMINGS_H 10 #define LARDATAALG_DETECTORINFO_DETECTORTIMINGS_H 20 #include <type_traits> 63 : fClockData(detClocks)
224 template <
typename TimeScale>
228 template <
typename TimeScale>
232 template <
typename TimeScale>
330 template <
typename TargetTime,
typename FromTime>
331 TargetTime toTimeScale(FromTime time)
const;
347 template <
typename TargetTick,
typename FromTime>
348 TargetTick toTick(FromTime time)
const;
360 template <
typename Ticks>
363 return Ticks::castFrom(time / ClockPeriodFor<Ticks>());
379 template <
typename FromTime>
382 return toTimeScale<electronics_time>(time);
398 template <
typename FromTime>
401 return toTick<electronics_tick_d>(time);
417 template <
typename FromTime>
420 return toTick<electronics_tick>(time);
435 template <
typename FromTime>
438 return toTimeScale<trigger_time>(time);
453 template <
typename FromTime>
456 return toTimeScale<simulation_time>(time);
467 template <
typename TimeScale>
471 template <
typename TimeScale>
478 template <
typename TimeScale>
504 template <
typename Ticks = optical_time_ticks>
508 "Specified ticks are not for optical time scale!");
509 return toTicks<Ticks>(time);
524 template <
typename TimePo
int>
527 return toTick<optical_tick>(time);
542 template <
typename TimePo
int>
545 return toTick<optical_tick_d>(time);
593 template <
typename TimePo
int,
typename TimeScale = electronics_time>
594 constexpr TimeScale startTime()
const;
629 template <
typename TickPo
int,
typename TimeTickScale = electronics_tick>
630 constexpr TimeTickScale startTick()
const;
680 template <
typename TimePo
int,
typename TimeScale = TimePo
int,
typename =
void>
685 static_assert(util::always_false_v<TimePoint>,
686 "Start time not implemented for this time in this time scale.");
693 template <
typename TimePo
int>
754 template <
typename TimeScale>
758 std::enable_if_t<!std::is_same_v<TimeScale, detinfo::timescales::electronics_time>>> {
779 template <
typename TimePo
int,
typename TimeScale>
783 std::enable_if_t<!std::is_same_v<TimePoint, detinfo::timescales::electronics_time> &&
784 !std::is_same_v<TimeScale, detinfo::timescales::electronics_time> &&
785 !std::is_same_v<TimeScale, TimePoint>>> {
795 template <
typename TickPo
int,
typename TimeTickScale = TickPo
int>
799 template <
typename TickPo
int>
804 return TickPoint::castFrom(0.0);
837 template <
typename FromTime,
typename TargetTime,
typename =
void>
842 return timings->
startTime<FromTime, TargetTime>() + time.quantity();
847 template <
typename TargetTime>
855 template <
typename FromTick,
typename TargetTime>
858 std::enable_if_t<detinfo::timescales::is_tick_v<FromTick>>> {
863 typename FromTick::category_t>::time_point_t;
865 FromTime{tick.value() * timings->
ClockPeriodFor<FromTick>().quantity()});
872 template <
typename FromTime,
typename TargetTick,
typename =
void>
878 if constexpr (detinfo::timescales::is_tick_v<FromTime>)
879 return convertTick(time, timings);
881 return convertTime(time, timings);
886 static_assert(!detinfo::timescales::is_tick_v<FromTime>);
888 typename TargetTick::category_t>::time_point_t;
889 auto const timeFromStart = time - timings->
startTime<TargetTime, FromTime>();
891 return TargetTick::castFrom(timeFromStart / clockPeriod);
896 static_assert(detinfo::timescales::is_tick_v<FromTime>);
900 typename TargetTick::category_t>::time_point_t;
902 return timings->
toTick<TargetTick>(time);
910 template <
typename TimeScale,
typename =
void>
915 static_assert(util::always_false_v<TimeScale>,
916 "Electronics clock not defined for this time scale.");
922 template <
typename TimeScale>
930 return timings->clockData().TPCClock();
938 return timings->clockData().OpticalClock();
946 return timings->clockData().TriggerClock();
952 :
ClockForImpl<detinfo::timescales::TPCelectronicsTimeCategory> {};
959 template <
typename TimePoint,
typename TimeScale >
966 template <
typename TickPoint,
typename TimeTickScale >
973 template <
typename TargetTime,
typename FromTime>
980 template <
typename TargetTick,
typename FromTime>
987 template <
typename TimeScale>
996 return time - startTime<electronics_time, electronics_time>();
1005 #endif // LARDATAALG_DETECTORINFO_DETECTORTIMINGS_H Literal constants for electronics quantities.
timescale_traits< TriggerTimeCategory >::tick_d_t trigger_tick_d
A point on the trigger time scale expressed in its ticks (real).
electronics_time BeamGateTime() const
megahertz OpticalClockFrequency() const
Dimensioned variables representing frequency quantities.
ticks_d TPCTick2TDC(double tpcticks) const
Equivalent to detinfo::DetectorClocksData::G4ToElecTime().
static detinfo::ElecClock const & get(DetectorTimings const *)
microsecond OpticalClockPeriod() const
timescale_traits< ElectronicsTimeCategory >::tick_t electronics_tick
A point on the electronics time scale expressed in its ticks.
megahertz OpticalClockFrequency() const
Returns the frequency of the optical clock tick.
microsecond BeamGateTime() const
Equivalent to detinfo::DetectorClocksData::BeamGateTime().
static TimeScale startTime(DetectorTimings const *detTiming)
detinfo::timescales::TPCelectronics_time_ticks TPCelectronics_time_ticks
Constructor: wraps around a specified detinfo::DetectorClocksData object.
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
detinfo::timescales::TPCelectronics_time TPCelectronics_time
Constructor: wraps around a specified detinfo::DetectorClocksData object.
microsecond G4ToElecTime(nanosecond simTime) const
Equivalent to detinfo::DetectorClocksData::G4ToElecTime().
Ticks toTicks(time_interval time) const
Returns the number of ticks corresponding to a time interval.
static constexpr TimePoint startTime(DetectorTimings const *)
optical_tick toOpticalTick(TimePoint time) const
Returns the time point converted in units of optical time ticks.
DetectorClocksWithUnits(detinfo::DetectorClocksData const &detClocks)
Constructor: uses detClocks for internal conversions.
trigger_time toTriggerTime(FromTime time) const
Converts a time point into trigger time scale.
detinfo::DetectorClocksData const & clockData() const
Returns the detector clocks data.
ticks_d TPCTick2TDC(ticks_d tpcticks) const
Equivalent to detinfo::DetectorClocksData::G4ToElecTime().
static constexpr detinfo::timescales::electronics_time startTime(DetectorTimings const *)
detinfo::timescales::electronics_time_ticks electronics_time_ticks
Constructor: wraps around a specified detinfo::DetectorClocksData object.
timescale_traits< TriggerTimeCategory >::tick_t trigger_tick
A point on the trigger time scale expressed in its ticks.
Category for electronics time scale.
static TargetTime convert(FromTick tick, DetectorTimings const *timings)
static TargetTime convert(FromTime time, DetectorTimings const *timings)
detinfo::timescales::electronics_tick electronics_tick
Constructor: wraps around a specified detinfo::DetectorClocksData object.
util::quantities::intervals::microseconds time_interval
tick_d ticks_d
Alias for common language habits.
frequency_for< TimeScale > ClockFrequencyFor() const
Returns the frequency of the clock for the specified time scale.
detinfo::timescales::TPCelectronics_tick_d TPCelectronics_tick_d
Constructor: wraps around a specified detinfo::DetectorClocksData object.
A collection of traits for a time scale.
static constexpr TimeScale startTime(DetectorTimings const *)
detinfo::DetectorClocksData const & clockData() const
Returns the detector clocks data object.
constexpr value_t value() const
Returns the value of the quantity.
detinfo::timescales::trigger_tick_d trigger_tick_d
Constructor: wraps around a specified detinfo::DetectorClocksData object.
static detinfo::timescales::electronics_time startTime(DetectorTimings const *detTiming)
static TargetTime convert(TargetTime time, DetectorTimings const *)
detinfo::timescales::electronics_time electronics_time
Constructor: wraps around a specified detinfo::DetectorClocksData object.
microsecond G4ToElecTime(double simTime) const
Equivalent to detinfo::DetectorClocksData::G4ToElecTime().
constexpr double TickPeriod() const noexcept
A single tick period in microseconds.
DetectorTimings(detinfo::DetectorClocksData const &clockData)
Constructor: wraps around a specified detinfo::DetectorClocksData object.
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.
detinfo::DetectorClocksWithUnits const & detClocksUnits() const
Returns a DetectorClocksWithUnits object.
A partial detinfo::DetectorClocksData supporting units.
DetectorClocksWithUnits(detinfo::DetectorClocksData const *detClocks)
Constructor: uses detClocks for internal conversions.
timescale_traits< ElectronicsTimeCategory >::tick_interval_t electronics_time_ticks
An interval on the electronics time scale expressed in its ticks.
electronics_time toElectronicsTime(FromTime time) const
Converts a time point into electronics time scale.
typename traits_of< TimeScale >::time_interval_t time_interval_for
The time interval type of a specific TimeScale.
time_interval_for< TimeScale > ClockPeriodFor() const
Returns the period of the clock for the specified time scale.
double BeamGateTime() const
Beam gate electronics clock time in [us].
detinfo::timescales::simulation_time simulation_time
Constructor: wraps around a specified detinfo::DetectorClocksData object.
Ticks toOpticalTicks(time_interval time) const
Returns the optical ticks corresponding to a time interval.
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.
detinfo::timescales::trigger_time_ticks trigger_time_ticks
Constructor: wraps around a specified detinfo::DetectorClocksData object.
A value measured in the specified unit.
microsecond TPCTime() const
Equivalent to detinfo::DetectorClocksData::TPCTime().
detinfo::DetectorTimings makeDetectorTimings(detinfo::DetectorClocksData const &detClocks)
static TimeScale startTime(DetectorTimings const *detTiming)
static constexpr detinfo::timescales::electronics_tick_d startTick(DetectorTimings const *)
megahertz_as<> megahertz
Type of frequency stored in megahertz, in double precision.
simulation_time toSimulationTime(FromTime time) const
Converts a time point into simulation time scale.
detinfo::timescales::trigger_tick trigger_tick
Constructor: wraps around a specified detinfo::DetectorClocksData object.
detinfo::DetectorClocksData fClockData
The backend instance of detinfo::DetectorClocksData this object uses.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
typename traits_of< TimeScale >::frequency_t frequency_for
The frequency type of a specific TimeScale.
ElecClock const & OpticalClock() const noexcept
Borrow a const Optical clock with time set to Trigger time [us].
static TargetTick convertTick(FromTime tick, DetectorTimings const *timings)
timescale_traits< OpticalTimeCategory >::time_point_t optical_time
A point in time on the optical detector electronics time scale.
detinfo::timescales::optical_time optical_time
Constructor: wraps around a specified detinfo::DetectorClocksData object.
constexpr TimeTickScale startTick() const
Returns the start tick of the specified time tick scale.
timescale_traits< ElectronicsTimeCategory >::tick_d_t electronics_tick_d
A point on the electronics time scale expressed in its ticks (real).
static detinfo::timescales::electronics_tick_d startTick(DetectorTimings const *detTiming)
General LArSoft Utilities.
detinfo::DetectorClocksWithUnits makeDetectorClocksWithUnits(detinfo::DetectorClocksData const &clockData)
static detinfo::timescales::electronics_time startTime(DetectorTimings const *detTiming)
An interval (duration, length, distance) between two quantity points.
electronics_tick_d toElectronicsTickD(FromTime time) const
Converts a time point into electronics tick (real).
electronics_time TriggerTime() const
Category for trigger time scale.
Literal constants for time quantities.
double TriggerTime() const
Trigger electronics clock time in [us].
detinfo::timescales::TPCelectronics_tick TPCelectronics_tick
Constructor: wraps around a specified detinfo::DetectorClocksData object.
detinfo::ElecClock const & ClockFor() const
Returns the electronics clock for the specified time scale.
detinfo::timescales::trigger_time trigger_time
Constructor: wraps around a specified detinfo::DetectorClocksData object.
Category for electronics time scale.
Category for TPC electronics time scale.
Dimensioned variables related to electronics.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
detinfo::timescales::electronics_tick_d electronics_tick_d
Constructor: wraps around a specified detinfo::DetectorClocksData object.
static TargetTick convertTime(FromTime time, DetectorTimings const *timings)
TargetTime toTimeScale(FromTime time) const
Returns a time point in a different time scale.
double G4ToElecTime(double const g4_time) const
TargetTick toTick(FromTime time) const
Returns a time point as a tick on a different time scale.
Contains all timing reference information for the detector.
Dimensioned variables representing space or time quantities.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
Data types for detinfo::DetectorTimings.
nanosecond_as<> nanosecond
Type of time stored in nanoseconds, in double precision.
constexpr double Frequency() const
Frequency in MHz.
detinfo::timescales::optical_tick_d optical_tick_d
Constructor: wraps around a specified detinfo::DetectorClocksData object.
static detinfo::timescales::electronics_time startTime(DetectorTimings const *detTiming)
timescale_traits< OpticalTimeCategory >::tick_d_t optical_tick_d
time_interval fromStart(electronics_time time) const
Converts a electronics time point into a duration from the start of electronics time.
timescale_traits< TPCelectronicsTimeCategory >::time_point_t TPCelectronics_time
A point in time on the TPC electronics time scale.
Class representing the time measured by an electronics clock.
auto OpticalClockPeriod() const
Returns the duration of the optical clock period and tick.
microsecond TriggerTime() const
Equivalent to detinfo::DetectorClocksData::TriggerTime().
optical_tick_d toOpticalTickD(TimePoint time) const
Returns the time point converted in units of optical time ticks.
detinfo::timescales::optical_time_ticks optical_time_ticks
Constructor: wraps around a specified detinfo::DetectorClocksData object.
double TPCTick2TDC(double const tick) const
timescale_traits< TPCelectronicsTimeCategory >::tick_t TPCelectronics_tick
A point on the TPC electronics time scale expressed in its ticks.
detinfo::timescales::optical_tick optical_tick
Constructor: wraps around a specified detinfo::DetectorClocksData object.
timescale_traits< ElectronicsTimeCategory >::time_point_t electronics_time
A point in time on the electronics time scale.
electronics_tick toElectronicsTick(FromTime time) const
Converts a time point into electronics tick (truncated).
static constexpr TickPoint startTick(DetectorTimings const *)
constexpr TimeScale startTime() const
Returns the start time of the specified time scale.
DetectorTimings(detinfo::DetectorClocksData const *clockData)
Constructor: wraps around a specified detinfo::DetectorClocksData object.
static TargetTick convert(FromTime time, DetectorTimings const *timings)