gdata
Loading...
Searching...
No Matches
GEventHeader Class Reference

Minimal event metadata header: event number, thread id, and timestamp. More...

#include <gEventHeader.h>

Public Member Functions

 GEventHeader (const std::shared_ptr< GOptions > &gopts, int n, int tid)
 Construct an event header with explicit values.
 
std::string getTimeStamp () const
 Get the formatted timestamp string.
 
int getG4LocalEvn () const
 Get the local event number.
 
int getThreadID () const
 Get the thread ID associated with this event.
 
- Public Member Functions inherited from GBase< GEventHeader >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Static Public Member Functions

static std::unique_ptr< GEventHeadercreate (const std::shared_ptr< GOptions > &gopts, int tid=-1)
 Factory method used by examples/tests to create a header with a unique event number.
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GEventHeader >
std::shared_ptr< GLoggerlog
 

Detailed Description

This object is typically owned by GEventDataCollection as a std::unique_ptr.

It is primarily used for:

  • labeling events in logs/output
  • reproducing the event/thread provenance for debugging

Definition at line 59 of file gEventHeader.h.

Constructor & Destructor Documentation

◆ GEventHeader()

GEventHeader::GEventHeader ( const std::shared_ptr< GOptions > & gopts,
int n,
int tid )
inline

The constructor:

  • assigns timeStamp based on local time
  • emits an informational log summarizing the header values
Parameters
goptsShared options object used to configure logging and behavior.
nLocal event number.
tidThread ID associated with this event.

Definition at line 74 of file gEventHeader.h.

Member Function Documentation

◆ create()

static std::unique_ptr< GEventHeader > GEventHeader::create ( const std::shared_ptr< GOptions > & gopts,
int tid = -1 )
inlinestatic

If tid is negative, a default thread ID is derived from the event number (currently mod 8) to mimic multi-threaded execution.

Threading notes:

  • Uses an atomic counter so that concurrent calls from multiple threads produce unique event numbers.
Parameters
goptsShared options.
tidOptional thread ID override.
Returns
Newly created event header.

Definition at line 98 of file gEventHeader.h.

◆ getG4LocalEvn()

int GEventHeader::getG4LocalEvn ( ) const
inline

This is "run-local" in typical Geant4 usage (i.e. it resets each run).

Returns
Event number.

Definition at line 121 of file gEventHeader.h.

◆ getThreadID()

int GEventHeader::getThreadID ( ) const
inline
Returns
Thread ID.

Definition at line 127 of file gEventHeader.h.

◆ getTimeStamp()

std::string GEventHeader::getTimeStamp ( ) const
inline
Returns
Timestamp string.

Definition at line 111 of file gEventHeader.h.


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