R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BEventHeader.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2014 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2014-2026 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14#pragma once
15
16#include <FairEventHeader.h>
17#include <Rtypes.h>
18#include <TObject.h>
19#include <cstdint>
20#include <stdexcept>
21
22class R3BEventHeader : public FairEventHeader
23{
24 public:
25 R3BEventHeader() = default;
26
27 ~R3BEventHeader() override = default;
28
29 inline void SetExpId(const int expid) { fExpId = expid; }
30 inline void SetEventno(const uint64_t eventno) { fEventno = eventno; }
31 inline void SetTrigger(const int trigger) { fTrigger = trigger; }
32 inline void SetTimeStamp(const uint64_t timeStamp) { fTimeStamp = timeStamp; }
33 inline void SetTpat(const int tpat) { fTpat = tpat; }
34 inline void SetTStart(const double tStart) { fTStart = tStart; }
35 inline void SetTStartMaster(const double tStart) { fTStartMaster = tStart; }
36 inline void SetTStartSimple(const double tStart) { fTStartSimple = tStart; }
37 inline void SetTprev(const double tPrev) { fTprev = tPrev; }
38 inline void SetTnext(const double tNext) { fTnext = tNext; }
39
40 [[nodiscard]] inline int GetExpId() const { return fExpId; }
41 [[nodiscard]] inline uint64_t GetEventno() const { return fEventno; }
42 [[nodiscard]] inline int GetTrigger() const { return fTrigger; }
43 [[nodiscard]] inline uint64_t GetTimeStamp() const { return fTimeStamp; }
44 [[nodiscard]] inline int GetTpat() const { return fTpat; }
45
46 static constexpr uint32_t MakeTpatBit(uint8_t trigNo)
47 {
48 return (1 <= trigNo && trigNo <= 16) ? (1 << (trigNo - 1)) : throw std::runtime_error("Bad trigNo.");
49 }
50
51 bool HasTpatTrig(int trigNo) const { return fTpat & MakeTpatBit(trigNo); }
52
53 [[nodiscard]] inline double GetTStart() const { return fTStart; }
54
55 [[nodiscard]] inline double GetTStartMaster() const { return fTStartMaster; }
56
57 [[nodiscard]] inline double GetTStartSimple() const { return fTStartSimple; }
58
59 [[nodiscard]] inline double GetTprev() const { return fTprev; }
60
61 [[nodiscard]] inline double GetTnext() const { return fTnext; }
62
63 // void Register(bool Persistance = true) override{};
64
65 auto operator=(const TNamed& obj) -> R3BEventHeader&
66 {
67 obj.Copy(*this);
68 // auto& event_header = dynamic_cast<R3BEventHeader&>(obj);
69 if (const auto* event_header = dynamic_cast<const FairEventHeader*>(&obj); event_header != nullptr)
70 {
71 SetRunId(event_header->GetRunId());
72 SetEventTime(event_header->GetEventTime());
73 SetInputFileId(event_header->GetInputFileId());
74 SetMCEntryNumber(event_header->GetMCEntryNumber());
75 }
76 if (const auto* event_header = dynamic_cast<const R3BEventHeader*>(&obj); event_header != nullptr)
77 {
78 fExpId = event_header->fExpId;
79 fEventno = event_header->fEventno;
80 fTrigger = event_header->fTrigger;
81 fTimeStamp = event_header->fTimeStamp;
82 fTpat = event_header->fTpat;
83 fTStart = event_header->fTStart;
84 fTStartSimple = event_header->fTStartSimple;
85 fTprev = event_header->fTprev;
86 fTnext = event_header->fTnext;
87 }
88 return *this;
89 }
90
91 void Copy(TObject& obj) const override
92 {
93 TNamed::Copy(obj);
94 // auto& event_header = dynamic_cast<R3BEventHeader&>(obj);
95 if (auto* event_header = dynamic_cast<FairEventHeader*>(&obj); event_header != nullptr)
96 {
97 event_header->SetRunId(GetRunId());
98 event_header->SetEventTime(GetEventTime());
99 event_header->SetInputFileId(GetInputFileId());
100 event_header->SetMCEntryNumber(GetMCEntryNumber());
101 }
102 if (auto* event_header = dynamic_cast<R3BEventHeader*>(&obj); event_header != nullptr)
103 {
104 event_header->fExpId = fExpId;
105 event_header->fEventno = fEventno;
106 event_header->fTrigger = fTrigger;
107 event_header->fTimeStamp = fTimeStamp;
108 event_header->fTpat = fTpat;
109 event_header->fTStart = fTStart;
110 event_header->fTStartSimple = fTStartSimple;
111 event_header->fTprev = fTprev;
112 event_header->fTnext = fTnext;
113 }
114 }
115
116 private:
117 int fExpId{};
118 uint64_t fEventno{};
119 int fTrigger{};
120 uint64_t fTimeStamp{};
121 int fTpat{};
122 double fTStart{};
125 double fTprev{};
126 double fTnext{};
127
128 public:
130};
void SetTrigger(const int trigger)
auto operator=(const TNamed &obj) -> R3BEventHeader &
double GetTnext() const
uint64_t GetEventno() const
bool HasTpatTrig(int trigNo) const
void SetEventno(const uint64_t eventno)
void SetTpat(const int tpat)
void SetTStartMaster(const double tStart)
void SetTStartSimple(const double tStart)
static constexpr uint32_t MakeTpatBit(uint8_t trigNo)
uint64_t GetTimeStamp() const
void SetTimeStamp(const uint64_t timeStamp)
~R3BEventHeader() override=default
double GetTprev() const
double GetTStartSimple() const
R3BEventHeader()=default
void SetExpId(const int expid)
int GetTrigger() const
double GetTStartMaster() const
void SetTStart(const double tStart)
int GetTpat() const
ClassDefOverride(R3BEventHeader, 11)
double GetTStart() const
void Copy(TObject &obj) const override
void SetTprev(const double tPrev)
void SetTnext(const double tNext)
int GetExpId() const