gdata
gEventDataCollectionHeader.h
Go to the documentation of this file.
1 #pragma once
2 
11 #include "glogger.h"
12 #include <string>
13 
15 public:
25  GEventDataCollectionHeader(int n, int tid, std::shared_ptr<GLogger> logger) : g4localEventNumber(n), threadID(tid),
26  log(logger) {
27  timeStamp = assignTimeStamp();
28  log->debug(CONSTRUCTOR, "GEventDataCollectionHeader");
29  log->info(1, TPOINTITEM, " Event Number: ", g4localEventNumber);
30  log->info(1, TPOINTITEM, " Thread ID: ", threadID);
31  log->info(1, TPOINTITEM, " Time Stamp: ", timeStamp);
32  }
33 
37  ~GEventDataCollectionHeader() { log->debug(DESTRUCTOR, "GEventDataCollectionHeader"); }
38 
43  [[nodiscard]] inline std::string getTimeStamp() const { return timeStamp; }
44 
49  [[nodiscard]] inline int getG4LocalEvn() const { return g4localEventNumber; }
50 
55  [[nodiscard]] inline int getThreadID() const { return threadID; }
56 
57 private:
58  int g4localEventNumber;
59  int threadID;
60  std::shared_ptr<GLogger> log;
61 
69  std::string assignTimeStamp() {
70  time_t now = time(nullptr);
71  struct tm* ptm = localtime(&now);
72  char buffer[32];
73  // Format: Mo, 15.06.2009 20:20:00
74  strftime(buffer, 32, "%a, %m.%d.%Y %H:%M:%S", ptm);
75  return {buffer};
76  }
77 
78  std::string timeStamp;
79 };
80 
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.