CMS 3D CMS Logo

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