LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
Class representing the time measured by an electronics clock. More...
#include "ElecClock.h"
Public Member Functions | |
ElecClock (double const time, double const frame_period, double const frequency) | |
Constructor: sets all values. More... | |
constexpr ElecClock | WithTime (double const time) const noexcept |
constexpr ElecClock | WithTick (int const tick, int const frame=0) const noexcept |
constexpr ElecClock | AdvanceTimeBy (double const time) const noexcept |
constexpr ElecClock | AdvanceTicksBy (int const ticks) const noexcept |
constexpr double | Time () const noexcept |
Current time (as stored) in microseconds. More... | |
constexpr double | Time (int const sample, int const frame) const noexcept |
Returns the absolute time of the start of the specified sample. More... | |
constexpr double | Time (double const time) const noexcept |
Returns the discretized value of the specified time. More... | |
constexpr double | Time (int const ticks) const noexcept |
Returns the absolute start time of the specified tick. More... | |
constexpr double | Frequency () const |
Frequency in MHz. More... | |
constexpr double | FramePeriod () const noexcept |
A single frame period in microseconds. More... | |
constexpr int | Ticks () const noexcept |
Current clock tick (that is, the number of tick Time() falls in). More... | |
constexpr int | Ticks (double const time) const noexcept |
Returns the number of tick the specified time falls in. More... | |
constexpr int | Ticks (int const sample, int const frame) const noexcept |
Returns the number of tick the specified sample falls in. More... | |
constexpr int | Sample () const noexcept |
Returns number of the sample containing the clock current time. More... | |
constexpr int | Sample (double const time) const noexcept |
Returns the number of the sample containing the specified time. More... | |
constexpr int | Sample (int const tick) const noexcept |
Returns the number of the sample containing the specified tick. More... | |
constexpr int | Frame () const noexcept |
Returns the number of the frame containing the clock current time. More... | |
constexpr int | Frame (double const time) const noexcept |
Returns the number of the frame containing the specified time. More... | |
constexpr int | Frame (int const tick) const noexcept |
Returns the number of the frame containing the specified tick. More... | |
constexpr unsigned int | FrameTicks () const noexcept |
Number ticks in a frame. More... | |
constexpr double | TickPeriod () const noexcept |
A single tick period in microseconds. More... | |
constexpr bool | operator< (const ElecClock &rhs) const noexcept |
constexpr bool | operator> (const ElecClock &rhs) const noexcept |
constexpr bool | operator<= (const ElecClock &rhs) const noexcept |
constexpr bool | operator>= (const ElecClock &rhs) const noexcept |
Private Member Functions | |
constexpr | ElecClock (double const time, double const frame_period, double const frequency, std::nothrow_t) noexcept |
Private Attributes | |
double | fTime {} |
Time in microseconds. More... | |
double | fFramePeriod {kTIME_MAX} |
Frame period in microseconds. More... | |
double | fFrequency {1e9} |
Clock speed in MHz. More... | |
Class representing the time measured by an electronics clock.
This class represents the status of a running electronics clock. As such, it has:
Note that this object is actually able to manage any (continuous) value of time, and the concepts of frame and sample are not used to store the clock state, which is instead defined by its current time.
All these quantities are stored in real time units as opposed to clock tick counts. The nominal units for all times and frequencies are microseconds and megahertz, respectively, but ElecClock
will give consistent results as long as the units of frame period and time are the same, and reciprocal to the frequency unit.
The clock can update its time directly (SetTime()
) or through operators.
The clock started at time 0, with the sample 0 of the frame 0 (that is also tick 0). This implies that all times and ticks returned by the clock implicitly have the same reference as the input time specified by the constructors or by the last call to SetTime()
.
Some usage examples:
double
, in which case it is interpreted as a time, or int
, where it is interpreted as a clock tick. Be especially careful when utilizing data types which are neither int
not double
, because a conversion to one of them will occur, and you need to be in control of which one. Definition at line 91 of file ElecClock.h.
|
inline |
Constructor: sets all values.
time | starting time of the clock [µs] |
frame_period | period of the clock [µs] |
frequency | clock frequency [MHz] |
Definition at line 100 of file ElecClock.h.
References fFrequency.
|
inlineprivatenoexcept |
Definition at line 320 of file ElecClock.h.
|
inlinenoexcept |
Definition at line 122 of file ElecClock.h.
References fFramePeriod, fFrequency, fTime, and Time().
|
inlinenoexcept |
Definition at line 117 of file ElecClock.h.
References fFramePeriod, fFrequency, and fTime.
|
inlinenoexcept |
Returns the number of the frame containing the clock current time.
Frame(double)
The returned value is the number of the frame which the current clock time falls in.
Definition at line 269 of file ElecClock.h.
References Frame(), and fTime.
Referenced by opdet::ConstructFlash(), opdet::ConstructHit(), Frame(), Sample(), and Time().
|
inlinenoexcept |
Returns the number of the frame containing the specified time.
time | a clock time [µs] |
Sample(double)
The returned value is the number of the frame which the specified time falls in.
The result is not related to the current time of the clock.
Definition at line 282 of file ElecClock.h.
References fFramePeriod.
|
inlinenoexcept |
Returns the number of the frame containing the specified tick.
tick | a clock tick number |
Frame(int)
The returned value is the number of the frame the specified tick belongs to.
The result is not related to the current time of the clock.
Definition at line 298 of file ElecClock.h.
References FrameTicks().
|
inlinenoexcept |
A single frame period in microseconds.
Definition at line 179 of file ElecClock.h.
References fFramePeriod.
|
inlinenoexcept |
Number ticks in a frame.
Definition at line 304 of file ElecClock.h.
References fFramePeriod, and fFrequency.
Referenced by Frame(), Sample(), and Ticks().
|
inline |
Frequency in MHz.
Definition at line 176 of file ElecClock.h.
References fFrequency.
Referenced by detinfo::DetectorClocksData::debugReport(), detinfo::DetectorClocksWithUnits::OpticalClockFrequency(), detinfo::DetectorClocksStandard::TriggerOffsetTPC(), and detinfo::DetectorClocksData::TriggerOffsetTPC().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns number of the sample containing the clock current time.
Sample(double)
The returned value is the number of the sample within a frame, which the current clock time falls in. The number of the frame is not returned. To univocally define the sample, the number of the frame must also be obtained, e.g. via Frame()
.
Definition at line 224 of file ElecClock.h.
References fTime, and Sample().
Referenced by Sample(), and Time().
|
inlinenoexcept |
Returns the number of the sample containing the specified time.
time | a clock time [µs] |
Frame(double)
The returned value is the number of the sample within a frame, which the specified time falls in. The number of the frame is not returned. To univocally define the sample, the number of the frame must also be obtained, e.g. via Frame(double)
.
The result is not related to the current time of the clock.
Definition at line 239 of file ElecClock.h.
References fFramePeriod, fFrequency, and Frame().
|
inlinenoexcept |
Returns the number of the sample containing the specified tick.
tick | a clock tick number |
Frame(int)
The returned value is the number of the sample within a frame, of the specified tick. The number of the frame is not returned. To univocally define the sample, the number of the frame must also be obtained, e.g. via Frame(int)
.
The result is not related to the current time of the clock.
Definition at line 257 of file ElecClock.h.
References FrameTicks().
|
inlinenoexcept |
A single tick period in microseconds.
Definition at line 310 of file ElecClock.h.
References fFrequency.
Referenced by opdet::ConstructHit(), detinfo::DetectorClocksData::doTime2Tick(), detinfo::DetectorClocksData::ExternalG4Time2TDC(), detinfo::DetectorClocksData::ExternalTick2BeamTime(), detinfo::DetectorClocksData::ExternalTick2Time(), detinfo::DetectorClocksData::ExternalTick2TrigTime(), detinfo::DetectorClocksWithUnits::OpticalClockPeriod(), detinfo::DetectorClocksData::OpticalG4Time2TDC(), detinfo::DetectorClocksData::OpticalTick2BeamTime(), detinfo::DetectorClocksData::OpticalTick2Time(), detinfo::DetectorClocksData::OpticalTick2TrigTime(), detinfo::sampling_rate(), pma::Track3D::SetT0FromDx(), detinfo::DetectorClocksData::TPCG4Time2TDC(), detinfo::DetectorClocksData::TPCG4Time2Tick(), detinfo::DetectorClocksData::TPCTDC2Tick(), detinfo::DetectorClocksData::TPCTick2TDC(), detinfo::DetectorClocksData::TPCTick2Time(), detinfo::DetectorClocksData::TPCTick2TrigTime(), and DUNE::NeutrinoTrackingEff::truthLength().
|
inlinenoexcept |
Current clock tick (that is, the number of tick Time()
falls in).
Definition at line 182 of file ElecClock.h.
References fTime, and Ticks().
Referenced by detinfo::DetectorClocksData::ExternalTick2TDC(), detinfo::DetectorClocksData::OpticalTick2TDC(), Ticks(), and detinfo::trigger_offset().
|
inlinenoexcept |
Returns the number of tick the specified time falls in.
time | time to be converted in ticks [µs] |
The tick number 0 starts at time 0.0 µs.
int
). Definition at line 194 of file ElecClock.h.
References fFrequency.
|
inlinenoexcept |
Returns the number of tick the specified sample falls in.
sample | number of sample in the specified frame |
frame | number of frame the specified sample is in |
The sample 0 of frame 0 is the tick number 0.
int
). Definition at line 210 of file ElecClock.h.
References FrameTicks().
|
inlinenoexcept |
Current time (as stored) in microseconds.
Note that this is different than Time(Time())
, which is discretized.
Definition at line 132 of file ElecClock.h.
References fTime.
Referenced by AdvanceTicksBy(), detinfo::DetectorClocksData::ExternalTick2BeamTime(), detinfo::DetectorClocksData::ExternalTick2Time(), detinfo::DetectorClocksData::ExternalTick2TrigTime(), detinfo::DetectorClocksData::OpticalTick2BeamTime(), detinfo::DetectorClocksData::OpticalTick2Time(), detinfo::DetectorClocksData::OpticalTick2TrigTime(), Time(), and WithTick().
|
inlinenoexcept |
Returns the absolute time of the start of the specified sample.
sample | sample number within the specified frame |
frame | number of the frame the specified sample is in |
The sample number is not checked to be actually within the specified frame.
The returned time is not related to the current time of the clock.
Definition at line 145 of file ElecClock.h.
References fFramePeriod, and fFrequency.
|
inlinenoexcept |
Returns the discretized value of the specified time.
time | a clock time [µs] |
The returned time is the start time of the sample time
falls in.
It is not related to the current time of the clock.
Definition at line 159 of file ElecClock.h.
References Frame(), Sample(), and Time().
|
inlinenoexcept |
Returns the absolute start time of the specified tick.
ticks | a clock time [µs] |
The returned time is the start time of the tick which time
falls in.
It is not related to the current time of the clock.
Definition at line 173 of file ElecClock.h.
References fFrequency.
|
inlinenoexcept |
Definition at line 112 of file ElecClock.h.
References fFramePeriod, fFrequency, and Time().
|
inlinenoexcept |
Definition at line 107 of file ElecClock.h.
References fFramePeriod, and fFrequency.
|
private |
Frame period in microseconds.
Definition at line 328 of file ElecClock.h.
Referenced by AdvanceTicksBy(), AdvanceTimeBy(), Frame(), FramePeriod(), FrameTicks(), Sample(), Time(), WithTick(), and WithTime().
|
private |
Clock speed in MHz.
Definition at line 329 of file ElecClock.h.
Referenced by AdvanceTicksBy(), AdvanceTimeBy(), ElecClock(), FrameTicks(), Frequency(), Sample(), TickPeriod(), Ticks(), Time(), WithTick(), and WithTime().
|
private |
Time in microseconds.
Definition at line 327 of file ElecClock.h.
Referenced by AdvanceTicksBy(), AdvanceTimeBy(), Frame(), operator<(), operator<=(), operator>(), operator>=(), Sample(), Ticks(), and Time().