CbmRoot
CbmEventStore.h
Go to the documentation of this file.
1 
7 #ifndef CBMEVENTSTORE_H
8 #define CBMEVENTSTORE_H 1
9 
10 #include <Rtypes.h> // for THashConsistencyHolder, ClassDef
11 #include <RtypesCore.h> // for UInt_t, Bool_t, kFALSE, kTRUE
12 #include <TObjArray.h> // for TObjArray
13 #include <TObject.h> // for TObject
14 
15 #include <FairLogger.h> // for LOG
16 
17 #include <boost/any.hpp> // for any_cast
18 
19 #include <assert.h> // for assert
20 #include <string> // for string
21 
22 #include "CbmDefs.h" // for kNofSystems
23 #include "CbmDigiContainer.h" // for CbmDigiContainer
24 #include "CbmDigiVector.h" // for CbmDigiVector
25 
26 class CbmMatch;
27 
39 class CbmEventStore : public TObject {
40 
41 public:
46  CbmEventStore(UInt_t eventId = 0, Bool_t hasMatches = kFALSE);
47 
48 
51 
52 
55 
56 
58  virtual ~CbmEventStore();
59 
60 
69  template<class Digi>
70  void AddDigi(const Digi* digi) {
71  if (fHasMatches) {
72  LOG(fatal) << "CbmEventStore: Trying to add digi without match!";
73  return;
74  }
75  assert(digi);
76  ECbmModuleId system = Digi::GetSystem();
77  assert(system < ECbmModuleId::kNofSystems);
78  if (!fDigis[system]) fDigis[system] = new CbmDigiVector<Digi>(kFALSE);
79  auto digis = static_cast<CbmDigiContainer*>(fDigis.at(system));
80  assert(digis);
81  digis->AddDigi(digi, nullptr);
82  }
83 
84 
94  template<class Digi>
95  void AddDigi(const Digi* digi, const CbmMatch* match) {
96  if (!fHasMatches) {
97  LOG(fatal) << "CbmEventStore: Trying to add digi without match!";
98  return;
99  }
100  assert(digi);
101  assert(match);
102  ECbmModuleId system = Digi::GetSystem();
103  assert(system < ECbmModuleId::kNofSystems);
104  if (!fDigis[system]) fDigis[system] = new CbmDigiVector<Digi>(kTRUE);
105  auto digis = static_cast<CbmDigiContainer*>(fDigis.at(system));
106  assert(digis);
107  digis->AddDigi(digi, match);
108  }
109 
110 
118  template<class Digi>
119  const Digi* GetDigi(UInt_t index) const {
120  ECbmModuleId system = Digi::GetSystem();
121  assert(system < ECbmModuleId::kNofSystems);
122  auto digis = static_cast<CbmDigiContainer*>(fDigis.at(system));
123  assert(digis);
124  return boost::any_cast<const Digi*>(digis->GetDigi(index));
125  }
126 
127 
131  UInt_t GetEventId() const { return fEventId; }
132 
133 
138  UInt_t GetNofDigis(ECbmModuleId system) const;
139 
140 
144  Bool_t HasMatches() const { return fHasMatches; }
145 
146 
150  Bool_t IsEmpty() const;
151 
152 
159  void MatchToMC(CbmMatch& result) const;
160 
161 
164 
165 
167  std::string ToString() const;
168 
169 
170 private:
171  UInt_t fEventId = -1;
172  Bool_t fHasMatches = kFALSE;
173  // TObjArray* fDigis = nullptr; ///< Array of CbmDigiVector
174  std::map<ECbmModuleId, TObject*> fDigis;
175 
177 };
178 
179 #endif /* CBMEVENTSTORE_H */
CbmMatch
Definition: CbmMatch.h:22
CbmEventStore::fEventId
UInt_t fEventId
Event identifier.
Definition: CbmEventStore.h:171
CbmEventStore
Storable event class for CBM.
Definition: CbmEventStore.h:39
CbmDigiContainer
Abstract container for digis in CBM.
Definition: CbmDigiContainer.h:30
CbmEventStore::IsEmpty
Bool_t IsEmpty() const
Indicate whether event contains no digis.
Definition: CbmEventStore.cxx:47
CbmDigiVector
std::vector implementation of CbmDigiContainer
Definition: CbmDigiVector.h:23
CbmEventStore::MatchToMC
void MatchToMC(CbmMatch &result) const
Match to MC event.
Definition: CbmEventStore.cxx:76
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmEventStore::CbmEventStore
CbmEventStore(CbmEventStore &&)=default
Move constructor.
CbmEventStore::CbmEventStore
CbmEventStore(UInt_t eventId=0, Bool_t hasMatches=kFALSE)
Default constructor.
Definition: CbmEventStore.cxx:18
CbmEventStore::fDigis
std::map< ECbmModuleId, TObject * > fDigis
Map of CbmDigiVector.
Definition: CbmEventStore.h:174
CbmDigiVector.h
CbmEventStore::AddDigi
void AddDigi(const Digi *digi)
Add a digi object to the event.
Definition: CbmEventStore.h:70
CbmEventStore::GetNofDigis
UInt_t GetNofDigis(ECbmModuleId system) const
Number of digis for a given system.
Definition: CbmEventStore.cxx:66
ECbmModuleId::kNofSystems
@ kNofSystems
For loops over active systems.
CbmEventStore::HasMatches
Bool_t HasMatches() const
Presence of match objects.
Definition: CbmEventStore.h:144
CbmEventStore::fHasMatches
Bool_t fHasMatches
Presence of matches to MC.
Definition: CbmEventStore.h:172
CbmEventStore::GetEventId
UInt_t GetEventId() const
Get event ID.
Definition: CbmEventStore.h:131
CbmEventStore::operator=
CbmEventStore & operator=(const CbmEventStore &)=delete
Assignment operator.
CbmEventStore::ClassDef
ClassDef(CbmEventStore, 2)
CbmDigiContainer.h
CbmEventStore::AddDigi
void AddDigi(const Digi *digi, const CbmMatch *match)
Add a digi and its match object to the event.
Definition: CbmEventStore.h:95
CbmEventStore::ToString
std::string ToString() const
Definition: CbmEventStore.cxx:112
CbmEventStore::~CbmEventStore
virtual ~CbmEventStore()
Destructor.
Definition: CbmEventStore.cxx:37
CbmEventStore::GetDigi
const Digi * GetDigi(UInt_t index) const
Get a digi object.
Definition: CbmEventStore.h:119
CbmDefs.h