LArSoft
v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
|
Class representing the time measured by an electronics clock. More...
#include "ElecClock.h"
Public Member Functions | |
ElecClock () | |
Default constructor. More... | |
ElecClock (double time, double frame_period, double frequency) | |
Constructor: sets all values. More... | |
void | SetTime (double time) |
Directly sets the current time on the clock. More... | |
void | SetTime (int sample, int frame) |
Sets the current time on the clock from frame and sample number. More... | |
void | SetTime (unsigned int sample, unsigned int frame) |
Sets the current time on the clock from frame and sample number. More... | |
void | SetTime (int ticks) |
Sets the current time on the clock from tick number. More... | |
void | SetTime (unsigned int ticks) |
Sets the current time on the clock from tick number. More... | |
double | Time () const |
Current time (as stored) in microseconds. More... | |
double | Time (int sample, int frame) const |
Returns the absolute time of the start of the specified sample. More... | |
double | Time (double time) const |
Returns the discretized value of the specified time. More... | |
double | Time (int ticks) const |
Returns the absolute start time of the specified tick. More... | |
double | Frequency () const |
Frequency in MHz. More... | |
double | FramePeriod () const |
A single frame period in microseconds. More... | |
int | Ticks () const |
Current clock tick (that is, the number of tick Time() falls in). More... | |
int | Ticks (double time) const |
Returns the number of tick the specified time falls in. More... | |
int | Ticks (int sample, int frame) const |
Returns the number of tick the specified sample falls in. More... | |
int | Sample () const |
Returns number of the sample containing the clock current time. More... | |
int | Sample (double time) const |
Returns the number of the sample containing the specified time. More... | |
int | Sample (int tick) const |
Returns the number of the sample containing the specified tick. More... | |
int | Frame () const |
Returns the number of the frame containing the clock current time. More... | |
int | Frame (double time) const |
Returns the number of the frame containing the specified time. More... | |
int | Frame (int tick) const |
Returns the number of the frame containing the specified tick. More... | |
unsigned int | FrameTicks () const |
Number ticks in a frame. More... | |
double | TickPeriod () const |
A single tick period in microseconds. More... | |
bool | operator< (const ElecClock &rhs) const |
Compares the current time of this clock with the one of rhs . More... | |
bool | operator> (const ElecClock &rhs) const |
Compares the current time of this clock with the one of rhs . More... | |
bool | operator<= (const ElecClock &rhs) const |
Compares the current time of this clock with the one of rhs . More... | |
bool | operator>= (const ElecClock &rhs) const |
Compares the current time of this clock with the one of rhs . More... | |
Operators to modify clock time. | |
ElecClock & | operator++ () |
Increases the current clock time by a full tick time. More... | |
ElecClock | operator++ (int) |
Increases the current clock time by a full tick time. More... | |
ElecClock & | operator-- () |
Decreases the current clock time by a full tick time. More... | |
ElecClock | operator-- (int) |
Decreases the current clock time by a full tick time. More... | |
ElecClock & | operator+= (const double &rhs) |
Increases the current clock time by the specified time in microseconds. More... | |
ElecClock & | operator-= (const double &rhs) |
Decreases the current clock time by the specified time in microseconds. More... | |
ElecClock & | operator+= (const float &rhs) |
Increases the current clock time by the specified time in microseconds. More... | |
ElecClock & | operator-= (const float &rhs) |
Decreases the current clock time by the specified time in microseconds. More... | |
ElecClock & | operator+= (const int &rhs) |
Increases the current clock time by the specified number of ticks. More... | |
ElecClock & | operator-= (const int &rhs) |
Decreases the current clock time by the specified number of ticks. More... | |
ElecClock & | operator+= (const unsigned int &rhs) |
Increases the current clock time by the specified number of ticks. More... | |
ElecClock & | operator-= (const unsigned int &rhs) |
Decreases the current clock time by the specified number of ticks. More... | |
ElecClock & | operator+= (const ElecClock &rhs) |
Increases the current clock time by the current time of another clock. More... | |
ElecClock & | operator-= (const ElecClock &rhs) |
Decreases the current clock time by the current time of another clock. More... | |
ElecClock | operator+ (const ElecClock &rhs) |
ElecClock | operator- (const ElecClock &rhs) |
Protected Attributes | |
double | fTime |
Time in microseconds. More... | |
double | fFramePeriod |
Frame period in microseconds. More... | |
double | fFrequency |
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 |
Default constructor.
A default-constructed clock is useless. It is caller's responsibility to set all the information of the default-constructed clock by assignment from another clock.
Better yet, don't use this constructor and instead construct the clock immediately right.
Definition at line 105 of file ElecClock.h.
Referenced by operator+(), and operator-().
|
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 114 of file ElecClock.h.
References fFrequency.
|
inline |
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 310 of file ElecClock.h.
References Frame().
Referenced by opdet::ConstructFlash(), opdet::ConstructHit(), Frame(), Sample(), and Time().
|
inline |
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 323 of file ElecClock.h.
References fFramePeriod.
|
inline |
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 336 of file ElecClock.h.
References FrameTicks().
|
inline |
A single frame period in microseconds.
Definition at line 232 of file ElecClock.h.
References fFramePeriod.
Referenced by detinfo::DetectorClocksStandard::ExternalClock(), detinfo::DetectorClocksStandard::OpticalClock(), detinfo::DetectorClocksStandard::TPCClock(), and detinfo::DetectorClocksStandard::TriggerClock().
|
inline |
Number ticks in a frame.
Definition at line 339 of file ElecClock.h.
References fFrequency.
Referenced by Frame(), Sample(), and Ticks().
|
inline |
Frequency in MHz.
Definition at line 229 of file ElecClock.h.
References fFrequency.
Referenced by detinfo::DetectorClocksStandard::debugReport(), detinfo::DetectorClocksStandard::ExternalClock(), detinfo::DetectorClocksStandard::OpticalClock(), detinfo::DetectorClocksStandard::TPCClock(), detinfo::DetectorClocksStandard::TriggerClock(), and detinfo::DetectorClocksStandard::TriggerOffsetTPC().
Returns a clock like this one, with its current time increased by the current time of rhs
.
Definition at line 390 of file ElecClock.h.
References ElecClock(), fFramePeriod, fFrequency, and Time().
|
inline |
Increases the current clock time by a full tick time.
Definition at line 351 of file ElecClock.h.
References fFrequency.
|
inline |
Increases the current clock time by a full tick time.
Definition at line 354 of file ElecClock.h.
References operator++(), and tmp.
Referenced by operator++().
|
inline |
Increases the current clock time by the specified time in microseconds.
Definition at line 363 of file ElecClock.h.
|
inline |
Increases the current clock time by the specified time in microseconds.
Definition at line 368 of file ElecClock.h.
|
inline |
Increases the current clock time by the specified number of ticks.
Definition at line 373 of file ElecClock.h.
References Time().
|
inline |
Increases the current clock time by the specified number of ticks.
Definition at line 378 of file ElecClock.h.
References Time().
Increases the current clock time by the current time of another clock.
Definition at line 383 of file ElecClock.h.
References Time().
Returns a clock like this one, with its current time decreased by the current time of rhs
.
Definition at line 395 of file ElecClock.h.
References ElecClock(), fFramePeriod, fFrequency, and Time().
|
inline |
Decreases the current clock time by a full tick time.
Definition at line 357 of file ElecClock.h.
References fFrequency.
|
inline |
Decreases the current clock time by a full tick time.
Definition at line 360 of file ElecClock.h.
References operator--(), and tmp.
Referenced by operator--().
|
inline |
Decreases the current clock time by the specified time in microseconds.
Definition at line 365 of file ElecClock.h.
|
inline |
Decreases the current clock time by the specified time in microseconds.
Definition at line 370 of file ElecClock.h.
|
inline |
Decreases the current clock time by the specified number of ticks.
Definition at line 375 of file ElecClock.h.
References Time().
|
inline |
Decreases the current clock time by the specified number of ticks.
Definition at line 380 of file ElecClock.h.
References Time().
Decreases the current clock time by the current time of another clock.
Definition at line 386 of file ElecClock.h.
References Time().
|
inline |
Compares the current time of this clock with the one of rhs
.
Definition at line 401 of file ElecClock.h.
References Time().
|
inline |
Compares the current time of this clock with the one of rhs
.
Definition at line 405 of file ElecClock.h.
References Time().
|
inline |
Compares the current time of this clock with the one of rhs
.
Definition at line 403 of file ElecClock.h.
References Time().
|
inline |
Compares the current time of this clock with the one of rhs
.
Definition at line 407 of file ElecClock.h.
References Time().
|
inline |
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 271 of file ElecClock.h.
References Sample().
Referenced by Sample(), and Time().
|
inline |
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 286 of file ElecClock.h.
References fFramePeriod, and Frame().
|
inline |
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 301 of file ElecClock.h.
References FrameTicks().
|
inline |
Directly sets the current time on the clock.
time | reference time (expected in microseconds) |
Definition at line 138 of file ElecClock.h.
Referenced by detinfo::DetectorClocksStandard::ExternalClock(), detinfo::DetectorClocksStandard::OpticalClock(), SetTime(), detinfo::DetectorClocksStandard::SetTriggerTime(), detinfo::DetectorClocksStandard::TPCClock(), and detinfo::DetectorClocksStandard::TriggerClock().
|
inline |
Sets the current time on the clock from frame and sample number.
sample | the number of the sample within the specified frame |
frame | the frame containing the time to be sets |
The current clock time is set to the instant of the start of the specified sample.
Definition at line 148 of file ElecClock.h.
References Time().
|
inline |
Sets the current time on the clock from frame and sample number.
sample | the number of the sample within the specified frame |
frame | the frame containing the time to be sets |
The current clock time is set to the instant of the start of the specified sample.
Definition at line 160 of file ElecClock.h.
References SetTime().
|
inline |
Sets the current time on the clock from tick number.
ticks | the number of tick to set the clock to |
The current clock time is set to the instant of the start of the specified tick.
Definition at line 171 of file ElecClock.h.
References Time().
|
inline |
Sets the current time on the clock from tick number.
ticks | the number of tick to set the clock to |
The current clock time is set to the instant of the start of the specified tick.
Definition at line 181 of file ElecClock.h.
References SetTime().
|
inline |
A single tick period in microseconds.
Definition at line 342 of file ElecClock.h.
References fFrequency.
Referenced by opdet::ConstructHit(), detinfo::DetectorClocksStandard::ExternalG4Time2TDC(), detinfo::DetectorClocksStandard::ExternalTick2BeamTime(), detinfo::DetectorClocksStandard::ExternalTick2Time(), detinfo::DetectorClocksStandard::ExternalTick2TrigTime(), detinfo::DetectorClocksStandard::OpticalG4Time2TDC(), detinfo::DetectorClocksStandard::OpticalTick2BeamTime(), detinfo::DetectorClocksStandard::OpticalTick2Time(), detinfo::DetectorClocksStandard::OpticalTick2TrigTime(), util::DetectorPropertiesServiceArgoNeuT::SamplingRate(), detinfo::DetectorPropertiesStandard::SamplingRate(), detinfo::DetectorClocksStandard::TPCG4Time2TDC(), detinfo::DetectorClocksStandard::TPCG4Time2Tick(), detinfo::DetectorClocksStandard::TPCTDC2Tick(), detinfo::DetectorClocksStandard::TPCTick2TDC(), detinfo::DetectorClocksStandard::TPCTick2Time(), and detinfo::DetectorClocksStandard::TPCTick2TrigTime().
|
inline |
Current clock tick (that is, the number of tick Time()
falls in).
Definition at line 235 of file ElecClock.h.
References Ticks().
Referenced by larg4::LArVoxelReadout::DriftIonizationElectrons(), detinfo::DetectorClocksStandard::ExternalTick2TDC(), detinfo::DetectorClocksStandard::OpticalTick2TDC(), detsim::SimDriftElectrons::produce(), Ticks(), util::DetectorPropertiesServiceArgoNeuT::TriggerOffset(), and detinfo::DetectorPropertiesStandard::TriggerOffset().
|
inline |
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 247 of file ElecClock.h.
References fFrequency.
|
inline |
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 260 of file ElecClock.h.
References FrameTicks().
|
inline |
Current time (as stored) in microseconds.
Note that this is different than Time(Time())
, which is discretized.
Definition at line 191 of file ElecClock.h.
References fTime.
Referenced by detinfo::DetectorClocksStandard::ExternalTick2BeamTime(), detinfo::DetectorClocksStandard::ExternalTick2Time(), detinfo::DetectorClocksStandard::ExternalTick2TrigTime(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator<=(), operator>(), operator>=(), detinfo::DetectorClocksStandard::OpticalTick2BeamTime(), detinfo::DetectorClocksStandard::OpticalTick2Time(), detinfo::DetectorClocksStandard::OpticalTick2TrigTime(), and SetTime().
|
inline |
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 204 of file ElecClock.h.
|
inline |
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 215 of file ElecClock.h.
References Frame(), Sample(), and Time().
Referenced by Time().
|
inline |
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 226 of file ElecClock.h.
References fFrequency.
|
protected |
Frame period in microseconds.
Definition at line 127 of file ElecClock.h.
Referenced by Frame(), FramePeriod(), operator+(), operator-(), and Sample().
|
protected |
Clock speed in MHz.
Definition at line 128 of file ElecClock.h.
Referenced by ElecClock(), FrameTicks(), Frequency(), operator+(), operator++(), operator-(), operator--(), TickPeriod(), Ticks(), and Time().
|
protected |