All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Friends | List of all members
detinfo::DetectorTimings Class Reference

A class exposing an upgraded interface of detinfo::DetectorClocksData. More...

#include <DetectorTimings.h>

Inheritance diagram for detinfo::DetectorTimings:
detinfo::DetectorClocksWithUnits

Public Member Functions

electronics_time TriggerTime () const
 
electronics_time BeamGateTime () const
 
auto OpticalClockPeriod () const
 Returns the duration of the optical clock period and tick. More...
 
megahertz OpticalClockFrequency () const
 Returns the frequency of the optical clock tick. More...
 
template<typename Ticks = optical_time_ticks>
Ticks toOpticalTicks (time_interval time) const
 Returns the optical ticks corresponding to a time interval. More...
 
template<typename TimePoint >
optical_tick toOpticalTick (TimePoint time) const
 Returns the time point converted in units of optical time ticks. More...
 
template<typename TimePoint >
optical_tick_d toOpticalTickD (TimePoint time) const
 Returns the time point converted in units of optical time ticks. More...
 
Access to underlying service providers.
detinfo::DetectorClocksWithUnits
const & 
detClocksUnits () const
 Returns a DetectorClocksWithUnits object. More...
 
detinfo::DetectorClocksData const & clockData () const
 Returns the detector clocks data. More...
 
Conversions
template<typename TargetTime , typename FromTime >
TargetTime toTimeScale (FromTime time) const
 Returns a time point in a different time scale. More...
 
template<typename TargetTick , typename FromTime >
TargetTick toTick (FromTime time) const
 Returns a time point as a tick on a different time scale. More...
 
template<typename Ticks >
Ticks toTicks (time_interval time) const
 Returns the number of ticks corresponding to a time interval. More...
 
template<typename FromTime >
electronics_time toElectronicsTime (FromTime time) const
 Converts a time point into electronics time scale. More...
 
template<typename FromTime >
electronics_tick_d toElectronicsTickD (FromTime time) const
 Converts a time point into electronics tick (real). More...
 
template<typename FromTime >
electronics_tick toElectronicsTick (FromTime time) const
 Converts a time point into electronics tick (truncated). More...
 
template<typename FromTime >
trigger_time toTriggerTime (FromTime time) const
 Converts a time point into trigger time scale. More...
 
template<typename FromTime >
simulation_time toSimulationTime (FromTime time) const
 Converts a time point into simulation time scale. More...
 
Clocks
template<typename TimeScale >
detinfo::ElecClock const & ClockFor () const
 Returns the electronics clock for the specified time scale. More...
 
template<typename TimeScale >
time_interval_for< TimeScale > ClockPeriodFor () const
 Returns the period of the clock for the specified time scale. More...
 
template<typename TimeScale >
frequency_for< TimeScale > ClockFrequencyFor () const
 Returns the frequency of the clock for the specified time scale. More...
 
Reference times
time_interval fromStart (electronics_time time) const
 Converts a electronics time point into a duration from the start of electronics time. More...
 
template<typename TimePoint , typename TimeScale = electronics_time>
constexpr TimeScale startTime () const
 Returns the start time of the specified time scale. More...
 
template<typename TickPoint , typename TimeTickScale = electronics_tick>
constexpr TimeTickScale startTick () const
 Returns the start tick of the specified time tick scale. More...
 

Private Types

template<typename TimeScale >
using traits_of = detinfo::timescales::timescale_traits< typename TimeScale::category_t >
 The traits of a specific TimeScale. More...
 
template<typename TimeScale >
using time_interval_for = typename traits_of< TimeScale >::time_interval_t
 The time interval type of a specific TimeScale. More...
 
template<typename TimeScale >
using frequency_for = typename traits_of< TimeScale >::frequency_t
 The frequency type of a specific TimeScale. More...
 
- Private Types inherited from detinfo::DetectorClocksWithUnits
using nanosecond = util::quantities::nanosecond
 
using microsecond = util::quantities::microsecond
 
using megahertz = util::quantities::megahertz
 
using ticks_d = util::quantities::ticks_d
 

Friends

detinfo::DetectorTimings makeDetectorTimings (detinfo::DetectorClocksWithUnits const &)
 

Imported time scale types

