Public Member Functions | Private Attributes | List of all members
evgen::GeneratedEventTimestamp Class Reference

Plugin to assign an empty event a time stamp from the clock. More...

Inheritance diagram for evgen::GeneratedEventTimestamp:
art::EmptyEventTimestampPlugin

Public Member Functions

 GeneratedEventTimestamp (fhicl::ParameterSet const &pset)
 Constructor: nothing specific. More...
 
virtual art::Timestamp eventTimestamp (art::EventID const &id) override
 Returns the time stamp for the specified event. More...
 
virtual void rewind () override
 Resets the status; since this plug in is stateless, this is a no-op. More...
 
- Public Member Functions inherited from art::EmptyEventTimestampPlugin
 EmptyEventTimestampPlugin (fhicl::ParameterSet const &pset)
 
void doBeginJob ()
 
void doEndJob ()
 
void doBeginRun (Run const &r)
 
Timestamp doBeginRunTimestamp (RunID const &rid)
 
void doBeginSubRun (SubRun const &sr)
 
Timestamp doBeginSubRunTimestamp (SubRunID const &srid)
 
Timestamp doEventTimestamp (EventID const &e)
 
void doRewind ()
 
virtual ~EmptyEventTimestampPlugin ()=default
 

Private Attributes

art::TimeValue_t const fOffsetFromEpoch = 0
 Offset to be added to the chosen clock to get an absolute time. More...
 

Detailed Description

Plugin to assign an empty event a time stamp from the clock.

See also
art::EmptyEventTimestampPlugin

The plug in returns a time stamp that is taken from the current time on the execution node, in nanoseconds.

The time is currently defined as absolute from the UNIX "epoch" (first day of year 1970), but its absolute precision should not be relied upon.

Also note that the time is not guaranteed to be monotonic, that is, generating two events in sequence, it is not guaranteed that the second one has a time stamp larger than the previous. This may for example happen if the clock relies on a CPU internal counter, on a machine with multiple CPUs (that is probably all of them).

Configuration

None so far.

Definition at line 46 of file GeneratedEventTimestamp_plugin.cc.

Constructor & Destructor Documentation

evgen::GeneratedEventTimestamp::GeneratedEventTimestamp ( fhicl::ParameterSet const &  pset)

Constructor: nothing specific.

Definition at line 297 of file GeneratedEventTimestamp_plugin.cc.

300 {
301 
302  mf::LogInfo("GeneratedEventTimestamp")
303  << "Timestamp plugin: timestamp from local clock time in nanoseconds";
304  if (fOffsetFromEpoch != 0) {
305  MF_LOG_TRACE("GeneratedEventTimestamp")
306  << " Time offset from epoch: " << fOffsetFromEpoch << " ns";
307  }
308 
309 } // evgen::GeneratedEventTimestamp::GeneratedEventTimestamp()
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
#define MF_LOG_TRACE(id)
art::TimeValue_t const fOffsetFromEpoch
Offset to be added to the chosen clock to get an absolute time.

Member Function Documentation

art::Timestamp evgen::GeneratedEventTimestamp::eventTimestamp ( art::EventID const &  id)
overridevirtual

Returns the time stamp for the specified event.

Implements art::EmptyEventTimestampPlugin.

Definition at line 314 of file GeneratedEventTimestamp_plugin.cc.

315 {
316  // obtain from the high resolution clock the current time, from the "epoch",
317  // in nanoseconds; if the clock is less precise than the nanosecond,
318  // the precision gap is filled with randomness
319  details::ns_clock_t get_time;
320 
321  const long long int now_ns = fOffsetFromEpoch + get_time();
322 
323  // convert into a timestamp
324  art::Timestamp ts(now_ns);
325 
326  mf::LogTrace("GeneratedEventTimestamp")
327  << "Generated time stamp: " << ts.value() << " for event " << id;
328 
329  return ts;
330 } // evgen::GeneratedEventTimestamp::eventTimestamp()
details::TimeInUnits< std::chrono::high_resolution_clock, std::chrono::nanoseconds > ns_clock_t
art::TimeValue_t const fOffsetFromEpoch
Offset to be added to the chosen clock to get an absolute time.
MaybeLogger_< ELseverityLevel::ELsev_success, true > LogTrace
virtual void evgen::GeneratedEventTimestamp::rewind ( )
inlineoverridevirtual

Resets the status; since this plug in is stateless, this is a no-op.

Implements art::EmptyEventTimestampPlugin.

Definition at line 57 of file GeneratedEventTimestamp_plugin.cc.

57 {}

Member Data Documentation

art::TimeValue_t const evgen::GeneratedEventTimestamp::fOffsetFromEpoch = 0
private

Offset to be added to the chosen clock to get an absolute time.

Definition at line 62 of file GeneratedEventTimestamp_plugin.cc.


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