Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-06 07:38:04

0001 //----------Author's Name:F.X. Gentit + modifs by B.Fabbro DSM/IRFU/SPP CEA-Saclay
0002 //----------Copyright:Those valid for CEA sofware
0003 //----------Modified:24/03/2011
0004 
0005 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaNArrayD.h"
0006 #include "Riostream.h"
0007 
0008 //--------------------------------------
0009 //  TEcnaNArrayD.cc
0010 //  Class creation: 03 Dec 2002
0011 //  Documentation: see TEcnaNArrayD.h
0012 //--------------------------------------
0013 
0014 ClassImp(TEcnaNArrayD);
0015 //______________________________________________________________________________
0016 //
0017 
0018 // TEcnaNArrayD  ROOT class for multidimensional arrays of Double_t
0019 //
0020 //   up to dimension 6
0021 //   book one place more for overflow
0022 //   detects overflow
0023 //
0024 
0025 TEcnaNArrayD::TEcnaNArrayD() {
0026   //constructor without argument
0027 
0028   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0029 
0030   Init();
0031 }
0032 
0033 TEcnaNArrayD::TEcnaNArrayD(const TEcnaNArrayD &orig) : TObject::TObject(orig) {
0034   //copy constructor
0035 
0036   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0037 
0038   fNd = orig.fNd;
0039   fN1 = orig.fN1;
0040   fN2 = orig.fN2;
0041   fN3 = orig.fN3;
0042   fN4 = orig.fN4;
0043   fN5 = orig.fN5;
0044   fN6 = orig.fN6;
0045   fNL = orig.fNL;
0046   fA = new Double_t[fNL];
0047   for (Int_t i = 0; i < fNL; i++)
0048     fA[i] = orig.fA[i];
0049 }
0050 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1) {
0051   //constructor for a 1 dimensional array of size n1. Array is put to 0
0052 
0053   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0054 
0055   Long_t i_this = (Long_t)this;
0056   pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
0057 
0058   const Double_t zero = 0.0;
0059   Init();
0060   fNd = 1;
0061   fN1 = n1;
0062   fNL = n1 + 1;
0063   fA = new Double_t[fNL];
0064   for (Int_t i = 0; i < fNL; i++)
0065     fA[i] = zero;
0066 }
0067 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2) {
0068   //constructor for a 2 dimensional array of sizes n1,n2. Array is put to 0
0069 
0070   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0071 
0072   Long_t i_this = (Long_t)this;
0073   pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
0074 
0075   const Double_t zero = 0.0;
0076   Init();
0077   fNd = 2;
0078   fN1 = n1;
0079   fN2 = n2;
0080   fNL = n1 * n2 + 1;
0081   fA = new Double_t[fNL];
0082   for (Int_t i = 0; i < fNL; i++)
0083     fA[i] = zero;
0084 }
0085 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3) {
0086   //constructor 3 dimensional array of sizes n1,n2,n3. Array is put to 0
0087 
0088   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0089 
0090   Long_t i_this = (Long_t)this;
0091   pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
0092 
0093   const Double_t zero = 0.0;
0094   Init();
0095   fNd = 3;
0096   fN1 = n1;
0097   fN2 = n2;
0098   fN3 = n3;
0099   fNL = n1 * n2 * n3 + 1;
0100   fA = new Double_t[fNL];
0101   for (Int_t i = 0; i < fNL; i++)
0102     fA[i] = zero;
0103 }
0104 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3, Int_t n4) {
0105   //constructor for a 4 dimensional array of sizes n1,n2,n3,n4. Array is put to 0
0106 
0107   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0108 
0109   Long_t i_this = (Long_t)this;
0110   pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
0111 
0112   const Double_t zero = 0.0;
0113   Init();
0114   fNd = 4;
0115   fN1 = n1;
0116   fN2 = n2;
0117   fN3 = n3;
0118   fN4 = n4;
0119   fNL = n1 * n2 * n3 * n4 + 1;
0120   fA = new Double_t[fNL];
0121   for (Int_t i = 0; i < fNL; i++)
0122     fA[i] = zero;
0123 }
0124 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5) {
0125   //constructor for a 5 dimensional array of sizes n1,n2,n3,n4,n5. Array is put to 0
0126 
0127   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0128 
0129   Long_t i_this = (Long_t)this;
0130   pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
0131 
0132   const Double_t zero = 0.0;
0133   Init();
0134   fNd = 5;
0135   fN1 = n1;
0136   fN2 = n2;
0137   fN3 = n3;
0138   fN4 = n4;
0139   fN5 = n5;
0140   fNL = n1 * n2 * n3 * n4 * n5 + 1;
0141   fA = new Double_t[fNL];
0142   for (Int_t i = 0; i < fNL; i++)
0143     fA[i] = zero;
0144 }
0145 TEcnaNArrayD::TEcnaNArrayD(TEcnaObject *pObjectManager, Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6) {
0146   //constructor for a 6 dimensional array of sizes n1,n2,n3,n4,n5,n6. Array is put to 0
0147 
0148   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          CREATE OBJECT: this = " << this << std::endl;
0149 
0150   Long_t i_this = (Long_t)this;
0151   pObjectManager->RegisterPointer("TEcnaNArrayD", i_this);
0152 
0153   const Double_t zero = 0.0;
0154   Init();
0155   fNd = 6;
0156   fN1 = n1;
0157   fN2 = n2;
0158   fN3 = n3;
0159   fN4 = n4;
0160   fN5 = n5;
0161   fN6 = n6;
0162   fNL = n1 * n2 * n3 * n4 * n5 * n6 + 1;
0163   fA = new Double_t[fNL];
0164   for (Int_t i = 0; i < fNL; i++)
0165     fA[i] = zero;
0166 }
0167 
0168 TEcnaNArrayD::~TEcnaNArrayD() {
0169   //destructor
0170 
0171   // std::cout << "[Info Management] CLASS: TEcnaNArrayD.          DESTROY OBJECT: this = " << this << std::endl;
0172 
0173   Clean();
0174 }
0175 
0176 //------------------------------------- methods
0177 
0178 void TEcnaNArrayD::Clean() {
0179   //
0180   if (fA)
0181     delete[] fA;
0182   Init();
0183 }
0184 void TEcnaNArrayD::Init() {
0185   //Initialization
0186   fNd = 0;
0187   fN1 = 1;
0188   fN2 = 1;
0189   fN3 = 1;
0190   fN4 = 1;
0191   fN5 = 1;
0192   fN6 = 1;
0193   fNL = 0;
0194   fA = nullptr;
0195 }
0196 inline Int_t TEcnaNArrayD::OneDim(Int_t i1) const {
0197   //Index from 1 dimension to 1 dimension
0198   if ((i1 >= fNL - 1) || (i1 < 0)) {
0199     i1 = fNL - 1;
0200     Error("OneDim", "Index outside bounds");
0201     std::cout << "i1  = " << i1 << "; fNL = " << fNL << std::endl;
0202   }
0203   return i1;
0204 }
0205 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2) const {
0206   //Index from 2 dimension to 1 dimension
0207   Int_t i;
0208   i = i1 + fN1 * i2;
0209   if ((i >= fNL - 1) || (i < 0)) {
0210     i = fNL - 1;
0211     Error("OneDim", "Index outside bounds");
0212     std::cout << "i1  = " << i1 << ", i2 = " << i2 << "; fN1 = " << fN1 << ", fNL = " << fNL << std::endl;
0213   }
0214   return i;
0215 }
0216 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3) const {
0217   //Index from 3 dimension to 1 dimension
0218   Int_t i;
0219   i = i1 + fN1 * (i2 + fN2 * i3);
0220   if ((i >= fNL - 1) || (i < 0)) {
0221     i = fNL - 1;
0222     Error("OneDim", "Index outside bounds");
0223     std::cout << "i1  = " << i1 << ", i2 = " << i2 << ", i3 = " << i3 << "; fN1 = " << fN1 << ", fN2 = " << fN2
0224               << ", fNL = " << fNL << std::endl;
0225   }
0226   return i;
0227 }
0228 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3, Int_t i4) const {
0229   //Index from 4 dimension to 1 dimension
0230   Int_t i;
0231   i = i1 + fN1 * (i2 + fN2 * (i3 + fN3 * i4));
0232   if ((i >= fNL - 1) || (i < 0)) {
0233     i = fNL - 1;
0234     Error("OneDim", "Index outside bounds");
0235   }
0236   return i;
0237 }
0238 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5) const {
0239   //Index from 5 dimension to 1 dimension
0240   Int_t i;
0241   i = i1 + fN1 * (i2 + fN2 * (i3 + fN3 * (i4 + fN4 * i5)));
0242   if ((i >= fNL - 1) || (i < 0)) {
0243     i = fNL - 1;
0244     Error("OneDim", "Index outside bounds");
0245   }
0246   return i;
0247 }
0248 inline Int_t TEcnaNArrayD::OneDim(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5, Int_t i6) const {
0249   //Index from 6 dimension to 1 dimension
0250   Int_t i;
0251   i = i1 + fN1 * (i2 + fN2 * (i3 + fN3 * (i4 + fN4 * (i5 + fN5 * i6))));
0252   if ((i >= fNL - 1) || (i < 0)) {
0253     i = fNL - 1;
0254     Error("OneDim", "Index outside bounds");
0255   }
0256   return i;
0257 }
0258 void TEcnaNArrayD::ReSet(Int_t n1) {
0259   //Reset this to be 1 dimensional of dimension n1
0260   const Double_t zero = 0.0;
0261   Clean();
0262   fNd = 1;
0263   fN1 = n1;
0264   fNL = n1 + 1;
0265   fA = new Double_t[fNL];
0266   for (Int_t i = 0; i < fNL; i++)
0267     fA[i] = zero;
0268 }
0269 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2) {
0270   //Reset this to be 2 dimensional of dimension n1,n2
0271   const Double_t zero = 0.0;
0272   Clean();
0273   fNd = 2;
0274   fN1 = n1;
0275   fN2 = n2;
0276   fNL = n1 * n2 + 1;
0277   fA = new Double_t[fNL];
0278   for (Int_t i = 0; i < fNL; i++)
0279     fA[i] = zero;
0280 }
0281 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3) {
0282   //Reset this to be 3 dimensional of dimension n1,n2,n3
0283   const Double_t zero = 0.0;
0284   Clean();
0285   fNd = 3;
0286   fN1 = n1;
0287   fN2 = n2;
0288   fN3 = n3;
0289   fNL = n1 * n2 * n3 + 1;
0290   fA = new Double_t[fNL];
0291   for (Int_t i = 0; i < fNL; i++)
0292     fA[i] = zero;
0293 }
0294 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3, Int_t n4) {
0295   //Reset this to be 4 dimensional of dimension n1,n2,n3,n4
0296   const Double_t zero = 0.0;
0297   Clean();
0298   fNd = 4;
0299   fN1 = n1;
0300   fN2 = n2;
0301   fN3 = n3;
0302   fN4 = n4;
0303   fNL = n1 * n2 * n3 * n4 + 1;
0304   fA = new Double_t[fNL];
0305   for (Int_t i = 0; i < fNL; i++)
0306     fA[i] = zero;
0307 }
0308 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5) {
0309   //Reset this to be 5 dimensional of dimension n1,n2,n3,n4,n5
0310   const Double_t zero = 0.0;
0311   Clean();
0312   fNd = 5;
0313   fN1 = n1;
0314   fN2 = n2;
0315   fN3 = n3;
0316   fN4 = n4;
0317   fN5 = n5;
0318   fNL = n1 * n2 * n3 * n4 * n5 + 1;
0319   fA = new Double_t[fNL];
0320   for (Int_t i = 0; i < fNL; i++)
0321     fA[i] = zero;
0322 }
0323 void TEcnaNArrayD::ReSet(Int_t n1, Int_t n2, Int_t n3, Int_t n4, Int_t n5, Int_t n6) {
0324   //Reset this to be 6 dimensional of dimension n1,n2,n3,n4,n5,n6
0325   const Double_t zero = 0.0;
0326   Clean();
0327   fNd = 6;
0328   fN1 = n1;
0329   fN2 = n2;
0330   fN3 = n3;
0331   fN4 = n4;
0332   fN5 = n5;
0333   fN6 = n6;
0334   fNL = n1 * n2 * n3 * n4 * n5 * n6 + 1;
0335   fA = new Double_t[fNL];
0336   for (Int_t i = 0; i < fNL; i++)
0337     fA[i] = zero;
0338 }
0339 Double_t &TEcnaNArrayD::operator()(Int_t i1) {
0340   Int_t i;
0341   i = OneDim(i1);
0342   return fA[i];
0343 }
0344 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2) {
0345   Int_t i;
0346   i = OneDim(i1, i2);
0347   return fA[i];
0348 }
0349 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3) {
0350   Int_t i;
0351   i = OneDim(i1, i2, i3);
0352   return fA[i];
0353 }
0354 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4) {
0355   Int_t i;
0356   i = OneDim(i1, i2, i3, i4);
0357   return fA[i];
0358 }
0359 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5) {
0360   Int_t i;
0361   i = OneDim(i1, i2, i3, i4, i5);
0362   return fA[i];
0363 }
0364 Double_t &TEcnaNArrayD::operator()(Int_t i1, Int_t i2, Int_t i3, Int_t i4, Int_t i5, Int_t i6) {
0365   Int_t i;
0366   i = OneDim(i1, i2, i3, i4, i5, i6);
0367   return fA[i];
0368 }