using electronics_time = detinfo::timescales::electronics_time
 
using TPCelectronics_time = detinfo::timescales::TPCelectronics_time
 
using optical_time = detinfo::timescales::optical_time
 
using trigger_time = detinfo::timescales::trigger_time
 
using simulation_time = detinfo::timescales::simulation_time
 
using electronics_tick = detinfo::timescales::electronics_tick
 
using TPCelectronics_tick = detinfo::timescales::TPCelectronics_tick
 
using optical_tick = detinfo::timescales::optical_tick
 
using trigger_tick = detinfo::timescales::trigger_tick
 
using electronics_tick_d = detinfo::timescales::electronics_tick_d
 
using TPCelectronics_tick_d = detinfo::timescales::TPCelectronics_tick_d
 
using optical_tick_d = detinfo::timescales::optical_tick_d
 
using trigger_tick_d = detinfo::timescales::trigger_tick_d
 
using time_interval = detinfo::timescales::time_interval
 
using electronics_time_ticks = detinfo::timescales::electronics_time_ticks
 
using TPCelectronics_time_ticks = detinfo::timescales::TPCelectronics_time_ticks
 
using optical_time_ticks = detinfo::timescales::optical_time_ticks
 
using trigger_time_ticks = detinfo::timescales::trigger_time_ticks
 
 DetectorTimings (detinfo::DetectorClocksData const &clockData)
 Constructor: wraps around a specified detinfo::DetectorClocksData object. More...
 
 DetectorTimings (detinfo::DetectorClocksData const *clockData)
 

Additional Inherited Members

- Private Member Functions inherited from detinfo::DetectorClocksWithUnits
detinfo::DetectorClocksData const & clockData () const
 Returns the detector clocks data object. More...
 
microsecond TriggerTime () const
 Equivalent to detinfo::DetectorClocksData::TriggerTime(). More...
 
microsecond BeamGateTime () const
 Equivalent to detinfo::DetectorClocksData::BeamGateTime(). More...
 
microsecond TPCTime () const
 Equivalent to detinfo::DetectorClocksData::TPCTime(). More...
 
microsecond OpticalClockPeriod () const
 
megahertz OpticalClockFrequency () const
 
 DetectorClocksWithUnits (detinfo::DetectorClocksData const *detClocks)
 Constructor: uses detClocks for internal conversions. More...
 
 DetectorClocksWithUnits (detinfo::DetectorClocksData const &detClocks)
 
microsecond G4ToElecTime (nanosecond simTime) const
 Equivalent to detinfo::DetectorClocksData::G4ToElecTime(). More...
 
microsecond G4ToElecTime (double simTime) const
 
ticks_d TPCTick2TDC (ticks_d tpcticks) const
 Equivalent to detinfo::DetectorClocksData::G4ToElecTime(). More...
 
ticks_d TPCTick2TDC (double tpcticks) const
 

Detailed Description

A class exposing an upgraded interface of detinfo::DetectorClocksData.

This object extends detinfo::DetectorClocksData interface. For example, in art/LArSoft, one can be created as:

(art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob());

in a non-event context or, if a current event is available:

(art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event));

It can also wrap around an existing detinfo::DetectorClocksWithUnits object:

(lar::provider_from<detinfo::DetectorClocksService const>()->DataFor(event));
auto const& timings = detinfo::makeDetectorTimings(detClocksWU);

The timing data is copied locally; see detinfo::DetectorClocksData for considerations on the validity time span of the timing information.

Data types

Several data types are designed to resolve the ambiguity of which time, which time scale and which time unit are used. The class distinguish between time points, which identify events in absolute terms, and time intervals and durations, which identify the time lapsed between two events or time points.

The time duration is generally expressed by a single type, since it is common to all main time scales expressed in real time:

Note that while each data type has a native representation (usually microseconds), these objects can convert into other units to remain consistent. Still, they are not fool-proof...

Different time point types are defined to reflect the different time scales:

For each time scale, a "category" is defined (e.g. electronics_time::category_t), and traits are available for each category as timescale_traits objects (for example detinfo::timescales::timescale_traits<electronics_time::category_t>). From the traits, it is possible to access the type of time point (time_point_t, which is equivalent e.g. to electronics_time, simulation_time etc.) as well as the time interval type (time_interval_t), the tick type in integral units (tick_t) and real units (tick_d_t), the name of the time scale itself (name()) and little more.

