1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 EMCal trigger board super class
20 run the sliding window algorithm
21 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
24 #include "AliEMCALTriggerBoard.h"
25 #include "AliEMCALTriggerPatch.h"
28 #include <TClonesArray.h>
34 ClassImp(AliEMCALTriggerBoard)
37 AliEMCALTriggerBoard::AliEMCALTriggerBoard() : TObject(),
49 AliEMCALTriggerBoard::AliEMCALTriggerBoard(const TVector2& RS) : TObject(),
52 fRegionSize( new TVector2( RS ) ),
53 fSubRegionSize( new TVector2() ),
54 fPatchSize( new TVector2() ),
55 fPatches( new TClonesArray("AliEMCALTriggerPatch",10) )
59 fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );
61 if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n",
62 int(fRegionSize->X() * sizeof( int* )));
64 fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );
66 if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n",
67 int(fRegionSize->X() * sizeof( int* )));
69 for (Int_t i=0;i<fRegionSize->X();i++)
72 fRegion[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) );
74 if (!fRegion[i]) printf("Error: malloc could not allocate %d bytes for fRegion[%d]\n",
75 i,int(fRegionSize->Y() * sizeof( int )));
78 fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) );
80 if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n",
81 i,int(fRegionSize->Y() * sizeof( int )));
85 // Initialize region matrix
88 for (int i=0; i<fRegionSize->X(); ++i)
89 for (int j=0; j<fRegionSize->Y(); ++j) fMap[i][j] = 0;
94 AliEMCALTriggerBoard::~AliEMCALTriggerBoard()
98 for (Int_t i=0;i<fRegionSize->X();i++)
100 if (fRegion[i]) {free(fRegion[i]); fRegion[i] = 0;}
101 if ( fMap[i]) {free(fMap[i]); fMap[i] = 0;}
104 free(fRegion); fRegion = 0x0;
105 free(fMap); fMap = 0x0;
107 if(fPatches)fPatches->Delete();
113 void AliEMCALTriggerBoard::ZeroRegion()
118 for (Int_t i=0;i<int(fRegionSize->X());i++) for (Int_t j=0;j<int(fRegionSize->Y());j++) fRegion[i][j] = 0;
121 AliFatal("fRegion was not previously initialized");
127 void AliEMCALTriggerBoard::SlidingWindow(Int_t thres)
130 for (int i = 0; i <= int(fRegionSize->X() - fPatchSize->X() * fSubRegionSize->X()); i += int(fSubRegionSize->X())) {
131 for (int j = 0; j <= int(fRegionSize->Y() - fPatchSize->Y() * fSubRegionSize->Y()); j += int(fSubRegionSize->Y())) {
133 AliDebug(999, Form("--- Current window at (%2d,%2d) ---",i,j));
136 for (int k = 0; k < int(fPatchSize->X() * fSubRegionSize->X()); k++) {
137 for (int l = 0; l < int(fPatchSize->Y() * fSubRegionSize->Y()); l++) {
139 sum += fRegion[i + k][j + l];
140 AliDebug(999, Form("Adding fRegion[%2d + %2d][%2d + %2d]: %d and sum is %d",i,k,j,l,fRegion[i + k][j + l],sum));
145 AliDebug(999, Form("Adding new patch at (%2d,%2d) w/ amplitude %d", i, j, sum));
146 new((*fPatches)[fPatches->GetEntriesFast()]) AliEMCALTriggerPatch(i, j, sum);
153 void AliEMCALTriggerBoard::Scan()
158 for (Int_t i=0; i<int(fRegionSize->X()); i++) printf("%8d ",i);
160 for (Int_t i=0; i<int(fRegionSize->X())-5; i++) printf("-------");
163 for (Int_t i=0; i<int(fRegionSize->Y()); i++)
167 for (Int_t j=0; j<int(fRegionSize->X())-5; j++) printf("-------");
172 for (Int_t j=0; j<int(fRegionSize->X()); j++)
174 printf("%2d/%5d ", fMap[j][i], fRegion[j][i]);
181 void AliEMCALTriggerBoard::Reset()