Public Member Functions | Protected Attributes | List of all members
gar::detinfo::ElecClock Class Reference

#include <ElecClock.h>

Public Member Functions

 ElecClock (double time=0, double frame_period=kTIME_MAX, double frequency=1e9)
 Default constructor. More...
 
 ~ElecClock ()
 Default destructor. More...
 
void SetTime (double time)
 
void SetTime (int sample, int frame)
 
void SetTime (unsigned int sample, unsigned int frame)
 
void SetTime (int ticks)
 
void SetTime (unsigned int ticks)
 
double Time () const
 Time (stored) in nano-second. More...
 
double Time (int sample, int frame) const
 Given sample & frame number in this clock, returns double precision time [ns]. More...
 
double Time (double time) const
 Given time [ns] w.r.t. electronics clock counting, return discretized time in double precision. More...
 
double Time (int ticks) const
 Given time in ticks w.r.t. electronics clock counting, return discretized time in double precision. More...
 
double Frequency () const
 Frequency in MHz. More...
 
double FramePeriod () const
 A single frame period in micro-second. More...
 
int Ticks () const
 

of Ticks

More...
 
int Ticks (double time) const
 Given time [ns] w.r.t. electronics clock T0, return # of ticks. More...
 
int Ticks (int sample, int frame) const
 Given sample & frame returns # ticks. More...
 
int Sample () const
 Sample number. More...
 
int Sample (double time) const
 Given time [ns] w.r.t. electronics clock T0, return sample number. More...
 
int Sample (int tick) const
 Given ticks w.r.t. electronics clock T0, return sample number. More...
 
int Frame () const
 Frame number. More...
 
int Frame (double time) const
 Given time [ns] w.r.t. electronics clock T0, return frame number. More...
 
int Frame (int tick) const
 Given ticks w.r.t. electronics clock T0, return frame number. More...
 
unsigned int FrameTicks () const
 Number ticks in a frame. More...
 
double TickPeriod () const
 A single tick period in nano-second, frequency is in MHz. More...
 
ElecClock operator+ (const ElecClock &rhs)
 
ElecClock operator- (const ElecClock &rhs)
 
bool operator< (const ElecClock &rhs) const
 
bool operator> (const ElecClock &rhs) const
 
bool operator<= (const ElecClock &rhs) const
 
bool operator>= (const ElecClock &rhs) const
 

Protected Attributes

double fTime
 Time in nano-second. More...
 
double fFramePeriod
 Frame period in micro-second. More...
 
double fFrequency
 Clock speed in MHz. More...
 

Detailed Description

Electronics clock class which holds double precision time in nanosecond, frequency in Hz, and frame period in seconds.

Definition at line 28 of file ElecClock.h.

Constructor & Destructor Documentation

gar::detinfo::ElecClock::ElecClock ( double  time = 0,
double  frame_period = kTIME_MAX,
double  frequency = 1e9 
)
inline

Default constructor.

Definition at line 33 of file ElecClock.h.

36  : fTime(time)
37  , fFramePeriod(frame_period)
38  , fFrequency(frequency)
39  {
40  if( fFrequency <= 0 ) throw detinfo::DetectorClocksException("Negative frequency is prohibited!");
41  }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
gar::detinfo::ElecClock::~ElecClock ( )
inline

Default destructor.

Definition at line 44 of file ElecClock.h.

44 {};

Member Function Documentation

int gar::detinfo::ElecClock::Frame ( ) const
inline

Frame number.

Definition at line 113 of file ElecClock.h.

113 { return Frame(fTime); }
int Frame() const
Frame number.
Definition: ElecClock.h:113
double fTime
Time in nano-second.
Definition: ElecClock.h:44
int gar::detinfo::ElecClock::Frame ( double  time) const
inline

Given time [ns] w.r.t. electronics clock T0, return frame number.

Definition at line 116 of file ElecClock.h.

116 { return (int)(time / fFramePeriod); }
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
int gar::detinfo::ElecClock::Frame ( int  tick) const
inline