Note that not all time scales support all features. For example, simulation time is not actually associated to any clock, so that for example an attempt to convert a time into simulation time ticks will result in a compilation failure.

Definition at line 249 of file DetectorTimings.h.

Member Typedef Documentation

Definition at line 274 of file DetectorTimings.h.

Definition at line 279 of file DetectorTimings.h.

Definition at line 268 of file DetectorTimings.h.

Definition at line 286 of file DetectorTimings.h.

template<typename TimeScale >
using detinfo::DetectorTimings::frequency_for = typename traits_of<TimeScale>::frequency_t
private

The frequency type of a specific TimeScale.

Definition at line 261 of file DetectorTimings.h.

Definition at line 276 of file DetectorTimings.h.

Definition at line 281 of file DetectorTimings.h.

Definition at line 270 of file DetectorTimings.h.

Definition at line 288 of file DetectorTimings.h.

Definition at line 272 of file DetectorTimings.h.

Definition at line 284 of file DetectorTimings.h.

template<typename TimeScale >
using detinfo::DetectorTimings::time_interval_for = typename traits_of<TimeScale>::time_interval_t
private

The time interval type of a specific TimeScale.

Definition at line 257 of file DetectorTimings.h.

Definition at line 275 of file DetectorTimings.h.

Definition at line 280 of file DetectorTimings.h.

Definition at line 269 of file DetectorTimings.h.

Definition at line 287 of file DetectorTimings.h.

template<typename TimeScale >
using detinfo::DetectorTimings::traits_of = detinfo::timescales::timescale_traits<typename TimeScale::category_t>
private

The traits of a specific TimeScale.

Definition at line 253 of file DetectorTimings.h.

Definition at line 277 of file DetectorTimings.h.

Definition at line 282 of file DetectorTimings.h.

Definition at line 271 of file DetectorTimings.h.

Definition at line 289 of file DetectorTimings.h.

Constructor & Destructor Documentation

detinfo::DetectorTimings::DetectorTimings ( detinfo::DetectorClocksData const &  clockData)
inlineexplicit

Constructor: wraps around a specified detinfo::DetectorClocksData object.

Definition at line 297 of file DetectorTimings.h.

299  {}
detinfo::DetectorClocksData const & clockData() const
Returns the detector clocks data.
A partial detinfo::DetectorClocksData supporting units.
detinfo::DetectorTimings::DetectorTimings ( detinfo::DetectorClocksData const *  clockData)
inlineexplicit

Definition at line 300 of file DetectorTimings.h.

302  {}
detinfo::DetectorClocksData const & clockData() const
Returns the detector clocks data.
A partial detinfo::DetectorClocksData supporting units.

Member Function Documentation

electronics_time detinfo::DetectorTimings::BeamGateTime ( ) const
inline

Returns the beam gate time as a point in electronics time.

See Also
detinfo::DetectorClocksData::BeamGateTime()

Definition at line 339 of file DetectorTimings.h.

340  {
342  }
microsecond BeamGateTime() const
Equivalent to detinfo::DetectorClocksData::BeamGateTime().
detinfo::timescales::electronics_time electronics_time
detinfo::DetectorClocksWithUnits const & detClocksUnits() const
Returns a DetectorClocksWithUnits object.
detinfo::DetectorClocksData const& detinfo::DetectorTimings::clockData ( ) const
inline

Returns the detector clocks data.

Definition at line 318 of file DetectorTimings.h.

319  {
320  return detClocksUnits().clockData();
321  }
detinfo::DetectorClocksData const & clockData() const
Returns the detector clocks data object.
detinfo::DetectorClocksWithUnits const & detClocksUnits() const
Returns a DetectorClocksWithUnits object.
template<typename TimeScale >
detinfo::ElecClock const & detinfo::DetectorTimings::ClockFor ( ) const

Returns the electronics clock for the specified time scale.

Definition at line 1077 of file DetectorTimings.h.

1078  {
1080  }
static detinfo::ElecClock const & get(DetectorTimings const *)
template<typename TimeScale >
frequency_for<TimeScale> detinfo::DetectorTimings::ClockFrequencyFor ( ) const
inline

