CbmRoot
CbmEventStore.cxx
Go to the documentation of this file.
1 
6 #include "CbmEventStore.h"
7 
8 #include "CbmLink.h" // for CbmLink
9 #include "CbmMatch.h" // for CbmMatch
10 #include "CbmModuleList.h" // for CbmModuleList
11 
12 #include <TString.h> // for operator<<
13 
14 #include <iostream> // for operator<<, basic_ostream, stringstream
15 
16 
17 // ----- Constructor ---------------------------------------------------
18 CbmEventStore::CbmEventStore(UInt_t eventId, Bool_t hasMatches)
19  : fEventId(eventId), fHasMatches(hasMatches) {
20  // fDigis = new TObjArray(ToIntegralType(ECbmModuleId::kNofSystems));
21 }
22 // -------------------------------------------------------------------------
23 
24 
25 // ----- Copy constructor ----------------------------------------------
26 CbmEventStore::CbmEventStore(const CbmEventStore& other) : TObject(other) {
27  fEventId = other.fEventId;
28  fHasMatches = other.fHasMatches;
29  // TODO: Create new map with a copy of the original map
30  // Don't know how to do that yet
31  // fDigis = (TObjArray*)other.fDigis->Clone();
32 }
33 // -------------------------------------------------------------------------
34 
35 
36 // ----- Destructor ----------------------------------------------------
38  for (auto system : fDigis) {
39  delete system.second;
40  }
41  // fDigis->Delete();
42 }
43 // -------------------------------------------------------------------------
44 
45 
46 // ----- Test for being empty ------------------------------------------
47 Bool_t CbmEventStore::IsEmpty() const {
48  UInt_t nDigis = 0;
49  for (auto system : fDigis) {
50  auto* digis = dynamic_cast<CbmDigiContainer*>(system.second);
51  nDigis += digis->GetNofDigis();
52  }
53 
54  /*
55 for ( Int_t system = 0; system < fDigis->GetEntriesFast(); system++) {
56  auto* digis = dynamic_cast<CbmDigiContainer*>(fDigis->At(system));
57  if ( digis ) nDigis += digis->GetNofDigis();
58  }
59 */
60  return (nDigis > 0 ? kFALSE : kTRUE);
61 }
62 // -------------------------------------------------------------------------
63 
64 
65 // ----- Get number of data for a given system -------------------------
67  if (system >= ECbmModuleId::kNofSystems) return 0;
68  auto* digis = dynamic_cast<CbmDigiContainer*>(fDigis.at(system));
69  if (!digis) return 0;
70  return digis->GetNofDigis();
71 }
72 // -------------------------------------------------------------------------
73 
74 
75 // ----- Match to MC event ---------------------------------------------
76 void CbmEventStore::MatchToMC(CbmMatch& result) const {
77  result.ClearLinks();
78  if (!fHasMatches) return;
79  for (auto system : fDigis) {
80  auto* digis = dynamic_cast<CbmDigiContainer*>(system.second);
81  if (!digis) continue;
82  for (UInt_t index = 0; index < digis->GetNofDigis(); index++) {
83  const CbmMatch* match = digis->GetDigiMatch(index);
84  assert(match);
85  for (Int_t iLink = 0; iLink < match->GetNofLinks(); iLink++) {
86  const CbmLink& link = match->GetLink(iLink);
87  result.AddLink(link.GetWeight(), 0, link.GetEntry(), link.GetFile());
88  } //# Links in match
89  } //# Matches in system
90  } //# Systems
91 
92 
93  /*
94  for (Int_t system = 0; system < fDigis->GetEntriesFast(); system++) {
95  auto* digis = dynamic_cast<CbmDigiContainer*>(fDigis->At(system));
96  if ( ! digis ) continue;
97  for (UInt_t index = 0; index < digis->GetNofDigis(); index++) {
98  const CbmMatch* match = digis->GetDigiMatch(index);
99  assert(match);
100  for (Int_t iLink = 0; iLink < match->GetNofLinks(); iLink++) {
101  const CbmLink& link = match->GetLink(iLink);
102  result.AddLink(link.GetWeight(), 0, link.GetEntry(), link.GetFile());
103  } //# Links in match
104  } //# Matches in system
105  } //# Systems
106 */
107 }
108 // -------------------------------------------------------------------------
109 
110 
111 // ----- String output -------------------------------------------------
112 std::string CbmEventStore::ToString() const {
113  std::stringstream ss;
114  ss << "Event " << fEventId;
115  if (IsEmpty())
116  ss << " empty";
117  else {
118  ss << " Data: ";
119  for (auto system : fDigis) {
120  auto* vec = dynamic_cast<CbmDigiContainer*>(system.second);
121  // for ( Int_t system = 0; system < fDigis->GetEntriesFast(); system++) {
122  // if ( fDigis->At(system) ) {
123  // auto vec = static_cast<CbmDigiContainer*>(fDigis->At(system));
124  assert(vec);
125  ss << CbmModuleList::GetModuleNameCaps(system.first) << " "
126  << vec->GetNofDigis() << " ";
127  // } //? Digi vector present
128  } //# Systems
129  } //? Not empty
130 
131  if (fHasMatches) ss << ", matches present";
132  return ss.str();
133 }
134 // -------------------------------------------------------------------------
135 
136 
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
CbmMatch::GetLink
const CbmLink & GetLink(Int_t i) const
Definition: CbmMatch.h:35
CbmMatch::GetNofLinks
Int_t GetNofLinks() const
Definition: CbmMatch.h:38
CbmDigiContainer
Abstract container for digis in CBM.
Definition: CbmDigiContainer.h:30
CbmDigiContainer::GetNofDigis
virtual ULong64_t GetNofDigis() const =0
Get the number of digis in the container.
CbmEventStore::IsEmpty
Bool_t IsEmpty() const
Indicate whether event contains no digis.
Definition: CbmEventStore.cxx:47
CbmEventStore::MatchToMC
void MatchToMC(CbmMatch &result) const
Match to MC event.
Definition: CbmEventStore.cxx:76
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmEventStore::CbmEventStore
CbmEventStore(UInt_t eventId=0, Bool_t hasMatches=kFALSE)
Default constructor.
Definition: CbmEventStore.cxx:18
CbmMatch.h
CbmEventStore::fDigis
std::map< ECbmModuleId, TObject * > fDigis
Map of CbmDigiVector.
Definition: CbmEventStore.h:174
CbmModuleList::GetModuleNameCaps
static TString GetModuleNameCaps(ECbmModuleId moduleId)
Definition: CbmModuleList.cxx:77
CbmEventStore::GetNofDigis
UInt_t GetNofDigis(ECbmModuleId system) const
Number of digis for a given system.
Definition: CbmEventStore.cxx:66
CbmMatch::AddLink
void AddLink(const CbmLink &newLink)
Definition: CbmMatch.cxx:42
ECbmModuleId::kNofSystems
@ kNofSystems
For loops over active systems.
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmModuleList.h
CbmEventStore::fHasMatches
Bool_t fHasMatches
Presence of matches to MC.
Definition: CbmEventStore.h:172
CbmEventStore::ToString
std::string ToString() const
Definition: CbmEventStore.cxx:112
CbmMatch::ClearLinks
void ClearLinks()
Definition: CbmMatch.cxx:74
CbmEventStore::~CbmEventStore
virtual ~CbmEventStore()
Destructor.
Definition: CbmEventStore.cxx:37
CbmEventStore.h