CMS 3D CMS Logo

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 
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++) fA[i] = orig.fA[i];
48 }
49 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject* pObjectManager, Int_t n1) {
50 //constructor for a 1 dimensional array of size n1. Array is put to 0
51 
52  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
53 
54  Long_t i_this = (Long_t)this;
55  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
56 
57  const Double_t zero = 0.0;
58  Init();
59  fNd = 1;
60  fN1 = n1;
61  fNL = n1 + 1;
62  fA = new Double_t [fNL];
63  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
64 }
65 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject* pObjectManager, Int_t n1,Int_t n2) {
66 //constructor for a 2 dimensional array of sizes n1,n2. Array is put to 0
67 
68  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
69 
70  Long_t i_this = (Long_t)this;
71  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
72 
73  const Double_t zero = 0.0;
74  Init();
75  fNd = 2;
76  fN1 = n1;
77  fN2 = n2;
78  fNL = n1*n2 + 1;
79  fA = new Double_t [fNL];
80  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
81 }
82 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject* pObjectManager, Int_t n1,Int_t n2,Int_t n3) {
83 //constructor 3 dimensional array of sizes n1,n2,n3. Array is put to 0
84 
85  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
86 
87  Long_t i_this = (Long_t)this;
88  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
89 
90  const Double_t zero = 0.0;
91  Init();
92  fNd = 3;
93  fN1 = n1;
94  fN2 = n2;
95  fN3 = n3;
96  fNL = n1*n2*n3 + 1;
97  fA = new Double_t [fNL];
98  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
99 }
100 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject* pObjectManager, Int_t n1,Int_t n2,Int_t n3,Int_t n4) {
101 //constructor for a 4 dimensional array of sizes n1,n2,n3,n4. Array is put to 0
102 
103  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
104 
105  Long_t i_this = (Long_t)this;
106  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
107 
108  const Double_t zero = 0.0;
109  Init();
110  fNd = 4;
111  fN1 = n1;
112  fN2 = n2;
113  fN3 = n3;
114  fN4 = n4;
115  fNL = n1*n2*n3*n4 + 1;
116  fA = new Double_t [fNL];
117  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
118 }
119 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject* pObjectManager, Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5) {
120 //constructor for a 5 dimensional array of sizes n1,n2,n3,n4,n5. Array is put to 0
121 
122  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
123 
124  Long_t i_this = (Long_t)this;
125  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
126 
127  const Double_t zero = 0.0;
128  Init();
129  fNd = 5;
130  fN1 = n1;
131  fN2 = n2;
132  fN3 = n3;
133  fN4 = n4;
134  fN5 = n5;
135  fNL = n1*n2*n3*n4*n5 + 1;
136  fA = new Double_t [fNL];
137  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
138 }
139 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject* pObjectManager, Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5,Int_t n6) {
140 //constructor for a 6 dimensional array of sizes n1,n2,n3,n4,n5,n6. Array is put to 0
141 
142  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. CREATE OBJECT: this = " << this << std::endl;
143 
144  Long_t i_this = (Long_t)this;
145  pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
146 
147  const Double_t zero = 0.0;
148  Init();
149  fNd = 6;
150  fN1 = n1;
151  fN2 = n2;
152  fN3 = n3;
153  fN4 = n4;
154  fN5 = n5;
155  fN6 = n6;
156  fNL = n1*n2*n3*n4*n5*n6 + 1;
157  fA = new Double_t [fNL];
158  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
159 }
160 
162 //destructor
163 
164  // std::cout << "[Info Management] CLASS: TEcnaNArrayD. DESTROY OBJECT: this = " << this << std::endl;
165 
166  Clean();
167 }
168 
169 //------------------------------------- methods
170 
172 //
173  if (fA) delete [] fA;
174  Init();
175 }
177 {
178 //Initialization
179  fNd = 0;
180  fN1 = 1;
181  fN2 = 1;
182  fN3 = 1;
183  fN4 = 1;
184  fN5 = 1;
185  fN6 = 1;
186  fNL = 0;
187  fA = 0;
188 }
189 inline Int_t TEcnaNArrayD::OneDim(Int_t i1) const {
190 //Index from 1 dimension to 1 dimension
191  if ((i1>=fNL - 1) || (i1<0)) {
192  i1 = fNL - 1;
193  Error("OneDim","Index outside bounds");
194  std::cout << "i1 = " << i1
195  << "; fNL = " << fNL << std::endl;
196  }
197  return i1;
198 }
199 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2) const {
200 //Index from 2 dimension to 1 dimension
201  Int_t i;
202  i = i1 + fN1*i2;
203  if ((i>=fNL - 1) || (i<0)) {
204  i = fNL - 1;
205  Error("OneDim","Index outside bounds");
206  std::cout << "i1 = " << i1 << ", i2 = " << i2
207  << "; fN1 = " << fN1 << ", fNL = " << fNL << std::endl;
208  }
209  return i;
210 }
211 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3) const {
212 //Index from 3 dimension to 1 dimension
213  Int_t i;
214  i = i1 + fN1*(i2 + fN2*i3);
215  if ((i>=fNL - 1) || (i<0)) {
216  i = fNL - 1;
217  Error("OneDim","Index outside bounds");
218  std::cout << "i1 = " << i1 << ", i2 = " << i2 << ", i3 = " << i3
219  << "; fN1 = " << fN1 << ", fN2 = " << fN2 << ", fNL = " << fNL << std::endl;
220  }
221  return i;
222 }
223 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3,Int_t i4) const {
224 //Index from 4 dimension to 1 dimension
225  Int_t i;
226  i = i1 + fN1*(i2 + fN2*(i3 + fN3*i4));
227  if ((i>=fNL - 1) || (i<0)) {
228  i = fNL - 1;
229  Error("OneDim","Index outside bounds");
230  }
231  return i;
232 }
233 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5) const {
234 //Index from 5 dimension to 1 dimension
235  Int_t i;
236  i = i1 + fN1*(i2 + fN2*(i3 + fN3*(i4 + fN4*i5)));
237  if ((i>=fNL - 1) || (i<0)) {
238  i = fNL - 1;
239  Error("OneDim","Index outside bounds");
240  }
241  return i;
242 }
243 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5,Int_t i6) const {
244 //Index from 6 dimension to 1 dimension
245  Int_t i;
246  i = i1 + fN1*(i2 + fN2*(i3 + fN3*(i4 + fN4*(i5 + fN5*i6))));
247  if ((i>=fNL - 1) || (i<0)) {
248  i = fNL - 1;
249  Error("OneDim","Index outside bounds");
250  }
251  return i;
252 }
253 void TEcnaNArrayD::ReSet(Int_t n1) {
254 //Reset this to be 1 dimensional of dimension n1
255  const Double_t zero = 0.0;
256  Clean();
257  fNd = 1;
258  fN1 = n1;
259  fNL = n1 + 1;
260  fA = new Double_t [fNL];
261  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
262 }
263 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2) {
264 //Reset this to be 2 dimensional of dimension n1,n2
265  const Double_t zero = 0.0;
266  Clean();
267  fNd = 2;
268  fN1 = n1;
269  fN2 = n2;
270  fNL = n1*n2 + 1;
271  fA = new Double_t [fNL];
272  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
273 }
274 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3) {
275 //Reset this to be 3 dimensional of dimension n1,n2,n3
276  const Double_t zero = 0.0;
277  Clean();
278  fNd = 3;
279  fN1 = n1;
280  fN2 = n2;
281  fN3 = n3;
282  fNL = n1*n2*n3 + 1;
283  fA = new Double_t [fNL];
284  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
285 }
286 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3,Int_t n4) {
287 //Reset this to be 4 dimensional of dimension n1,n2,n3,n4
288  const Double_t zero = 0.0;
289  Clean();
290  fNd = 4;
291  fN1 = n1;
292  fN2 = n2;
293  fN3 = n3;
294  fN4 = n4;
295  fNL = n1*n2*n3*n4 + 1;
296  fA = new Double_t [fNL];
297  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
298 }
299 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5) {
300 //Reset this to be 5 dimensional of dimension n1,n2,n3,n4,n5
301  const Double_t zero = 0.0;
302  Clean();
303  fNd = 5;
304  fN1 = n1;
305  fN2 = n2;
306  fN3 = n3;
307  fN4 = n4;
308  fN5 = n5;
309  fNL = n1*n2*n3*n4*n5 + 1;
310  fA = new Double_t [fNL];
311  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
312 }
313 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5,Int_t n6) {
314 //Reset this to be 6 dimensional of dimension n1,n2,n3,n4,n5,n6
315  const Double_t zero = 0.0;
316  Clean();
317  fNd = 6;
318  fN1 = n1;
319  fN2 = n2;
320  fN3 = n3;
321  fN4 = n4;
322  fN5 = n5;
323  fN6 = n6;
324  fNL = n1*n2*n3*n4*n5*n6 + 1;
325  fA = new Double_t [fNL];
326  for (Int_t i=0;i<fNL;i++) fA[i] = zero;
327 }
328 Double_t &TEcnaNArrayD::operator()(Int_t i1) {
329  Int_t i;
330  i = OneDim(i1);
331  return fA[i];
332 }
333 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2) {
334  Int_t i;
335  i = OneDim(i1,i2);
336  return fA[i];
337 }
338 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3) {
339  Int_t i;
340  i = OneDim(i1,i2,i3);
341  return fA[i];
342 }
343 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4) {
344  Int_t i;
345  i = OneDim(i1,i2,i3,i4);
346  return fA[i];
347 }
348 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5) {
349  Int_t i;
350  i = OneDim(i1,i2,i3,i4,i5);
351  return fA[i];
352 }
353 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5,Int_t i6) {
354  Int_t i;
355  i = OneDim(i1,i2,i3,i4,i5,i6);
356  return fA[i];
357 }
358 const Double_t &TEcnaNArrayD::operator()(Int_t i1) const
359 {
360  return (Double_t&)(this->operator()(i1));
361 }
362 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2) const
363 {
364  return (Double_t&)(this->operator()(i1,i2));
365 }
366 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3) const
367 {
368  return (Double_t&)(this->operator()(i1,i2,i3));
369 }
370 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4) const
371 {
372  return (Double_t&)(this->operator()(i1,i2,i3,i4));
373 }
374 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5) const
375 {
376  return (Double_t&)(this->operator()(i1,i2,i3,i4,i5));
377 }
378 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5,Int_t i6) const
379 {
380  return (Double_t&)(this->operator()(i1,i2,i3,i4,i5,i6));
381 }
const Double_t & operator()(Int_t i1) const
Bool_t RegisterPointer(const TString &, const Long_t &)
Definition: TEcnaObject.cc:105
Double_t * fA
Definition: TEcnaNArrayD.h:34
ClassImp(TEcnaNArrayD) TEcnaNArrayD
Definition: TEcnaNArrayD.cc:14
Int_t OneDim(Int_t) const
virtual ~TEcnaNArrayD()
void ReSet(Int_t)