X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDdataArray.cxx;h=e344751999423e8dab684918286c2c15fc844528;hb=c0e54947d8771c20ffd8e8a75aacd56104012611;hp=23a04b36e778a539b31f5088e96145432961f8d0;hpb=88cb7938ca21d4a80991d4e7aa564008c29340f7;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDdataArray.cxx b/TRD/AliTRDdataArray.cxx index 23a04b36e77..e3447519994 100644 --- a/TRD/AliTRDdataArray.cxx +++ b/TRD/AliTRDdataArray.cxx @@ -26,6 +26,9 @@ #include "TClass.h" #include "TError.h" + +#include "AliLog.h" + #include "AliTRDsegmentID.h" #include "AliTRDarrayI.h" #include "AliTRDdataArray.h" @@ -34,48 +37,66 @@ ClassImp(AliTRDdataArray) //_____________________________________________________________________________ AliTRDdataArray::AliTRDdataArray() + :fNrow(0) + ,fNcol(0) + ,fNtime(0) + ,fNdim1(-1) + ,fNdim2(-1) + ,fIndex(0) + ,fBufType(-1) + ,fNelems(-1) + ,fCurrentIdx1(0) + ,fCurrentIdx2(0) + ,fCurrentIndex(0) { // // Default constructor // - fIndex = 0; - - fNdim1 = -1; - fNdim2 = -1; - fNelems = -1; - - fBufType = -1; - - fNrow = 0; - fNcol = 0; - fNtime = 0; - } //_____________________________________________________________________________ AliTRDdataArray::AliTRDdataArray(Int_t nrow, Int_t ncol, Int_t ntime) + :fNrow(0) + ,fNcol(0) + ,fNtime(0) + ,fNdim1(-1) + ,fNdim2(-1) + ,fIndex(0) + ,fBufType(-1) + ,fNelems(-1) + ,fCurrentIdx1(0) + ,fCurrentIdx2(0) + ,fCurrentIndex(0) { // // Creates a AliTRDdataArray with the dimensions , , and . // The row- and column dimensions are compressible. // - fIndex = 0; - Allocate(nrow,ncol,ntime); } //_____________________________________________________________________________ AliTRDdataArray::AliTRDdataArray(const AliTRDdataArray &d) + :AliTRDsegmentID(d) + ,fNrow(d.fNrow) + ,fNcol(d.fNcol) + ,fNtime(d.fNtime) + ,fNdim1(d.fNdim1) + ,fNdim2(d.fNdim2) + ,fIndex(d.fIndex) + ,fBufType(d.fBufType) + ,fNelems(d.fNelems) + ,fCurrentIdx1(0) + ,fCurrentIdx2(0) + ,fCurrentIndex(0) { // // AliTRDdataArray copy constructor // - ((AliTRDdataArray &) d).Copy(*this); - } //_____________________________________________________________________________ @@ -85,7 +106,10 @@ AliTRDdataArray::~AliTRDdataArray() // AliTRDdataArray destructor // - if (fIndex) delete fIndex; + if (fIndex) { + delete fIndex; + fIndex = 0; + } } @@ -102,7 +126,7 @@ AliTRDdataArray &AliTRDdataArray::operator=(const AliTRDdataArray &d) } //_____________________________________________________________________________ -void AliTRDdataArray::Copy(TObject &d) +void AliTRDdataArray::Copy(TObject &d) const { // // Copy function @@ -127,7 +151,7 @@ void AliTRDdataArray::Copy(TObject &d) } //_____________________________________________________________________________ -void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime) +void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol, Int_t ntime) { // // Allocates memory for a AliTRDdataArray with the dimensions @@ -136,15 +160,15 @@ void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime) // if (nrow <= 0) { - Error("AliTRDdataArray::Allocate","The number of rows has to be positive"); + AliError("The number of rows has to be positive"); exit(1); } if (ncol <= 0) { - Error("AliTRDdataArray::Allocate","The number of columns has to be positive"); + AliError("The number of columns has to be positive"); exit(1); } if (ntime <= 0) { - Error("AliTRDdataArray::Allocate","The number of timebins has to be positive"); + AliError("The number of timebins has to be positive"); exit(1); } @@ -154,7 +178,7 @@ void AliTRDdataArray::Allocate(Int_t nrow, Int_t ncol,Int_t ntime) fNdim1 = nrow * ncol; fNdim2 = ntime; fNelems = fNdim1 * fNdim2; - + fNrow = nrow; fNcol = ncol; fNtime = ntime; @@ -171,32 +195,36 @@ 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) +Bool_t AliTRDdataArray::CheckBounds(Int_t idx1, Int_t idx2) { // // Does the boundary checking // - if ((idx2 >= fNdim2) || (idx2 < 0)) - return OutOfBoundsError(where,idx1,idx2); + if ((idx2 >= fNdim2) || + (idx2 < 0)) { + return OutOfBoundsError(idx1,idx2); + } Int_t index = (*fIndex).At(idx2) + idx1; - if ((index < 0) || (index > fNelems)) - return OutOfBoundsError(where,idx1,idx2); + if ((index < 0) || + (index > fNelems)) { + return OutOfBoundsError(idx1,idx2); + } return kTRUE; } //_____________________________________________________________________________ -Bool_t AliTRDdataArray::OutOfBoundsError(const char *where, Int_t idx1, Int_t idx2) +Bool_t AliTRDdataArray::OutOfBoundsError(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); + AliError(Form("idx1 %d idx2 %d out of bounds (size: %d x %d, this: 0x%08x)" + ,idx1,idx2,fNdim1,fNdim2,this)); return kFALSE; @@ -209,7 +237,10 @@ void AliTRDdataArray::Reset() // Reset the array (old content gets deleted) // - if (fIndex) delete fIndex; + if (fIndex) { + delete fIndex; + } + fIndex = new AliTRDarrayI(); fIndex->Set(0); @@ -233,16 +264,12 @@ Int_t AliTRDdataArray::GetIdx1(Int_t row, Int_t col) const // if (row >= fNrow) { - TObject::Error("GetIdx1" - ,"row %d out of bounds (size: %d, this: 0x%08x)" - ,row,fNrow,this); + AliError(Form("row %d out of bounds (size: %d, this: 0x%08x)",row,fNrow,this)); return -1; } if (col >= fNcol) { - TObject::Error("GetIdx1" - ,"col %d out of bounds (size: %d, this: 0x%08x)" - ,col,fNcol,this); + AliError(Form("col %d out of bounds (size: %d, this: 0x%08x)",col,fNcol,this)); return -1; } @@ -258,9 +285,7 @@ Int_t AliTRDdataArray::GetIndex(Int_t row, Int_t col, Int_t time) const // if (time > fNtime) { - TObject::Error("GetIdx1" - ,"time %d out of bounds (size: %d, this: 0x%08x)" - ,time,fNtime,this); + AliError(Form("time %d out of bounds (size: %d, this: 0x%08x)",time,fNtime,this)); return -1; }