Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
ObjectMatrix.cxx
1/*
2 * HalHistogramManager.cxx
3 *
4 * Created on: 12-08-2014
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "Package.h"
11
12#include <TList.h>
13
14#include "ObjectMatrix.h"
15
16namespace Hal {
17 ObjectMatrix_1::ObjectMatrix_1(const ObjectMatrix_1& manager) :
18 TNamed(manager), fSize(manager.fSize), fComments(NULL), fArray(NULL) {
19 if (manager.fComments) {
20 fComments = new TString(fSize);
21 fArray = new TObject*[fSize];
22 for (int i = 0; i < fSize; i++) {
23 fComments[i] = manager.fComments[i];
24 fArray[i] = (TObject*) manager.fArray[i]->Clone();
25 }
26 }
27 }
28
29 ObjectMatrix_1& ObjectMatrix_1::operator=(const ObjectMatrix_1& manager) {
30 if (this == &manager) { return *this; }
31 if (fSize > 0) {
32 for (int i = 0; i < fSize; i++) {
33 delete fArray[i];
34 }
35 delete[] fArray;
36 delete[] fComments;
37 fArray = NULL;
38 fComments = NULL;
39 }
40 fSize = manager.fSize;
41 if (manager.fSize > 0) {
42 fComments = new TString(fSize);
43 fArray = new TObject*[fSize];
44 for (int i = 0; i < fSize; i++) {
45 fComments[i] = manager.fComments[i];
46 fArray[i] = (TObject*) manager.fArray[i]->Clone();
47 }
48 }
49 return *this;
50 }
51
52 void ObjectMatrix_1::Init(Int_t size, const TObject* temp) {
53 fSize = size;
54 fArray = new TObject*[fSize];
55 fComments = new TString[fSize];
56 TString title = Form("%s[%%i]", temp->GetName());
57 for (int i = 0; i < fSize; i++) {
58 fArray[i] = (TObject*) temp->Clone(Form(title, i));
59 fComments[i] = " ";
60 }
61 }
62
63 Package* ObjectMatrix_1::Report() const {
64 Package* pack = new Package(this);
65 for (int i = 0; i < fSize; i++) {
66 pack->AddObject(fArray[i]);
67 }
68 return pack;
69 }
70
71 TList* ObjectMatrix_1::GetFlatList() const {
72 TList* list = new TList();
73 list->SetOwner(kFALSE);
74 for (int i = 0; i < fSize; i++) {
75 list->Add(fArray[i]);
76 }
77 return list;
78 }
79
80 ObjectMatrix_2::ObjectMatrix_2(const ObjectMatrix_2& manager) : TNamed(manager), fSize(manager.fSize), fArray(NULL) {
81 if (manager.fArray) {
82 fArray = new ObjectMatrix_1*[fSize];
83 for (int i = 0; i < fSize; i++) {
84 fArray[i] = new ObjectMatrix_1(*manager.fArray[i]);
85 }
86 }
87 }
88
89 ObjectMatrix_2& ObjectMatrix_2::operator=(const ObjectMatrix_2& manager) {
90 if (this == &manager) { return *this; }
91 if (fSize > 0) {
92 delete[] fArray;
93 fArray = NULL;
94 }
95 fSize = manager.fSize;
96 if (manager.fSize > 0) {
97 fArray = new ObjectMatrix_1*[fSize];
98 for (int i = 0; i < fSize; i++) {
99 fArray[i] = new ObjectMatrix_1(*manager.fArray[i]);
100 }
101 }
102 return *this;
103 }
104
105 void ObjectMatrix_2::Init(Int_t sizeX, Int_t sizeY, const TObject* temp) {
106 fSize = sizeX;
108 TString title = Form("%s[%%i]", temp->GetName());
109 for (int i = 0; i < fSize; i++) {
110 TString Title = Form(title, i);
111 fArray[i] = new ObjectMatrix_1();
112 TObject* temp_obj = (TObject*) temp->Clone(Form(title, i));
113 fArray[i]->Init(sizeY, temp_obj);
114 delete temp_obj;
115 }
116 }
117
119 Package* pack = new Package(this);
120 for (int i = 0; i < fSize; i++) {
121 pack->AddObject(fArray[i]->Report());
122 }
123 return pack;
124 }
125
127 TList* list = new TList();
128 list->SetOwner(kFALSE);
129 for (int i = 0; i < fSize; i++) {
130 for (int j = 0; j < fArray[i]->GetSize(); j++) {
131 list->Add(fArray[i]->At(j));
132 }
133 }
134 return list;
135 }
136
137 ObjectMatrix_2::~ObjectMatrix_2() {
138 if (fArray == NULL) return;
139 for (int i = 0; i < fSize; i++)
140 delete fArray[i];
141 delete[] fArray;
142 }
143
144 ObjectMatrix_3::ObjectMatrix_3(const ObjectMatrix_3& manager) : TNamed(manager), fSize(manager.fSize), fArray(NULL) {
145 if (manager.fArray) {
146 fArray = new ObjectMatrix_2*[fSize];
147 for (int i = 0; i < fSize; i++) {
148 fArray[i] = new ObjectMatrix_2(*manager.fArray[i]);
149 }
150 }
151 }
152
153 ObjectMatrix_3& ObjectMatrix_3::operator=(const ObjectMatrix_3& manager) {
154 if (this == &manager) { return *this; }
155 if (fSize > 0) {
156 delete[] fArray;
157 fArray = NULL;
158 }
159 fSize = manager.fSize;
160 if (manager.fSize > 0) {
161 fArray = new ObjectMatrix_2*[fSize];
162 for (int i = 0; i < fSize; i++) {
163 fArray[i] = new ObjectMatrix_2(*manager.fArray[i]);
164 }
165 }
166 return *this;
167 }
168
169 void ObjectMatrix_3::Init(Int_t sizeX, Int_t sizeY, Int_t sizeZ, const TObject* temp) {
170 fSize = sizeX;
171 fArray = new ObjectMatrix_2*[fSize];
172 TString name = "";
173 if (temp->InheritsFrom("TNamed")) name = temp->GetName();
174 TString title = Form("%s[%%i]", temp->GetName());
175 for (int i = 0; i < fSize; i++) {
176 TObject* temp_obj = (TObject*) temp->Clone(Form(title, i));
177 fArray[i] = new ObjectMatrix_2();
178 fArray[i]->Init(sizeY, sizeZ, temp_obj);
179 delete temp_obj;
180 }
181 }
182
184 Package* pack = new Package(this);
185 for (int i = 0; i < fSize; i++) {
186 pack->AddObject(fArray[i]->Report());
187 }
188 return pack;
189 }
190
192 TList* list = new TList();
193 list->SetOwner(kFALSE);
194 for (int i = 0; i < fSize; i++) {
195 for (int j = 0; j < fArray[i]->GetSize(); j++) {
196 for (int k = 0; k < fArray[i]->Get(j)->GetSize(); k++) {
197 list->Add(At(i, j, k));
198 }
199 }
200 }
201 return list;
202 }
203
204 ObjectMatrix_3::~ObjectMatrix_3() {
205 if (fArray == NULL) return;
206 for (int i = 0; i < fSize; i++)
207 delete fArray[i];
208 delete[] fArray;
209 }
210
211 ObjectMatrix_4::ObjectMatrix_4(const ObjectMatrix_4& manager) : TNamed(manager), fSize(manager.fSize), fArray(NULL) {
212 if (manager.fArray) {
213 fArray = new ObjectMatrix_3*[fSize];
214 for (int i = 0; i < fSize; i++) {
215 fArray[i] = new ObjectMatrix_3(*manager.fArray[i]);
216 }
217 }
218 }
219
220 ObjectMatrix_4& ObjectMatrix_4::operator=(const ObjectMatrix_4& manager) {
221 if (this == &manager) { return *this; }
222 if (fSize > 0) {
223 delete[] fArray;
224 fArray = NULL;
225 }
226 fSize = manager.fSize;
227 if (manager.fSize > 0) {
228 fArray = new ObjectMatrix_3*[fSize];
229 for (int i = 0; i < fSize; i++) {
230 fArray[i] = new ObjectMatrix_3(*manager.fArray[i]);
231 }
232 }
233 return *this;
234 }
235
236 void ObjectMatrix_4::Init(Int_t sizeX, Int_t sizeY, Int_t sizeZ, Int_t sizeD, const TObject* temp) {
237 fSize = sizeX;
238 fArray = new ObjectMatrix_3*[fSize];
239 TString title = Form("%s[%%i]", temp->GetName());
240 for (int i = 0; i < fSize; i++) {
241 TString Title = Form(title, i);
242 TObject* temp_obj = (TObject*) temp->Clone(Form(title, i));
243 fArray[i] = new ObjectMatrix_3();
244 fArray[i]->Init(sizeY, sizeZ, sizeD, temp_obj);
245 delete temp_obj;
246 }
247 }
248
250 Package* pack = new Package(this);
251 for (int i = 0; i < fSize; i++) {
252 pack->AddObject(fArray[i]->Report());
253 }
254 return pack;
255 }
256
258 TList* list = new TList();
259 list->SetOwner(kFALSE);
260 for (int i = 0; i < fSize; i++) {
261 for (int j = 0; j < fArray[i]->GetSize(); j++) {
262 for (int k = 0; k < fArray[i]->Get(j)->GetSize(); k++) {
263 for (int l = 0; l < fArray[i]->Get(j)->Get(k)->GetSize(); l++) {
264 list->Add(At(i, j, k, l));
265 }
266 }
267 }
268 }
269 return list;
270 }
271
272 ObjectMatrix_4::~ObjectMatrix_4() {
273 if (fArray == NULL) return;
274 for (int i = 0; i < fSize; i++)
275 delete fArray[i];
276 delete[] fArray;
277 }
278} // namespace Hal
Int_t GetSize() const
virtual void Init(Int_t size, const TObject *temp)
TList * GetFlatList() const
ObjectMatrix_1 * Get(Int_t i) const
Int_t GetSize() const
TObject * At(Int_t i, Int_t j) const
ObjectMatrix_1 ** fArray
virtual void Init(Int_t sizeX, Int_t sizeY, const TObject *temp)
Package * Report() const
ObjectMatrix_2 ** fArray
Int_t GetSize() const
void Init(Int_t sizeX, Int_t sizeY, Int_t sizeZ, const TObject *temp)
TList * GetFlatList() const
ObjectMatrix_2 * Get(Int_t i) const
Package * Report() const
TObject * At(Int_t i, Int_t j, Int_t k) const
TObject * At(Int_t i, Int_t j, Int_t k, Int_t l) const
ObjectMatrix_3 ** fArray
ObjectMatrix_3 * Get(const Int_t i) const
Int_t GetSize() const
TList * GetFlatList() const
Package * Report() const
virtual void Init(Int_t sizeX, Int_t sizeY, Int_t sizeZ, Int_t sizeT, const TObject *temp)
void AddObject(TObject *object)
Definition Package.cxx:209