]>
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 | ||
dc483a03 | 29 | #include <iostream> |
30 | #include <cstdlib> | |
31 | ||
32 | using namespace std; | |
916f1e76 | 33 | |
34 | ClassImp(AliEMCALTriggerBoard) | |
35 | ||
36 | //_______________ | |
37 | AliEMCALTriggerBoard::AliEMCALTriggerBoard() : TObject(), | |
38 | fRegion(0x0), | |
39 | fMap(0x0), | |
40 | fRegionSize(0x0), | |
41 | fSubRegionSize(0x0), | |
42 | fPatchSize(0x0), | |
43 | fPatches( new TClonesArray("AliEMCALTriggerPatch",10) ) | |
44 | { | |
45 | ||
46 | } | |
47 | ||
48 | //_______________ | |
fff39dd1 | 49 | AliEMCALTriggerBoard::AliEMCALTriggerBoard(const TVector2& RS) : TObject(), |
916f1e76 | 50 | fRegion(0x0), |
51 | fMap(0x0), | |
52 | fRegionSize( new TVector2( RS ) ), | |
53 | fSubRegionSize( new TVector2() ), | |
54 | fPatchSize( new TVector2() ), | |
55 | fPatches( new TClonesArray("AliEMCALTriggerPatch",10) ) | |
56 | { | |
a51e676d | 57 | fRegion = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); |
58 | ||
59 | if (!fRegion) printf("Error: malloc could not allocate %d bytes for fRegion\n", | |
60 | int(fRegionSize->X() * sizeof( int* ))); | |
61 | ||
62 | fMap = (int**)malloc( (int)fRegionSize->X() * sizeof( int* ) ); | |
63 | ||
64 | if (!fMap) printf("Error: malloc could not allocate %d bytes for fMap\n", | |
65 | int(fRegionSize->X() * sizeof( int* ))); | |
66 | ||
67 | for (Int_t i=0;i<fRegionSize->X();i++) | |
68 | { | |
69 | if(fRegion){ | |
916f1e76 | 70 | fRegion[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) ); |
a51e676d | 71 | |
916f1e76 | 72 | if (!fRegion[i]) printf("Error: malloc could not allocate %d bytes for fRegion[%d]\n", |
a51e676d | 73 | i,int(fRegionSize->Y() * sizeof( int ))); |
74 | } | |
75 | if(fMap){ | |
76 | fMap[i] = (int*)malloc( (int)fRegionSize->Y() * sizeof( int ) ); | |
77 | ||
78 | if (!fMap[i]) printf("Error: malloc could not allocate %d bytes for fMap[%d]\n", | |
79 | i,int(fRegionSize->Y() * sizeof( int ))); | |
80 | } | |
81 | } | |
82 | ||
916f1e76 | 83 | // Initialize region matrix |
84 | ZeroRegion(); | |
a51e676d | 85 | if(fMap){ |
916f1e76 | 86 | for (int i=0; i<fRegionSize->X(); ++i) |
87 | for (int j=0; j<fRegionSize->Y(); ++j) fMap[i][j] = 0; | |
a51e676d | 88 | } |
916f1e76 | 89 | } |
90 | ||
91 | //_______________ | |
92 | AliEMCALTriggerBoard::~AliEMCALTriggerBoard() | |
93 | { | |
94 | for (Int_t i=0;i<fRegionSize->X();i++) | |
95 | { | |
de39a0ff | 96 | if (fRegion[i]) {free(fRegion[i]); fRegion[i] = 0;} |
97 | if ( fMap[i]) {free(fMap[i]); fMap[i] = 0;} | |
916f1e76 | 98 | } |
99 | ||
de39a0ff | 100 | free(fRegion); fRegion = 0x0; |
101 | free(fMap); fMap = 0x0; | |
916f1e76 | 102 | |
0341167b | 103 | if(fPatches)fPatches->Delete(); |
de39a0ff | 104 | |
0341167b | 105 | delete fPatches; |
916f1e76 | 106 | } |
107 | ||
108 | //_______________ | |
109 | void AliEMCALTriggerBoard::ZeroRegion() | |
110 | { | |
111 | // | |
112 | for (Int_t i=0;i<int(fRegionSize->X());i++) for (Int_t j=0;j<int(fRegionSize->Y());j++) fRegion[i][j] = 0; | |
113 | } | |
114 | ||
115 | //_______________ | |
de39a0ff | 116 | void AliEMCALTriggerBoard::SlidingWindow(TriggerType_t /*type*/, Int_t thres, Int_t time) |
916f1e76 | 117 | { |
118 | // | |
119 | Int_t ipatch = 0; | |
120 | ||
121 | for (Int_t i=0; i<=int(fRegionSize->X()-fPatchSize->X()*fSubRegionSize->X()); i+=int(fSubRegionSize->X())) | |
122 | { | |
123 | for (Int_t j=0; j<=int(fRegionSize->Y()-fPatchSize->Y()*fSubRegionSize->Y()); j+=int(fSubRegionSize->Y())) | |
124 | { | |
125 | ipatch++; | |
126 | ||
127 | Int_t sum = 0; | |
128 | ||
129 | for (Int_t k=0; k<int(fPatchSize->X()*fSubRegionSize->X()); k++) | |
130 | { | |
131 | for (Int_t l=0; l<int(fPatchSize->Y()*fSubRegionSize->Y()); l++) | |
132 | { | |
133 | sum += fRegion[i+k][j+l]; | |
134 | } | |
135 | } | |
136 | ||
137 | if ( sum > thres ) | |
138 | { | |
139 | //if ( type == kJet ) sum /= 4; // truncate patch sum for jet case | |
140 | ||
141 | new((*fPatches)[fPatches->GetLast()+1]) | |
de39a0ff | 142 | AliEMCALTriggerPatch(int(i/fSubRegionSize->X()), int(j/fSubRegionSize->Y()), int(sum), time); |
916f1e76 | 143 | } |
144 | } | |
145 | } | |
146 | } | |
147 | ||
148 | //__________ | |
149 | void AliEMCALTriggerBoard::Scan() | |
150 | { | |
151 | // | |
152 | cout << " "; | |
153 | for (Int_t i=0; i<int(fRegionSize->X()); i++) printf("%8d ",i); | |
154 | cout << "\n"; | |
155 | for (Int_t i=0; i<int(fRegionSize->X())-5; i++) printf("-------"); | |
156 | cout << "\n"; | |
157 | ||
158 | for (Int_t i=0; i<int(fRegionSize->Y()); i++) | |
159 | { | |
160 | if (i && !(i%12)) | |
161 | { | |
162 | for (Int_t j=0; j<int(fRegionSize->X())-5; j++) printf("-------"); | |
163 | cout << endl; | |
164 | } | |
165 | ||
166 | printf("%3d |",i); | |
167 | for (Int_t j=0; j<int(fRegionSize->X()); j++) | |
168 | { | |
169 | printf("%2d/%5d ", fMap[j][i], fRegion[j][i]); | |
170 | } | |
171 | cout << endl; | |
172 | } | |
173 | } | |
174 | ||
175 | //__________ | |
176 | void AliEMCALTriggerBoard::Reset() | |
177 | { | |
178 | // | |
179 | fPatches->Delete(); | |
180 | ZeroRegion(); | |
181 | } | |
182 |