CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TEcnaNArrayD.cc
Go to the documentation of this file.
1 //----------Author's Name:F.X. Gentit + modifs by B.Fabbro DSM/IRFU/SPP CEA-Saclay
2 //----------Copyright:Those valid for CEA sofware
3 //----------Modified:24/03/2011
4 
6 #include "Riostream.h"
7 
8 //--------------------------------------
9 // TEcnaNArrayD.cc
10 // Class creation: 03 Dec 2002
11 // Documentation: see TEcnaNArrayD.h
12 //--------------------------------------
13 
15 //______________________________________________________________________________
16 //
17 
18 // TEcnaNArrayD ROOT class for multidimensional arrays of Double_t
19 //
20 // up to dimension 6
21 // book one place more for overflow
22 // detects overflow
23 //
24 
26  //constructor without argument
27 
28  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
29 
30  Init();
31 }
32 
33 TEcnaNArrayD::TEcnaNArrayD(const TEcnaNArrayD &orig) : TObject::TObject(orig) {
34  //copy constructor
35 
36  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
37 
38  fNd = orig.fNd;
39  fN1 = orig.fN1;
40  fN2 = orig.fN2;
41  fN3 = orig.fN3;
42  fN4 = orig.fN4;
43  fN5 = orig.fN5;
44  fN6 = orig.fN6;
45  fNL = orig.fNL;
46  fA = new Double_t[fNL];
47  for (Int_t i = 0; i < fNL; i++)
48  fA[i] = orig.fA[i];
49 }
50 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1) {
51  //constructor for a 1 dimensional array of size n1. Array is put to 0
52 
53  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
54 
55  Long_t i_this = (Long_t)this;
56  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
57 
58  const Double_t zero = 0.0;
59  Init();
60  fNd = 1;
61  fN1 = n1;
62  fNL = n1 + 1;
63  fA = new Double_t[fNL];
64  for (Int_t i = 0; i < fNL; i++)
65  fA[i] = zero;
66 }
67 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2) {
68  //constructor for a 2 dimensional array of sizes n1,n2. Array is put to 0
69 
70  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
71 
72  Long_t i_this = (Long_t)this;
73  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
74 
75  const Double_t zero = 0.0;
76  Init();
77  fNd = 2;
78  fN1 = n1;
79  fN2 = n2;
80  fNL = n1 * n2 + 1;
81  fA = new Double_t[fNL];
82  for (Int_t i = 0; i < fNL; i++)
83  fA[i] = zero;
84 }
85 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3) {
86  //constructor 3 dimensional array of sizes n1,n2,n3. Array is put to 0
87 
88  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
89 
90  Long_t i_this = (Long_t)this;
91  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
92 
93  const Double_t zero = 0.0;
94  Init();
95  fNd = 3;
96  fN1 = n1;
97  fN2 = n2;
98  fN3 = n3;
99  fNL = n1 * n2 * n3 + 1;
100  fA = new Double_t[fNL];
101  for (Int_t i = 0; i < fNL; i++)
102  fA[i] = zero;
103 }
104 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3, Int_t n4) {
105  //constructor for a 4 dimensional array of sizes n1,n2,n3,n4. Array is put to 0
106 
107  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
108 
109  Long_t i_this = (Long_t)this;
110  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
111 
112  const Double_t zero = 0.0;
113  Init();
114  fNd = 4;
115  fN1 = n1;
116  fN2 = n2;
117  fN3 = n3;
118  fN4 = n4;
119  fNL = n1 * n2 * n3 * n4 + 1;
120  fA = new Double_t[fNL];
121  for (Int_t i = 0; i < fNL; i++)
122  fA[i] = zero;
123 }
124 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5) {
125  //constructor for a 5 dimensional array of sizes n1,n2,n3,n4,n5. Array is put to 0
126 
127  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
128 
129  Long_t i_this = (Long_t)this;
130  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
131 
132  const Double_t zero = 0.0;
133  Init();
134  fNd = 5;
135  fN1 = n1;
136  fN2 = n2;
137  fN3 = n3;
138  fN4 = n4;
139  fN5 = n5;
140  fNL = n1 * n2 * n3 * n4 * n5 + 1;
141  fA = new Double_t[fNL];
142  for (Int_t i = 0; i < fNL; i++)
143  fA[i] = zero;
144 }
145 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6) {
146  //constructor for a 6 dimensional array of sizes n1,n2,n3,n4,n5,n6. Array is put to 0
147 
148  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
149 
150  Long_t i_this = (Long_t)this;
151  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
152 
153  const Double_t zero = 0.0;
154  Init();
155  fNd = 6;
156  fN1 = n1;
157  fN2 = n2;
158  fN3 = n3;
159  fN4 = n4;
160  fN5 = n5;
161  fN6 = n6;
162  fNL = n1 * n2 * n3 * n4 * n5 * n6 + 1;
163  fA = new Double_t[fNL];
164  for (Int_t i = 0; i < fNL; i++)
165  fA[i] = zero;
166 }
167 
169  //destructor
170 
171  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. DESTROY OBJECT: this = " << this << std::endl;
172 
173  Clean();
174 }
175 
176 //------------------------------------- methods
177 
179  //
180  if (fA)
181  delete[] fA;
182  Init();
183 }
185  //Initialization
186  fNd = 0;
187  fN1 = 1;
188  fN2 = 1;
189  fN3 = 1;
190  fN4 = 1;
191  fN5 = 1;
192  fN6 = 1;
193  fNL = 0;
194  fA = nullptr;
195 }
196 inline Int_t TEcnaNArrayD::OneDim(Int_t i1) const {
197  //Index from 1 dimension to 1 dimension
198  if ((i1 >= fNL - 1) || (i1 < 0)) {
199  i1 = fNL - 1;
200  Error("OneDim", "Index outside bounds");
201  std::cout << "i1 = " << i1 << "; fNL = " << fNL << std::endl;
202  }
203  return i1;
204 }
205 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2) const {
206  //Index from 2 dimension to 1 dimension
207  Int_t i;
208  i = i1 + fN1 * i2;
209  if ((i >= fNL - 1) || (i < 0)) {
210  i = fNL - 1;
211  Error("OneDim", "Index outside bounds");
212  std::cout << "i1 = " << i1 << ", i2 = " << i2 << "; fN1 = " << fN1 << ", fNL = " << fNL << std::endl;
213  }
214  return i;
215 }
216 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3) const {
217  //Index from 3 dimension to 1 dimension
218  Int_t i;
219  i = i1 + fN1 * (i2 + fN2 * i3);
220  if ((i >= fNL - 1) || (i < 0)) {
221  i = fNL - 1;
222  Error("OneDim", "Index outside bounds");
223  std::cout << "i1 = " << i1 << ", i2 = " << i2 << ", i3 = " << i3 << "; fN1 = " << fN1 << ", fN2 = " << fN2
224  << ", fNL = " << fNL << std::endl;
225  }
226  return i;
227 }
228 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3, Int_t i4) const {
229  //Index from 4 dimension to 1 dimension
230  Int_t i;
231  i = i1 + fN1 * (i2 + fN2 * (i3 + fN3 * i4));
232  if ((i >= fNL - 1) || (i < 0)) {
233  i = fNL - 1;
234  Error("OneDim", "Index outside bounds");
235  }
236  return i;
237 }
238 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5) const {
239  //Index from 5 dimension to 1 dimension
240  Int_t i;
241  i = i1 + fN1 * (i2 + fN2 * (i3 + fN3 * (i4 + fN4 * i5)));
242  if ((i >= fNL - 1) || (i < 0)) {
243  i = fNL - 1;
244  Error("OneDim", "Index outside bounds");
245  }
246  return i;
247 }
248 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5, Int_t i6) const {
249  //Index from 6 dimension to 1 dimension
250  Int_t i;
251  i = i1 + fN1 * (i2 + fN2 * (i3 + fN3 * (i4 + fN4 * (i5 + fN5 * i6))));
252  if ((i >= fNL - 1) || (i < 0)) {
253  i = fNL - 1;
254  Error("OneDim", "Index outside bounds");
255  }
256  return i;
257 }
258 void TEcnaNArrayD::ReSet(Int_t n1) {
259  //Reset this to be 1 dimensional of dimension n1
260  const Double_t zero = 0.0;
261  Clean();
262  fNd = 1;
263  fN1 = n1;
264  fNL = n1 + 1;
265  fA = new Double_t[fNL];
266  for (Int_t i = 0; i < fNL; i++)
267  fA[i] = zero;
268 }
269 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2) {
270  //Reset this to be 2 dimensional of dimension n1,n2
271  const Double_t zero = 0.0;
272  Clean();
273  fNd = 2;
274  fN1 = n1;
275  fN2 = n2;
276  fNL = n1 * n2 + 1;
277  fA = new Double_t[fNL];
278  for (Int_t i = 0; i < fNL; i++)
279  fA[i] = zero;
280 }
281 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3) {
282  //Reset this to be 3 dimensional of dimension n1,n2,n3
283  const Double_t zero = 0.0;
284  Clean();
285  fNd = 3;
286  fN1 = n1;
287  fN2 = n2;
288  fN3 = n3;
289  fNL = n1 * n2 * n3 + 1;
290  fA = new Double_t[fNL];
291  for (Int_t i = 0; i < fNL; i++)
292  fA[i] = zero;
293 }
294 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3, Int_t n4) {
295  //Reset this to be 4 dimensional of dimension n1,n2,n3,n4
296  const Double_t zero = 0.0;
297  Clean();
298  fNd = 4;
299  fN1 = n1;
300  fN2 = n2;
301  fN3 = n3;
302  fN4 = n4;
303  fNL = n1 * n2 * n3 * n4 + 1;
304  fA = new Double_t[fNL];
305  for (Int_t i = 0; i < fNL; i++)
306  fA[i] = zero;
307 }
308 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5) {
309  //Reset this to be 5 dimensional of dimension n1,n2,n3,n4,n5
310  const Double_t zero = 0.0;
311  Clean();
312  fNd = 5;
313  fN1 = n1;
314  fN2 = n2;
315  fN3 = n3;
316  fN4 = n4;
317  fN5 = n5;
318  fNL = n1 * n2 * n3 * n4 * n5 + 1;
319  fA = new Double_t[fNL];
320  for (Int_t i = 0; i < fNL; i++)
321  fA[i] = zero;
322 }
323 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6) {
324  //Reset this to be 6 dimensional of dimension n1,n2,n3,n4,n5,n6
325  const Double_t zero = 0.0;
326  Clean();
327  fNd = 6;
328  fN1 = n1;
329  fN2 = n2;
330  fN3 = n3;
331  fN4 = n4;
332  fN5 = n5;
333  fN6 = n6;
334  fNL = n1 * n2 * n3 * n4 * n5 * n6 + 1;
335  fA = new Double_t[fNL];
336  for (Int_t i = 0; i < fNL; i++)
337  fA[i] = zero;
338 }
339 Double_t &TEcnaNArrayD::operator()(Int_t i1) {
340  Int_t i;
341  i = OneDim(i1);
342  return fA[i];
343 }
344 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2) {
345  Int_t i;
346  i = OneDim(i1, i2);
347  return fA[i];
348 }
349 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3) {
350  Int_t i;
351  i = OneDim(i1, i2, i3);
352  return fA[i];
353 }
354 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4) {
355  Int_t i;
356  i = OneDim(i1, i2, i3, i4);
357  return fA[i];
358 }
359 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5) {
360  Int_t i;
361  i = OneDim(i1, i2, i3, i4, i5);
362  return fA[i];
363 }
364 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5, Int_t i6) {
365  Int_t i;
366  i = OneDim(i1, i2, i3, i4, i5, i6);
367  return fA[i];
368 }
369 const Double_t &TEcnaNArrayD::operator()(Int_t i1) const { return const_cast<TEcnaNArrayD *>(this)->operator()(i1); }
370 const Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2) const {
371  return const_cast<TEcnaNArrayD *>(this)->operator()(i1, i2);
372 }
373 const Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3) const {
374  return const_cast<TEcnaNArrayD *>(this)->operator()(i1, i2, i3);
375 }
376 const Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4) const {
377  return const_cast<TEcnaNArrayD *>(this)->operator()(i1, i2, i3, i4);
378 }
379 const Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5) const {
380  return const_cast<TEcnaNArrayD *>(this)->operator()(i1, i2, i3, i4, i5);
381 }
382 const Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5, Int_t i6) const {
383  return const_cast<TEcnaNArrayD *>(this)->operator()(i1, i2, i3, i4, i5, i6);
384 }
edm::ErrorSummaryEntry Error
const Double_t & operator()(Int_t i1) const
Bool_t RegisterPointer(const TString &, const Long_t &)
Definition: TEcnaObject.cc:100
Double_t * fA
Definition: TEcnaNArrayD.h:32
ClassImp(AliDaqEventHeader)
Int_t OneDim(Int_t) const
void ReSet(Int_t)
tuple cout
Definition: gather_cfg.py:144
~TEcnaNArrayD() override