LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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...
 
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)
 

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 293 of file GeneratedEventTimestamp_plugin.cc.

References eventTimestamp(), fOffsetFromEpoch, and MF_LOG_TRACE.

296 {
297 
298  mf::LogInfo("GeneratedEventTimestamp")
299  << "Timestamp plugin: timestamp from local clock time in nanoseconds";
300  if (fOffsetFromEpoch != 0) {
301  MF_LOG_TRACE("GeneratedEventTimestamp")
302  << " Time offset from epoch: " << fOffsetFromEpoch << " ns";
303  }
304 
305 } // 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

void art::EmptyEventTimestampPlugin::doBeginJob ( )
inlineinherited

Definition at line 107 of file EmptyEventTimestampPlugin.h.

References breakpoints::beginJob().

108 {
109  beginJob();
110 }
void art::EmptyEventTimestampPlugin::doBeginRun ( Run const &  r)
inlineinherited

Definition at line 119 of file EmptyEventTimestampPlugin.h.

120 {
121  beginRun(r);
122 }
TRandom r
Definition: spectrum.C:23
art::Timestamp art::EmptyEventTimestampPlugin::doBeginRunTimestamp ( RunID const &  rid)
inlineinherited

Definition at line 125 of file EmptyEventTimestampPlugin.h.

126 {
127  return beginRunTimestamp(rid);
128 }
virtual Timestamp beginRunTimestamp(RunID const &)
void art::EmptyEventTimestampPlugin::doBeginSubRun ( SubRun const &  sr)
inlineinherited

Definition at line 131 of file EmptyEventTimestampPlugin.h.

132 {
133  beginSubRun(sr);
134 }
virtual void beginSubRun(SubRun const &)
art::Timestamp art::EmptyEventTimestampPlugin::doBeginSubRunTimestamp ( SubRunID const &  srid)
inlineinherited

Definition at line 137 of file EmptyEventTimestampPlugin.h.

138 {
139  return beginSubRunTimestamp(srid);
140 }
virtual Timestamp beginSubRunTimestamp(SubRunID const &)
void art::EmptyEventTimestampPlugin::doEndJob ( )
inlineinherited

Definition at line 113 of file EmptyEventTimestampPlugin.h.

114 {
115  endJob();
116 }
art::Timestamp art::EmptyEventTimestampPlugin::doEventTimestamp ( EventID const &  e)
inlineinherited

Definition at line 143 of file EmptyEventTimestampPlugin.h.

144 {
146  return lastEventTimestamp_;
147 }
virtual Timestamp eventTimestamp(EventID const &)=0
art::Timestamp evgen::GeneratedEventTimestamp::eventTimestamp ( art::EventID const &  id)
overridevirtual

Returns the time stamp for the specified event.

Implements art::EmptyEventTimestampPlugin.

Definition at line 310 of file GeneratedEventTimestamp_plugin.cc.

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

Referenced by GeneratedEventTimestamp().

311 {
312  // obtain from the high resolution clock the current time, from the "epoch",
313  // in nanoseconds; if the clock is less precise than the nanosecond,
314  // the precision gap is filled with randomness
315  details::ns_clock_t get_time;
316 
317  const long long int now_ns = fOffsetFromEpoch + get_time();
318 
319  // convert into a timestamp
320  art::Timestamp ts(now_ns);
321 
322  mf::LogTrace("GeneratedEventTimestamp")
323  << "Generated time stamp: " << ts.value() << " for event " << id;
324 
325  return ts;
326 } // 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

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 58 of file GeneratedEventTimestamp_plugin.cc.

Referenced by eventTimestamp(), and GeneratedEventTimestamp().


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