CbmRoot
Loading...
Searching...
No Matches
CbmTimeSlice.h
Go to the documentation of this file.
1/* Copyright (C) 2012-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], Florian Uhlig */
4
10#ifndef CBMTIMESLICE_H
11#define CBMTIMESLICE_H 1
12
13#include "CbmDefs.h" // for ECbmModuleId
14#include "CbmMatch.h" // for CbmMatch
15
16#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
17#include <TNamed.h> // for TNamed
18
19#include <cstdint>
20#include <map> // for map
21#include <string> // for string
22
23// boost
24#include <boost/serialization/access.hpp>
25#include <boost/serialization/vector.hpp>
26
27
33class CbmTimeSlice : public TNamed {
34
35public:
37 enum EType
38 {
41 kEvent = 2
42 };
43
44
50
51
56 CbmTimeSlice(double start, double duration);
57
58
61
62
68 void AddData(ECbmModuleId detector)
69 {
70 fNofData[detector]++;
71 fIsEmpty = false;
72 }
73 // TODO: Obsolete, remove
74
84 bool AddData(ECbmModuleId detector, double time);
85 // TODO: Obsolete, remove
86
87
92 int32_t GetNofData(ECbmModuleId detector) const;
93
94
99 double GetLength() const { return fLength; }
100
101
105 const CbmMatch& GetMatch() const { return fMatch; }
106
107
114 double GetStartTime() const { return fStartTime; }
115
116
123 double GetEndTime() const;
124
125
129 double GetTimeDataFirst() const { return fTimeDataFirst; }
130
131
135 double GetTimeDataLast() const { return fTimeDataLast; }
136
137
141 bool IsEmpty() const { return fNofData.empty(); }
142
143
147 bool IsEvent() const { return fType == kEvent; }
148
149
153 bool IsFlexible() const { return fType == kFlexible; }
154
155
159 bool IsRegular() const { return fType == kRegular; }
160
161
171 bool RegisterData(ECbmModuleId system, double time);
172
173
185 bool RegisterData(ECbmModuleId system, double time, const CbmMatch& match);
186
187
192 void Reset();
193
194
202 void Reset(double start, double length);
203
204
208 void SetStartTime(double time) { fStartTime = time; }
209
210
212 std::string ToString() const;
213
214
215 template<class Archive>
216 void serialize(Archive& ar, const unsigned int /*version*/)
217 {
218 ar& fLength;
219 ar& fIsEmpty;
220 }
221
222private:
224 double fStartTime;
225 double fLength;
226 bool fIsEmpty;
227 std::map<ECbmModuleId, int32_t> fNofData;
231
232
234 void ResetCounters();
235
236
238
239 ClassDef(CbmTimeSlice, 7)
240};
241
242#endif /* CBMTIMESLICE_H */
ECbmModuleId
Definition CbmDefs.h:39
Bookkeeping of time-slice content.
bool IsFlexible() const
void SetStartTime(double time)
Set start time.
EType
Time-slice type enumerator.
@ kEvent
Flexible time slice; no fixed time limits.
@ kFlexible
Regular time slice with fixed-size time interval.
void ResetCounters()
Reset the time slice bookkeeping.
std::string ToString() const
const CbmMatch & GetMatch() const
double GetLength() const
bool fIsEmpty
Flag for containing no data.
double GetTimeDataFirst() const
Time stamp of first data.
CbmTimeSlice(EType type=kFlexible)
Constructor without time interval.
double fStartTime
Start time [ns].
double fTimeDataLast
Time of last data object.
bool IsEvent() const
double GetEndTime() const
void Reset()
Reset the time slice.
bool RegisterData(ECbmModuleId system, double time)
Register data to time-slice header.
void AddData(ECbmModuleId detector)
Add data to time-slice.
CbmMatch fMatch
Link time slice to events.
double fTimeDataFirst
Time of first data object.
double fLength
Length of time-slice [ns].
std::map< ECbmModuleId, int32_t > fNofData
SystemId -> Number of digis.
double GetTimeDataLast() const
Time stamp of last data.
bool IsRegular() const
double GetStartTime() const
EType fType
Time-slice type.
friend class boost::serialization::access
void serialize(Archive &ar, const unsigned int)
bool IsEmpty() const
int32_t GetNofData(ECbmModuleId detector) const
Get size of raw data container for given detector.