]>
Commit | Line | Data |
---|---|---|
787342d6 | 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 | ||
20 | ||
21 | Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3 | |
22 | */ | |
23 | ||
24 | #include "AliEMCALTriggerMapping.h" | |
25 | #include "AliEMCALTriggerMappingV1.h" | |
26 | #include "AliEMCALGeometry.h" | |
27 | #include "AliLog.h" | |
28 | ||
29 | ClassImp(AliEMCALTriggerMappingV1) | |
30 | ||
31 | //________________________________________________________________________________________________ | |
32 | AliEMCALTriggerMappingV1::AliEMCALTriggerMappingV1() : AliEMCALTriggerMapping() | |
33 | { | |
34 | // Ctor | |
35 | ||
36 | SetUniqueID(1); | |
37 | } | |
38 | //________________________________________________________________________________________________ | |
39 | AliEMCALTriggerMappingV1::AliEMCALTriggerMappingV1(const Int_t ntru, const AliEMCALGeometry* geo) : AliEMCALTriggerMapping(ntru, geo) | |
40 | { | |
41 | // Ctor | |
42 | ||
43 | SetUniqueID(1); | |
44 | } | |
45 | ||
46 | //________________________________________________________________________________________________ | |
47 | Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const | |
48 | { | |
49 | //Trigger mapping method, get FastOr Index from TRU | |
50 | ||
51 | if (iTRU > fNTRU - 1 || iTRU < 0 || iADC > 95 || iADC < 0) { | |
52 | AliError("TRU out of range!"); | |
53 | return kFALSE; | |
54 | } | |
55 | ||
56 | id = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4); | |
57 | id += iTRU * 96; | |
58 | return kTRUE; | |
59 | } | |
60 | ||
61 | //________________________________________________________________________________________________ | |
62 | Bool_t AliEMCALTriggerMappingV1::GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const | |
63 | { | |
64 | // Trigger mapping method, get TRU number from FastOr Index | |
65 | ||
66 | if (id > fNTRU * 96 - 1 || id < 0) { | |
67 | AliError("Fast-OR ID is out of range!"); | |
68 | return kFALSE; | |
69 | } | |
70 | ||
71 | iTRU = id / 96; | |
72 | iADC = id % 96; | |
73 | iADC = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4); | |
74 | return kTRUE; | |
75 | } | |
76 | ||
77 | //________________________________________________________________________________________________ | |
78 | Bool_t AliEMCALTriggerMappingV1::GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const | |
79 | { | |
80 | // Trigger mapping method, get position in TRU from FasOr Index | |
81 | ||
82 | Int_t iADC = -1; | |
83 | if (!GetTRUFromAbsFastORIndex(id, iTRU, iADC)) return kFALSE; | |
84 | ||
85 | Int_t x = iADC / 4; | |
86 | Int_t y = iADC % 4; | |
87 | if ( iTRU % 2 ) { // C side | |
88 | iEta = 23 - x; | |
89 | iPhi = y; | |
90 | } | |
91 | else { // A side | |
92 | iEta = x; | |
93 | iPhi = 3 - y; | |
94 | } | |
95 | return kTRUE; | |
96 | } | |
97 | ||
98 | //________________________________________________________________________________________________ | |
99 | Bool_t AliEMCALTriggerMappingV1::GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const | |
100 | { | |
101 | //Trigger mapping method, get position in Super Module from FasOr Index | |
102 | ||
103 | Int_t iTRU = -1; | |
104 | if (!GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi)) return kFALSE; | |
105 | if (iTRU % 2) { // C side | |
106 | iSM = 2 * (int(int(iTRU / 2) / 3)) + 1; | |
107 | } else { // A side | |
108 | iSM = 2 * (int(int(iTRU / 2) / 3)); | |
109 | } | |
110 | iPhi += 4 * int((iTRU % 6) / 2); | |
111 | return kTRUE; | |
112 | } | |
113 | ||
114 | //________________________________________________________________________________________________ | |
115 | Bool_t AliEMCALTriggerMappingV1::GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const | |
116 | { | |
117 | //Trigger mapping method, get position in EMCAL from FastOR index | |
118 | ||
119 | Int_t iSM = -1; | |
120 | if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi)) { | |
121 | if (iSM % 2) iEta += 24; | |
122 | iPhi += 12 * int(iSM / 2); | |
123 | return kTRUE; | |
124 | } | |
125 | return kFALSE; | |
126 | } | |
127 | ||
128 | //________________________________________________________________________________________________ | |
129 | Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const | |
130 | { | |
131 | //Trigger mapping method, get Index if FastOr from Position in TRU | |
132 | if (iTRU < 0 || iTRU > fNTRU - 1 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 3) { | |
133 | AliError(Form("Out of range! iTRU=%d, iEta=%d, iPhi=%d", iTRU, iEta, iPhi)); | |
134 | return kFALSE; | |
135 | } | |
136 | id = iPhi + 4 * iEta + iTRU * 96; | |
137 | return kTRUE; | |
138 | } | |
139 | ||
140 | //________________________________________________________________________________________________ | |
141 | Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromPositionInSM(const Int_t iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const | |
142 | { | |
143 | // Trigger mapping method, from position in SM Index get FastOR index | |
144 | ||
145 | if (iSM < 0 || iSM >= 12 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 11) { | |
146 | AliError(Form("Out of range! iSM=%d, iEta=%d, iPhi=%d", iSM, iEta, iPhi)); | |
147 | return kFALSE; | |
148 | } | |
149 | ||
150 | Int_t x = iEta; | |
151 | Int_t y = iPhi % 4; | |
152 | Int_t iOff = (iSM % 2) ? 1 : 0; | |
153 | Int_t iTRU = 2 * int(iPhi / 4) + 6 * int(iSM / 2) + iOff; | |
154 | if (GetAbsFastORIndexFromPositionInTRU(iTRU, x, y, id)) { | |
155 | return kTRUE; | |
156 | } | |
157 | return kFALSE; | |
158 | } | |
159 | ||
160 | //________________________________________________________________________________________________ | |
161 | Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromPositionInEMCAL(const Int_t iEta, const Int_t iPhi, Int_t& id) const | |
162 | { | |
163 | // Trigger mapping method, from position in EMCAL Index get FastOR index | |
164 | ||
165 | if (iEta < 0 || iEta > 47 || iPhi < 0 || iPhi > 59) { | |
166 | AliError(Form("Out of range! iEta: %2d iPhi: %2d", iEta, iPhi)); | |
167 | return kFALSE; | |
168 | } | |
169 | ||
170 | id = iEta * 48 + iPhi; | |
171 | ||
172 | return kTRUE; | |
173 | } | |
174 | ||
175 | //________________________________________________________________________________________________ | |
176 | Bool_t AliEMCALTriggerMappingV1::GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const | |
177 | { | |
178 | // Trigger mapping method, from cell index get FastOR index | |
179 | ||
180 | Int_t iSupMod, nModule, nIphi, nIeta, iphim, ietam; | |
181 | Bool_t isOK = fGeometry->GetCellIndex( id, iSupMod, nModule, nIphi, nIeta ); | |
182 | fGeometry->GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam ); | |
183 | ||
184 | if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx)) return kTRUE; | |
185 | return kFALSE; | |
186 | } | |
187 | ||
188 | //________________________________________________________________________________________________ | |
189 | Bool_t AliEMCALTriggerMappingV1::GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const | |
190 | { | |
191 | // Trigger mapping method, from FASTOR index get cell index | |
192 | ||
193 | Int_t iSM=-1, iEta=-1, iPhi=-1; | |
194 | if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi)) { | |
195 | Int_t ix = 2 * iEta; | |
196 | Int_t iy = 2 * iPhi; | |
197 | for (Int_t i = 0; i < 2; i++) { | |
198 | for (Int_t j = 0; j < 2; j++) { | |
199 | idx[2 * i + j] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy + i, ix + j); | |
200 | } | |
201 | } | |
202 | return kTRUE; | |
203 | } | |
204 | return kFALSE; | |
205 | } | |
206 | ||
207 | //________________________________________________________________________________________________ | |
208 | Bool_t AliEMCALTriggerMappingV1::GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const | |
209 | { | |
210 | // STU mapping: TRU# 0 and 16 are missing | |
211 | ||
212 | if (id > 31 || id < 0) { | |
213 | AliError(Form("TRU index out of range: %d",id)); | |
214 | return kFALSE; | |
215 | } | |
216 | ||
217 | idx = GetTRUIndexFromSTUIndex(id); | |
218 | return kTRUE; | |
219 | } | |
220 | ||
221 | //________________________________________________________________________________________________ | |
222 | Int_t AliEMCALTriggerMappingV1::GetTRUIndexFromSTUIndex(const Int_t id) const | |
223 | { | |
224 | // STU mapping: TRU# 0 and 16 are missing | |
225 | ||
226 | if (id > 31 || id < 0) { | |
227 | AliError(Form("TRU index out of range: %d",id)); | |
228 | } | |
229 | return (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1; | |
230 | } | |
231 | ||
232 | //________________________________________________________________________________________________ | |
233 | Bool_t AliEMCALTriggerMappingV1::GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx) const | |
234 | { | |
235 | //Trigger mapping method, from STU index get TRU index | |
236 | ||
237 | idx = GetOnlineIndexFromTRUIndex(id); | |
238 | if (idx > fNTRU - 1 || idx < 0) { | |
239 | AliError(Form("TRU index out of range: %d",idx)); | |
240 | return kFALSE; | |
241 | } | |
242 | return kTRUE; | |
243 | } | |
244 | ||
245 | //________________________________________________________________________________________________ | |
246 | Int_t AliEMCALTriggerMappingV1::GetTRUIndexFromOnlineIndex(const Int_t id) const | |
247 | { | |
248 | //Trigger mapping method, from STU index get TRU index | |
249 | ||
250 | if (id > fNTRU - 1 || id < 0) { | |
251 | AliError(Form("TRU index out of range: %d",id)); | |
252 | } | |
253 | if (id == 31) { | |
254 | return 31; | |
255 | } | |
256 | ||
257 | //jump 4 TRUs for DCAL | |
258 | Int_t tmp=0; | |
259 | if(id > 31) tmp = id+4; | |
260 | else tmp = id; | |
261 | Int_t idx = ((tmp% 6) < 3) ? 6 * int(tmp/ 6) + 2 * (tmp% 3) : 6 * int(tmp/ 6) + 2 * (2 - (tmp% 3)) + 1; | |
262 | if(id > 31) idx-=4; | |
263 | return idx; | |
264 | } | |
265 | ||
266 | //________________________________________________________________________________________________ | |
267 | Bool_t AliEMCALTriggerMappingV1::GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx) const | |
268 | { | |
269 | //Trigger mapping method, from STU index get TRU index | |
270 | ||
271 | idx = GetOnlineIndexFromTRUIndex(id); | |
272 | if (idx > fNTRU-1 || idx < 0) | |
273 | { | |
274 | AliError(Form("TRU index out of range: %d",idx)); | |
275 | return kFALSE; | |
276 | } | |
277 | return kTRUE; | |
278 | } | |
279 | //________________________________________________________________________________________________ | |
280 | Int_t AliEMCALTriggerMappingV1::GetOnlineIndexFromTRUIndex(const Int_t id) const | |
281 | { | |
282 | //Trigger mapping method, from STU index get TRU index | |
283 | ||
284 | if (id > fNTRU-1 || id < 0) | |
285 | { | |
286 | AliError(Form("TRU index out of range: %d",id)); | |
287 | } | |
288 | if (id == 31) { | |
289 | return 31; | |
290 | } | |
291 | ||
292 | //jump 4 TRUs for DCAL | |
293 | Int_t tmp=0; | |
294 | if(id > 31) tmp = id+4; | |
295 | else tmp = id; | |
296 | Int_t idx = (tmp % 2) ? int((6 - (tmp % 6)) / 2) + 3 * (2 * int(tmp / 6) + 1) : 3 * int(tmp / 6) + int(tmp / 2); | |
297 | if(id > 31) idx-=4; | |
298 | return idx; | |
299 | } | |
300 | ||
301 | //________________________________________________________________________________________________ | |
302 | Bool_t AliEMCALTriggerMappingV1::GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const | |
303 | { | |
304 | //Trigger mapping method, from L0 index get FastOR index | |
305 | ||
306 | if (size <= 0 || size > 4) { | |
307 | AliError("Size not supported!"); | |
308 | return kFALSE; | |
309 | } | |
310 | ||
311 | Int_t motif[4] = {0, 1, 4, 5}; | |
312 | switch (size) { | |
313 | case 1: // Cosmic trigger | |
314 | if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[1])) return kFALSE; | |
315 | break; | |
316 | case 4: // 4 x 4 | |
317 | for (Int_t k = 0; k < 4; k++) { | |
318 | Int_t iADC = motif[k] + 4 * int(id / 3) + (id % 3); | |
319 | ||
320 | if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE; | |
321 | } | |
322 | break; | |
323 | default: | |
324 | break; | |
325 | } | |
326 | ||
327 | return kTRUE; | |
328 | } | |
329 | ||
330 | ||
331 |