]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDdataArrayI.cxx
Add ADC offset and change default digitazation parameters
[u/mrichter/AliRoot.git] / TRD / AliTRDdataArrayI.cxx
index 35887f545a2aca61c0cfb8f0843584ead23a3005..c8a4c76234ee6958bb8b05227db9ab5b3263f15e 100644 (file)
 
 /*
 $Log$
+Revision 1.10.6.2  2002/07/24 10:09:30  alibrary
+Updating VirtualMC
+
+Revision 1.10.6.1  2002/06/10 15:28:58  hristov
+Merged with v3-08-02
+
+Revision 1.11  2002/03/28 14:59:07  cblume
+Coding conventions
+
+Revision 1.11  2002/03/28 14:59:07  cblume
+Coding conventions
+
+Revision 1.10  2002/02/11 14:27:54  cblume
+Geometry and hit structure update
+
+Revision 1.9  2001/05/07 08:08:05  cblume
+Update of TRD code
+
+Revision 1.8  2000/11/23 14:34:08  cblume
+Fixed bug in expansion routine of arrays (initialize buffers properly)
+
+Revision 1.7  2000/11/20 08:56:07  cblume
+Cleanup of data arrays
+
+Revision 1.6  2000/11/01 14:53:20  cblume
+Merge with TRD-develop
+
 Revision 1.1.2.3  2000/10/06 16:49:46  cblume
 Made Getters const
 
@@ -70,6 +97,8 @@ AliTRDdataArrayI::AliTRDdataArrayI(Int_t nrow, Int_t ncol, Int_t ntime)
   // The row- and column dimensions are compressible.
   //
 
+  fElements = 0;
+
   Allocate(nrow,ncol,ntime);
   
 }
@@ -92,8 +121,7 @@ AliTRDdataArrayI::~AliTRDdataArrayI()
   // Destructor
   //
 
-  if (fElements) fElements->Delete();
-  delete fElements;
+  if (fElements) delete fElements;
   
 }
 
@@ -109,7 +137,7 @@ void AliTRDdataArrayI::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
   if (fNelems < 0) AliTRDdataArray::Allocate(nrow,ncol,ntime);
 
   if (fElements) delete fElements;
-  fElements = new AliTRDarrayI;
+  fElements = new AliTRDarrayI();
   fElements->Set(fNelems);
 
 }
@@ -137,7 +165,7 @@ void AliTRDdataArrayI::Reset()
   //
 
   if (fElements) delete fElements;
-  fElements = new AliTRDarrayI;
+  fElements = new AliTRDarrayI();
   fElements->Set(0); 
 
   AliTRDdataArray::Reset();
@@ -146,7 +174,7 @@ void AliTRDdataArrayI::Reset()
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDdataArrayI::GetSize()
+Int_t AliTRDdataArrayI::GetSize() const
 {
   //
   // Returns the size of the complete object
@@ -164,7 +192,7 @@ Int_t AliTRDdataArrayI::GetSize()
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDdataArrayI::GetDataSize()
+Int_t AliTRDdataArrayI::GetDataSize() const
 {
   //
   // Returns the size of only the data part
@@ -190,8 +218,8 @@ Int_t AliTRDdataArrayI::GetOverThreshold(Int_t threshold)
   Int_t over = 0;
 
   for (Bool_t cont = First(); cont == kTRUE; cont = Next()) {
-    if ((fCurrentIdx1 < 0) || (fCurrentIdx1 > fNdim1)) continue;
-    if ((fCurrentIdx2 < 0) || (fCurrentIdx2 > fNdim2)) continue;
+    if ((fCurrentIdx1 < 0) || (fCurrentIdx1 >= fNdim1)) continue;
+    if ((fCurrentIdx2 < 0) || (fCurrentIdx2 >= fNdim2)) continue;
     if (fElements->At(fCurrentIndex) > threshold) over++;
   }
 
@@ -225,6 +253,18 @@ Int_t AliTRDdataArrayI::GetData(Int_t row, Int_t col, Int_t time) const
 
 }
 
+//_____________________________________________________________________________
+Int_t AliTRDdataArrayI::GetDataFast(Int_t idx1, Int_t idx2) const
+{
+  //
+  // Returns the data value at a given position of the array
+  // No boundary checking
+  //
+
+  return fElements->At(fIndex->At(idx2)+idx1);
+
+}
+
 //_____________________________________________________________________________
 void AliTRDdataArrayI::Compress(Int_t bufferType, Int_t threshold)
 {
@@ -326,6 +366,7 @@ void AliTRDdataArrayI::Expand1()
   fNelems = fNdim1 * fNdim2;
 
   Int_t *buf = new Int_t[fNelems];
+  memset(buf,0,fNelems*sizeof(Int_t));
 
   fIndex->Set(fNdim2);
 
@@ -339,10 +380,10 @@ void AliTRDdataArrayI::Expand1()
 
     // Negative sign counts the unwritten values (under threshold)
     if ((*fElements)[i] < 0) {
-      idx1 -= fElements->At(i);
+      idx1 -= (*fElements)[i];
     } 
     else {
-      buf[(*fIndex)[idx2] + idx1] = fElements->At(i);
+      buf[(*fIndex)[idx2] + idx1] = (*fElements)[i];
       idx1++;
     }
     if (idx1 == fNdim1) {
@@ -368,17 +409,17 @@ void AliTRDdataArrayI::Compress1()
   // Compress a buffer of type 1
   //
 
-  AliTRDarrayI  buf;  
-  buf.Set(fNelems);
-  AliTRDarrayI  index;
-  index.Set(fNdim2);
+  AliTRDarrayI *buf   = new AliTRDarrayI();  
+  buf->Set(fNelems);
+  AliTRDarrayI *index = new AliTRDarrayI();
+  index->Set(fNdim2);
 
   Int_t icurrent = -1;
   Int_t izero;
   for (Int_t idx2 = 0; idx2 < fNdim2; idx2++){      
 
     // Set the idx2 pointer
-    index[idx2] = icurrent + 1;
+    (*index)[idx2] = icurrent + 1;
 
     // Reset the zero counter 
     izero = 0;  
@@ -392,31 +433,33 @@ void AliTRDdataArrayI::Compress1()
        if (izero > 0) {
          // If we have currently izero counts under threshold
          icurrent++;     
-         if (icurrent >= buf.fN) buf.Expand(icurrent*2);
+         if (icurrent >= buf->fN) buf->Expand(icurrent*2);
           // Store the number of entries below zero
-         buf[icurrent] = -izero;  
+         (*buf)[icurrent] = -izero;  
          izero = 0;
        } 
        icurrent++;
-       if (icurrent >= buf.fN) buf.Expand(icurrent*2);
-       buf[icurrent] = GetDataFast(idx1,idx2);     
+       if (icurrent >= buf->fN) buf->Expand(icurrent*2);
+       (*buf)[icurrent] = GetDataFast(idx1,idx2);          
       } // If signal larger than threshold             
     } // End of loop over idx1
 
     if (izero > 0) {
       icurrent++;        
-      if (icurrent >= buf.fN) buf.Expand(icurrent*2);
+      if (icurrent >= buf->fN) buf->Expand(icurrent*2);
       // Store the number of entries below zero
-      buf[icurrent] = -izero; 
+      (*buf)[icurrent] = -izero; 
     }
 
   }
 
-  buf.Expand(icurrent+1);
-  (*fElements) = buf;
+  buf->Expand(icurrent+1);
+  if (fElements) delete fElements;
+  fElements = buf;
   fNelems   = fElements->fN;
   fBufType  = 1;
-  (*fIndex) = index;
+  if (fIndex) delete fIndex;
+  fIndex    = index;
 
 }
 
@@ -428,7 +471,9 @@ void AliTRDdataArrayI::Expand2()
   //
 
   Int_t i, k;
+
   Int_t *buf = new Int_t[fNelems];
+  memset(buf,0,fNelems*sizeof(Int_t)); 
 
   fNelems = fNdim1 * fNdim2;
   fIndex->Set(fNdim2);
@@ -622,17 +667,6 @@ Int_t AliTRDdataArrayI::GetData1(Int_t idx1, Int_t idx2) const
 
 }
 
-//_____________________________________________________________________________
-Int_t AliTRDdataArrayI::GetDataFast(Int_t idx1, Int_t idx2) const
-{
-  //
-  // Returns the value at a given position in the array
-  //
-  
-  return fElements->At(fIndex->At(idx2) + idx1); 
-
-}
-
 //_____________________________________________________________________________
 void AliTRDdataArrayI::SetData(Int_t row, Int_t col, Int_t time, Int_t value)
 {
@@ -658,20 +692,14 @@ void AliTRDdataArrayI::SetData(Int_t row, Int_t col, Int_t time, Int_t value)
 }
 
 //_____________________________________________________________________________
-void  AliTRDdataArrayI::SetDataFast(Int_t idx1, Int_t idx2, Int_t value)
+void AliTRDdataArrayI::SetDataFast(Int_t idx1, Int_t idx2, Int_t value)
 {
   //
-  // Set the value at a given position in the array
+  // Sets the data value at a given position of the array
+  // No boundary checking
   //
 
-  if ((idx1 < 0) || (idx1 >= fNdim1) || 
-      (idx2 < 0) || (idx2 >= fNdim2)) { 
-    TObject::Error("SetDataFast"
-                  ,"idx1 %d  idx2 %d out of bounds (size: %d x %d, this: 0x%08x)"
-                  ,idx1,idx2,fNdim1,fNdim2,this);
-  }
-
-  (*fElements)[fIndex->fArray[idx2] + idx1] = value; 
+  (*fElements)[fIndex->fArray[idx2]+idx1] = value;
 
 }