CbmRoot
CbmMCEventList.h
Go to the documentation of this file.
1 
6 #ifndef CBMMCEVENTLIST_H
7 #define CBMMCEVENTLIST_H 1
8 
9 #include <Rtypes.h> // for THashConsistencyHolder, ClassDef
10 #include <RtypesCore.h> // for UInt_t, Bool_t, Double_t, Int_t, Option_t
11 #include <TNamed.h> // for TNamed
12 
13 #include <stddef.h> // for size_t
14 #include <string> // for string
15 #include <vector> // for vector, vector<>::iterator
16 
17 #include "CbmMCEventInfo.h" // for CbmMCEventInfo
18 
19 /* Implementation note (VF/180618):
20  * Both indexed access (for loops over all MC events in a time slice)
21  * and random access (to get the event time for a given fileId and EventId)
22  * are required. It was thus chosen to internally represent the event list
23  * as a sortable vector of CbmMCEventInfo. I tried to use std::tuple instead
24  * of CbmMCEventInfo, but ROOT seems not to be able to stream that.
25  * Since it is assumed that the creation of the list is separate from the
26  * access to the list, no sorting or checking for double occurrences of events
27  * is done on insertion for performance reasons.
28  * Sorting will be done on first access to the list. It includes checking of
29  * double occurrences of (fileId, eventId).
30  */
31 
38 class CbmMCEventList : public TNamed {
39 
40 public:
43 
44 
46  virtual ~CbmMCEventList();
47 
48 
50  virtual void Clear(Option_t*) { fEvents.clear(); }
51 
52 
58  Int_t GetEventIdByIndex(UInt_t index);
59 
60 
68  Double_t GetEventTime(UInt_t event, UInt_t file);
69 
70 
76  Double_t GetEventTimeByIndex(UInt_t index);
77 
78 
84  Int_t GetFileIdByIndex(UInt_t index);
85 
86 
90  std::size_t GetNofEvents() const { return fEvents.size(); }
91 
92 
105  Bool_t Insert(UInt_t event, UInt_t file, Double_t time);
106 
107 
109  virtual void Print(Option_t* opt = "") const;
110 
111 
119  void Sort();
120 
121 
123  std::string ToString(const char* option = "") const;
124 
125 
126 private:
128  std::vector<CbmMCEventInfo> fEvents;
129 
131  Bool_t fIsSorted;
132 
133 
137  Bool_t Check();
138 
139 
144  std::vector<CbmMCEventInfo>::iterator Find(UInt_t file, UInt_t event);
145 
146 
148 };
149 
150 
151 #endif /* CBMMCEVENTLIST_H */
CbmMCEventList::GetFileIdByIndex
Int_t GetFileIdByIndex(UInt_t index)
File number by index @value File number for event at given index in list.
Definition: CbmMCEventList.cxx:106
CbmMCEventList::Sort
void Sort()
Sort the list.
Definition: CbmMCEventList.cxx:133
CbmMCEventList::Insert
Bool_t Insert(UInt_t event, UInt_t file, Double_t time)
Definition: CbmMCEventList.cxx:116
CbmMCEventList::fIsSorted
Bool_t fIsSorted
Definition: CbmMCEventList.h:131
CbmMCEventList::GetEventTimeByIndex
Double_t GetEventTimeByIndex(UInt_t index)
Event time by index @value Event time for event at given index in list.
Definition: CbmMCEventList.cxx:96
CbmMCEventList::fEvents
std::vector< CbmMCEventInfo > fEvents
Definition: CbmMCEventList.h:128
CbmMCEventList::GetNofEvents
std::size_t GetNofEvents() const
Number of events in the list @value Number of events.
Definition: CbmMCEventList.h:90
CbmMCEventList::GetEventTime
Double_t GetEventTime(UInt_t event, UInt_t file)
Event start time.
Definition: CbmMCEventList.cxx:86
CbmMCEventList::ToString
std::string ToString(const char *option="") const
Definition: CbmMCEventList.cxx:143
CbmMCEventList
Container class for MC events with number, file and start time.
Definition: CbmMCEventList.h:38
CbmMCEventList::CbmMCEventList
CbmMCEventList()
Standard constructor.
Definition: CbmMCEventList.cxx:24
CbmMCEventList::ClassDef
ClassDef(CbmMCEventList, 3)
CbmMCEventList::Find
std::vector< CbmMCEventInfo >::iterator Find(UInt_t file, UInt_t event)
Find an element in the list.
Definition: CbmMCEventList.cxx:64
CbmMCEventInfo.h
CbmMCEventList::GetEventIdByIndex
Int_t GetEventIdByIndex(UInt_t index)
Event number by index @value Event number for event at given index in list.
Definition: CbmMCEventList.cxx:77
CbmMCEventList::Clear
virtual void Clear(Option_t *)
Delete all event entries.
Definition: CbmMCEventList.h:50
CbmMCEventList::~CbmMCEventList
virtual ~CbmMCEventList()
Destructor.
Definition: CbmMCEventList.cxx:30
CbmMCEventList::Print
virtual void Print(Option_t *opt="") const
Definition: CbmMCEventList.cxx:126
CbmMCEventList::Check
Bool_t Check()
Check for double occurrences of events in list @value kTRUE is no double occurrences,...
Definition: CbmMCEventList.cxx:35