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