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 **************************************************************************/
22 H. YOKOYAMA Tsukuba University
23 R. GUERNANE LPSC Grenoble CNRS/IN2P3
26 #include "AliEMCALTriggerMapping.h"
27 #include "AliEMCALTriggerMappingV2.h"
28 #include "AliEMCALGeometry.h"
31 ClassImp(AliEMCALTriggerMappingV2)
33 //________________________________________________________________________________________________
34 AliEMCALTriggerMappingV2::AliEMCALTriggerMappingV2() : AliEMCALTriggerMapping()
39 for(Int_t iTRU=0; iTRU<46; iTRU++){
40 fTRUFastOROffsetX[iTRU] = 0 ;
41 fTRUFastOROffsetY[iTRU] = 0 ;
42 fnFastORInTRUPhi[ iTRU] = 0 ;
43 fnFastORInTRUEta[ iTRU] = 0 ;
45 for(Int_t iSM=0; iSM<20; iSM++){
46 fSMFastOROffsetX[ iSM] = 0 ;
47 fSMFastOROffsetY[ iSM] = 0 ;
48 fnFastORInSMPhi[ iSM] = 0 ;
49 fnFastORInSMEta[ iSM] = 0 ;
51 fnModuleInEMCALPhi = 0 ;
56 //________________________________________________________________________________________________
57 AliEMCALTriggerMappingV2::AliEMCALTriggerMappingV2(const Int_t ntru, const AliEMCALGeometry* geo) : AliEMCALTriggerMapping(ntru, geo)
62 for(Int_t iTRU=0; iTRU<46; iTRU++){
63 fTRUFastOROffsetX[iTRU] = geo.fTRUFastOROffsetX[iTRU] ;
64 fTRUFastOROffsetY[iTRU] = geo.fTRUFastOROffsetY[iTRU] ;
65 fnFastORInTRUPhi[ iTRU] = geo.fnFastORInTRUPhi[ iTRU] ;
66 fnFastORInTRUEta[ iTRU] = geo.fnFastORInTRUEta[ iTRU] ;
68 for(Int_t iSM=0; iSM<20; iSM++){
69 fSMFastOROffsetX[ iSM] = geo.fSMFastOROffsetX[ iSM] ;
70 fSMFastOROffsetY[ iSM] = geo.fSMFastOROffsetY[ iSM] ;
71 fnFastORInSMPhi[ iSM] = geo.fnFastORInSMPhi[ iSM] ;
72 fnFastORInSMEta[ iSM] = geo.fnFastORInSMEta[ iSM] ;
74 fnModuleInEMCALPhi = geo.fnModuleInEMCALPhi ;
77 //________________________________________________________________________________________________
78 Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const
80 //Trigger mapping method, get FastOr Index from TRU
81 if (iTRU > fNTotalTRU-1 || iTRU < 0 ||
82 iADC > fNModulesInTRU-1 || iADC < 0
84 AliError(Form("Out of range! iTRU=%d, iADC=%d", iTRU, iADC));
87 Int_t x = fTRUFastOROffsetX[iTRU] + (iADC % fnFastORInTRUEta[iTRU]) ;
88 Int_t y = fTRUFastOROffsetY[iTRU] + int(iADC / fnFastORInTRUEta[iTRU]) ;
93 //________________________________________________________________________________________________
94 Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const
96 //Trigger mapping method, get Index if FastOr from Position in TRU
97 if (iTRU > fNTotalTRU-1 || iTRU < 0 ||
98 iEta > fnFastORInTRUEta[iTRU] - 1 || iEta < 0 ||
99 iPhi > fnFastORInTRUPhi[iTRU] - 1 || iPhi < 0
101 AliError(Form("Out of range! iTRU=%d, iEta=%d, iPhi=%d", iTRU, iEta, iPhi));
104 Int_t x = fTRUFastOROffsetX[iTRU] + iEta ;
105 Int_t y = fTRUFastOROffsetY[iTRU] + iPhi ;
110 //________________________________________________________________________________________________
111 Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromPositionInSM(const Int_t iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const
113 //Trigger mapping method, from position in SM Index get FastOR index
114 if (iSM > fNumberOfSuperModules-1 || iSM < 0 ||
115 iEta > fnFastORInSMEta[iSM] -1 || iEta < 0 ||
116 iPhi > fnFastORInSMPhi[iSM] -1 || iPhi < 0
118 AliError(Form("Out of range! iSM=%d, iEta=%d, iPhi=%d", iSM, iEta, iPhi));
121 Int_t x = fSMFastOROffsetX[iSM] + iEta ;
122 Int_t y = fSMFastOROffsetY[iSM] + iPhi ;
127 //________________________________________________________________________________________________
128 Bool_t AliEMCALTriggerMappingV2::GetAbsFastORIndexFromPositionInEMCAL(const Int_t iEta, const Int_t iPhi, Int_t& id) const
130 //Trigger mapping method, from position in EMCAL Index get FastOR index
132 iEta > 2 * fNEta - 1 || iEta < 0 ||
133 iPhi > fnModuleInEMCALPhi - 1 || iPhi < 0
135 AliError(Form("Out of range! eta: %2d phi: %2d", iEta, iPhi));
138 id = iPhi*fNEta*2 + iEta ;
142 //________________________________________________________________________________________________
143 Bool_t AliEMCALTriggerMappingV2::GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const
145 //Trigger mapping method, get TRU number from FastOr Index
146 Int_t iEta_TRU , iPhi_TRU , iSM , iEta_SM , iPhi_SM ;
147 return GetInfoFromAbsFastORIndex(
149 iTRU , iADC , iEta_TRU , iPhi_TRU ,
150 iSM , iEta_SM , iPhi_SM
154 //________________________________________________________________________________________________
155 Bool_t AliEMCALTriggerMappingV2::GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const
157 //Trigger mapping method, get position in TRU from FasOr Index
158 Int_t iADC , iSM , iEta_SM , iPhi_SM ;
159 return GetInfoFromAbsFastORIndex(
161 iTRU , iADC , iEta , iPhi ,
162 iSM , iEta_SM , iPhi_SM
166 //________________________________________________________________________________________________
167 Bool_t AliEMCALTriggerMappingV2::GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const
169 //Trigger mapping method, get position in Super Module from FasOr Index
170 Int_t iTRU , iADC , iEta_TRU , iPhi_TRU ;
171 return GetInfoFromAbsFastORIndex(
173 iTRU , iADC , iEta_TRU , iPhi_TRU ,
178 //________________________________________________________________________________________________
179 Bool_t AliEMCALTriggerMappingV2::GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const
181 //Trigger mapping method, get position in EMCAL from FastOR index
182 Int_t nModule = fNEta * 2 * fnModuleInEMCALPhi;
183 if (id > nModule-1 || id < 0){
184 AliError("Id out of range!");
187 iEta = id % (2*fNEta) ;
188 iPhi = id / (2*fNEta) ;
192 //________________________________________________________________________________________________
193 Bool_t AliEMCALTriggerMappingV2::GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const
195 // Trigger mapping method, from cell index get FastOR index
197 Int_t iSupMod, nModule, nIphi, nIeta, iphim, ietam;
198 Bool_t isOK = fGeometry->GetCellIndex( id, iSupMod, nModule, nIphi, nIeta );
199 fGeometry->GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam );
201 if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx)) return kTRUE;
205 //________________________________________________________________________________________________
206 Bool_t AliEMCALTriggerMappingV2::GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const
208 //Trigger mapping method, from FASTOR index get cell index
209 Int_t iSM=-1, iEta=-1, iPhi=-1;
210 if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi))
214 idx[0] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy , ix );
215 idx[1] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy , ix + 1);
216 idx[2] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy + 1, ix );
217 idx[3] = fGeometry->GetAbsCellIdFromCellIndexes(iSM, iy + 1, ix + 1);
223 //________________________________________________________________________________________________
224 Bool_t AliEMCALTriggerMappingV2::GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const
226 //Trigger mapping method, from STU index get TRU index
227 idx = GetTRUIndexFromSTUIndex(id);
231 //________________________________________________________________________________________________
232 Int_t AliEMCALTriggerMappingV2::GetTRUIndexFromSTUIndex(const Int_t id) const
234 //Trigger mapping method, from STU index get TRU index
235 if (id > fNTotalTRU-1 || id < 0){
236 AliError(Form("TRU index out of range: %d",id));
241 //________________________________________________________________________________________________
242 Bool_t AliEMCALTriggerMappingV2::GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx) const
244 //Trigger mapping method, from STU index get TRU index
245 idx = GetTRUIndexFromOnlineIndex(id);
249 //________________________________________________________________________________________________
250 Int_t AliEMCALTriggerMappingV2::GetTRUIndexFromOnlineIndex(const Int_t id) const
252 //Trigger mapping method, from STU index get TRU index
253 if (id > fNTotalTRU-1 || id < 0){
254 AliError(Form("TRU index out of range: %d",id));
259 //________________________________________________________________________________________________
260 Bool_t AliEMCALTriggerMappingV2::GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx) const
262 //Trigger mapping method, from STU index get TRU index
263 idx = GetOnlineIndexFromTRUIndex(id);
267 //________________________________________________________________________________________________
268 Int_t AliEMCALTriggerMappingV2::GetOnlineIndexFromTRUIndex(const Int_t id) const
270 //Trigger mapping method, from STU index get TRU index
271 if (id > fNTotalTRU-1 || id < 0){
272 AliError(Form("TRU index out of range: %d",id));
277 //________________________________________________________________________________________________
278 Bool_t AliEMCALTriggerMappingV2::GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const
280 //Trigger mapping method, from L0 index get FastOR index
282 if (size <= 0 ||size > 4){
283 AliError("Size not supported!");
290 motif[2] = fnFastORInTRUEta[iTRU] ;
291 motif[3] = fnFastORInTRUEta[iTRU] + 1 ;
295 case 1: // Cosmic trigger
296 if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[1])) return kFALSE;
299 for (Int_t k = 0; k < 4; k++)
301 Int_t iADC = motif[k] + fnFastORInTRUEta[iTRU] * int(id/(fnFastORInTRUEta[iTRU]-1)) + (id%(fnFastORInTRUEta[iTRU]-1));
303 if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE;
313 //________________________________________________________________________________________________
314 Bool_t AliEMCALTriggerMappingV2::Init_TRU_offset(){
315 fTRUFastOROffsetX[0] = 0 ;
316 fTRUFastOROffsetY[0] = 0 ;
319 for(int iSM=0; iSM<fNumberOfSuperModules; iSM++){
320 Int_t SM_type = GetSMType(iSM);
323 Int_t nTRU_inSM = fNTRU ;
324 Int_t nTRU_inSM_phi = fNTRUPhi ;
325 Int_t nTRU_inSM_eta = fNTRUEta ;
326 Int_t nModule_inTRU_phi = fNModulesInTRUPhi ;
327 Int_t nModule_inTRU_eta = fNModulesInTRUEta ;
329 //kEMCAL_Standard -> default value
330 if( SM_type == kEMCAL_3rd ){
331 nTRU_inSM = (Int_t)((Float_t)nTRU_inSM / 3. );
332 nTRU_inSM_eta = (Int_t)((Float_t)nTRU_inSM_eta / 3. );
333 nModule_inTRU_phi = (Int_t)((Float_t)nModule_inTRU_phi / 3. );
334 nModule_inTRU_eta = nModule_inTRU_eta * 3 ;
336 else if(SM_type == kDCAL_Standard ){
337 nTRU_inSM = (Int_t)((Float_t)nTRU_inSM * 2./3. );
338 nTRU_inSM_eta = (Int_t)((Float_t)nTRU_inSM_eta * 2./3. );
340 else if(SM_type == kDCAL_Ext ){
341 nTRU_inSM = (Int_t)((Float_t)nTRU_inSM / 3. );
342 nTRU_inSM_eta = (Int_t)((Float_t)nTRU_inSM_eta / 3. );
343 nModule_inTRU_phi = (Int_t)((Float_t)nModule_inTRU_phi / 3. );
344 nModule_inTRU_eta = nModule_inTRU_eta * 3 ;
347 //TRU ieta/iphi offset calculation
348 for(Int_t i=0; i<nTRU_inSM; i++){
349 fnFastORInTRUPhi[iTRU] = nModule_inTRU_phi ;
350 fnFastORInTRUEta[iTRU] = nModule_inTRU_eta ;
351 if((iTRU+1) >= fNTotalTRU)break;
354 if( i==nTRU_inSM-1 ){//last TRU in SM
355 if( iSM%2==0 && SM_type==kDCAL_Standard ) TRU_type = 2 ;//left DCAL
356 else if( iSM%2==1 && SM_type==kDCAL_Standard ) TRU_type = 3 ;//right DCAL
357 else if( iSM%2==1 ) TRU_type = 1 ;//right EMCAL
360 fTRUFastOROffsetX[iTRU+1] = fTRUFastOROffsetX[iTRU] + nModule_inTRU_eta ;
361 fTRUFastOROffsetY[iTRU+1] = fTRUFastOROffsetY[iTRU] ;
362 }else if(TRU_type == 1){
363 fTRUFastOROffsetX[iTRU+1] = 0 ;
364 fTRUFastOROffsetY[iTRU+1] = fTRUFastOROffsetY[iTRU] + nModule_inTRU_phi ;
365 }else if(TRU_type == 2){
366 fTRUFastOROffsetX[iTRU+1] = fTRUFastOROffsetX[iTRU] + nModule_inTRU_eta * 3 ;
367 fTRUFastOROffsetY[iTRU+1] = fTRUFastOROffsetY[iTRU] ;
368 }else if(TRU_type == 3){
369 fTRUFastOROffsetX[iTRU+1] = 0 ;
370 fTRUFastOROffsetY[iTRU+1] = fTRUFastOROffsetY[iTRU] + nModule_inTRU_phi ;
379 //________________________________________________________________________________________________
380 Bool_t AliEMCALTriggerMappingV2::Init_SM_offset(){
382 fSMFastOROffsetX[0] = 0 ;
383 fSMFastOROffsetY[0] = 0 ;
384 fnModuleInEMCALPhi = 0 ;
386 for(int iSM=0; iSM<fNumberOfSuperModules; iSM++){
387 Int_t SM_type = GetSMType(iSM);
389 Int_t nModule_inSM_phi = fNPhi ;
390 Int_t nModule_inSM_eta = fNEta ;
392 //kEMCAL_Standard:kEMCAL_Half -> default value
393 if( SM_type == kEMCAL_3rd ){
394 nModule_inSM_phi = (Int_t)((Float_t)nModule_inSM_phi / 3.);
396 else if(SM_type == kDCAL_Standard ){
397 nModule_inSM_eta = (Int_t)((Float_t)nModule_inSM_eta * 2. / 3.);
399 else if(SM_type == kDCAL_Ext ){
400 nModule_inSM_phi = (Int_t)((Float_t)nModule_inSM_phi / 3.);
403 fnFastORInSMPhi[iSM] = nModule_inSM_phi ;
404 fnFastORInSMEta[iSM] = nModule_inSM_eta ;
405 if( (iSM+1) >= fNumberOfSuperModules)break ;
407 if(iSM%2 == 1){//right SM
408 fSMFastOROffsetX[iSM+1] = 0 ;
409 fSMFastOROffsetY[iSM+1] = fSMFastOROffsetY[iSM] + nModule_inSM_phi ;
412 fnModuleInEMCALPhi += nModule_inSM_phi ;
413 if(SM_type == kDCAL_Standard){
414 fSMFastOROffsetX[iSM+1] = fSMFastOROffsetX[iSM] + nModule_inSM_eta * 2 ;
415 fSMFastOROffsetY[iSM+1] = fSMFastOROffsetY[iSM] ;
417 fSMFastOROffsetX[iSM+1] = fSMFastOROffsetX[iSM] + nModule_inSM_eta ;
418 fSMFastOROffsetY[iSM+1] = fSMFastOROffsetY[iSM] ;
425 //________________________________________________________________________________________________
426 Bool_t AliEMCALTriggerMappingV2::GetInfoFromAbsFastORIndex(
428 Int_t& iTRU , Int_t& iADC , Int_t& iEta_TRU , Int_t& iPhi_TRU ,
429 Int_t& iSM , Int_t& iEta_SM , Int_t& iPhi_SM
433 Int_t nModule = fNEta * 2 * fnModuleInEMCALPhi;
434 if (id > nModule-1 || id < 0){
435 AliError("Id out of range!");
439 Int_t x = id % (fNEta * 2) ;
440 Int_t y = id / (fNEta * 2) ;
441 if(y >= fNPhi*5 + 4) y = y + 8 ;
443 Int_t y_class = int(y/fNModulesInTRUPhi) ;
444 Int_t x_class = int(x/fNModulesInTRUEta) ;
445 iTRU = y_class*(fNTRUEta*2) + x_class ;
447 Int_t Cside = int(x/fNEta);//Cside SM
448 //y_class = 5 : EMCAL 1/3 SM
449 //y_class = 9 : DCAL 1/3 SM
450 Int_t DCAL_sepC = (y_class>5 && y_class<9 && Cside==1)? 1 : 0 ;
451 Bool_t IsPHOS = (y_class>5 && y_class<9 && (x_class==2 || x_class==3))? kTRUE : kFALSE ;
453 if(y_class==5 || y_class==9 ) iTRU = iTRU - (x_class%3) - Cside*2 ;
454 if(y_class> 5 ) iTRU = iTRU - 2 - (y_class-5)*2 - DCAL_sepC*2 ;
456 iADC = (y_class==5 || y_class==9)? (y%(fNModulesInTRUPhi/3))*(fNModulesInTRUEta*3) + (x%(fNModulesInTRUEta*3)) :
457 (y% fNModulesInTRUPhi )* fNModulesInTRUEta + (x% fNModulesInTRUEta ) ;
459 iSM = int(y/fNPhi)*2 + Cside ;
460 iEta_TRU = (y_class==5 || y_class==9)? x%(fNModulesInTRUEta*3) : x%(fNModulesInTRUEta);
461 iPhi_TRU = y%fNModulesInTRUPhi;
462 iEta_SM = (DCAL_sepC == 1)? (x%fNEta - 8) : (x%fNEta);