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"
27 #include <TClonesArray.h>
34 ClassImp(AliEMCALTriggerBoard)
37 AliEMCALTriggerBoard::AliEMCALTriggerBoard() : TObject(),
43 fPatches( new TClonesArray("AliEMCALTriggerPatch",10) )
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) )
57 fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );
59 if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n",
60 int(fRegionSize->X() * sizeof( int* )));
62 fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) );
64 if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n",
65 int(fRegionSize->X() * sizeof( int* )));
67 for (Int_t i=0;i<fRegionSize->X();i++)
69 fRegion[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) );
71 if (!fRegion[i]) printf("Error: malloc could not allocate %d bytes for fRegion[%d]\n",
72 i,int(fRegionSize->Y() * sizeof( int )));
74 fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) );
76 if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n",
77 i,int(fRegionSize->Y() * sizeof( int )));
80 // Initialize region matrix
83 for (int i=0; i<fRegionSize->X(); ++i)
84 for (int j=0; j<fRegionSize->Y(); ++j) fMap[i][j] = 0;
88 AliEMCALTriggerBoard::~AliEMCALTriggerBoard()
90 for (Int_t i=0;i<fRegionSize->X();i++)
92 if (fRegion[i]) {delete fRegion[i]; fRegion[i] = 0;}
93 if ( fMap[i]) {delete fMap[i]; fMap[i] = 0;}
96 delete [] fRegion; fRegion = 0x0;
97 delete [] fMap; fMap = 0x0;
99 if(fPatches)fPatches->Delete();
104 void AliEMCALTriggerBoard::ZeroRegion()
107 for (Int_t i=0;i<int(fRegionSize->X());i++) for (Int_t j=0;j<int(fRegionSize->Y());j++) fRegion[i][j] = 0;
111 void AliEMCALTriggerBoard::SlidingWindow( L1TriggerType_t /*type*/, Int_t thres )
116 for (Int_t i=0; i<=int(fRegionSize->X()-fPatchSize->X()*fSubRegionSize->X()); i+=int(fSubRegionSize->X()))
118 for (Int_t j=0; j<=int(fRegionSize->Y()-fPatchSize->Y()*fSubRegionSize->Y()); j+=int(fSubRegionSize->Y()))
124 for (Int_t k=0; k<int(fPatchSize->X()*fSubRegionSize->X()); k++)
126 for (Int_t l=0; l<int(fPatchSize->Y()*fSubRegionSize->Y()); l++)
128 sum += fRegion[i+k][j+l];
134 //if ( type == kJet ) sum /= 4; // truncate patch sum for jet case
136 new((*fPatches)[fPatches->GetLast()+1])
137 AliEMCALTriggerPatch( int(i/fSubRegionSize->X()), int(j/fSubRegionSize->Y()), int(sum) );
144 void AliEMCALTriggerBoard::Scan()
148 for (Int_t i=0; i<int(fRegionSize->X()); i++) printf("%8d ",i);
150 for (Int_t i=0; i<int(fRegionSize->X())-5; i++) printf("-------");
153 for (Int_t i=0; i<int(fRegionSize->Y()); i++)
157 for (Int_t j=0; j<int(fRegionSize->X())-5; j++) printf("-------");
162 for (Int_t j=0; j<int(fRegionSize->X()); j++)
164 printf("%2d/%5d ", fMap[j][i], fRegion[j][i]);
171 void AliEMCALTriggerBoard::Reset()