ToolDAQFramework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
TimeDelta Class Reference

#include <TimeDelta.h>

Public Types

typedef int64_t long_time_t
 Type for absolute timestamps of a SubSample. Unit = ns. More...
 
typedef float short_time_t
 Type for relative hit times within a SubSample. Unit = ns. More...
 

Public Member Functions

 TimeDelta ()
 Default constructor (sets all times to 0) More...
 
 TimeDelta (const TimeDelta &)=default
 Copy constructor (just copies all member variables) More...
 
 TimeDelta (double naive_ns)
 Constructor from naive floating point value (in ns) More...
 
void Normalize ()
 Ensure that the time difference stored in m_short_time is small and positive. More...
 

Public Attributes

long_time_t m_long_time
 Member for long time delta. More...
 
short_time_t m_short_time
 Member for short time deltas. More...
 

Static Public Attributes

static const TimeDelta ms = 1000 * TimeDelta::us
 TimeDelta of 1 ms. More...
 
static const TimeDelta ns = TimeDelta(1.0)
 TimeDelta of 1 ns. More...
 
static const TimeDelta ps = TimeDelta(0.001)
 TimeDelta of 1 ps. More...
 
static const TimeDelta s = 1000 * TimeDelta::ms
 TimeDelta of 1 s. More...
 
static constexpr double s_long_time_unit = 1.
 Relative unit of long time member, i.e. long_unit / short_unit, both ns so = 1. More...
 
static const TimeDelta us = 1000 * TimeDelta::ns
 TimeDelta of 1 us. More...
 

Detailed Description

Universal data type to store both large scale (unix timestamp) and short scale (hit times) time differences

The type and unit of the long and short scale times are optimised to allow SubSamples to store many hits relative to a single timestamp efficiently.

The base unit for physics simulations (at least in WCSim) is ns, that that is the chosen as the unit for the short time scales. A signed 64 bit integer can hold values up to 2^63 = 9.22337204 x 10^18, which in ns would be more than 290 years. Long enough for the long time deltas.

When creating TimeDelta instances, one should use the unit constants to do so:

TimeDelta t = 0.7 * TimeDelta::ms;

To convert into a naive floating point value, use them with the division operator:

double naive_t = t / TimeDelta::us;

Definition at line 26 of file TimeDelta.h.

Member Typedef Documentation

typedef int64_t TimeDelta::long_time_t

Type for absolute timestamps of a SubSample. Unit = ns.

Definition at line 39 of file TimeDelta.h.

typedef float TimeDelta::short_time_t

Type for relative hit times within a SubSample. Unit = ns.

Definition at line 37 of file TimeDelta.h.

Constructor & Destructor Documentation

TimeDelta::TimeDelta ( )
inline

Default constructor (sets all times to 0)

Definition at line 30 of file TimeDelta.h.

TimeDelta::TimeDelta ( const TimeDelta )
default

Copy constructor (just copies all member variables)

TimeDelta::TimeDelta ( double  naive_ns)

Constructor from naive floating point value (in ns)

Definition at line 4 of file TimeDelta.cpp.

Member Function Documentation

void TimeDelta::Normalize ( )

Ensure that the time difference stored in m_short_time is small and positive.

Definition at line 14 of file TimeDelta.cpp.

Member Data Documentation

long_time_t TimeDelta::m_long_time

Member for long time delta.

Definition at line 44 of file TimeDelta.h.

short_time_t TimeDelta::m_short_time

Member for short time deltas.

Definition at line 42 of file TimeDelta.h.

const TimeDelta TimeDelta::ms = 1000 * TimeDelta::us
static

TimeDelta of 1 ms.

Definition at line 61 of file TimeDelta.h.

const TimeDelta TimeDelta::ns = TimeDelta(1.0)
static

TimeDelta of 1 ns.

Definition at line 57 of file TimeDelta.h.

const TimeDelta TimeDelta::ps = TimeDelta(0.001)
static

TimeDelta of 1 ps.

Definition at line 55 of file TimeDelta.h.

const TimeDelta TimeDelta::s = 1000 * TimeDelta::ms
static

TimeDelta of 1 s.

Definition at line 63 of file TimeDelta.h.

constexpr double TimeDelta::s_long_time_unit = 1.
static

Relative unit of long time member, i.e. long_unit / short_unit, both ns so = 1.

Definition at line 47 of file TimeDelta.h.

const TimeDelta TimeDelta::us = 1000 * TimeDelta::ns
static

TimeDelta of 1 us.

Definition at line 59 of file TimeDelta.h.


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