Returns the frequency of the clock for the specified time scale.

Definition at line 522 of file DetectorTimings.h.

523  {
524  return frequency_for<TimeScale>{megahertz{ClockFor<TimeScale>().Frequency()}};
525  }
util::quantities::megahertz megahertz
template<typename TimeScale >
time_interval_for<TimeScale> detinfo::DetectorTimings::ClockPeriodFor ( ) const
inline

Returns the period of the clock for the specified time scale.

Definition at line 514 of file DetectorTimings.h.

515  {
516  return time_interval_for<TimeScale>{microsecond{ClockFor<TimeScale>().TickPeriod()}};
517  }
util::quantities::microsecond microsecond
detinfo::DetectorClocksWithUnits const& detinfo::DetectorTimings::detClocksUnits ( ) const
inline

Returns a DetectorClocksWithUnits object.

Definition at line 311 of file DetectorTimings.h.

312  {
313  return static_cast<detinfo::DetectorClocksWithUnits const&>(*this);
314  }
A partial detinfo::DetectorClocksData supporting units.
auto detinfo::DetectorTimings::fromStart ( electronics_time  time) const
inline

Converts a electronics time point into a duration from the start of electronics time.

Parameters
timeelectronics time point to be converted
Returns
time elapsed from the start of electronics time to time

This is mostly a logic operation, since the value of the returned time duration is the same as the value of the time point (i.e. the start time is 0).

Definition at line 1084 of file DetectorTimings.h.

1085  {
1086  return time - startTime<electronics_time, electronics_time>();
1087  }
megahertz detinfo::DetectorTimings::OpticalClockFrequency ( ) const
inline

Returns the frequency of the optical clock tick.

Definition at line 540 of file DetectorTimings.h.

541  {
542  return ClockFrequencyFor<optical_time>();
543  }
auto detinfo::DetectorTimings::OpticalClockPeriod ( ) const
inline

Returns the duration of the optical clock period and tick.

Definition at line 533 of file DetectorTimings.h.

534  {
535  return ClockPeriodFor<optical_time>();
536  }
template<typename TickPoint , typename TimeTickScale >
constexpr TimeTickScale detinfo::DetectorTimings::startTick ( ) const

Returns the start tick of the specified time tick scale.

Template Parameters
TickPointthe type of tick point on the requested scale
TimeTickScalethe type of scale to get the result in, also a time tick point (default: electronics_tick)

This method returns the start tick of a time tick scale, in another time tick scale (or in the very same, in which case the result is trivially 0). Example:

using namespace detinfo::timescales;
electronics_time_tick const TPCstartTick
= detTimings.startTick<TPCelectronics_time_tick>();

sets TPCstartTime to the instant the TPC electronics time starts, in the electronics time tick scale. This example in particular is yielding the same value as calling detinfo::DetectorClocksData::TPCTick2TDC(0).

Todo:
The example is not even supported yet!

Implemented scales

  • all where TickPoint is the same as TimeScale (trivially, 0)
  • TPCelectronics_time to:
    • electronics_time

Definition at line 1053 of file DetectorTimings.h.

1054  {
1055  return details::StartTickImpl<TickPoint, TimeTickScale>::startTick(this);
1056  }
template<typename TimePoint , typename TimeScale >
constexpr TimeScale detinfo::DetectorTimings::startTime ( ) const

Returns the start time of the specified time scale.

Template Parameters
TimePointthe type of time point on the requested scale
TimeScalethe type of scale to get the result in (default: electronics_time)

This method returns the start time of a time scale, in another time scale (or in the very same, in which case the result is trivially 0). Example:

using namespace detinfo::timescales;
electronics_time const TPCstartTime

sets TPCstartTime to the instant the TPC electronics time starts, in the electronics time scale. This example in particular is yielding the same value as calling detinfo::DetectorClocksData::TPCTime().

Implemented scales

  • all where TimePoint is the same as TimeScale (trivially, 0)
  • TPCelectronics_time to:
    • electronics_time

Definition at line 1045 of file DetectorTimings.h.

