Coverity ... next iteration ...
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Oct 2010 16:23:39 +0000 (16:23 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 10 Oct 2010 16:23:39 +0000 (16:23 +0000)
TRD/AliTRDarrayADC.cxx
TRD/AliTRDarrayDictionary.cxx
TRD/AliTRDarraySignal.cxx
TRD/AliTRDdigitizer.cxx
TRD/AliTRDdigitsManager.cxx
TRD/AliTRDgeometry.cxx
TRD/AliTRDsimTR.cxx

index 470a10d..1c0f966 100644 (file)
@@ -302,129 +302,127 @@ void AliTRDarrayADC::Compress()
   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++;
-       }
-    }
-
-  //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]; 
-    }
+             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;
+        } 
 
-  //Delete auxiliary arrays
-  if(buffer)
-    {
-      delete [] buffer;
-      buffer=0;
-    } 
-  if(longz) 
-    {
       delete [] longz;
       longz=0;
-    }
-  if(longm) 
-    {
       delete [] longm;
       longm=0;
+
     }
 
 }
index a35dcf4..c25215a 100644 (file)
@@ -284,71 +284,77 @@ void AliTRDarrayDictionary::Expand()
   //  Expand the array
   //  
 
-  Int_t *longArr;
-  longArr = new Int_t[fNDdim];
   Int_t dimexp=0;
-
-  //Initialize the array
-  memset(longArr,0,sizeof(Int_t)*fNDdim);
-
-  Int_t r2=0;
-  for(Int_t i=0; i<fNDdim;i++)
+  Int_t *longArr = new Int_t[fNDdim];
+  if(longArr && fDictionary)
     {
-      if((fDictionary[i]<0)&&(fDictionary[i]!=-1))  
-       {
-         longArr[r2]=-fDictionary[i]; 
-         r2++;
-       }
-    }
 
-  //Calculate new dimensions
-  for(Int_t i=0; i<fNDdim;i++)
-    {
-      if(longArr[i]!=0)      
-       {
-         dimexp=dimexp+longArr[i]-1;
-       }
-    }
-  dimexp=dimexp+fNDdim;  
-
-  //Write in the buffer the new array
-  Int_t* bufferE;
-  bufferE = new Int_t[dimexp];
-  Int_t contaexp =0;    
-  Int_t h=0;
-  for(Int_t i=0; i<dimexp; i++)
-    {
-      if(fDictionary[contaexp]>=-1)  
-       {
-         bufferE[i]=fDictionary[contaexp];
-       }
-      if(fDictionary[contaexp]<-1)  
-       {
-         for(Int_t j=0; j<longArr[h];j++)
+      //Initialize the array
+      memset(longArr,0,sizeof(Int_t)*fNDdim);
+
+      Int_t r2=0;
+      for(Int_t i=0; i<fNDdim;i++)
+        {
+          if((fDictionary[i]<0)&&(fDictionary[i]!=-1))  
            {
-             bufferE[i+j]=-1;
+             longArr[r2]=-fDictionary[i]; 
+             r2++;
            }
-         i=i+longArr[h]-1;
-         h++;
+        }
+
+      //Calculate new dimensions
+      for(Int_t i=0; i<fNDdim;i++)
+        {
+          if(longArr[i]!=0)      
+           {
+             dimexp=dimexp+longArr[i]-1;
+           }
+        }
+      dimexp=dimexp+fNDdim;  
+
+      //Write in the buffer the new array
+      Int_t contaexp =0;    
+      Int_t h=0;
+      Int_t* bufferE = new Int_t[dimexp];
+
+      if(bufferE)
+       {
+
+          for(Int_t i=0; i<dimexp; i++)
+            {
+              if(fDictionary[contaexp]>=-1)  
+               {
+                 bufferE[i]=fDictionary[contaexp];
+               }
+              if(fDictionary[contaexp]<-1)  
+               {
+                 for(Int_t j=0; j<longArr[h];j++)
+                   {
+                     bufferE[i+j]=-1;
+                   }
+                 i=i+longArr[h]-1;
+                 h++;
+               }
+              contaexp++;
+            }
+
+          //Copy the buffer
+          delete [] fDictionary;
+          fDictionary=0;
+          fDictionary = new Int_t[dimexp];
+          fNDdim = dimexp;
+          for(Int_t i=0; i<dimexp; i++)
+            {
+              fDictionary[i] = bufferE[i]; 
+            }
+          delete [] bufferE;
+
        }
-      contaexp++;
-    }
 
-  //Copy the buffer
-  if(fDictionary)
-    {
-      delete [] fDictionary;
-      fDictionary=0;
-    }
+      delete [] longArr;
 
-  fDictionary = new Int_t[dimexp];
-  fNDdim = dimexp;
-  for(Int_t i=0; i<dimexp; i++)
-    {
-      fDictionary[i] = bufferE[i]; 
     }
-  if(bufferE) delete [] bufferE;
-  if(longArr) delete [] longArr;
 
 }
 //________________________________________________________________________________
