]>
Commit | Line | Data |
---|---|---|
916f1e76 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | ||
18 | ||
19 | EMCal trigger board super class | |
20 | run the sliding window algorithm | |
21 | Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3 | |
22 | */ | |
23 | ||
24 | #include "AliEMCALTriggerBoard.h" | |
25 | #include "AliEMCALTriggerPatch.h" | |
26 | ||
27 | #include <TClonesArray.h> | |
28 | ||
29 | #include <iostream.h> | |
30 | ||
31 | ClassImp(AliEMCALTriggerBoard) | |
32 | ||
33 | //_______________ | |
34 | AliEMCALTriggerBoard::AliEMCALTriggerBoard() : TObject(), | |
35 | fRegion(0x0), | |
36 | fMap(0x0), | |
37 | fRegionSize(0x0), | |
38 | fSubRegionSize(0x0), | |
39 | fPatchSize(0x0), | |
40 | fPatches( new TClonesArray("AliEMCALTriggerPatch",10) ) | |
41 | { | |
42 | ||
43 | } | |
44 | ||
45 | //_______________ | |
46 | AliEMCALTriggerBoard::AliEMCALTriggerBoard(const AliEMCALCalibData */*calibData*/, const TVector2& RS) : TObject(), | |
47 | fRegion(0x0), | |
48 | fMap(0x0), | |
49 | fRegionSize( new TVector2( RS ) ), | |
50 | fSubRegionSize( new TVector2() ), | |
51 | fPatchSize( new TVector2() ), | |
52 | fPatches( new TClonesArray("AliEMCALTriggerPatch",10) ) | |
53 | { | |
54 | fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); | |
55 | ||
56 | if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n", | |
57 | int(fRegionSize->X() * sizeof( int* ))); | |
58 | ||
59 | fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); | |
60 | ||
61 | if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n", | |
62 | int(fRegionSize->X() * sizeof( int* ))); | |
63 | ||
64 | for (Int_t i=0;i<fRegionSize->X();i++) | |
65 | { | |
66 | fRegion[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) ); | |
67 | ||
68 | if (!fRegion[i]) printf("Error: malloc could not allocate %d bytes for fRegion[%d]\n", | |
69 | i,int(fRegionSize->Y() * sizeof( int ))); | |
70 | ||
71 | fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) ); | |
72 | ||
73 | if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n", | |
74 | i,int(fRegionSize->Y() * sizeof( int ))); | |
75 | } | |
76 | ||
77 | // Initialize region matrix | |
78 | ZeroRegion(); | |
79 | ||
80 | for (int i=0; i<fRegionSize->X(); ++i) | |
81 | for (int j=0; j<fRegionSize->Y(); ++j) fMap[i][j] = 0; | |
82 | } | |
83 | ||
84 | //_______________ | |
85 | AliEMCALTriggerBoard::~AliEMCALTriggerBoard() | |
86 | { | |
87 | for (Int_t i=0;i<fRegionSize->X();i++) | |
88 | { | |
89 | if (fRegion[i]) {delete fRegion[i]; fRegion[i] = 0;} | |
90 | if ( fMap[i]) {delete fMap[i]; fMap[i] = 0;} | |
91 | } | |
92 | ||
93 | delete [] fRegion; fRegion = 0x0; | |
94 | delete [] fMap; fMap = 0x0; | |
95 | ||
96 | fPatches->Delete(); | |
97 | } | |
98 | ||
99 | //_______________ | |
100 | void AliEMCALTriggerBoard::ZeroRegion() | |
101 | { | |
102 | // | |
103 | for (Int_t i=0;i<int(fRegionSize->X());i++) for (Int_t j=0;j<int(fRegionSize->Y());j++) fRegion[i][j] = 0; | |
104 | } | |
105 | ||
106 | //_______________ | |
107 | void AliEMCALTriggerBoard::SlidingWindow( L1TriggerType_t /*type*/, Int_t thres ) | |
108 | { | |
109 | // | |
110 | Int_t ipatch = 0; | |
111 | ||
112 | for (Int_t i=0; i<=int(fRegionSize->X()-fPatchSize->X()*fSubRegionSize->X()); i+=int(fSubRegionSize->X())) | |
113 | { | |
114 | for (Int_t j=0; j<=int(fRegionSize->Y()-fPatchSize->Y()*fSubRegionSize->Y()); j+=int(fSubRegionSize->Y())) | |
115 | { | |
116 | ipatch++; | |
117 | ||
118 | Int_t sum = 0; | |
119 | ||
120 | for (Int_t k=0; k<int(fPatchSize->X()*fSubRegionSize->X()); k++) | |
121 | { | |
122 | for (Int_t l=0; l<int(fPatchSize->Y()*fSubRegionSize->Y()); l++) | |
123 | { | |
124 | sum += fRegion[i+k][j+l]; | |
125 | } | |
126 | } | |
127 | ||
128 | if ( sum > thres ) | |
129 | { | |
130 | //if ( type == kJet ) sum /= 4; // truncate patch sum for jet case | |
131 | ||
132 | new((*fPatches)[fPatches->GetLast()+1]) | |
133 | AliEMCALTriggerPatch( int(i/fSubRegionSize->X()), int(j/fSubRegionSize->Y()), int(sum) ); | |
134 | } | |
135 | } | |
136 | } | |
137 | } | |
138 | ||
139 | //__________ | |
140 | void AliEMCALTriggerBoard::Scan() | |
141 | { | |
142 | // | |
143 | cout << " "; | |
144 | for (Int_t i=0; i<int(fRegionSize->X()); i++) printf("%8d ",i); | |
145 | cout << "\n"; | |
146 | for (Int_t i=0; i<int(fRegionSize->X())-5; i++) printf("-------"); | |
147 | cout << "\n"; | |
148 | ||
149 | for (Int_t i=0; i<int(fRegionSize->Y()); i++) | |
150 | { | |
151 | if (i && !(i%12)) | |
152 | { | |
153 | for (Int_t j=0; j<int(fRegionSize->X())-5; j++) printf("-------"); | |
154 | cout << endl; | |
155 | } | |
156 | ||
157 | printf("%3d |",i); | |
158 | for (Int_t j=0; j<int(fRegionSize->X()); j++) | |
159 | { | |
160 | printf("%2d/%5d ", fMap[j][i], fRegion[j][i]); | |
161 | } | |
162 | cout << endl; | |
163 | } | |
164 | } | |
165 | ||
166 | //__________ | |
167 | void AliEMCALTriggerBoard::Reset() | |
168 | { | |
169 | // | |
170 | fPatches->Delete(); | |
171 | ZeroRegion(); | |
172 | } | |
173 |