1046  {
1048  }
static constexpr TimeScale startTime(DetectorTimings const *)
template<typename FromTime >
electronics_tick detinfo::DetectorTimings::toElectronicsTick ( FromTime  time) const
inline

Converts a time point into electronics tick (truncated).

Template Parameters
FromTimethe time scale the input time is measured in
Parameters
timethe time instant to be converted, in FromTime scale
Returns
the time instant converted into electronics tick number.
See Also
toTick(), toElectronicsTime(), toElectronicsTickD()

Example:

simulation_time nuTime = 47.5_ns;
electronics_tick_d nuElecTick = timings.toElectronicsTime(nuTime);

Definition at line 457 of file DetectorTimings.h.

458  {
459  return toTick<electronics_tick>(time);
460  }
template<typename FromTime >
electronics_tick_d detinfo::DetectorTimings::toElectronicsTickD ( FromTime  time) const
inline

Converts a time point into electronics tick (real).

Template Parameters
FromTimethe time scale the input time is measured in
Parameters
timethe time instant to be converted, in FromTime scale
Returns
the time instant converted into electronics tick number.
See Also
toTick(), toElectronicsTime(), toElectronicsTick()

Example:

simulation_time nuTime = 47.5_ns;
electronics_tick_d nuElecTick = timings.toElectronicsTime(nuTime);

Definition at line 437 of file DetectorTimings.h.

438  {
439  return toTick<electronics_tick_d>(time);
440  }
template<typename FromTime >
electronics_time detinfo::DetectorTimings::toElectronicsTime ( FromTime  time) const
inline

Converts a time point into electronics time scale.

Template Parameters
FromTimethe time scale the input time is measured in
Parameters
timethe time instant to be converted, in FromTime scale
Returns
the time instant converted into electronics time scale.

Example:

simulation_time nuTime = 47.5_ns;
electronics_time nuElecTime = timings.toElectronicsTime(nuTime);

is equivalent to use detinfo::DetectorClocksData::G4ToElecTime(47.5).

Definition at line 417 of file DetectorTimings.h.

418  {
419  return toTimeScale<electronics_time>(time);
420  }
template<typename TimePoint >
optical_tick detinfo::DetectorTimings::toOpticalTick ( TimePoint  time) const
inline

Returns the time point converted in units of optical time ticks.

Template Parameters
TimePointtype of the time to be converted
Parameters
timetime point to be converted into an optical tick
Returns
the time point expressed as integral number of ticks
See Also
toTick(), toOpticalTickD()

The specified time point is converted in ticks from the start of the optical time scale (i.e., from startTime<optical_time>()). The ticks are from the optical detector clock (OpticalClockPeriod()). The number of ticks is truncated.

Definition at line 578 of file DetectorTimings.h.

579  {
580  return toTick<optical_tick>(time);
581  }
template<typename TimePoint >
optical_tick_d detinfo::DetectorTimings::toOpticalTickD ( TimePoint  time) const
inline

Returns the time point converted in units of optical time ticks.

Template Parameters
TimePointtype of the time to be converted
Parameters
timetime point to be converted into an optical tick
Returns
the time point expressed as real number of ticks
See Also
toTick(), toOpticalTickD()

The specified time point is converted in ticks from the start of the optical time scale (i.e., from startTime<optical_time>()). The ticks are from the optical detector clock (OpticalClockPeriod()). The number of ticks may be fractional.

Definition at line 597 of file DetectorTimings.h.

598  {
599  return toTick<optical_tick_d>(time);
600  }
template<typename Ticks = optical_time_ticks>
Ticks detinfo::DetectorTimings::toOpticalTicks ( time_interval  time) const
inline

Returns the optical ticks corresponding to a time interval.

Template Parameters
Tickstype of tick interval returned (default: optical_time_ticks)
Returns
the time interval expressed as number of optical ticks

The time interval is represented by the number of optical detector electronics ticks fitting in it. If Ticks is based on an integral type, the resulting number of ticks is usually truncated.

Definition at line 557 of file DetectorTimings.h.

558  {
559  static_assert(traits_of<Ticks>::template same_category_as<optical_tick>,
560  "Specified ticks are not for optical time scale!");
561  return toTicks<Ticks>(time);
562  }
template<typename FromTime >
simulation_time detinfo::DetectorTimings::toSimulationTime ( FromTime  time) const
inline