Given ticks w.r.t. electronics clock T0, return frame number.

Definition at line 119 of file ElecClock.h.

119 { return (tick / (int)(FrameTicks())); }
unsigned int FrameTicks() const
Number ticks in a frame.
Definition: ElecClock.h:122
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
double gar::detinfo::ElecClock::FramePeriod ( ) const
inline

A single frame period in micro-second.

Definition at line 92 of file ElecClock.h.

92 { return fFramePeriod; }
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
unsigned int gar::detinfo::ElecClock::FrameTicks ( ) const
inline

Number ticks in a frame.

Definition at line 122 of file ElecClock.h.

122 { return (int)(fFramePeriod * 1.e-3 * fFrequency);}
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
double gar::detinfo::ElecClock::Frequency ( ) const
inline

Frequency in MHz.

Definition at line 89 of file ElecClock.h.

89 { return fFrequency; }
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
ElecClock gar::detinfo::ElecClock::operator+ ( const ElecClock rhs)
inline

Definition at line 148 of file ElecClock.h.

149  { return ElecClock(fTime + rhs.Time(),fFramePeriod,fFrequency); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
ElecClock(double time=0, double frame_period=kTIME_MAX, double frequency=1e9)
Default constructor.
Definition: ElecClock.h:33
ElecClock gar::detinfo::ElecClock::operator- ( const ElecClock rhs)
inline

Definition at line 151 of file ElecClock.h.

152  { return ElecClock(fTime - rhs.Time(),fFramePeriod,fFrequency); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
ElecClock(double time=0, double frame_period=kTIME_MAX, double frequency=1e9)
Default constructor.
Definition: ElecClock.h:33
bool gar::detinfo::ElecClock::operator< ( const ElecClock rhs) const
inline

Definition at line 154 of file ElecClock.h.

154 { return fTime < rhs.Time(); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
bool gar::detinfo::ElecClock::operator<= ( const ElecClock rhs) const
inline

Definition at line 156 of file ElecClock.h.

156 { return fTime <= rhs.Time(); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
bool gar::detinfo::ElecClock::operator> ( const ElecClock rhs) const
inline

Definition at line 155 of file ElecClock.h.

155 { return fTime > rhs.Time(); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
bool gar::detinfo::ElecClock::operator>= ( const ElecClock rhs) const
inline

Definition at line 157 of file ElecClock.h.

157 { return fTime >= rhs.Time(); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
int gar::detinfo::ElecClock::Sample ( ) const
inline

Sample number.

Definition at line 104 of file ElecClock.h.

104 { return Sample(fTime); }
int Sample() const
Sample number.
Definition: ElecClock.h:104
double fTime
Time in nano-second.
Definition: ElecClock.h:44
int gar::detinfo::ElecClock::Sample ( double  time) const
inline

Given time [ns] w.r.t. electronics clock T0, return sample number.

Definition at line 107 of file ElecClock.h.

107 { return (int)((time - Frame(time) * fFramePeriod) * 1.e-3 * fFrequency); }
int Frame() const
Frame number.
Definition: ElecClock.h:113
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
const double e
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
int gar::detinfo::ElecClock::Sample ( int  tick) const
inline

Given ticks w.r.t. electronics clock T0, return sample number.

Definition at line 110 of file ElecClock.h.

110 { return (tick % (int)(FrameTicks())); }
unsigned int FrameTicks() const
Number ticks in a frame.
Definition: ElecClock.h:122
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
void gar::detinfo::ElecClock::SetTime ( double  time)
inline

Definition at line 58 of file ElecClock.h.

58 { fTime = time; }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
void gar::detinfo::ElecClock::SetTime ( int  sample,
int  frame 
)
inline

Definition at line 60 of file ElecClock.h.

62  { fTime = Time(sample, frame); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
double Time() const
Time (stored) in nano-second.
Definition: ElecClock.h:77
void gar::detinfo::ElecClock::SetTime ( unsigned int  sample,
unsigned int  frame 
)
inline

Definition at line 64 of file ElecClock.h.

66  { SetTime(int(sample),int(frame)); }
void SetTime(double time)
Definition: ElecClock.h:58
void gar::detinfo::ElecClock::SetTime ( int  ticks)
inline

Definition at line 68 of file ElecClock.h.

69  { fTime = Time(ticks,0); }
tick ticks
Alias for common language habits.
Definition: electronics.h:78
double fTime
Time in nano-second.
Definition: ElecClock.h:44
double Time() const
Time (stored) in nano-second.
Definition: ElecClock.h:77
void gar::detinfo::ElecClock::SetTime ( unsigned int  ticks)
inline

Definition at line 71 of file ElecClock.h.

72  { SetTime(int(ticks)); }
tick ticks
Alias for common language habits.
Definition: electronics.h:78
void SetTime(double time)
Definition: ElecClock.h:58
double gar::detinfo::ElecClock::TickPeriod ( ) const
inline

A single tick period in nano-second, frequency is in MHz.

Definition at line 125 of file ElecClock.h.

125 { return 1.e3 / fFrequency; }
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
int gar::detinfo::ElecClock::Ticks ( ) const
inline

of Ticks

Definition at line 95 of file ElecClock.h.

95 { return Ticks(fTime); }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
int Ticks() const
of Ticks
Definition: ElecClock.h:95
int gar::detinfo::ElecClock::Ticks ( double  time) const
inline

Given time [ns] w.r.t. electronics clock T0, return # of ticks.

Definition at line 98 of file ElecClock.h.

98 { return (int)(time * 1.e-3 * fFrequency); }
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
int gar::detinfo::ElecClock::Ticks ( int  sample,
int  frame 
) const
inline

Given sample & frame returns # ticks.

Definition at line 101 of file ElecClock.h.

101 { return sample + frame * FrameTicks(); }
unsigned int FrameTicks() const
Number ticks in a frame.
Definition: ElecClock.h:122
double gar::detinfo::ElecClock::Time ( ) const
inline

Time (stored) in nano-second.

Definition at line 77 of file ElecClock.h.

77 { return fTime; }
double fTime
Time in nano-second.
Definition: ElecClock.h:44
double gar::detinfo::ElecClock::Time ( int  sample,
int  frame 
) const
inline

Given sample & frame number in this clock, returns double precision time [ns].

Definition at line 80 of file ElecClock.h.

80 { return (sample * 1.e3 / fFrequency + frame * fFramePeriod); }
double fFramePeriod
Frame period in micro-second.
Definition: ElecClock.h:51
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52
double gar::detinfo::ElecClock::Time ( double  time) const
inline

Given time [ns] w.r.t. electronics clock counting, return discretized time in double precision.

Definition at line 83 of file ElecClock.h.

83 { return Time(Sample(time),Frame(time)); }
int Frame() const
Frame number.
Definition: ElecClock.h:113
int Sample() const
Sample number.
Definition: ElecClock.h:104
double Time() const
Time (stored) in nano-second.
Definition: ElecClock.h:77
double gar::detinfo::ElecClock::Time ( int  ticks) const
inline

Given time in ticks w.r.t. electronics clock counting, return discretized time in double precision.

Definition at line 86 of file ElecClock.h.

86 {return ticks * 1.e3 / fFrequency; }
tick ticks
Alias for common language habits.
Definition: electronics.h:78
double fFrequency
Clock speed in MHz.
Definition: ElecClock.h:52

Member Data Documentation

double gar::detinfo::ElecClock::fFramePeriod
protected

Frame period in micro-second.

Definition at line 51 of file ElecClock.h.

double gar::detinfo::ElecClock::fFrequency
protected

Clock speed in MHz.

Definition at line 52 of file ElecClock.h.

double gar::detinfo::ElecClock::fTime
protected

Time in nano-second.

Definition at line 44 of file ElecClock.h.


The documentation for this class was generated from the following file: