LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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...
 
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 ()
 

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.

References eventTimestamp(), fOffsetFromEpoch, and LOG_TRACE.

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

Member Function Documentation

void art::EmptyEventTimestampPlugin::doBeginJob ( )
inlineinherited

Definition at line 113 of file EmptyEventTimestampPlugin.h.

References breakpoints::beginJob().

114 {
115  beginJob();
116 }
void art::EmptyEventTimestampPlugin::doBeginRun ( Run const &  r)
inlineinherited

Definition at line 125 of file EmptyEventTimestampPlugin.h.

126 {
127  beginRun(r);
128 }
art::Timestamp art::EmptyEventTimestampPlugin::doBeginRunTimestamp ( RunID const &  rid)
inlineinherited

Definition at line 131 of file EmptyEventTimestampPlugin.h.

132 {
133  return beginRunTimestamp(rid);
134 }
virtual Timestamp beginRunTimestamp(RunID const &)
void art::EmptyEventTimestampPlugin::doBeginSubRun ( SubRun const &  sr)
inlineinherited

Definition at line 137 of file EmptyEventTimestampPlugin.h.

138 {
139  beginSubRun(sr);
140 }
virtual void beginSubRun(SubRun const &)
art::Timestamp art::EmptyEventTimestampPlugin::doBeginSubRunTimestamp ( SubRunID const &  srid)
inlineinherited

Definition at line 143 of file EmptyEventTimestampPlugin.h.

144 {
145  return beginSubRunTimestamp(srid);
146 }
virtual Timestamp beginSubRunTimestamp(SubRunID const &)
void art::EmptyEventTimestampPlugin::doEndJob ( )
inlineinherited

Definition at line 119 of file EmptyEventTimestampPlugin.h.

120 {
121  endJob();
122 }
art::Timestamp art::EmptyEventTimestampPlugin::doEventTimestamp ( EventID const &  e)
inlineinherited

Definition at line 149 of file EmptyEventTimestampPlugin.h.

150 {
152  return lastEventTimestamp_;
153 }
virtual Timestamp eventTimestamp(EventID const &)=0
void art::EmptyEventTimestampPlugin::doRewind ( )
inlineinherited

Definition at line 156 of file EmptyEventTimestampPlugin.h.

157 {
158  rewind();
159 }
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.

References DEFINE_ART_EMPTYEVENTTIMESTAMP_PLUGIN, fOffsetFromEpoch, and art::Timestamp::value().

Referenced by GeneratedEventTimestamp().

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.

Referenced by eventTimestamp(), and GeneratedEventTimestamp().


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