CbmRoot
Loading...
Searching...
No Matches
CbmCluster.cxx
Go to the documentation of this file.
1/* Copyright (C) 2012-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese, Florian Uhlig [committer], Andrey Lebedev */
4
10#include "CbmCluster.h"
11
12#include "CbmMatch.h" // for CbmMatch
13
14#include <TObject.h> // for TObject
15#include <type_traits> // for move
16
17#include <sstream> // for operator<<, basic_ostream, stringstream
18#include <string> // for char_traits
19
20using namespace std;
21
22CbmCluster::CbmCluster() : TObject(), fDigis(), fAddress(0), fMatch(nullptr) {}
23CbmCluster::CbmCluster(const std::vector<int32_t>& indices, int32_t address)
24 : TObject()
25 , fDigis()
26 , fAddress(address)
27 , fMatch(nullptr)
28{
29 fDigis.assign(indices.begin(), indices.end());
30}
31
33 : TObject(other)
34 , fDigis(other.fDigis)
35 , fAddress(other.fAddress)
36 , fMatch(nullptr)
37{
38 if (other.fMatch) {
39 fMatch = new CbmMatch();
40 fMatch->AddLinks(*(other.fMatch));
41 }
42}
43
45 : TObject(other)
46 , fDigis(std::move(other.fDigis))
47 , fAddress(std::move(other.fAddress))
48 , fMatch(other.fMatch)
49{
50 other.fMatch = nullptr;
51}
52
54{
55 if (this != &other) {
56 fDigis = other.fDigis;
57 fAddress = other.fAddress;
58 fMatch = nullptr;
59 if (other.fMatch) {
60 fMatch = new CbmMatch();
61 fMatch->AddLinks(*(other.fMatch));
62 }
63 }
64 return *this;
65}
66
68{
69 if (this != &other) {
70 fDigis = std::move(other.fDigis);
71 fAddress = std::move(other.fAddress);
72 fMatch = other.fMatch;
73 other.fMatch = nullptr;
74 }
75 return *this;
76}
77
79
81{
82 if (fMatch) delete fMatch;
83 fMatch = match;
84}
85
86
88{
89 stringstream ss;
90 ss << "CbmCluster: ";
91 int32_t nofDigis = GetNofDigis();
92 ss << "nofDigis=" << nofDigis << " | ";
93 for (int32_t i = 0; i < nofDigis; i++) {
94 ss << fDigis[i] << " ";
95 }
96 ss << " | address=" << fAddress << endl;
97 return ss.str();
98}
99
ClassImp(CbmCluster)
Base class for cluster objects.
Base class for cluster objects.
Definition CbmCluster.h:30
CbmMatch * fMatch
link to Monte-Carlo information
Definition CbmCluster.h:106
std::vector< int32_t > fDigis
Array of digi indices.
Definition CbmCluster.h:104
int32_t fAddress
Unique detector ID.
Definition CbmCluster.h:105
void SetMatch(CbmMatch *match)
virtual std::string ToString() const
Return string representation of the object.
virtual ~CbmCluster()
Destructor.
CbmCluster()
Constructor.
CbmCluster & operator=(const CbmCluster &)
int32_t GetNofDigis() const
Number of digis in cluster.
Definition CbmCluster.h:69
void AddLinks(const CbmMatch &match)
Definition CbmMatch.cxx:39
Hash for CbmL1LinkKey.