9 #ifndef LARDATAALG_DETECTORINFO_DETECTORTIMINGS_H 10 #define LARDATAALG_DETECTORINFO_DETECTORTIMINGS_H 20 #include <type_traits> 63 : fClockData(detClocks)
252 template <
typename TimeScale>
256 template <
typename TimeScale>
260 template <
typename TimeScale>
320 return detClocksUnits().clockData();
365 template <
typename TargetTime,
typename FromTime>
366 TargetTime toTimeScale(FromTime
time)
const;
382 template <
typename TargetTick,
typename FromTime>
383 TargetTick toTick(FromTime time)
const;
395 template <
typename Ticks>
399 return Ticks::castFrom(time / ClockPeriodFor<Ticks>());
415 template <
typename FromTime>
419 return toTimeScale<electronics_time>(time);
435 template <
typename FromTime>
439 return toTick<electronics_tick_d>(time);
455 template <
typename FromTime>
459 return toTick<electronics_tick>(time);
474 template <
typename FromTime>
478 return toTimeScale<trigger_time>(time);
493 template <
typename FromTime>
497 return toTimeScale<simulation_time>(time);
508 template <
typename TimeScale>
512 template <
typename TimeScale>
520 template <
typename TimeScale>
535 return ClockPeriodFor<optical_time>();
542 return ClockFrequencyFor<optical_time>();
555 template <
typename Ticks = optical_time_ticks>
560 "Specified ticks are not for optical time scale!");
561 return toTicks<Ticks>(time);
576 template <
typename TimePo
int>
580 return toTick<optical_tick>(time);
595 template <
typename TimePo
int>
599 return toTick<optical_tick_d>(time);
647 template <
typename TimePo
int,
typename TimeScale = electronics_time>
648 constexpr TimeScale startTime()
const;
683 template <
typename TickPo
int,
typename TimeTickScale = electronics_tick>
684 constexpr TimeTickScale startTick()
const;
737 template <
typename TimePo
int,
typename TimeScale = TimePo
int,
typename =
void>
742 static_assert(util::always_false_v<TimePoint>,
743 "Start time not implemented for this time in this time scale.");
750 template <
typename TimePo
int>
753 static constexpr TimePoint
756 return TimePoint{0_us};
819 template <
typename TimeScale>
823 std::enable_if_t<!std::is_same_v<TimeScale, detinfo::timescales::electronics_time>>> {
845 template <
typename TimePo
int,
typename TimeScale>
849 std::enable_if_t<!std::is_same_v<TimePoint, detinfo::timescales::electronics_time> &&
850 !std::is_same_v<TimeScale, detinfo::timescales::electronics_time> &&
851 !std::is_same_v<TimeScale, TimePoint>>> {
862 template <
typename TickPo
int,
typename TimeTickScale = TickPo
int>
866 template <
typename TickPo
int>
869 static constexpr TickPoint
872 return TickPoint::castFrom(0.0);
907 template <
typename FromTime,
typename TargetTime,
typename =
void>
913 return timings->
startTime<FromTime, TargetTime>() + time.quantity();
918 template <
typename TargetTime>
930 template <
typename FromTick,
typename TargetTime>
933 std::enable_if_t<detinfo::timescales::is_tick_v<FromTick>>> {
939 typename FromTick::category_t>::time_point_t;
948 template <
typename FromTime,
typename TargetTick,
typename =
void>
956 if constexpr(detinfo::timescales::is_tick_v<FromTime>)
957 return convertTick(time, timings);
959 return convertTime(time, timings);
966 static_assert(!detinfo::timescales::is_tick_v<FromTime>);
968 typename TargetTick::category_t>::time_point_t;
969 auto const timeFromStart = time - timings->
startTime<TargetTime, FromTime>();
971 return TargetTick::castFrom(timeFromStart / clockPeriod);
977 static_assert(detinfo::timescales::is_tick_v<FromTime>);
981 typename TargetTick::category_t>::time_point_t;
983 return timings->
toTick<TargetTick>(time);
991 template <
typename TimeScale,
typename =
void>
996 static_assert(util::always_false_v<TimeScale>,
997 "Electronics clock not defined for this time scale.");
1003 template <
typename TimeScale>
1012 return timings->clockData().TPCClock();
1021 return timings->clockData().OpticalClock();
1030 return timings->clockData().TriggerClock();
1036 :
ClockForImpl<detinfo::timescales::TPCelectronicsTimeCategory> {};
1043 template <
typename TimePoint,
typename TimeScale >
1051 template <
typename TickPoint,
typename TimeTickScale >
1052 constexpr TimeTickScale
1059 template <
typename TargetTime,
typename FromTime>
1067 template <
typename TargetTick,
typename FromTime>
1075 template <
typename TimeScale>
1086 return time - startTime<electronics_time, electronics_time>();
1095 #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
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
microsecond_as<> microsecond
Type of time stored in microseconds, in double precision.
detinfo::timescales::TPCelectronics_time TPCelectronics_time
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)
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
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
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
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
static detinfo::timescales::electronics_time startTime(DetectorTimings const *detTiming)
static TargetTime convert(TargetTime time, DetectorTimings const *)
detinfo::timescales::electronics_time electronics_time
microsecond G4ToElecTime(double simTime) const
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
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
A value measured in the specified unit.
def convert(inputfile, outputfile="wire-cell-garfield-fine-response.json.bz2", average=False, shaped=False)
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
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
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
detinfo::ElecClock const & ClockFor() const
Returns the electronics clock for the specified time scale.
detinfo::timescales::trigger_time trigger_time
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
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
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
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
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)
static TargetTick convert(FromTime time, DetectorTimings const *timings)