]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDarrayADC.cxx
Fix histo title axis name; fix checking of NLM in Pi0EbE
[u/mrichter/AliRoot.git] / TRD / AliTRDarrayADC.cxx
index e65987809061f71d9e1e2a3ab003017e731a9e0c..0a8b3e4a9d474124e7151e58c66e7a77fe19bc9a 100644 (file)
@@ -27,6 +27,8 @@
 #include "AliTRDarrayADC.h"
 #include "Cal/AliTRDCalPadStatus.h"
 #include "AliTRDfeeParam.h"
+#include "AliTRDSignalIndex.h"
+#include "AliLog.h"
 
 ClassImp(AliTRDarrayADC)
 
@@ -41,7 +43,6 @@ AliTRDarrayADC::AliTRDarrayADC()
               ,fNumberOfChannels(0)
                ,fNtime(0) 
                ,fNAdim(0)
-              ,fBaseline(0)
                ,fADC(0)
 {
   //
@@ -61,7 +62,6 @@ AliTRDarrayADC::AliTRDarrayADC(Int_t nrow, Int_t ncol, Int_t ntime)
               ,fNumberOfChannels(0)
                ,fNtime(0) 
                ,fNAdim(0)
-              ,fBaseline(0)
                ,fADC(0)
 {
   //
@@ -82,7 +82,6 @@ AliTRDarrayADC::AliTRDarrayADC(const AliTRDarrayADC &b)
               ,fNumberOfChannels(b.fNumberOfChannels)
                ,fNtime(b.fNtime) 
                ,fNAdim(b.fNAdim)
-              ,fBaseline(b.fBaseline)
                ,fADC(0)         
 {
   //
@@ -101,11 +100,8 @@ AliTRDarrayADC::~AliTRDarrayADC()
   // AliTRDarrayADC destructor
   //
 
-  if(fADC)
-    {
-      delete [] fADC;
-      fADC=0;
-    }
+  delete [] fADC;
+  fADC=0;
 
 }
 
@@ -171,7 +167,7 @@ Short_t AliTRDarrayADC::GetDataBits(Int_t row, Int_t col, Int_t time) const
   // Get the ADC value for a given position: row, col, time
   // Taking bit masking into account
   //
-  // Adapted from code of the class AliTRDdataArrayDigits 
+  // Adapted from code of the class AliTRDclusterizer 
   //
 
   Short_t tempval = GetData(row,col,time);
@@ -197,7 +193,7 @@ UChar_t AliTRDarrayADC::GetPadStatus(Int_t row, Int_t col, Int_t time) const
   //               Bridged Right Masking    8
   //               Not Connected Masking Digits
   //
-  // Adapted from code of the class AliTRDdataArrayDigits
+  // Adapted from code of the class AliTRDclusterizer
   //
 
   UChar_t padstatus = 0;
@@ -238,7 +234,7 @@ void AliTRDarrayADC::SetPadStatus(Int_t row, Int_t col, Int_t time, UChar_t stat
   //               Bridged Left masking:    Bit 11(0), Bit 12(1)
   //               Bridged Right masking:   Bit 11(1), Bit 12(1)
   // 
-  // Adapted from code of the class AliTRDdataArrayDigits
+  // Adapted from code of the class AliTRDclusterizer
   //
 
   Short_t signal = GetData(row,col,time);
@@ -267,6 +263,7 @@ void AliTRDarrayADC::SetPadStatus(Int_t row, Int_t col, Int_t time, UChar_t stat
          SETBIT(signal, 10);
          SETBIT(signal, 11);
          SETBIT(signal, 12);
+          break;
        default:
          CLRBIT(signal, 10);
          CLRBIT(signal, 11);
@@ -283,7 +280,7 @@ Bool_t AliTRDarrayADC::IsPadCorrupted(Int_t row, Int_t col, Int_t time)
   // 
   // Checks if the pad has any masking as corrupted (Bit 10 in signal set)
   // 
-  // Adapted from code of the class AliTRDdataArrayDigits
+  // Adapted from code of the class AliTRDclusterizer
   //
 
   Short_t signal = GetData(row,col,time);
@@ -298,135 +295,146 @@ void AliTRDarrayADC::Compress()
   // Compress the array
   //
 
+  if(fNAdim!=fNrow*fNumberOfChannels*fNtime)
+    {
+      AliDebug(1,"The ADC array is already compressed");
+      return;
+    }
+
   Int_t counter=0;
   Int_t newDim=0;
   Int_t j;                  
   Int_t l;                  
   Int_t r=0;                
   Int_t s=0;                
-  Int_t *longm;            
-  longm = new Int_t[fNAdim];  
-  Int_t *longz;            
-  longz = new Int_t[fNAdim];
   Int_t k=0;
-  memset(longz,0,sizeof(Int_t)*fNAdim);
-  memset(longm,0,sizeof(Int_t)*fNAdim);
 
-  for(Int_t i=0;i<fNAdim; i++)
+  Int_t *longm = new Int_t[fNAdim];  
+  Int_t *longz = new Int_t[fNAdim];
+
+  if(longz && longm && fADC)
     {
-      j=0;
-      if(fADC[i]==-1)
-       {
-         for(k=i;k<fNAdim;k++)
+
+      memset(longz,0,sizeof(Int_t)*fNAdim);
+      memset(longm,0,sizeof(Int_t)*fNAdim);
+
+      for(Int_t i=0;i<fNAdim; i++)
+        {
+          j=0;
+          if(fADC[i]==-1)
            {
-             if((fADC[k]==-1)&&(j<16000))   
-               {
-                 j=j+1;
-                 longm[r]=j;                
-               }
-             else
-               {
-                 break;
-               }
+             for(k=i;k<fNAdim;k++)
+               {
+                 if((fADC[k]==-1)&&(j<16000))   
+                   {
+                     j=j+1;
+                     longm[r]=j;                
+                   }
+                 else
+                   {
+                     break;
+                   }
+               }
+             r=r+1;            
            }
-         r=r+1;            
-       }
-      l=16001;
-      if(fADC[i]==0)
-       {
-         for(k=i;k<fNAdim;k++)
+          l=16001;
+          if(fADC[i]==0)
            {
-             if((fADC[k]==0)&&(l<32767))     
-               {                             
-                 l=l+1;
-                 longz[s]=l;                
-               }
-             else
-               {
-                 break;
-               }
+             for(k=i;k<fNAdim;k++)
+               {
+                 if((fADC[k]==0)&&(l<32767))     
+                   {                             
+                     l=l+1;
+                     longz[s]=l;                
+                   }
+                 else
+                   {
+                     break;
+                   }
+               }
+             s=s+1;         
            }
-         s=s+1;         
-       }
-      if(fADC[i]>0)
-       {
-         i=i+1;
-       }
-      i=i+j+(l-16001-1); 
-    }
-
-  //Calculate the size of the compressed array
-  for(Int_t i=0; i<fNAdim;i++)
-    {
-      if(longm[i]!=0)   
-       {
-         counter=counter+longm[i]-1;
-       }
-      if(longz[i]!=0)  
-       {
-         counter=counter+(longz[i]-16001)-1;
-       }
-    }
-  newDim = fNAdim-counter;   //Dimension of the compressed array
-  Short_t* buffer;
-  buffer = new Short_t[newDim];
-  Int_t counterTwo=0;
-
-  //Fill the buffer of the compressed array
-  Int_t g=0;
-  Int_t h=0; 
-  for(Int_t i=0; i<newDim; i++)
-    {
-      if(counterTwo<fNAdim)
-       {
-         if(fADC[counterTwo]>0)
+          if(fADC[i]>0)
            {
-             buffer[i]=fADC[counterTwo];
+             i=i+1;
            }
-         if(fADC[counterTwo]==-1)
+          i=i+j+(l-16001-1); 
+        }
+
+      //Calculate the size of the compressed array
+      for(Int_t i=0; i<fNAdim;i++)
+        {
+          if(longm[i]!=0)   
            {
-             buffer[i]=-(longm[g]);
-             counterTwo=counterTwo+longm[g]-1;
-             g++;
-           }  
-         if(fADC[counterTwo]==0)
+             counter=counter+longm[i]-1;
+           }
+          if(longz[i]!=0)  
            {
-             buffer[i]=-(longz[h]); 
-             counterTwo=counterTwo+(longz[h]-16001)-1;
-             h++;
-           }  
-         counterTwo++;
-       }
-    }
+             counter=counter+(longz[i]-16001)-1;
+           }
+        }
+
+      Int_t counterTwo=0;
+      newDim = fNAdim-counter;   //Dimension of the compressed array
+      Short_t* buffer = new Short_t[newDim];
+
+      if(buffer)
+        {
+
+          //Fill the buffer of the compressed array
+          Int_t g=0;
+          Int_t h=0; 
+          for(Int_t i=0; i<newDim; i++)
+            {
+              if(counterTwo<fNAdim)
+               {
+                 if(fADC[counterTwo]>0)
+                   {
+                     buffer[i]=fADC[counterTwo];
+                   }
+                 if(fADC[counterTwo]==-1)
+                   {
+                     buffer[i]=-(longm[g]);
+                     counterTwo=counterTwo+longm[g]-1;
+                     g++;
+                   }  
+                 if(fADC[counterTwo]==0)
+                   {
+                     buffer[i]=-(longz[h]); 
+                     counterTwo=counterTwo+(longz[h]-16001)-1;
+                     h++;
+                   }  
+                 counterTwo++;
+               }
+            }
+
+          //Copy the buffer
+          delete [] fADC;
+          fADC=0;
+          fADC = new Short_t[newDim];
+          fNAdim = newDim;
+          for(Int_t i=0; i<newDim; i++)
+            {
+              fADC[i] = buffer[i]; 
+            }
+
+          //Delete auxiliary arrays
+          delete [] buffer;
+          buffer=0;
+        } 
 
-  //Copy the buffer
-  if(fADC)
-    {
-      delete [] fADC;
-      fADC=0;
-    }
-  fADC = new Short_t[newDim];
-  fNAdim = newDim;
-  for(Int_t i=0; i<newDim; i++)
-    {
-      fADC[i] = buffer[i]; 
     }
 
-  //Delete auxiliary arrays
-  if(buffer)
-    {
-      delete [] buffer;
-      buffer=0;
-    } 
-  if(longz) 
+  if (longz)
     {
       delete [] longz;
       longz=0;
     }
-  if(longm) 
+  if (longm)
     {
       delete [] longm;
       longm=0;
+
     }
 
 }
@@ -438,111 +446,119 @@ void AliTRDarrayADC::Expand()
   // Expand the array
   //
 
-  //Check if the array has not been already expanded
-  Int_t verif=0;
-  for(Int_t i=0; i<fNAdim; i++)
+  if (fADC)
     {
-      if(fADC[i]<-1)
-       {
-         verif++;
-       }
-    }
+
+      //Check if the array has not been already expanded
+      Int_t verif=0;
+      for(Int_t i=0; i<fNAdim; i++)
+        {
+          if(fADC[i]<-1)
+           {
+             verif++;
+           }
+        }
   
-  if(verif==0)
-    {
-      //       AliDebug(1,"Nothing to expand");
-      return;
-    }
+      if(verif==0)
+        {
+          AliDebug(1,"Nothing to expand");
+          return;
+        }
 
-  Int_t *longz;
-  longz = new Int_t[fNAdim];
-  Int_t *longm;
-  longm = new Int_t[fNAdim];
-  Int_t dimexp=0;
-  //Initialize arrays
-  memset(longz,0,sizeof(Int_t)*fNAdim);
-  memset(longm,0,sizeof(Int_t)*fNAdim);
-  Int_t r2=0; 
-  Int_t r3=0; 
-  for(Int_t i=0; i<fNAdim;i++)
-    {
-      if((fADC[i]<0)&&(fADC[i]>=-16000))      
-       {
-         longm[r2]=-fADC[i];
-         r2++;
-       }
-      if(fADC[i]<-16000)  
-       {
-         longz[r3]=-fADC[i]-16001;  
-         r3++;
-       }
-    }
-  //Calculate the new dimensions of the array
-  for(Int_t i=0; i<fNAdim;i++)
-    {
-      if(longm[i]!=0)       
-       {
-         dimexp=dimexp+longm[i]-1;
-       }
-      if(longz[i]!=0)      
-       {
-         dimexp=dimexp+longz[i]-1;
-       }
-    }
-  dimexp=dimexp+fNAdim;   
-
-  //Write in the buffer the new array
-  Short_t* bufferE;
-  bufferE = new Short_t[dimexp];
-  Int_t contaexp =0;     
-  Int_t h=0;
-  Int_t l=0;  
-  for(Int_t i=0; i<dimexp; i++)
-    {
-      if(fADC[contaexp]>0)  
-       {
-         bufferE[i]=fADC[contaexp];
-       }
+      Int_t dimexp=0;
+      Int_t *longz = new Int_t[fNAdim];
+      Int_t *longm = new Int_t[fNAdim];
 
-      if((fADC[contaexp]<0)&&(fADC[contaexp]>=-16000))  
+      if (longz && longm)
        {
-         for(Int_t j=0; j<longm[h];j++)
-           {
-             bufferE[i+j]=-1;
-           }
-         i=i+longm[h]-1;
-         h++;
-       }
-      if(fADC[contaexp]<-16000)  
-       {
-         for(Int_t j=0; j<longz[l];j++)
+
+          //Initialize arrays
+          memset(longz,0,sizeof(Int_t)*fNAdim);
+          memset(longm,0,sizeof(Int_t)*fNAdim);
+          Int_t r2=0; 
+          Int_t r3=0; 
+          for(Int_t i=0; i<fNAdim;i++)
+            {
+              if((fADC[i]<0)&&(fADC[i]>=-16000))      
+               {
+                 longm[r2]=-fADC[i];
+                 r2++;
+               }
+              if(fADC[i]<-16000)  
+               {
+                 longz[r3]=-fADC[i]-16001;  
+                 r3++;
+               }
+            }
+
+          //Calculate the new dimensions of the array
+          for(Int_t i=0; i<fNAdim;i++)
+            {
+              if(longm[i]!=0)       
+               {
+                 dimexp=dimexp+longm[i]-1;
+               }
+              if(longz[i]!=0)      
+               {
+                 dimexp=dimexp+longz[i]-1;
+               }
+            }
+          dimexp=dimexp+fNAdim;   
+
+          //Write in the buffer the new array
+          Int_t contaexp =0;     
+          Int_t h=0;
+          Int_t l=0;  
+          Short_t* bufferE = new Short_t[dimexp];
+          if(bufferE)
            {
-             bufferE[i+j]=0;  
+              for(Int_t i=0; i<dimexp; i++)
+                {
+                  if(fADC[contaexp]>0)  
+                   {
+                     bufferE[i]=fADC[contaexp];
+                   }
+                  if((fADC[contaexp]<0)&&(fADC[contaexp]>=-16000))  
+                   {
+                     for(Int_t j=0; j<longm[h];j++)
+                       {
+                         bufferE[i+j]=-1;
+                       }
+                     i=i+longm[h]-1;
+                     h++;
+                   }
+                  if(fADC[contaexp]<-16000)  
+                   {
+                     for(Int_t j=0; j<longz[l];j++)
+                       {
+                         bufferE[i+j]=0;  
+                       }
+                     i=i+longz[l]-1;
+                     l++;
+                   }
+                  contaexp++;
+                }
+              //Copy the buffer
+              delete [] fADC;
+              fADC = new Short_t[dimexp];
+              fNAdim = dimexp;
+              for(Int_t i=0; i<dimexp; i++)
+                {
+                  fADC[i] = bufferE[i]; 
+                }
+
+              delete [] bufferE;
+
            }
-         i=i+longz[l]-1;
-         l++;
+
+          //Delete auxiliary arrays
+          delete [] longm;
+          delete [] longz;
+
        }
-      contaexp++;
-    }
-  //Copy the buffer
-  if(fADC)
-    {
-      delete [] fADC;
-      fADC=0;
-    }
 
-  fADC = new Short_t[dimexp];
-  fNAdim = dimexp;
-  for(Int_t i=0; i<dimexp; i++)
-    {
-      fADC[i] = bufferE[i]; 
     }
 
-  //Delete auxiliary arrays
-  if(bufferE) delete [] bufferE;
-  if(longm) delete [] longm;
-  if(longz) delete [] longz;
-
 }
 //____________________________________________________________________________________
 void AliTRDarrayADC::DeleteNegatives()
