]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AOD/AliAODCaloCells.cxx
From Giacomo (AliRoot #96201): Patch for AliAODHMPIDrings in AODEvent + filtering
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODCaloCells.cxx
index 27e42a3439e7b0efd06d490da37a9318b0730ce3..c4551971a0e5326e029eedd65b755163d75d574d 100644 (file)
@@ -58,7 +58,7 @@ AliAODCaloCells::AliAODCaloCells(const AliAODCaloCells& cells) :
   for (Int_t i = 0; i < fNCells; i++) {
     fCellNumber[i]    = cells.fCellNumber[i];
     fAmplitude[i]     = cells.fAmplitude[i];
-    if(cells.fMCLabel)  fTime[i]      = cells.fTime[i];
+    if(cells.fTime)  fTime[i]      = cells.fTime[i];
     if(cells.fMCLabel)  fMCLabel[i]   = cells.fMCLabel[i];
     if(cells.fEFraction)fEFraction[i] = cells.fEFraction[i];    
   }
@@ -173,7 +173,8 @@ void AliAODCaloCells::CreateContainer(Short_t nCells)
 
   DeleteContainer();
   
-  if (nCells <= 0) {
+  if (nCells <= 0) 
+  {
     fNCells = 0;
     return;
   }
@@ -187,8 +188,13 @@ void AliAODCaloCells::CreateContainer(Short_t nCells)
   fEFraction  = new Double32_t[fNCells];
 
   // set to zero
-  for(int i = 0;i<fNCells;++i){
-    fAmplitude[i] = fCellNumber[i] = fTime[i] =fMCLabel[i] = fEFraction[i] = 0 ;
+  for(int i = 0;i<fNCells;++i)
+  {
+    fAmplitude [i] =  0.; 
+    fCellNumber[i] = -1 ; 
+    fEFraction [i] =  0.;
+    fTime      [i] = -1.;
+    fMCLabel   [i] = -1 ;
   }
 }
 
@@ -242,10 +248,14 @@ void AliAODCaloCells::Sort()
   
   Short_t    *newIndex     = new Short_t[fNCells];
   Double32_t *newAmplitude = new Double32_t[fNCells];
-  Double32_t *newTime      = new Double32_t[fNCells];
-  Short_t    *newMCLabel   = new Short_t[fNCells];
-  Double32_t *newEFraction = new Double32_t[fNCells];
-
+  
+  Double32_t *newTime      = 0; 
+  Short_t    *newMCLabel   = 0 ;
+  Double32_t *newEFraction = 0 ; 
+  if(fTime)      newTime      = new Double32_t[fNCells];
+  if(fMCLabel)   newMCLabel   = new Short_t[fNCells];
+  if(fEFraction) newEFraction = new Double32_t[fNCells];
+  
   for (Int_t i=0; i < fNCells; i++) 
   {
     newIndex[i]     = fCellNumber[idxArray[i]];
@@ -261,7 +271,6 @@ void AliAODCaloCells::Sort()
   delete [] fMCLabel;
   delete [] fEFraction;
 
-  
   fCellNumber = newIndex;
   fAmplitude  = newAmplitude;
   if(fTime)      fTime       = newTime;
@@ -284,9 +293,26 @@ Bool_t AliAODCaloCells::SetCell(Short_t pos,     Short_t cellNumber, Double32_t
     fCellNumber[pos] = cellNumber;
     fAmplitude[pos]  = amplitude;
     
-    if(!fTime)      fTime      = new Double_t[fNCells];
-    if(!fMCLabel)   fMCLabel   = new Short_t[fNCells];
-    if(!fEFraction) fEFraction = new Double32_t[fNCells];
+    // note: initialize (can't use memset for non-0 values)
+    //       plus sizeof(Double32_t) is 0
+    if(!fTime){
+      fTime  = new Double32_t[fNCells];
+      
+      for( Int_t i = 0; i < fNCells; i++ )
+        fTime[i] = -1;
+    }
+    if(!fMCLabel){
+      fMCLabel = new Short_t[fNCells];
+      
+      for( Int_t i = 0; i < fNCells; i++ )
+        fMCLabel[i] = -1;
+    }
+    if(!fEFraction){
+      fEFraction = new Double32_t[fNCells];
+      
+      for( Int_t i = 0; i < fNCells; i++ )
+        fEFraction[i] = 0;
+    }
     
     fTime[pos]       = time;
     fMCLabel[pos]    = mclabel;