]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDdataArray.cxx
Major upgrades to the strip structure
[u/mrichter/AliRoot.git] / TRD / AliTRDdataArray.cxx
index 759014a488c34520369c5d9ef3b7cc47d7b9690d..89f6f95eda280213470352ae28b86d271da8dfe3 100644 (file)
 
 /*
 $Log$
+Revision 1.7  2000/11/01 14:53:20  cblume
+Merge with TRD-develop
+
+Revision 1.1.4.3  2000/10/06 16:49:46  cblume
+Made Getters const
+
+Revision 1.1.4.2  2000/10/04 16:34:58  cblume
+Replace include files by forward declarations
+
+Revision 1.6  2000/06/09 11:10:07  cblume
+Compiler warnings and coding conventions, next round
+
+Revision 1.5  2000/06/08 18:32:58  cblume
+Make code compliant to coding conventions
+
 Revision 1.4  2000/06/07 16:27:01  cblume
 Try to remove compiler warnings on Sun and HP
 
@@ -78,18 +93,20 @@ AliTRDdataArray::AliTRDdataArray(Int_t nrow, Int_t ncol, Int_t ntime)
   // The row- and column dimensions are compressible.
   //
 
+  fIndex   = 0;
+
   Allocate(nrow,ncol,ntime);
 
 }
 
 //_____________________________________________________________________________
-AliTRDdataArray::AliTRDdataArray(AliTRDdataArray &d)
+AliTRDdataArray::AliTRDdataArray(const AliTRDdataArray &d)
 {
   //
   // AliTRDdataArray copy constructor
   //
 
-  d.Copy(*this);
+  ((AliTRDdataArray &) d).Copy(*this);
 
 }
 
@@ -100,32 +117,44 @@ AliTRDdataArray::~AliTRDdataArray()
   // AliTRDdataArray destructor
   //
 
-  if (fIndex) fIndex->Delete();
+  if (fIndex) delete fIndex;
   
 }
 
 //_____________________________________________________________________________
-void AliTRDdataArray::Copy(AliTRDdataArray &d)
+AliTRDdataArray &AliTRDdataArray::operator=(const AliTRDdataArray &d)
+{
+  //
+  // Assignment operator
+  //
+
+  if (this != &d) ((AliTRDdataArray &) d).Copy(*this);
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+void AliTRDdataArray::Copy(TObject &d)
 {
   //
   // Copy function
   //
 
-  d.fNrow         = fNrow;
-  d.fNcol         = fNcol;
-  d.fNtime        = fNtime;
+  ((AliTRDdataArray &) d).fNrow         = fNrow;
+  ((AliTRDdataArray &) d).fNcol         = fNcol;
+  ((AliTRDdataArray &) d).fNtime        = fNtime;
 
-  d.fNdim1        = fNdim1;
-  d.fNdim2        = fNdim2;
+  ((AliTRDdataArray &) d).fNdim1        = fNdim1;
+  ((AliTRDdataArray &) d).fNdim2        = fNdim2;
 
-  d.fBufType      = fBufType;
-  d.fNelems       = fNelems;
+  ((AliTRDdataArray &) d).fBufType      = fBufType;
+  ((AliTRDdataArray &) d).fNelems       = fNelems;
 
-  d.fCurrentIdx1  = 0;
-  d.fCurrentIdx2  = 0;
-  d.fCurrentIndex = 0;
+  ((AliTRDdataArray &) d).fCurrentIdx1  = 0;
+  ((AliTRDdataArray &) d).fCurrentIdx2  = 0;
+  ((AliTRDdataArray &) d).fCurrentIndex = 0;
 
-  fIndex->Copy(*d.fIndex);
+  fIndex->Copy(*((AliTRDdataArray &) d).fIndex);
 
 }
 
@@ -163,7 +192,7 @@ void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime)
   fNtime  = ntime;
 
   if (fIndex) delete fIndex;
-  fIndex = new AliTRDarrayI;
+  fIndex = new AliTRDarrayI();
   fIndex->Set(fNdim2);
   for (Int_t i = 0, k = 0; i < fNdim2; i++, k += fNdim1) { 
     (*fIndex)[i] = k;
@@ -173,6 +202,38 @@ void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime)
 
 }
 
+//_____________________________________________________________________________
+Bool_t AliTRDdataArray::CheckBounds(const char *where, Int_t idx1, Int_t idx2) 
+{
+  //
+  // Does the boundary checking
+  //
+
+  if ((idx2 >= fNdim2) || (idx2 < 0)) 
+    return OutOfBoundsError(where,idx1,idx2);
+
+  Int_t index = (*fIndex).At(idx2) + idx1;
+  if ((index < 0) || (index > fNelems)) 
+    return OutOfBoundsError(where,idx1,idx2);
+
+  return kTRUE;  
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliTRDdataArray::OutOfBoundsError(const char *where, Int_t idx1, Int_t idx2) 
+{
+  //
+  // Generate an out-of-bounds error. Always returns false.
+  //
+
+  TObject::Error(where, "idx1 %d  idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
+          ,idx1,idx2,fNdim1,fNdim2,this);
+
+  return kFALSE;
+
+}
+
 //_____________________________________________________________________________
 void AliTRDdataArray::Reset() 
 { 
@@ -181,7 +242,7 @@ void AliTRDdataArray::Reset()
   //
 
   if (fIndex) delete fIndex;
-  fIndex = new AliTRDarrayI;
+  fIndex = new AliTRDarrayI();
   fIndex->Set(0); 
 
   fNdim1   = -1;
@@ -197,7 +258,7 @@ void AliTRDdataArray::Reset()
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col)
+Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col) const
 {
   //
   // Maps the two-dimensional row/column plane into an one-dimensional array.
@@ -222,7 +283,7 @@ Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time)
+Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time) const
 {
   //
   // Maps the row/column/time into one number