]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTriggerBoard.cxx
ATO-98 AddCorrectionCompact - to make corrections compact in memory + UnitTests...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerBoard.cxx
index 4841bc250f75909dde0e8cabe95eada5639f415e..7bbf405098a5468f5806869fbe11019f6e0d5061 100644 (file)
@@ -23,9 +23,9 @@ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
 
 #include "AliEMCALTriggerBoard.h"
 #include "AliEMCALTriggerPatch.h"
+#include "AliLog.h"
 
 #include <TClonesArray.h>
-
 #include <iostream>
 #include <cstdlib>
 
@@ -40,7 +40,7 @@ fMap(0x0),
 fRegionSize(0x0),
 fSubRegionSize(0x0),
 fPatchSize(0x0),
-fPatches( new TClonesArray("AliEMCALTriggerPatch",10) )
+fPatches(0x0)
 {
        
 }      
@@ -54,6 +54,8 @@ fSubRegionSize( new TVector2() ),
 fPatchSize(     new TVector2() ),
 fPatches( new TClonesArray("AliEMCALTriggerPatch",10) )
 {
+       // Ctor
+       
   fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );  
   
   if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n",
@@ -91,6 +93,8 @@ fPatches( new TClonesArray("AliEMCALTriggerPatch",10) )
 //_______________
 AliEMCALTriggerBoard::~AliEMCALTriggerBoard()
 {
+       // Dtor
+       
    for (Int_t i=0;i<fRegionSize->X();i++) 
    {
       if (fRegion[i]) {free(fRegion[i]); fRegion[i] = 0;}
@@ -108,38 +112,38 @@ AliEMCALTriggerBoard::~AliEMCALTriggerBoard()
 //_______________
 void AliEMCALTriggerBoard::ZeroRegion()
 {
-       //
-       for (Int_t i=0;i<int(fRegionSize->X());i++) for (Int_t j=0;j<int(fRegionSize->Y());j++) fRegion[i][j] = 0;
+       // Initilize fRegion
+  
+  if(fRegion){
+    for (Int_t i=0;i<int(fRegionSize->X());i++) for (Int_t j=0;j<int(fRegionSize->Y());j++) fRegion[i][j] = 0;
+  }
+  else {
+    AliFatal("fRegion was not previously initialized");
+  }
+
 }
 
 //_______________
-void AliEMCALTriggerBoard::SlidingWindow(TriggerType_t /*type*/, Int_t thres, Int_t time)
+void AliEMCALTriggerBoard::SlidingWindow(Int_t thres)
 {
-       //
-       Int_t ipatch = 0;
-       
-       for (Int_t i=0; i<=int(fRegionSize->X()-fPatchSize->X()*fSubRegionSize->X()); i+=int(fSubRegionSize->X()))
-       {
-               for (Int_t j=0; j<=int(fRegionSize->Y()-fPatchSize->Y()*fSubRegionSize->Y()); j+=int(fSubRegionSize->Y()))
-               {
-                       ipatch++;
-                       
-                       Int_t sum = 0;
+       // Sliding window       
+       for (int i = 0; i <= int(fRegionSize->X() - fPatchSize->X() * fSubRegionSize->X()); i += int(fSubRegionSize->X())) {
+               for (int j = 0; j <= int(fRegionSize->Y() - fPatchSize->Y() * fSubRegionSize->Y()); j += int(fSubRegionSize->Y())) {
+                       //
+                       AliDebug(999, Form("--- Current window at (%2d,%2d) ---",i,j));
+                       int sum = 0;
                        
-                       for (Int_t k=0; k<int(fPatchSize->X()*fSubRegionSize->X()); k++)
-                       {
-                               for (Int_t l=0; l<int(fPatchSize->Y()*fSubRegionSize->Y()); l++)
-                               {
-                                       sum += fRegion[i+k][j+l];
+                       for (int k = 0; k < int(fPatchSize->X() * fSubRegionSize->X()); k++) {
+                               for (int l = 0; l < int(fPatchSize->Y() * fSubRegionSize->Y()); l++) {
+                                       //
+                                       sum += fRegion[i + k][j + l]; 
+                                       AliDebug(999, Form("Adding fRegion[%2d + %2d][%2d + %2d]: %d and sum is %d",i,k,j,l,fRegion[i + k][j + l],sum));
                                }
                        }
-
-                       if ( sum > thres ) 
-                       {
-                               //if ( type == kJet ) sum /= 4; // truncate patch sum for jet case
-                               
-                               new((*fPatches)[fPatches->GetLast()+1]) 
-                                               AliEMCALTriggerPatch(int(i/fSubRegionSize->X()), int(j/fSubRegionSize->Y()), int(sum), time);
+                       
+                       if (sum > thres) {
+                         AliDebug(999, Form("Adding new patch at (%2d,%2d) w/ amplitude %d", i, j, sum));
+                               new((*fPatches)[fPatches->GetEntriesFast()]) AliEMCALTriggerPatch(i, j, sum);
                        }
                }
        }
@@ -148,7 +152,8 @@ void AliEMCALTriggerBoard::SlidingWindow(TriggerType_t /*type*/, Int_t thres, In
 //__________
 void AliEMCALTriggerBoard::Scan()
 {
-       //
+       // Dump
+       
        cout << "     ";
        for (Int_t i=0; i<int(fRegionSize->X()); i++) printf("%8d ",i);
        cout << "\n";