CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/src/TEcnaNArrayD.cc

Go to the documentation of this file.
00001 //----------Author's Name:F.X. Gentit + modifs by B.Fabbro DSM/IRFU/SPP CEA-Saclay
00002 //----------Copyright:Those valid for CEA sofware
00003 //----------Modified:17/03/2010
00004 
00005 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaNArrayD.h"
00006 #include "Riostream.h"
00007 
00008 ClassImp(TEcnaNArrayD)
00009 //______________________________________________________________________________
00010 //
00011 // TEcnaNArrayD  ROOT class for multidimensional arrays of Double_t
00012 //
00013 //   up to dimension 6
00014 //   book one place more for overflow
00015 //   detects overflow
00016 //
00017 
00018 TEcnaNArrayD::TEcnaNArrayD(){
00019 //constructor without argument
00020 
00021  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00022 
00023   Init();
00024 }
00025 
00026 TEcnaNArrayD::TEcnaNArrayD(const TEcnaNArrayD &orig) {
00027 //copy constructor
00028 
00029  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00030 
00031   fNd = orig.fNd;
00032   fN1 = orig.fN1;
00033   fN2 = orig.fN2;
00034   fN3 = orig.fN3;
00035   fN4 = orig.fN4;
00036   fN5 = orig.fN5;
00037   fN6 = orig.fN6;
00038   fNL = orig.fNL;
00039   fA  = new Double_t [fNL];
00040   for (Int_t i=0;i<fNL;i++) fA[i] = orig.fA[i];
00041 }
00042 TEcnaNArrayD::TEcnaNArrayD(Int_t n1) {
00043 //constructor for a 1 dimensional array of size n1. Array is put to 0
00044 
00045  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00046 
00047   const Double_t zero = 0.0;
00048   Init();
00049   fNd  = 1;
00050   fN1  = n1;
00051   fNL  = n1 + 1;
00052   fA   = new Double_t [fNL];
00053   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00054 }
00055 TEcnaNArrayD::TEcnaNArrayD(Int_t n1,Int_t n2) {
00056 //constructor for a 2 dimensional array of sizes n1,n2. Array is put to 0
00057 
00058  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00059 
00060   const Double_t zero = 0.0;
00061   Init();
00062   fNd = 2;
00063   fN1 = n1;
00064   fN2 = n2;
00065   fNL = n1*n2 + 1;
00066   fA  = new Double_t [fNL];
00067   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00068 }
00069 TEcnaNArrayD::TEcnaNArrayD(Int_t n1,Int_t n2,Int_t n3) {
00070 //constructor 3 dimensional array of sizes n1,n2,n3. Array is put to 0
00071 
00072  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00073 
00074   const Double_t zero = 0.0;
00075   Init();
00076   fNd  = 3;
00077   fN1  = n1;
00078   fN2  = n2;
00079   fN3  = n3;
00080   fNL  = n1*n2*n3 + 1;
00081   fA   = new Double_t [fNL];
00082   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00083 }
00084 TEcnaNArrayD::TEcnaNArrayD(Int_t n1,Int_t n2,Int_t n3,Int_t n4) {
00085 //constructor for a 4 dimensional array of sizes n1,n2,n3,n4. Array is put to 0
00086 
00087  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00088 
00089   const Double_t zero = 0.0;
00090   Init();
00091   fNd  = 4;
00092   fN1  = n1;
00093   fN2  = n2;
00094   fN3  = n3;
00095   fN4  = n4;
00096   fNL  = n1*n2*n3*n4 + 1;
00097   fA   = new Double_t [fNL];
00098   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00099 }
00100 TEcnaNArrayD::TEcnaNArrayD(Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5) {
00101 //constructor for a 5 dimensional array of sizes n1,n2,n3,n4,n5. Array is put to 0
00102 
00103  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00104 
00105   const Double_t zero = 0.0;
00106   Init();
00107   fNd  = 5;
00108   fN1  = n1;
00109   fN2  = n2;
00110   fN3  = n3;
00111   fN4  = n4;
00112   fN5  = n5;
00113   fNL  = n1*n2*n3*n4*n5 + 1;
00114   fA   = new Double_t [fNL];
00115   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00116 }
00117 TEcnaNArrayD::TEcnaNArrayD(Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5,Int_t n6) {
00118 //constructor for a 6 dimensional array of sizes n1,n2,n3,n4,n5,n6. Array is put to 0
00119 
00120  // cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << endl;
00121 
00122   const Double_t zero = 0.0;
00123   Init();
00124   fNd  = 6;
00125   fN1  = n1;
00126   fN2  = n2;
00127   fN3  = n3;
00128   fN4  = n4;
00129   fN5  = n5;
00130   fN6  = n6;
00131   fNL  = n1*n2*n3*n4*n5*n6 + 1;
00132   fA   = new Double_t [fNL];
00133   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00134 }
00135 TEcnaNArrayD::~TEcnaNArrayD() {
00136 //destructor
00137 
00138  // cout << "[Info Management] CLASS: TEcnaNArrayD.          DESTROY OBJECT: this = " << this << endl;
00139 
00140   Clean();
00141 }
00142 void TEcnaNArrayD::Clean() {
00143 //
00144   if (fA) delete [] fA;
00145   Init();
00146 }
00147 void TEcnaNArrayD::Init()
00148 {
00149 //Initialization
00150   fNd  = 0;
00151   fN1  = 1;
00152   fN2  = 1;
00153   fN3  = 1;
00154   fN4  = 1;
00155   fN5  = 1;
00156   fN6  = 1;
00157   fNL  = 0;
00158   fA   = 0;
00159 }
00160 inline Int_t TEcnaNArrayD::OneDim(Int_t i1) const {
00161 //Index from 1 dimension to 1 dimension
00162   if ((i1>=fNL - 1) || (i1<0)) {
00163     i1 = fNL - 1;
00164     Error("OneDim","Index outside bounds");
00165     cout << "i1  = " << i1
00166     << "; fNL = " << fNL << endl;
00167   }
00168   return i1;
00169 }
00170 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2) const {
00171 //Index from 2 dimension to 1 dimension
00172   Int_t i;
00173   i = i1 + fN1*i2;
00174   if ((i>=fNL - 1) || (i<0)) {
00175     i = fNL - 1;
00176     Error("OneDim","Index outside bounds");
00177     cout << "i1  = " << i1  << ", i2 = "  << i2
00178          << "; fN1 = " << fN1 << ", fNL = " << fNL << endl;
00179   }
00180   return i;
00181 }
00182 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3) const {
00183 //Index from 3 dimension to 1 dimension
00184   Int_t i;
00185   i = i1 + fN1*(i2 + fN2*i3);
00186   if ((i>=fNL - 1) || (i<0)) {
00187     i = fNL - 1;
00188     Error("OneDim","Index outside bounds");
00189     cout << "i1  = " << i1  << ", i2 = "  << i2  << ", i3 = "  << i3
00190          << "; fN1 = " << fN1 << ", fN2 = " << fN2 << ", fNL = " << fNL << endl;
00191   }
00192   return i;
00193 }
00194 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3,Int_t i4) const {
00195 //Index from 4 dimension to 1 dimension
00196   Int_t i;
00197   i = i1 + fN1*(i2 + fN2*(i3 + fN3*i4));
00198   if ((i>=fNL - 1) || (i<0)) {
00199     i = fNL - 1;
00200     Error("OneDim","Index outside bounds");
00201   }
00202   return i;
00203 }
00204 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5) const {
00205 //Index from 5 dimension to 1 dimension
00206   Int_t i;
00207   i = i1 + fN1*(i2 + fN2*(i3 + fN3*(i4 + fN4*i5)));
00208   if ((i>=fNL - 1) || (i<0)) {
00209     i = fNL - 1;
00210     Error("OneDim","Index outside bounds");
00211   }
00212   return i;
00213 }
00214 inline Int_t TEcnaNArrayD::OneDim(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5,Int_t i6) const {
00215 //Index from 6 dimension to 1 dimension
00216   Int_t i;
00217   i = i1 + fN1*(i2 + fN2*(i3 + fN3*(i4 + fN4*(i5 + fN5*i6))));
00218   if ((i>=fNL - 1) || (i<0)) {
00219     i = fNL - 1;
00220     Error("OneDim","Index outside bounds");
00221   }
00222   return i;
00223 }
00224 void TEcnaNArrayD::ReSet(Int_t n1) {
00225 //Reset this to be 1 dimensional of dimension n1
00226   const Double_t zero = 0.0;
00227   Clean();
00228   fNd  = 1;
00229   fN1  = n1;
00230   fNL  = n1 + 1;
00231   fA   = new Double_t [fNL];
00232   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00233 }
00234 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2) {
00235 //Reset this to be 2 dimensional of dimension n1,n2
00236   const Double_t zero = 0.0;
00237   Clean();
00238   fNd  = 2;
00239   fN1  = n1;
00240   fN2  = n2;
00241   fNL  = n1*n2 + 1;
00242   fA   = new Double_t [fNL];
00243   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00244 }
00245 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3) {
00246 //Reset this to be 3 dimensional of dimension n1,n2,n3
00247   const Double_t zero = 0.0;
00248   Clean();
00249   fNd  = 3;
00250   fN1  = n1;
00251   fN2  = n2;
00252   fN3  = n3;
00253   fNL  = n1*n2*n3 + 1;
00254   fA   = new Double_t [fNL];
00255   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00256 }
00257 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3,Int_t n4) {
00258 //Reset this to be 4 dimensional of dimension n1,n2,n3,n4
00259   const Double_t zero = 0.0;
00260   Clean();
00261   fNd  = 4;
00262   fN1  = n1;
00263   fN2  = n2;
00264   fN3  = n3;
00265   fN4  = n4;
00266   fNL  = n1*n2*n3*n4 + 1;
00267   fA   = new Double_t [fNL];
00268   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00269 }
00270 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5) {
00271 //Reset this to be 5 dimensional of dimension n1,n2,n3,n4,n5
00272   const Double_t zero = 0.0;
00273   Clean();
00274   fNd  = 5;
00275   fN1  = n1;
00276   fN2  = n2;
00277   fN3  = n3;
00278   fN4  = n4;
00279   fN5  = n5;
00280   fNL  = n1*n2*n3*n4*n5 + 1;
00281   fA   = new Double_t [fNL];
00282   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00283 }
00284 void TEcnaNArrayD::ReSet(Int_t n1,Int_t n2,Int_t n3,Int_t n4,Int_t n5,Int_t n6) {
00285 //Reset this to be 6 dimensional of dimension n1,n2,n3,n4,n5,n6
00286   const Double_t zero = 0.0;
00287   Clean();
00288   fNd  = 6;
00289   fN1  = n1;
00290   fN2  = n2;
00291   fN3  = n3;
00292   fN4  = n4;
00293   fN5  = n5;
00294   fN6  = n6;
00295   fNL  = n1*n2*n3*n4*n5*n6 + 1;
00296   fA   = new Double_t [fNL];
00297   for (Int_t i=0;i<fNL;i++) fA[i] = zero;
00298 }
00299 const Double_t &TEcnaNArrayD::operator()(Int_t i1) const {
00300   Int_t i;
00301   i = OneDim(i1);
00302   return fA[i];
00303 }
00304 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2) const {
00305   Int_t i;
00306   i = OneDim(i1,i2);
00307   return fA[i];
00308 }
00309 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3) const {
00310   Int_t i;
00311   i = OneDim(i1,i2,i3);
00312   return fA[i];
00313 }
00314 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4) const {
00315   Int_t i;
00316   i = OneDim(i1,i2,i3,i4);
00317   return fA[i];
00318 }
00319 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5) const {
00320   Int_t i;
00321   i = OneDim(i1,i2,i3,i4,i5);
00322   return fA[i];
00323 }
00324 const Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5,Int_t i6) const {
00325   Int_t i;
00326   i = OneDim(i1,i2,i3,i4,i5,i6);
00327   return fA[i];
00328 }
00329 Double_t &TEcnaNArrayD::operator()(Int_t i1)
00330 {
00331    return (Double_t&)((*(const TEcnaNArrayD *)this)(i1));
00332 }
00333 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2)
00334 {
00335    return (Double_t&)((*(const TEcnaNArrayD *)this)(i1,i2));
00336 }
00337 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3)
00338 {
00339    return (Double_t&)((*(const TEcnaNArrayD *)this)(i1,i2,i3));
00340 }
00341 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4)
00342 {
00343    return (Double_t&)((*(const TEcnaNArrayD *)this)(i1,i2,i3,i4));
00344 }
00345 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5)
00346 {
00347    return (Double_t&)((*(const TEcnaNArrayD *)this)(i1,i2,i3,i4,i5));
00348 }
00349 Double_t &TEcnaNArrayD::operator()(Int_t i1,Int_t i2,Int_t i3,Int_t i4,Int_t i5,Int_t i6)
00350 {
00351    return (Double_t&)((*(const TEcnaNArrayD *)this)(i1,i2,i3,i4,i5,i6));
00352 }
00353