gdata
gEventDataCollectionHeader.h
Go to the documentation of this file.
1 #ifndef GEVENTHEADER_H
2 #define GEVENTHEADER_H 1
3 
12 #include "glogger.h"
13 #include <string>
14 
16 public:
26  GEventDataCollectionHeader(int n, int tid, std::shared_ptr<GLogger> logger) : g4localEventNumber(n), threadID(tid),
27  log(std::move(logger)) {
28  timeStamp = assignTimeStamp();
29  log->debug(CONSTRUCTOR, "GEventDataCollectionHeader");
30  log->info(1, TPOINTITEM, " Event Number: ", g4localEventNumber);
31  log->info(1, TPOINTITEM, " Thread ID: ", threadID);
32  log->info(1, TPOINTITEM, " Time Stamp: ", timeStamp);
33  }
34 
38  ~GEventDataCollectionHeader() { log->debug(DESTRUCTOR, "GEventDataCollectionHeader"); }
39 
44  [[nodiscard]] inline std::string getTimeStamp() const { return timeStamp; }
45 
50  [[nodiscard]] inline int getG4LocalEvn() const { return g4localEventNumber; }
51 
56  [[nodiscard]] inline int getThreadID() const { return threadID; }
57 
58 private:
59  int g4localEventNumber;
60  int threadID;
61  std::shared_ptr<GLogger> log;
62 
70  std::string assignTimeStamp() {
71  time_t now = time(nullptr);
72  struct tm* ptm = localtime(&now);
73  char buffer[32];
74  // Format: Mo, 15.06.2009 20:20:00
75  strftime(buffer, 32, "%a, %m.%d.%Y %H:%M:%S", ptm);
76  return {buffer};
77  }
78 
79  std::string timeStamp;
80 };
81 
82 #endif
int getThreadID() const
Gets the thread ID.
int getG4LocalEvn() const
Gets the local event number.
std::string getTimeStamp() const
Gets the timestamp.
GEventDataCollectionHeader(int n, int tid, std::shared_ptr< GLogger > logger)
Constructs a GEventDataCollectionHeader.
~GEventDataCollectionHeader()
Destructor for GEventDataCollectionHeader.