CbmRoot
CbmTimeSlice.h
Go to the documentation of this file.
1 
6 #ifndef CBMTIMESLICE_H
7 #define CBMTIMESLICE_H 1
8 
9 #include <Rtypes.h> // for THashConsistencyHolder, ClassDef
10 #include <RtypesCore.h> // for Double_t, Int_t, Bool_t, kFALSE
11 #include <TNamed.h> // for TNamed
12 
13 #include <map> // for map
14 #include <string> // for string
15 
16 #include "CbmDefs.h" // for ECbmModuleId
17 #include "CbmMatch.h" // for CbmMatch
18 
19 // boost
20 #include <boost/serialization/access.hpp>
21 #include <boost/serialization/vector.hpp>
22 
23 
29 class CbmTimeSlice : public TNamed {
30 
31 public:
33  enum EType {
34  kRegular = 0,
35  kFlexible = 1,
36  kEvent = 2
37  };
38 
39 
45 
46 
51  CbmTimeSlice(Double_t start, Double_t duration);
52 
53 
55  ~CbmTimeSlice();
56 
57 
63  void AddData(ECbmModuleId detector) {
64  fNofData[detector]++;
65  fIsEmpty = kFALSE;
66  }
67  // TODO: Obsolete, remove
68 
78  Bool_t AddData(ECbmModuleId detector, Double_t time);
79  // TODO: Obsolete, remove
80 
81 
86  Int_t GetNofData(ECbmModuleId detector) const;
87 
88 
93  Double_t GetLength() const { return fLength; }
94 
95 
99  const CbmMatch& GetMatch() const { return fMatch; }
100 
101 
108  Double_t GetStartTime() const { return fStartTime; }
109 
110 
117  Double_t GetEndTime() const;
118 
119 
123  Double_t GetTimeDataFirst() const { return fTimeDataFirst; }
124 
125 
129  Double_t GetTimeDataLast() const { return fTimeDataLast; }
130 
131 
135  Bool_t IsEmpty() const { return fNofData.empty(); }
136 
137 
141  Bool_t IsEvent() const { return fType == kEvent; }
142 
143 
147  Bool_t IsFlexible() const { return fType == kFlexible; }
148 
149 
153  Bool_t IsRegular() const { return fType == kRegular; }
154 
155 
165  Bool_t RegisterData(ECbmModuleId system, Double_t time);
166 
167 
179  Bool_t
180  RegisterData(ECbmModuleId system, Double_t time, const CbmMatch& match);
181 
182 
187  void Reset();
188 
189 
197  void Reset(Double_t start, Double_t length);
198 
199 
203  void SetStartTime(Double_t time) { fStartTime = time; }
204 
205 
207  std::string ToString() const;
208 
209 
210  template<class Archive>
211  void serialize(Archive& ar, const unsigned int /*version*/) {
212  ar& fLength;
213  ar& fIsEmpty;
214  }
215 
216 private:
218  Double_t fStartTime;
219  Double_t fLength;
220  Bool_t fIsEmpty;
221  std::map<ECbmModuleId, Int_t> fNofData;
222  Double_t fTimeDataFirst;
223  Double_t fTimeDataLast;
225 
226 
228  void ResetCounters();
229 
230 
232 
233  ClassDef(CbmTimeSlice, 7)
234 };
235 
236 #endif /* CBMTIMESLICE_H */
CbmTimeSlice::ResetCounters
void ResetCounters()
Reset the time slice bookkeeping.
Definition: CbmTimeSlice.cxx:185
CbmMatch
Definition: CbmMatch.h:22
CbmTimeSlice::IsEvent
Bool_t IsEvent() const
Definition: CbmTimeSlice.h:141
CbmTimeSlice::GetNofData
Int_t GetNofData(ECbmModuleId detector) const
Get size of raw data container for given detector.
Definition: CbmTimeSlice.cxx:108
CbmTimeSlice::~CbmTimeSlice
~CbmTimeSlice()
Definition: CbmTimeSlice.cxx:58
CbmTimeSlice::Reset
void Reset()
Reset the time slice.
Definition: CbmTimeSlice.cxx:166
CbmTimeSlice::IsRegular
Bool_t IsRegular() const
Definition: CbmTimeSlice.h:153
CbmTimeSlice::fTimeDataFirst
Double_t fTimeDataFirst
Time of first data object.
Definition: CbmTimeSlice.h:222
CbmTimeSlice::CbmTimeSlice
CbmTimeSlice(EType type=kFlexible)
Constructor without time interval.
Definition: CbmTimeSlice.cxx:30
CbmTimeSlice::access
friend class boost::serialization::access
Definition: CbmTimeSlice.h:231
CbmTimeSlice::IsFlexible
Bool_t IsFlexible() const
Definition: CbmTimeSlice.h:147
CbmTimeSlice::RegisterData
Bool_t RegisterData(ECbmModuleId system, Double_t time)
Register data to time-slice header.
Definition: CbmTimeSlice.cxx:117
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmTimeSlice::GetStartTime
Double_t GetStartTime() const
Definition: CbmTimeSlice.h:108
CbmTimeSlice::GetMatch
const CbmMatch & GetMatch() const
Definition: CbmTimeSlice.h:99
CbmTimeSlice::serialize
void serialize(Archive &ar, const unsigned int)
Definition: CbmTimeSlice.h:211
CbmMatch.h
CbmTimeSlice::GetEndTime
Double_t GetEndTime() const
Definition: CbmTimeSlice.cxx:94
CbmTimeSlice::SetStartTime
void SetStartTime(Double_t time)
Set start time.
Definition: CbmTimeSlice.h:203
CbmTimeSlice::fMatch
CbmMatch fMatch
Link time slice to events.
Definition: CbmTimeSlice.h:224
CbmTimeSlice::kRegular
@ kRegular
Definition: CbmTimeSlice.h:34
CbmTimeSlice::fNofData
std::map< ECbmModuleId, Int_t > fNofData
SystemId -> Number of digis.
Definition: CbmTimeSlice.h:221
CbmTimeSlice::GetLength
Double_t GetLength() const
Definition: CbmTimeSlice.h:93
CbmTimeSlice::EType
EType
Time-slice type enumerator.
Definition: CbmTimeSlice.h:33
CbmTimeSlice::AddData
void AddData(ECbmModuleId detector)
Add data to time-slice.
Definition: CbmTimeSlice.h:63
CbmTimeSlice::ToString
std::string ToString() const
Definition: CbmTimeSlice.cxx:196
CbmTimeSlice
Bookkeeping of time-slice content.
Definition: CbmTimeSlice.h:29
CbmTimeSlice::fType
EType fType
Time-slice type.
Definition: CbmTimeSlice.h:217
CbmTimeSlice::fTimeDataLast
Double_t fTimeDataLast
Time of last data object.
Definition: CbmTimeSlice.h:223
CbmTimeSlice::GetTimeDataLast
Double_t GetTimeDataLast() const
Time stamp of last data.
Definition: CbmTimeSlice.h:129
CbmTimeSlice::fIsEmpty
Bool_t fIsEmpty
Flag for containing no data.
Definition: CbmTimeSlice.h:220
CbmTimeSlice::fLength
Double_t fLength
Length of time-slice [ns].
Definition: CbmTimeSlice.h:219
CbmTimeSlice::kEvent
@ kEvent
Flexible time slice; no fixed time limits.
Definition: CbmTimeSlice.h:36
CbmTimeSlice::IsEmpty
Bool_t IsEmpty() const
Definition: CbmTimeSlice.h:135
CbmTimeSlice::GetTimeDataFirst
Double_t GetTimeDataFirst() const
Time stamp of first data.
Definition: CbmTimeSlice.h:123
CbmTimeSlice::fStartTime
Double_t fStartTime
Start time [ns].
Definition: CbmTimeSlice.h:218
CbmTimeSlice::kFlexible
@ kFlexible
Regular time slice with fixed-size time interval.
Definition: CbmTimeSlice.h:35
CbmDefs.h