Converts a time point into simulation time scale.

Template Parameters
FromTimethe time scale the input time is measured in
Parameters
timethe time instant to be converted, in FromTime scale
Returns
the time instant converted into simulation time scale.

Example:

electronics_time beamTime = 47.5_ns;
simulation_time firstParticleTime = timings.toSimulationTime(beamTime);

Definition at line 495 of file DetectorTimings.h.

496  {
497  return toTimeScale<simulation_time>(time);
498  }
template<typename TargetTick , typename FromTime >
TargetTick detinfo::DetectorTimings::toTick ( FromTime  time) const

Returns a time point as a tick on a different time scale.

Template Parameters
TargetTickthe desired time scale
FromTimethe time scale the input time is measured in
Parameters
timethe time instant to be converted, in FromTime scale
Returns
the time instant converted as tick into TargetTick time scale

Example:

simulation_time nuTime = 47.5_ns;
= timings.toTick<TPCelectronics_tick_d>(nuTime);

Definition at line 1069 of file DetectorTimings.h.

1070  {
1072  } // DetectorTimings::toTick()
static TargetTick convert(FromTime time, DetectorTimings const *timings)
template<typename Ticks >
Ticks detinfo::DetectorTimings::toTicks ( time_interval  time) const
inline

Returns the number of ticks corresponding to a time interval.

Template Parameters
Tickstype of tick interval returned
Returns
the time interval expressed as number of ticks

The time interval is represented by the number of ticks on the time scale of Ticks which fits in that interval. If Ticks is based on an integral type, the resulting number of ticks is usually truncated.

Definition at line 397 of file DetectorTimings.h.

398  {
399  return Ticks::castFrom(time / ClockPeriodFor<Ticks>());
400  }
template<typename TargetTime , typename FromTime >
TargetTime detinfo::DetectorTimings::toTimeScale ( FromTime  time) const

Returns a time point in a different time scale.

Template Parameters
TargetTimethe desired time scale
FromTimethe time scale the input time is measured in
Parameters
timethe time instant to be converted, in FromTime scale
Returns
the time instant converted into TargetTime time scale

Example:

simulation_time nuTime = 47.5_ns;
electronics_time nuElecTime
= timings.toTimeScale<electronics_time>(nuTime);

is equivalent to use detinfo::DetectorClocksData::G4ToElecTime(47.5).

Definition at line 1061 of file DetectorTimings.h.

1062  {
1064  } // DetectorTimings::toTimeScale()
static TargetTime convert(FromTime time, DetectorTimings const *timings)
template<typename FromTime >
trigger_time detinfo::DetectorTimings::toTriggerTime ( FromTime  time) const
inline

Converts a time point into trigger time scale.

Template Parameters
FromTimethe time scale the input time is measured in
Parameters
timethe time instant to be converted, in FromTime scale
Returns
the time instant converted into trigger time scale.

Example:

simulation_time nuTime = 47.5_ns;
trigger_time nuTriggerTime = timings.toTriggerTime(nuTime);

Definition at line 476 of file DetectorTimings.h.

477  {
478  return toTimeScale<trigger_time>(time);
479  }
electronics_time detinfo::DetectorTimings::TriggerTime ( ) const
inline

Returns the trigger time as a point in electronics time.

See Also
detinfo::DetectorClocksData::TriggerTime()

Definition at line 331 of file DetectorTimings.h.

332  {
334  }
detinfo::timescales::electronics_time electronics_time
detinfo::DetectorClocksWithUnits const & detClocksUnits() const
Returns a DetectorClocksWithUnits object.
microsecond TriggerTime() const
Equivalent to detinfo::DetectorClocksData::TriggerTime().

Friends And Related Function Documentation

detinfo::DetectorTimings makeDetectorTimings ( detinfo::DetectorClocksWithUnits const &  detClocksWU)
friend

Returns DetectorTimings object from specified detinfo::DetectorClocksWithUnits.

Definition at line 714 of file DetectorTimings.h.

715  {
716  return static_cast<detinfo::DetectorTimings const&>(detClocksWU);
717  }
A class exposing an upgraded interface of detinfo::DetectorClocksData.

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