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