@@ -570,35 +586,25 @@ void AliTRDarrayADC::Reset()
   //
  
   memset(fADC,0,sizeof(Short_t)*fNAdim);
-
 }
 //________________________________________________________________________________
-Short_t AliTRDarrayADC::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
+void AliTRDarrayADC::ConditionalReset(AliTRDSignalIndex* idx)
 {
   //
-  // Get the data using the pad numbering.
-  // To access data using the mcm scheme use instead
-  // the method GetDataByAdcCol
-  //
-
-  Int_t corrcolumn = fgLutPadNumbering[ncol];
-
-  return fADC[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
-
-}
-//________________________________________________________________________________
-void AliTRDarrayADC::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Short_t value)
-{
-  //
-  // Set the data using the pad numbering.
-  // To write data using the mcm scheme use instead
-  // the method SetDataByAdcCol
+  // Reset the array, the old contents are deleted
+  // The array keeps the same dimensions as before
   //
-
-  Int_t colnumb = fgLutPadNumbering[ncol];
-
-  fADC[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime] = TMath::Max(value-fBaseline
-                                                                 ,0);
+  if(idx->GetNoOfIndexes()>25)
+    memset(fADC,0,sizeof(Short_t)*fNAdim);
+  else
+    {
+      Int_t row, col;
+      while(idx->NextRCIndex(row, col)){
+       Int_t colnumb = fgLutPadNumbering[col];
+       memset(&fADC[(row*fNumberOfChannels+colnumb)*fNtime],0,fNtime);
+      }
+    }
 
 }