Line data Source code
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 : #include "AliEMCALTriggerMapping.h"
17 : #include "AliEMCALTriggerMappingV2.h"
18 : #include "AliEMCALGeometry.h"
19 : #include "AliLog.h"
20 :
21 72 : ClassImp(AliEMCALTriggerMappingV2)
22 :
23 : //________________________________________________________________________________________________
24 0 : AliEMCALTriggerMappingV2::AliEMCALTriggerMappingV2() : AliEMCALTriggerMapping()
25 0 : {
26 : // Ctor
27 0 : SetUniqueID(2);
28 :
29 0 : for(Int_t iTRU=0; iTRU<fNTotalTRU; iTRU++){
30 0 : fTRUFastOROffsetX[iTRU] = 0 ;
31 0 : fTRUFastOROffsetY[iTRU] = 0 ;
32 0 : fnFastORInTRUPhi[ iTRU] = 0 ;
33 0 : fnFastORInTRUEta[ iTRU] = 0 ;
34 0 : fTRUIsCside[ iTRU] = kFALSE ;
35 : }
36 0 : for(Int_t iSM=0; iSM<fNumberOfSuperModules; iSM++){
37 0 : fSMFastOROffsetX[ iSM] = 0 ;
38 0 : fSMFastOROffsetY[ iSM] = 0 ;
39 0 : fnFastORInSMPhi[ iSM] = 0 ;
40 0 : fnFastORInSMEta[ iSM] = 0 ;
41 : }
42 0 : for(Int_t iB=0; iB<5; iB++){
43 0 : fnModuleInEMCALPhi[iB] = 0 ;
44 : }
45 0 : }
46 : //________________________________________________________________________________________________
47 2 : AliEMCALTriggerMappingV2::AliEMCALTriggerMappingV2(Int_t ntru, const AliEMCALGeometry* geo) : AliEMCALTriggerMapping(ntru, geo)
48 10 : {
49 : // Ctor
50 2 : SetUniqueID(2);
51 :
52 212 : for(Int_t iTRU=0; iTRU<fNTotalTRU; iTRU++){
53 104 : fTRUFastOROffsetX[iTRU] = 0;
54 104 : fTRUFastOROffsetY[iTRU] = 0;
55 104 : fnFastORInTRUPhi[ iTRU] = 0;
56 104 : fnFastORInTRUEta[ iTRU] = 0;
57 104 : fTRUIsCside[ iTRU] = kFALSE ;
58 : }
59 84 : for(Int_t iSM=0; iSM<fNumberOfSuperModules; iSM++){
60 40 : fSMFastOROffsetX[ iSM] = 0;
61 40 : fSMFastOROffsetY[ iSM] = 0;
62 40 : fnFastORInSMPhi[ iSM] = 0;
63 40 : fnFastORInSMEta[ iSM] = 0;
64 : }
65 24 : for(Int_t iB=0; iB<5; iB++){
66 10 : fnModuleInEMCALPhi[iB] = 0 ;
67 : }
68 :
69 2 : Init_TRU_offset() ;
70 2 : Init_SM_offset() ;
71 4 : }
72 :
73 : //________________________________________________________________________________________________
74 : Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromTRU(Int_t iTRU, Int_t iADC, Int_t& id) const
75 : {
76 : //Trigger mapping method, get FastOr Index from TRU
77 0 : if (iTRU > fNTotalTRU-1 || iTRU < 0 ||
78 0 : iADC > fNModulesInTRU-1 || iADC < 0
79 : ){
80 0 : AliError(Form("Out of range! iTRU=%d, iADC=%d", iTRU, iADC));
81 0 : return kFALSE;
82 : }
83 :
84 0 : Int_t iADCtmp = (fTRUIsCside[ iTRU])? (fNModulesInTRU - iADC - 1) : iADC ;
85 0 : Int_t x = fTRUFastOROffsetX[iTRU] + int(iADCtmp / fnFastORInTRUPhi[iTRU]) ;
86 0 : Int_t y = fTRUFastOROffsetY[iTRU] + fnFastORInTRUPhi[iTRU] - 1 - int(iADCtmp % fnFastORInTRUPhi[iTRU]) ;
87 0 : id = y * fSTURegionNEta + x ;
88 0 : id = ConvAbsFastORIndexA2B(id) ;
89 : return kTRUE ;
90 0 : }
91 :
92 : //________________________________________________________________________________________________
93 : Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromPositionInTRU(Int_t iTRU, Int_t iEta, Int_t iPhi, Int_t& id) const
94 : {
95 : //Trigger mapping method, get Index if FastOr from Position in TRU
96 188 : if (iTRU > fNTotalTRU-1 || iTRU < 0 ||
97 94 : iEta > fnFastORInTRUEta[iTRU] - 1 || iEta < 0 ||
98 52 : iPhi > fnFastORInTRUPhi[iTRU] - 1 || iPhi < 0
99 : ){
100 42 : AliError(Form("Out of range! iTRU=%d, iEta=%d, iPhi=%d", iTRU, iEta, iPhi));
101 42 : return kFALSE;
102 : }
103 : Int_t iEtatmp = iEta ;//XXX
104 : Int_t iPhitmp = iPhi ;//XXX
105 : //Int_t iEtatmp = ( fTRUIsCside[ iTRU])? (fnFastORInTRUEta[iTRU] - 1 - iEta) : iEta ;
106 : //Int_t iPhitmp = (!fTRUIsCside[ iTRU])? (fnFastORInTRUPhi[iTRU] - 1 - iPhi) : iPhi ;
107 52 : Int_t x = fTRUFastOROffsetX[iTRU] + iEtatmp ;
108 52 : Int_t y = fTRUFastOROffsetY[iTRU] + iPhitmp ;
109 52 : id = y * fSTURegionNEta + x ;
110 52 : id = ConvAbsFastORIndexA2B(id) ;
111 : return kTRUE ;
112 94 : }
113 :
114 : //________________________________________________________________________________________________
115 : Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromPositionInSM(Int_t iSM, Int_t iEta, Int_t iPhi, Int_t& id) const
116 : {
117 : //Trigger mapping method, from position in SM Index get FastOR index
118 536 : if (iSM > fNumberOfSuperModules-1 || iSM < 0 ||
119 268 : iEta > fnFastORInSMEta[iSM] -1 || iEta < 0 ||
120 268 : iPhi > fnFastORInSMPhi[iSM] -1 || iPhi < 0
121 : ){
122 0 : AliError(Form("Out of range! iSM=%d, iEta=%d, iPhi=%d", iSM, iEta, iPhi));
123 0 : return kFALSE;
124 : }
125 : //Int_t iEtatmp = (GetSMIsCside(iSM) && GetSMType(iSM) == kDCAL_Standard)?(iEta + 8):iEta ;
126 : //Int_t x = fSMFastOROffsetX[iSM] + iEtatmp ;
127 268 : Int_t x = fSMFastOROffsetX[iSM] + iEta ;
128 268 : Int_t y = fSMFastOROffsetY[iSM] + iPhi ;
129 268 : id = y * fSTURegionNEta + x ;
130 268 : id = ConvAbsFastORIndexA2B(id) ;
131 : return kTRUE ;
132 268 : }
133 :
134 : //________________________________________________________________________________________________
135 : Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromPositionInEMCAL(Int_t iEta, Int_t iPhi, Int_t& id) const
136 : {
137 : //Trigger mapping method, from position in EMCAL Index get FastOR index
138 : if (
139 672 : iEta > fSTURegionNEta - 1 || iEta < 0 ||
140 336 : iPhi > fSTURegionNPhi - 1 || iPhi < 0
141 : ){
142 0 : AliError(Form("Out of range! eta: %2d phi: %2d", iEta, iPhi));
143 0 : return kFALSE;
144 : }
145 168 : id = iPhi * fSTURegionNEta + iEta ;
146 168 : id = ConvAbsFastORIndexA2B(id) ;
147 168 : return kTRUE ;
148 168 : }
149 :
150 : //________________________________________________________________________________________________
151 : Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromPHOSSubregion( Int_t iPHOS, Int_t& id) const
152 : {
153 0 : if(iPHOS > 35 || iPHOS < 0){
154 0 : AliError(Form("Out of range! phos subregion index: %2d ", iPHOS));
155 0 : return kFALSE;
156 : }
157 0 : Int_t iEta = 16 + 4 * (Int_t)(iPHOS % 4) ;
158 0 : Int_t iPhi = 64 + 4 * (Int_t)(iPHOS / 4) ;
159 0 : return GetAbsFastORIndexFromPositionInEMCAL(iEta,iPhi,id);
160 0 : }
161 :
162 : //________________________________________________________________________________________________
163 : Bool_t AliEMCALTriggerMappingV2::GetTRUFromAbsFastORIndex(Int_t id, Int_t& iTRU, Int_t& iADC) const
164 : {
165 : //Trigger mapping method, get TRU number from FastOr Index
166 68 : Int_t iEta_TRU , iPhi_TRU , iSM , iEta_SM , iPhi_SM ;
167 34 : Int_t id_tmp = ConvAbsFastORIndexB2A(id);
168 68 : return GetInfoFromAbsFastORIndex(
169 : id_tmp ,
170 : iTRU , iADC , iEta_TRU , iPhi_TRU ,
171 : iSM , iEta_SM , iPhi_SM
172 : );
173 34 : }
174 :
175 : //________________________________________________________________________________________________
176 : Bool_t AliEMCALTriggerMappingV2::GetPositionInTRUFromAbsFastORIndex(Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const
177 : {
178 : //Trigger mapping method, get position in TRU from FasOr Index
179 0 : Int_t iADC , iSM , iEta_SM , iPhi_SM ;
180 0 : Int_t id_tmp = ConvAbsFastORIndexB2A(id);
181 0 : return GetInfoFromAbsFastORIndex(
182 : id_tmp ,
183 : iTRU , iADC , iEta , iPhi ,
184 : iSM , iEta_SM , iPhi_SM
185 : );
186 0 : }
187 :
188 : //________________________________________________________________________________________________
189 : Bool_t AliEMCALTriggerMappingV2::GetPositionInSMFromAbsFastORIndex(Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const
190 : {
191 : //Trigger mapping method, get position in Super Module from FasOr Index
192 0 : Int_t iTRU , iADC , iEta_TRU , iPhi_TRU ;
193 0 : Int_t id_tmp = ConvAbsFastORIndexB2A(id);
194 0 : return GetInfoFromAbsFastORIndex(
195 : id_tmp ,
196 : iTRU , iADC , iEta_TRU , iPhi_TRU ,
197 : iSM , iEta , iPhi
198 : );
199 0 : }
200 :
201 : //________________________________________________________________________________________________
202 : Bool_t AliEMCALTriggerMappingV2::GetPositionInEMCALFromAbsFastORIndex(Int_t id, Int_t& iEta, Int_t& iPhi) const
203 : {
204 : //Trigger mapping method, get position in EMCAL from FastOR index
205 452 : if (id > fSTURegionN-1 || id < 0){
206 0 : AliError("Id out of range!");
207 0 : return kFALSE;
208 : }
209 226 : Int_t id_tmp = ConvAbsFastORIndexB2A(id);
210 226 : iEta = id_tmp % fSTURegionNEta ;
211 226 : iPhi = id_tmp / fSTURegionNEta ;
212 : return kTRUE;
213 226 : }
214 :
215 :
216 : //________________________________________________________________________________________________
217 : Bool_t AliEMCALTriggerMappingV2::GetFastORIndexFromCellIndex(Int_t id, Int_t& idx) const
218 : {
219 : // Trigger mapping method, from cell index get FastOR index
220 :
221 536 : Int_t iSupMod, nModule, nIphi, nIeta, iphim, ietam;
222 268 : Bool_t isOK = fGeometry->GetCellIndex( id, iSupMod, nModule, nIphi, nIeta );
223 :
224 : //- XXX fGeometry->GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam );
225 :
226 : //+ => XXX
227 268 : fGeometry->GetCellPhiEtaIndexInSModule(iSupMod, nModule, nIphi, nIeta, iphim, ietam);
228 : //ietam:0-31 for DCAL Cside
229 274 : if( GetSMType(iSupMod)==kDCAL_Standard && (iSupMod%2)==1)
230 0 : fGeometry->ShiftOfflineToOnlineCellIndexes(iSupMod, iphim, ietam);
231 : //ietam:16-47 for DCAL Cside
232 268 : iphim /= 2 ;
233 268 : ietam /= 2 ;
234 : //+ <= XXX
235 :
236 804 : if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx)) return kTRUE;
237 0 : return kFALSE;
238 268 : }
239 :
240 : //________________________________________________________________________________________________
241 : Bool_t AliEMCALTriggerMappingV2::GetCellIndexFromFastORIndex(Int_t id, Int_t idx[4]) const
242 : {
243 : //Trigger mapping method, from FASTOR index get cell index
244 0 : Int_t iSM=-1, iEta=-1, iPhi=-1;
245 0 : if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi))
246 : {
247 0 : Int_t ix = 2 * iEta;
248 0 : Int_t iy = 2 * iPhi;
249 :
250 : //+ => XXX
251 : //ietam:16-47 for DCAL Cside
252 0 : if( GetSMType(iSM)==kDCAL_Standard ){
253 0 : if( iSM%2==1 )
254 0 : fGeometry->ShiftOnlineToOfflineCellIndexes(iSM, iy, ix);
255 0 : if(ix < 0 || ix > 31)
256 0 : return kFALSE ;
257 : }
258 : //ietam:0-31 for DCAL Cside
259 : //+ <= XXX
260 :
261 0 : idx[0] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy , ix );
262 0 : idx[1] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy , ix + 1);
263 0 : idx[2] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy + 1, ix );
264 0 : idx[3] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy + 1, ix + 1);
265 0 : return kTRUE;
266 0 : }
267 0 : return kFALSE;
268 0 : }
269 :
270 : //________________________________________________________________________________________________
271 : Bool_t AliEMCALTriggerMappingV2::GetTRUIndexFromSTUIndex(Int_t id, Int_t& idx, Int_t detector ) const
272 : {
273 : //Trigger mapping method, from STU index get TRU index
274 0 : idx = GetTRUIndexFromSTUIndex(id,detector);
275 0 : return (idx>0)?kTRUE:kFALSE;
276 : }
277 :
278 : //________________________________________________________________________________________________
279 : Int_t AliEMCALTriggerMappingV2::GetTRUIndexFromSTUIndex(Int_t id, Int_t detector) const
280 : {
281 : //Trigger mapping method, from STU index get TRU index
282 0 : if ((id > 31 && detector == kEMCAL) || (id > 13 && detector == kDCAL) || id < 0){
283 0 : AliError(Form("TRU index out of range: %d",id));
284 0 : }
285 0 : if(detector == kEMCAL ){
286 0 : return id ;
287 : }
288 0 : else if(detector == kDCAL){
289 0 : return 32 + ((int)(id/4) * 6 ) + ((id%4 < 2)?(id%4):(id%4+2)) ;
290 : }
291 0 : return -1 ;
292 0 : }
293 :
294 : //________________________________________________________________________________________________
295 : Bool_t AliEMCALTriggerMappingV2::GetSTUIndexFromTRUIndex(Int_t id, Int_t& idx) const
296 : {
297 : //Trigger mapping method, from STU index get TRU index
298 0 : idx = GetSTUIndexFromTRUIndex(id);
299 0 : return (idx>0)?kTRUE:kFALSE;
300 : }
301 : //________________________________________________________________________________________________
302 : Int_t AliEMCALTriggerMappingV2::GetSTUIndexFromTRUIndex(Int_t id) const
303 : {
304 0 : if(id < 32)return id ;
305 : else{
306 : Int_t STUid = id ;
307 0 : if(STUid >= 48 ) STUid -= 2 ;
308 0 : if(STUid >= 42 ) STUid -= 2 ;
309 0 : if(STUid >= 36 ) STUid -= 2 ;
310 0 : STUid -= 32 ;
311 : return STUid ;
312 : }
313 : return -1 ;
314 0 : }
315 :
316 : ///
317 : /// \return TRU global offline number from:
318 : /// \param hwAdd: hardware address
319 : /// \param ddl number
320 : /// \param sm: uper-module number
321 : /// Used in AliEMCALTriggerRawDigitMaker::Add()
322 : ///
323 : Int_t AliEMCALTriggerMappingV2::GetTRUIndexFromOnlineHwAdd(Int_t hwAdd, Int_t ddl, Int_t sm) const
324 : {
325 : // 1/3 SMs
326 :
327 0 : if ( sm == 10 ) return 30;
328 0 : if ( sm == 11 ) return 31;
329 0 : if ( sm == 18 ) return 50;
330 0 : if ( sm == 19 ) return 51;
331 :
332 : // Full EMCal/DCal SMs
333 :
334 0 : UShort_t iBranch = ( hwAdd >> 11 ) & 0x1; // 0/1
335 :
336 0 : Int_t iTRU = ( (ddl << 1) | iBranch ) - 1; // 0..2
337 :
338 0 : iTRU = (sm%2) ? 2-iTRU : iTRU;
339 :
340 0 : if(sm < 10) iTRU += 3 * sm; // EMCal
341 0 : else iTRU += (3 * sm-4); // DCal
342 :
343 0 : if (iTRU > fNTotalTRU - 1 || iTRU < 0)
344 : {
345 0 : AliError(Form("TRU index out of range: %d",iTRU));
346 0 : return -1;
347 : }
348 :
349 0 : return iTRU;
350 0 : }
351 :
352 :
353 :
354 : //________________________________________________________________________________________________
355 : Bool_t AliEMCALTriggerMappingV2::GetFastORIndexFromL0Index(Int_t iTRU, Int_t id, Int_t idx[], Int_t size) const
356 : {
357 : //Trigger mapping method, from L0 index get FastOR index
358 :
359 0 : if (size <= 0 ||size > 4){
360 0 : AliError("Size not supported!");
361 0 : return kFALSE;
362 : }
363 :
364 0 : Int_t motif[4];
365 0 : motif[0] = 0;
366 0 : motif[2] = 1;
367 0 : motif[1] = fnFastORInTRUPhi[iTRU] ;
368 0 : motif[3] = fnFastORInTRUPhi[iTRU] + 1 ;
369 :
370 0 : switch (size)
371 : {
372 : case 1: // Cosmic trigger
373 0 : if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[1])) return kFALSE;
374 : break;
375 : case 4: // 4 x 4
376 0 : for (Int_t k = 0; k < 4; k++)
377 : {
378 0 : Int_t iADC = fnFastORInTRUPhi[iTRU] * int(id/(fnFastORInTRUPhi[iTRU]-1))
379 0 : + (id%(fnFastORInTRUPhi[iTRU]-1))
380 0 : + motif[k] ;
381 :
382 0 : if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE;
383 0 : }
384 : break;
385 : default:
386 : break;
387 : }
388 :
389 0 : return kTRUE;
390 0 : }
391 :
392 : //________________________________________________________________________________________________
393 : Bool_t AliEMCALTriggerMappingV2::Init_TRU_offset(){
394 4 : fTRUFastOROffsetX[0] = 0 ;
395 2 : fTRUFastOROffsetY[0] = 0 ;
396 : Int_t iTRU = 0 ;
397 :
398 84 : for(int iSM=0; iSM<fNumberOfSuperModules; iSM++){
399 40 : Int_t SM_type = GetSMType(iSM);
400 40 : Bool_t IsCside = GetSMIsCside( iSM);
401 : Int_t TRU_type = 0 ;
402 :
403 : //===================
404 : //TRU ieta/iphi size
405 : Int_t nTRU_inSM = fNTRU ;
406 : Int_t nTRU_inSM_phi = fNTRUPhi ;
407 : Int_t nTRU_inSM_eta = fNTRUEta ;
408 : Int_t nModule_inTRU_phi = fNModulesInTRUPhi ;
409 : Int_t nModule_inTRU_eta = fNModulesInTRUEta ;
410 40 : if( SM_type == kEMCAL_3rd
411 40 : || SM_type == kDCAL_Ext ){
412 8 : nTRU_inSM = (Int_t)((Float_t)nTRU_inSM / 3. );
413 : nTRU_inSM_eta = (Int_t)((Float_t)nTRU_inSM_eta / 3. );
414 8 : nModule_inTRU_phi = (Int_t)((Float_t)nModule_inTRU_phi / 3. );
415 : nModule_inTRU_eta = nModule_inTRU_eta * 3 ;
416 8 : }
417 :
418 : //===================
419 : //TRU ieta/iphi offset calculation
420 322 : for(Int_t i=0; i<nTRU_inSM; i++){
421 104 : fnFastORInTRUPhi[iTRU] = nModule_inTRU_phi ;
422 104 : fnFastORInTRUEta[iTRU] = nModule_inTRU_eta ;
423 104 : fTRUIsCside[ iTRU] = IsCside ;
424 :
425 106 : if((iTRU+1) >= fNTotalTRU)break;
426 :
427 : TRU_type = 0 ;
428 140 : if( i==nTRU_inSM-1 && IsCside ){//last TRU in SM
429 : TRU_type = 1 ;//right
430 18 : }
431 102 : if( TRU_type == 0){
432 84 : fTRUFastOROffsetX[iTRU+1] = fTRUFastOROffsetX[iTRU] + nModule_inTRU_eta ;
433 84 : fTRUFastOROffsetY[iTRU+1] = fTRUFastOROffsetY[iTRU] ;
434 102 : }else if(TRU_type == 1){
435 18 : fTRUFastOROffsetX[iTRU+1] = 0 ;
436 18 : fTRUFastOROffsetY[iTRU+1] = fTRUFastOROffsetY[iTRU] + nModule_inTRU_phi ;
437 18 : }
438 : iTRU++ ;
439 : }//TRU loop
440 : }//SM loop
441 :
442 2 : return kTRUE ;
443 : }
444 :
445 : //________________________________________________________________________________________________
446 : Bool_t AliEMCALTriggerMappingV2::Init_SM_offset(){
447 :
448 4 : fSMFastOROffsetX[0] = 0 ;
449 2 : fSMFastOROffsetY[0] = 0 ;
450 2 : fnModuleInEMCALPhi[0] = 0 ;
451 : Int_t iB=0 ;
452 :
453 : Int_t SM_type_buf = -1 ;
454 80 : for(int iSM=0; iSM<fNumberOfSuperModules; iSM++){
455 40 : Int_t SM_type = GetSMType(iSM);
456 40 : Bool_t IsCside = GetSMIsCside( iSM);
457 :
458 : Int_t nModule_inSM_phi = fNPhi ;
459 : Int_t nModule_inSM_eta = fNEta ;
460 :
461 40 : if( SM_type == kEMCAL_3rd
462 40 : || SM_type == kDCAL_Ext ){
463 8 : nModule_inSM_phi = (Int_t)((Float_t)nModule_inSM_phi / 3.);
464 8 : }
465 :
466 40 : fnFastORInSMPhi[iSM] = nModule_inSM_phi ;
467 40 : fnFastORInSMEta[iSM] = nModule_inSM_eta ;
468 :
469 40 : if(!IsCside){
470 20 : if(SM_type_buf == SM_type){
471 12 : fnModuleInEMCALPhi[iB] += nModule_inSM_phi ;
472 12 : }else{
473 8 : fnModuleInEMCALPhi[iB+1] = fnModuleInEMCALPhi[iB] + nModule_inSM_phi ;
474 : iB++ ;
475 : }
476 : SM_type_buf = SM_type ;
477 20 : }
478 :
479 42 : if( (iSM+1) >= fNumberOfSuperModules)break ;
480 :
481 38 : if(IsCside){//right SM
482 18 : fSMFastOROffsetX[iSM+1] = 0 ;
483 18 : fSMFastOROffsetY[iSM+1] = fSMFastOROffsetY[iSM] + nModule_inSM_phi ;
484 18 : }
485 : else{//left SM
486 20 : fSMFastOROffsetX[iSM+1] = fSMFastOROffsetX[iSM] + nModule_inSM_eta ;
487 20 : fSMFastOROffsetY[iSM+1] = fSMFastOROffsetY[iSM] ;
488 : }
489 38 : }//SM loop
490 :
491 2 : return kTRUE ;
492 : }
493 :
494 : //________________________________________________________________________________________________
495 : Bool_t AliEMCALTriggerMappingV2::GetInfoFromAbsFastORIndex(//conv from A
496 : Int_t id,
497 : Int_t& iTRU , Int_t& iADC , Int_t& iEta_TRU , Int_t& iPhi_TRU ,
498 : Int_t& iSM , Int_t& iEta_SM , Int_t& iPhi_SM
499 : ) const
500 : {
501 :
502 68 : if (id > fSTURegionN-1 || id < 0){
503 0 : AliError("Id out of range!");
504 0 : return kFALSE;
505 : }
506 34 : Int_t idB = ConvAbsFastORIndexA2B(id) ;
507 :
508 34 : iTRU = idB / fNModulesInTRU ;
509 34 : iADC = idB % fNModulesInTRU ;
510 34 : if( iTRU > fNTotalTRU - 1 ) return kFALSE;
511 :
512 34 : iEta_TRU = iADC / fnFastORInTRUPhi[iTRU] ;
513 34 : iPhi_TRU = iADC % fnFastORInTRUPhi[iTRU] ;
514 136 : iADC = fnFastORInTRUPhi[iTRU] * (( fTRUIsCside[iTRU])? (fnFastORInTRUEta[iTRU] - 1 - iEta_TRU ) : iEta_TRU )
515 102 : + ((!fTRUIsCside[iTRU])? (fnFastORInTRUPhi[iTRU] - 1 - iPhi_TRU ) : iPhi_TRU )
516 : ;
517 :
518 34 : Int_t x = id % fSTURegionNEta ;
519 34 : Int_t y = id / fSTURegionNEta ;
520 34 : Int_t idtmp = (y<fnModuleInEMCALPhi[2])? id : (id + fNModulesInTRU * 4) ;
521 34 : iSM = 2 * (int)(idtmp/(2 * fNEta * fNPhi)) + (int)(fTRUIsCside[iTRU]);
522 34 : if( iSM > fNumberOfSuperModules - 1 ) return kFALSE ;
523 :
524 34 : iEta_SM = x % fnFastORInSMEta[iSM] ;
525 34 : iPhi_SM = idB % fnFastORInSMPhi[iSM] ;
526 :
527 34 : return kTRUE;
528 34 : }
529 :
530 : //________________________________________________________________________________________________
531 : Int_t AliEMCALTriggerMappingV2::ConvAbsFastORIndexA2B(Int_t idA) const
532 : {
533 1044 : Int_t det_phi = int(idA/fSTURegionNEta) ;
534 : Int_t nModule_inSM_phi = fNPhi ;
535 : Int_t idB = 0 ;
536 1098 : for(int i=1;i<5;i++){
537 549 : if(det_phi < fnModuleInEMCALPhi[i]){
538 522 : idB = fSTURegionNEta * fnModuleInEMCALPhi[i-1] ;
539 535 : if(i == 2 || i == 4) nModule_inSM_phi /= 3;
540 522 : break ;
541 : }
542 : }
543 :
544 522 : Int_t tmp0 = idA - idB ;
545 522 : Int_t tmp1 = (int)(tmp0 / (fSTURegionNEta * nModule_inSM_phi)) ;
546 522 : Int_t tmp2 = (int)(tmp0 % (fSTURegionNEta * nModule_inSM_phi)) ;
547 522 : idB += tmp1 * (fSTURegionNEta * nModule_inSM_phi) ;
548 522 : idB += (int)(tmp2 % fSTURegionNEta) *nModule_inSM_phi ;
549 522 : idB += (int)(tmp2 / fSTURegionNEta) ;
550 :
551 522 : return idB ;
552 : }
553 : //________________________________________________________________________________________________
554 : Int_t AliEMCALTriggerMappingV2::ConvAbsFastORIndexB2A(Int_t idB) const
555 : {
556 520 : Int_t det_phi = int(idB/fSTURegionNEta) ;
557 : Int_t idA = 0 ;
558 : Int_t nModule_inSM_phi = fNPhi ;
559 532 : for(int i=1;i<5;i++){
560 266 : if(det_phi < fnModuleInEMCALPhi[i]){
561 260 : idA = fSTURegionNEta * fnModuleInEMCALPhi[i-1] ;
562 262 : if(i == 2 || i == 4) nModule_inSM_phi /= 3;
563 260 : break ;
564 : }
565 : }
566 :
567 260 : Int_t tmp0 = idB - idA ;
568 260 : Int_t tmp1 = (int)(tmp0 / (fSTURegionNEta * nModule_inSM_phi)) ;
569 260 : Int_t tmp2 = (int)(tmp0 % (fSTURegionNEta * nModule_inSM_phi)) ;
570 260 : Int_t x = tmp2 / nModule_inSM_phi;
571 260 : Int_t y = tmp2 % nModule_inSM_phi;
572 :
573 260 : idA += tmp1 * (fSTURegionNEta * nModule_inSM_phi);
574 260 : idA += y*fSTURegionNEta + x;
575 :
576 260 : return idA ;
577 : }
578 :
579 : //________________________________________________________________________________________________
580 : Bool_t AliEMCALTriggerMappingV2::GetTRUFromSTU(Int_t iTRU, Int_t iADC, Int_t& oTRU, Int_t& oADC, Int_t detector)const
581 : {
582 : Int_t ieta, iphi, oeta, ophi;
583 0 : oTRU = GetTRUIndexFromSTUIndex(iTRU,detector);
584 0 : if (oTRU == -1) return kFALSE;
585 0 : ieta = iADC % fnFastORInTRUEta[oTRU] ;
586 0 : iphi = iADC / fnFastORInTRUEta[oTRU] ;
587 0 : oeta = (fTRUIsCside[oTRU])? (fnFastORInTRUEta[oTRU] - ieta - 1) : ieta;
588 0 : ophi = (fTRUIsCside[oTRU])? iphi : (fnFastORInTRUPhi[oTRU] - iphi - 1);
589 0 : oADC = oeta * fnFastORInTRUPhi[oTRU] + ophi ;
590 0 : return kTRUE ;
591 0 : }
592 : //________________________________________________________________________________________________
593 : Bool_t AliEMCALTriggerMappingV2::GetTRUFromSTU(Int_t iTRU, Int_t ieta, Int_t iphi, Int_t& oTRU, Int_t& oeta, Int_t& ophi, Int_t detector) const
594 : {
595 0 : oTRU = GetTRUIndexFromSTUIndex(iTRU,detector);
596 0 : if (oTRU == -1) return kFALSE;
597 0 : oeta = (fTRUIsCside[oTRU])? (fnFastORInTRUEta[oTRU] - ieta - 1) : ieta;
598 0 : ophi = (fTRUIsCside[oTRU])? iphi : (fnFastORInTRUPhi[oTRU] - iphi - 1);
599 0 : return kTRUE ;
600 0 : }
601 : //________________________________________________________________________________________________
602 : Bool_t AliEMCALTriggerMappingV2::GetSTUFromTRU(Int_t iTRU, Int_t iADC, Int_t& oTRU, Int_t& oADC)const
603 : {
604 : Int_t ieta, iphi, oeta, ophi;
605 0 : ieta = iADC / fnFastORInTRUPhi[iTRU] ;
606 0 : iphi = iADC % fnFastORInTRUPhi[iTRU] ;
607 0 : oeta = (fTRUIsCside[iTRU])? (fnFastORInTRUEta[iTRU] - ieta - 1) : ieta;
608 0 : ophi = (fTRUIsCside[iTRU])? iphi : (fnFastORInTRUPhi[iTRU] - iphi - 1);
609 0 : oTRU = GetSTUIndexFromTRUIndex(iTRU);
610 0 : oADC = ophi * fnFastORInTRUEta[iTRU] + oeta ;
611 0 : return kTRUE ;
612 : }
613 : //________________________________________________________________________________________________
614 : Bool_t AliEMCALTriggerMappingV2::GetSTUFromTRU(Int_t iTRU, Int_t ieta, Int_t iphi, Int_t& oTRU, Int_t& oeta, Int_t& ophi ) const
615 : {
616 0 : oTRU = GetSTUIndexFromTRUIndex(iTRU);
617 0 : oeta = (fTRUIsCside[iTRU])? (fnFastORInTRUEta[iTRU] - ieta - 1) : ieta;
618 0 : ophi = (fTRUIsCside[iTRU])? iphi : (fnFastORInTRUPhi[iTRU] - iphi - 1);
619 0 : return kTRUE ;
620 : }
621 :
622 :
|