]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTriggerTRU.cxx
Major update of the way we make QA of the occupancy, and of what we
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerTRU.cxx
index 59b0418071e7c57f251adba69b84a79291018acc..6ba02cf12964d9dc4bcbba96e84cce773e4aabe0 100644 (file)
@@ -84,7 +84,6 @@ AliEMCALTriggerTRU::~AliEMCALTriggerTRU()
 {
    // delete TRU digits only used as transient containers 
    // to compute FastOR from energy deposit
-
 }
 
 //________________
@@ -128,8 +127,20 @@ Int_t AliEMCALTriggerTRU::L0()
        // and then move the space window
 
        AliDebug(1,"=== Running TRU L0 algorithm ===");
-       
-       Int_t buffer[int(fRegionSize->X())][int(fRegionSize->X())][kNup+kNdown];
+       const Int_t xsize    = Int_t(fRegionSize->X());
+       const Int_t ysize    = Int_t(fRegionSize->Y());
+       const Int_t zsize    = kNup+kNdown;
+
+       Int_t ***buffer = new Int_t**[xsize];
+       for (Int_t x = 0; x < xsize; x++)
+       {
+               buffer[x] = new Int_t*[ysize];
+               
+               for (Int_t y = 0; y < ysize; y++)
+               {
+                       buffer[x][y] = new Int_t[zsize];
+               }
+       }
        
        for (Int_t i=0; i<fRegionSize->X(); i++) for (Int_t j=0; j<fRegionSize->Y(); j++) 
                for (Int_t k=0; k<kNup+kNdown; k++)     buffer[i][j][k] = 0;
@@ -179,7 +190,11 @@ Int_t AliEMCALTriggerTRU::L0()
                        continue; 
                }
                
-               Int_t peaks[int(fRegionSize->X())][int(fRegionSize->X())];
+               Int_t **peaks = new Int_t*[xsize];
+               for (Int_t x = 0; x < xsize; x++)
+               {
+                       peaks[x] = new Int_t[ysize];
+               }
                
                for (Int_t j=0; j<fRegionSize->X(); j++) for (Int_t k=0; k<fRegionSize->Y(); k++) peaks[j][k] = 0;
                
@@ -231,8 +246,6 @@ Int_t AliEMCALTriggerTRU::L0()
 //             for(Int_t j=0; j<fRegionSize->X(); j++)
 //                     for (Int_t k=0; k<fRegionSize->Y(); k++) fRegion[j][k] = fRegion[j][k]>>2; // go to 12b before shipping to STU
                
-               Int_t nP = 0;
-               
                for (Int_t j=0; j<fPatches->GetEntriesFast(); j++)
                {
                        AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)fPatches->At( j );
@@ -247,6 +260,8 @@ Int_t AliEMCALTriggerTRU::L0()
                        
                        const Int_t psize =  sizeX * sizeY; // Number of FastOR in the patch
                        
+                       Int_t foundPeak = 0;
+                       
                        Int_t* idx = new Int_t[psize];
                        
                        for (Int_t xx=0;xx<sizeX;xx++) 
@@ -257,31 +272,44 @@ Int_t AliEMCALTriggerTRU::L0()
                                        
                                        idx[index] = fMap[int(v.X()*fSubRegionSize->X())+xx][int(v.Y()*fSubRegionSize->Y())+yy]; // Get current patch FastOR ADC channels 
                                        
-                                       if (peaks[int(v.X()*fSubRegionSize->X())+xx][int(v.Y()*fSubRegionSize->Y())+yy]) nP++;
+                                       if (peaks[int(v.X()*fSubRegionSize->X())+xx][int(v.Y()*fSubRegionSize->Y())+yy]) foundPeak++;
                                        
                                        if ( AliDebugLevel() ) ShowFastOR(i,idx[index]);
                                }
                        }
                        
-                       if ( nP ) 
+                       if ( !foundPeak ) 
                        {
-//                             cout << "break patch loop" << endl;
-                               break;
-                       }
+                               fPatches->RemoveAt( j );
+                               fPatches->Compress();
+                       }                               
                }
                
-               if ( !nP ) 
-                       fPatches->Delete();
+               //Delete, avoid leak
+               for (Int_t x = 0; x < xsize; x++)
+               {
+                       delete [] peaks[x];
+               }
+               delete [] peaks;
+
+               if ( !fPatches->GetEntriesFast() ) // No patch left
+                       ZeroRegion();
                else
                {
-//                     cout << "break time loop" << endl;
                        break;     // Stop the algo when at least one patch is found ( thres & max )
                }
-               
-               ZeroRegion();  // Clear fRegion for this time window before computing the next one              
        }
        
-//     cout << "Nof patches: " << fPatches->GetEntriesFast() << endl;
+       //Delete, avoid leak
+       for (Int_t x = 0; x < xsize; x++)
+       {
+               for (Int_t y = 0; y < ysize; y++)
+               {
+                       delete [] buffer[x][y];
+               }
+               delete [] buffer[x];
+       }
+       delete [] buffer;
        
        return fPatches->GetEntriesFast();
 }