CMS 3D CMS Logo

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