CbmRoot
CbmCluster.cxx
Go to the documentation of this file.
1 
6 #include "CbmCluster.h"
7 
8 #include "CbmMatch.h" // for CbmMatch
9 
10 #include <TObject.h> // for TObject
11 
12 #include <sstream> // for operator<<, basic_ostream, stringstream
13 #include <string> // for char_traits
14 #include <type_traits> // for move
15 
16 using namespace std;
17 
18 CbmCluster::CbmCluster() : TObject(), fDigis(), fAddress(0), fMatch(nullptr) {}
19 CbmCluster::CbmCluster(const std::vector<Int_t>& indices, Int_t address)
20  : TObject(), fDigis(), fAddress(address), fMatch(nullptr) {
21  fDigis.assign(indices.begin(), indices.end());
22 }
23 
25  : TObject(other)
26  , fDigis(other.fDigis)
27  , fAddress(other.fAddress)
28  , fMatch(nullptr) {
29  if (other.fMatch) {
30  fMatch = new CbmMatch();
31  fMatch->AddLinks(*(other.fMatch));
32  }
33 }
34 
36  : TObject(other)
37  , fDigis(std::move(other.fDigis))
38  , fAddress(std::move(other.fAddress))
39  , fMatch(other.fMatch) {
40  other.fMatch = nullptr;
41 }
42 
44  if (this != &other) {
45  fDigis = other.fDigis;
46  fAddress = other.fAddress;
47  fMatch = nullptr;
48  if (other.fMatch) {
49  fMatch = new CbmMatch();
50  fMatch->AddLinks(*(other.fMatch));
51  }
52  }
53  return *this;
54 }
55 
57  if (this != &other) {
58  fDigis = std::move(other.fDigis);
59  fAddress = std::move(other.fAddress);
60  fMatch = other.fMatch;
61  other.fMatch = nullptr;
62  }
63  return *this;
64 }
65 
67 
69  if (fMatch) delete fMatch;
70  fMatch = match;
71 }
72 
73 
74 string CbmCluster::ToString() const {
75  stringstream ss;
76  ss << "CbmCluster: ";
77  Int_t nofDigis = GetNofDigis();
78  ss << "nofDigis=" << nofDigis << " | ";
79  for (Int_t i = 0; i < nofDigis; i++) {
80  ss << fDigis[i] << " ";
81  }
82  ss << " | address=" << fAddress << endl;
83  return ss.str();
84 }
85 
CbmCluster::fDigis
std::vector< Int_t > fDigis
Array of digi indices.
Definition: CbmCluster.h:104
CbmMatch
Definition: CbmMatch.h:22
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmCluster::SetMatch
void SetMatch(CbmMatch *match)
Definition: CbmCluster.cxx:68
CbmCluster::fMatch
CbmMatch * fMatch
link to Monte-Carlo information
Definition: CbmCluster.h:106
CbmMatch.h
ClassImp
ClassImp(CbmCluster)
CbmCluster::GetNofDigis
Int_t GetNofDigis() const
Number of digis in cluster.
Definition: CbmCluster.h:69
CbmCluster::ToString
virtual std::string ToString() const
Return string representation of the object.
Definition: CbmCluster.cxx:74
CbmCluster::~CbmCluster
virtual ~CbmCluster()
Destructor.
Definition: CbmCluster.cxx:66
CbmCluster::operator=
CbmCluster & operator=(const CbmCluster &)
Definition: CbmCluster.cxx:43
CbmMatch::AddLinks
void AddLinks(const CbmMatch &match)
Definition: CbmMatch.cxx:35
CbmCluster
Base class for cluster objects.
Definition: CbmCluster.h:26
CbmCluster.h
Base class for cluster objects.
CbmCluster::CbmCluster
CbmCluster()
Constructor.
Definition: CbmCluster.cxx:18
CbmCluster::fAddress
Int_t fAddress
Unique detector ID.
Definition: CbmCluster.h:105