index d9b6fad..828a04a 100644 (file)
@@ -295,85 +295,97 @@ void AliTRDarraySignal::Expand()
   // Expand the array
   //
 
-  //Check if the array has not been already expanded
-  Int_t verif=0;
-  for(Int_t i=0; i<fNdim; i++)
+  if(fSignal)
     {
-      if(fSignal[i]<0)
-       {
-         verif++;
-       }
-    }
 
-  if(verif==0)
-    {
-      return;
-    }
+      //Check if the array has not been already expanded
+      Int_t verif=0;
+      for(Int_t i=0; i<fNdim; i++)
+        {
+          if(fSignal[i]<0)
+           {
+             verif++;
+           }
+        }
 
-  Int_t *longArr; 
-  longArr = new Int_t[fNdim];
-  Int_t dimexp=0;
-  memset(longArr,0,sizeof(Int_t)*fNdim);
+      if(verif==0)
+        {
+          return;
+        }
 
-  Int_t r2=0;
-  for(Int_t i=0; i<fNdim;i++)
-    {
-      if(fSignal[i]<0)  
-       {
-         longArr[r2]=(Int_t)(-fSignal[i]); 
-         r2++;
-       }
-    }
+      Int_t dimexp=0;
+      Int_t *longArr = new Int_t[fNdim];
 
-  //Calculate new dimensions
-  for(Int_t i=0; i<fNdim;i++)
-    {
-      if(longArr[i]!=0)      
-       {
-         dimexp=dimexp+longArr[i]-1;
-       }
-    }
-  dimexp=dimexp+fNdim;   //Dimension of the expanded array
-
-  //Write in the buffer the new array
-  Float_t* bufferE;
-  bufferE = new Float_t[dimexp];
-  Int_t contaexp =0;    
-  Int_t h=0;
-  for(Int_t i=0; i<dimexp; i++)
-    {
-      if(fSignal[contaexp]>0)  
+      if(longArr)
        {
-         bufferE[i]=fSignal[contaexp];
-       }
-      if(fSignal[contaexp]<0)  
-       {
-         for(Int_t j=0; j<longArr[h];j++)
+
+          memset(longArr,0,sizeof(Int_t)*fNdim);
+
+          Int_t r2=0;
+          for(Int_t i=0; i<fNdim;i++)
+            {
+              if(fSignal[i]<0)  
+               {
+                 longArr[r2]=(Int_t)(-fSignal[i]); 
+                 r2++;
+               }
+            }
+
+          //Calculate new dimensions
+          for(Int_t i=0; i<fNdim;i++)
+            {
+              if(longArr[i]!=0)      
+               {
+                 dimexp=dimexp+longArr[i]-1;
+               }
+            }
+          dimexp=dimexp+fNdim;   //Dimension of the expanded array
+
+          //Write in the buffer the new array
+          Int_t contaexp =0;    
+          Int_t h=0;
+          Float_t* bufferE = new Float_t[dimexp];
+
+          if(bufferE)
            {
-             bufferE[i+j]=0;
+
+              for(Int_t i=0; i<dimexp; i++)
+                {
+                  if(fSignal[contaexp]>0)  
+                   {
+                     bufferE[i]=fSignal[contaexp];
+                   }
+                  if(fSignal[contaexp]<0)  
+                   {
+                     for(Int_t j=0; j<longArr[h];j++)
+                       {
+                         bufferE[i+j]=0;
+                       }
+                     i=i+longArr[h]-1;
+                     h++;
+                   }
+                  contaexp++;
+                }
+
+              //Copy the buffer
+              delete [] fSignal;
+              fSignal=0;
+              fSignal = new Float_t[dimexp];
+              fNdim = dimexp;
+              for(Int_t i=0; i<dimexp; i++)
+                {
+                  fSignal[i] = bufferE[i]; 
+                }
+
+              delete [] bufferE;
+
            }
-         i=i+longArr[h]-1;
-         h++;
-       }
-      contaexp++;
-    }
 
