CbmRoot
Loading...
Searching...
No Matches
CbmMCEventList.h
Go to the documentation of this file.
1/* Copyright (C) 2015-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
10#ifndef CBMMCEVENTLIST_H
11#define CBMMCEVENTLIST_H 1
12
13#include "CbmLink.h"
14#include "CbmMCEventInfo.h" // for CbmMCEventInfo
15
16#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
17#include <TNamed.h> // for TNamed
18
19#include <cstddef> // for size_t
20#include <cstdint>
21#include <string> // for string
22#include <vector> // for vector, vector<>::iterator
23
24/* Implementation note (VF/180618):
25 * Both indexed access (for loops over all MC events in a time slice)
26 * and random access (to get the event time for a given fileId and EventId)
27 * are required. It was thus chosen to internally represent the event list
28 * as a sortable vector of CbmMCEventInfo. I tried to use std::tuple instead
29 * of CbmMCEventInfo, but ROOT seems not to be able to stream that.
30 * Since it is assumed that the creation of the list is separate from the
31 * access to the list, no sorting or checking for double occurrences of events
32 * is done on insertion for performance reasons.
33 * Sorting will be done on first access to the list. It includes checking of
34 * double occurrences of (fileId, eventId).
35 */
36
43class CbmMCEventList : public TNamed {
44
45public:
48
49
51 virtual ~CbmMCEventList();
52
53
55 virtual void Clear(Option_t*) { fEvents.clear(); }
56
57
63 int32_t GetEventIdByIndex(uint32_t index);
64
65
73 double GetEventTime(uint32_t event, uint32_t file);
74
78 Double_t GetEventTime(const CbmLink& link) { return GetEventTime(link.GetEntry(), link.GetFile()); }
79
85 double GetEventTimeByIndex(uint32_t index);
86
87
93 int32_t GetFileIdByIndex(uint32_t index);
94
102 Int_t GetEventIndex(UInt_t event, UInt_t file);
103
106 Int_t GetEventIndex(const CbmLink& link) { return GetEventIndex(link.GetEntry(), link.GetFile()); }
107
108
111 CbmLink GetEventLinkByIndex(uint32_t index);
112
116 std::size_t GetNofEvents() const { return fEvents.size(); }
117
118
131 bool Insert(uint32_t event, uint32_t file, double time);
132
133
135 virtual void Print(Option_t* opt = "") const;
136
137
145 void Sort();
146
147
149 std::string ToString(const char* option = "") const;
150
151
152private:
154 std::vector<CbmMCEventInfo> fEvents;
155
158
159
163 bool Check();
164
165
170 std::vector<CbmMCEventInfo>::iterator Find(uint32_t file, uint32_t event);
171
172
174};
175
176
177#endif /* CBMMCEVENTLIST_H */
Container class for MC events with number, file and start time.
std::vector< CbmMCEventInfo > fEvents
CbmLink GetEventLinkByIndex(uint32_t index)
Event file and event indices as CbmLink.
Int_t GetEventIndex(const CbmLink &link)
Event index.
int32_t GetFileIdByIndex(uint32_t index)
File number by index @value File number for event at given index in list.
std::string ToString(const char *option="") const
bool Check()
Check for double occurrences of events in list @value true is no double occurrences,...
virtual ~CbmMCEventList()
Destructor.
virtual void Print(Option_t *opt="") const
double GetEventTimeByIndex(uint32_t index)
Event time by index @value Event time for event at given index in list.
void Sort()
Sort the list.
int32_t GetEventIdByIndex(uint32_t index)
Event number by index @value Event number for event at given index in list.
Int_t GetEventIndex(UInt_t event, UInt_t file)
Event index.
ClassDef(CbmMCEventList, 3)
virtual void Clear(Option_t *)
Delete all event entries.
std::size_t GetNofEvents() const
Number of events in the list @value Number of events.
double GetEventTime(uint32_t event, uint32_t file)
Event start time.
CbmMCEventList()
Standard constructor.
Double_t GetEventTime(const CbmLink &link)
Event start time.
std::vector< CbmMCEventInfo >::iterator Find(uint32_t file, uint32_t event)
Find an element in the list.
bool Insert(uint32_t event, uint32_t file, double time)