X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALTriggerBoard.cxx;h=5da2bce3a3a06fcfaaad3897b2cd0d2191eacaaf;hb=8795e9935f62602e9f1a96cdab62af766d362125;hp=246f305fe5711eea18fe716b60813510792c31b1;hpb=0341167b566cd5317188db684658c6875af71e34;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALTriggerBoard.cxx b/EMCAL/AliEMCALTriggerBoard.cxx index 246f305fe57..5da2bce3a3a 100644 --- a/EMCAL/AliEMCALTriggerBoard.cxx +++ b/EMCAL/AliEMCALTriggerBoard.cxx @@ -23,9 +23,9 @@ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3 #include "AliEMCALTriggerBoard.h" #include "AliEMCALTriggerPatch.h" +#include "AliLog.h" #include - #include #include @@ -40,13 +40,13 @@ fMap(0x0), fRegionSize(0x0), fSubRegionSize(0x0), fPatchSize(0x0), -fPatches( new TClonesArray("AliEMCALTriggerPatch",10) ) +fPatches(0x0) { } //_______________ -AliEMCALTriggerBoard::AliEMCALTriggerBoard(const AliEMCALCalibData */*calibData*/, const TVector2& RS) : TObject(), +AliEMCALTriggerBoard::AliEMCALTriggerBoard(const TVector2& RS) : TObject(), fRegion(0x0), fMap(0x0), fRegionSize( new TVector2( RS ) ), @@ -54,87 +54,94 @@ fSubRegionSize( new TVector2() ), fPatchSize( new TVector2() ), fPatches( new TClonesArray("AliEMCALTriggerPatch",10) ) { - fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); - - if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n", - int(fRegionSize->X() * sizeof( int* ))); - - fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); - - if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n", - int(fRegionSize->X() * sizeof( int* ))); - - for (Int_t i=0;iX();i++) - { + // Ctor + + fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); + + if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n", + int(fRegionSize->X() * sizeof( int* ))); + + fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); + + if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n", + int(fRegionSize->X() * sizeof( int* ))); + + for (Int_t i=0;iX();i++) + { + if(fRegion){ fRegion[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) ); - + if (!fRegion[i]) printf("Error: malloc could not allocate %d bytes for fRegion[%d]\n", - i,int(fRegionSize->Y() * sizeof( int ))); - - fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) ); - - if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n", - i,int(fRegionSize->Y() * sizeof( int ))); - } - + i,int(fRegionSize->Y() * sizeof( int ))); + } + if(fMap){ + fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) ); + + if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n", + i,int(fRegionSize->Y() * sizeof( int ))); + } + } + // Initialize region matrix ZeroRegion(); - + if(fMap){ for (int i=0; iX(); ++i) for (int j=0; jY(); ++j) fMap[i][j] = 0; + } } //_______________ AliEMCALTriggerBoard::~AliEMCALTriggerBoard() { + // Dtor + for (Int_t i=0;iX();i++) { - if (fRegion[i]) {delete fRegion[i]; fRegion[i] = 0;} - if ( fMap[i]) {delete fMap[i]; fMap[i] = 0;} + if (fRegion[i]) {free(fRegion[i]); fRegion[i] = 0;} + if ( fMap[i]) {free(fMap[i]); fMap[i] = 0;} } - delete [] fRegion; fRegion = 0x0; - delete [] fMap; fMap = 0x0; + free(fRegion); fRegion = 0x0; + free(fMap); fMap = 0x0; if(fPatches)fPatches->Delete(); + delete fPatches; } //_______________ void AliEMCALTriggerBoard::ZeroRegion() { - // - for (Int_t i=0;iX());i++) for (Int_t j=0;jY());j++) fRegion[i][j] = 0; + // Initilize fRegion + + if(fRegion){ + for (Int_t i=0;iX());i++) for (Int_t j=0;jY());j++) fRegion[i][j] = 0; + } + else { + AliFatal("fRegion was not previously initialized"); + } + } //_______________ -void AliEMCALTriggerBoard::SlidingWindow( L1TriggerType_t /*type*/, Int_t thres ) +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())) { + // + int sum = 0; - for (Int_t k=0; kX()*fSubRegionSize->X()); k++) - { - for (Int_t l=0; lY()*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]; } } - - 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) ); + + if (sum > thres) { + AliDebug(999, Form("Adding new patch at (%2d,%2d)", i, j)); + new((*fPatches)[fPatches->GetEntriesFast()]) AliEMCALTriggerPatch(i, j, sum); } } } @@ -143,7 +150,8 @@ void AliEMCALTriggerBoard::SlidingWindow( L1TriggerType_t /*type*/, Int_t thres //__________ void AliEMCALTriggerBoard::Scan() { - // + // Dump + cout << " "; for (Int_t i=0; iX()); i++) printf("%8d ",i); cout << "\n";