-  //Copy the buffer
-  if(fSignal)
-    {
-      delete [] fSignal;
-      fSignal=0;
-    }
+          delete [] longArr;
 
-  fSignal = new Float_t[dimexp];
-  fNdim = dimexp;
-  for(Int_t i=0; i<dimexp; i++)
-    {
-      fSignal[i] = bufferE[i]; 
-    }
+        }
 
-  if(bufferE) delete [] bufferE;
-  if(longArr) delete [] longArr;
+    }
 
 }
 //________________________________________________________________________________
index 44e7a47..b571eab 100644 (file)
@@ -724,6 +724,7 @@ Bool_t AliTRDdigitizer::SortHits(Float_t **hits, Int_t *nhit)
   TTree *hitTree = gimme->TreeH();
   if (hitTree == 0x0) {
     AliError("Can not get TreeH");
+    delete [] lhit;
     return kFALSE;
   }
   fTRD->SetTreeAddress();
index 28a830d..cb38cf3 100644 (file)
@@ -374,8 +374,9 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree)
       // Make the branches for the dictionaries
       for (Int_t iDict = 0; iDict < kNDict; iDict++) 
        {
-         Char_t branchname[15];
-         sprintf(branchname,"TRDdictionary%d",iDict); 
+          const Int_t kBranchname = 15;
+         Char_t branchname[kBranchname];
+         snprintf(branchname,kBranchname,"TRDdictionary%d",iDict); 
          if (fDict[iDict]) 
            {
              const AliTRDarrayDictionary *kDictionary = (AliTRDarrayDictionary *) fDict[iDict]->At(0);
index c747c69..b2427a6 100644 (file)
@@ -2975,6 +2975,7 @@ Bool_t AliTRDgeometry::CreateClusterMatrixArray()
       case 13:
       case 14:
       case 15:
+        // Check for holes in from of PHOS
         if (istack == 2) {
           continue;
        }
@@ -2991,12 +2992,6 @@ Bool_t AliTRDgeometry::CreateClusterMatrixArray()
        continue;
       }
 
-      // Check for holes in from of PHOS
-      if (((isector == 13) || (isector == 14) || (isector == 15)) && 
-          (istack == 2)) {
-        continue; 
-      }
-
       UShort_t     volid   = AliGeomManager::LayerToVolUID(iLayer,iModule);
       const char  *symname = AliGeomManager::SymName(volid);
       TGeoPNEntry *pne     = gGeoManager->GetAlignableEntry(symname);
index 847e077..b1354f5 100644 (file)
@@ -180,8 +180,6 @@ AliTRDsimTR::AliTRDsimTR(const AliTRDsimTR &s)
     fSigma[iBin]     = ((AliTRDsimTR &) s).fSigma[iBin];
   }  
 
-  fSpectrum->Copy(*((AliTRDsimTR &) s).fSpectrum);
-
 }
 
 //_____________________________________________________________________________
@@ -274,8 +272,6 @@ void AliTRDsimTR::Copy(TObject &s) const
     ((AliTRDsimTR &) s).fSigma[iBin]     = fSigma[iBin];
   }  
 
-  fSpectrum->Copy(*((AliTRDsimTR &) s).fSpectrum);
-
 }
 
 //_____________________________________________________________________________