R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BEventHeader.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 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 SetTStartSimple(const double tStart) { fTStartSimple = tStart; }
36 inline void SetTprev(const double tPrev) { fTprev = tPrev; }
37 inline void SetTnext(const double tNext) { fTnext = tNext; }
38
39 [[nodiscard]] inline int GetExpId() const { return fExpId; }
40 [[nodiscard]] inline uint64_t GetEventno() const { return fEventno; }
41 [[nodiscard]] inline int GetTrigger() const { return fTrigger; }
42 [[nodiscard]] inline uint64_t GetTimeStamp() const { return fTimeStamp; }
43 [[nodiscard]] inline int GetTpat() const { return fTpat; }
44
45 static constexpr uint32_t MakeTpatBit(uint8_t trigNo)
46 {
47 return (1 <= trigNo && trigNo <= 16) ? (1 << (trigNo - 1)) : throw std::runtime_error("Bad trigNo.");
48 }
49
50 bool HasTpatTrig(int trigNo) const { return fTpat & MakeTpatBit(trigNo); }
51
52 [[nodiscard]] inline double GetTStart() const { return fTStart; }
53
54 [[nodiscard]] inline double GetTStartSimple() const { return fTStartSimple; }
55
56 [[nodiscard]] inline double GetTprev() const { return fTprev; }
57
58 [[nodiscard]] inline double GetTnext() const { return fTnext; }
59
60 // void Register(bool Persistance = true) override{};
61
62 auto operator=(const TNamed& obj) -> R3BEventHeader&
63 {
64 obj.Copy(*this);
65 // auto& event_header = dynamic_cast<R3BEventHeader&>(obj);
66 if (const auto* event_header = dynamic_cast<const FairEventHeader*>(&obj); event_header != nullptr)
67 {
68 SetRunId(event_header->GetRunId());
69 SetEventTime(event_header->GetEventTime());
70 SetInputFileId(event_header->GetInputFileId());
71 SetMCEntryNumber(event_header->GetMCEntryNumber());
72 }
73 if (const auto* event_header = dynamic_cast<const R3BEventHeader*>(&obj); event_header != nullptr)
74 {
75 fExpId = event_header->fExpId;
76 fEventno = event_header->fEventno;
77 fTrigger = event_header->fTrigger;
78 fTimeStamp = event_header->fTimeStamp;
79 fTpat = event_header->fTpat;
80 fTStart = event_header->fTStart;
81 fTStartSimple = event_header->fTStartSimple;
82 fTprev = event_header->fTprev;
83 fTnext = event_header->fTnext;
84 }
85 return *this;
86 }
87
88 void Copy(TObject& obj) const override
89 {
90 TNamed::Copy(obj);
91 // auto& event_header = dynamic_cast<R3BEventHeader&>(obj);
92 if (auto* event_header = dynamic_cast<FairEventHeader*>(&obj); event_header != nullptr)
93 {
94 event_header->SetRunId(GetRunId());
95 event_header->SetEventTime(GetEventTime());
96 event_header->SetInputFileId(GetInputFileId());
97 event_header->SetMCEntryNumber(GetMCEntryNumber());
98 }
99 if (auto* event_header = dynamic_cast<R3BEventHeader*>(&obj); event_header != nullptr)
100 {
101 event_header->fExpId = fExpId;
102 event_header->fEventno = fEventno;
103 event_header->fTrigger = fTrigger;
104 event_header->fTimeStamp = fTimeStamp;
105 event_header->fTpat = fTpat;
106 event_header->fTStart = fTStart;
107 event_header->fTStartSimple = fTStartSimple;
108 event_header->fTprev = fTprev;
109 event_header->fTnext = fTnext;
110 }
111 }
112
113 private:
114 int fExpId{};
115 uint64_t fEventno{};
116 int fTrigger{};
117 uint64_t fTimeStamp{};
118 int fTpat{};
119 double fTStart{};
121 double fTprev{};
122 double fTnext{};
123
124 public:
125 ClassDefOverride(R3BEventHeader, 10)
126};
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 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
void SetTStart(const double tStart)
int GetTpat() const
double GetTStart() const
void Copy(TObject &obj) const override
void SetTprev(const double tPrev)
void SetTnext(const double tNext)
int GetExpId() const