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 **************************************************************************/
21 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
24 #include "AliEMCALTriggerMapping.h"
25 #include "AliEMCALTriggerMappingV1.h"
26 #include "AliEMCALGeometry.h"
29 ClassImp(AliEMCALTriggerMappingV1)
31 //________________________________________________________________________________________________
32 AliEMCALTriggerMappingV1::AliEMCALTriggerMappingV1() : AliEMCALTriggerMapping()
38 //________________________________________________________________________________________________
39 AliEMCALTriggerMappingV1::AliEMCALTriggerMappingV1(const Int_t ntru, const AliEMCALGeometry* geo) : AliEMCALTriggerMapping(ntru, geo)
46 //________________________________________________________________________________________________
47 Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const
49 //Trigger mapping method, get FastOr Index from TRU
51 if (iTRU > fNTRU - 1 || iTRU < 0 || iADC > 95 || iADC < 0) {
52 AliError("TRU out of range!");
56 id = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4);
61 //________________________________________________________________________________________________
62 Bool_t AliEMCALTriggerMappingV1::GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const
64 // Trigger mapping method, get TRU number from FastOr Index
66 if (id > fNTRU * 96 - 1 || id < 0) {
67 AliError("Fast-OR ID is out of range!");
73 iADC = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4);
77 //________________________________________________________________________________________________
78 Bool_t AliEMCALTriggerMappingV1::GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const
80 // Trigger mapping method, get position in TRU from FasOr Index
83 if (!GetTRUFromAbsFastORIndex(id, iTRU, iADC)) return kFALSE;
87 if ( iTRU % 2 ) { // C side
98 //________________________________________________________________________________________________
99 Bool_t AliEMCALTriggerMappingV1::GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const
101 //Trigger mapping method, get position in Super Module from FasOr Index
104 if (!GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi)) return kFALSE;
105 if (iTRU % 2) { // C side
106 iSM = 2 * (int(int(iTRU / 2) / 3)) + 1;
108 iSM = 2 * (int(int(iTRU / 2) / 3));
110 iPhi += 4 * int((iTRU % 6) / 2);
114 //________________________________________________________________________________________________
115 Bool_t AliEMCALTriggerMappingV1::GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const
117 //Trigger mapping method, get position in EMCAL from FastOR index
120 if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi)) {
121 if (iSM % 2) iEta += 24;
122 iPhi += 12 * int(iSM / 2);
128 //________________________________________________________________________________________________
129 Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const
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));
136 id = iPhi + 4 * iEta + iTRU * 96;
140 //________________________________________________________________________________________________
141 Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromPositionInSM(const Int_t iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const
143 // Trigger mapping method, from position in SM Index get FastOR index
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));
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)) {
160 //________________________________________________________________________________________________
161 Bool_t AliEMCALTriggerMappingV1::GetAbsFastORIndexFromPositionInEMCAL(const Int_t iEta, const Int_t iPhi, Int_t& id) const
163 // Trigger mapping method, from position in EMCAL Index get FastOR index
165 if (iEta < 0 || iEta > 47 || iPhi < 0 || iPhi > 63) {
166 AliError(Form("Out of range! iEta: %2d iPhi: %2d", iEta, iPhi));
170 id = iEta * 48 + iPhi;
175 //________________________________________________________________________________________________
176 Bool_t AliEMCALTriggerMappingV1::GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const
178 // Trigger mapping method, from cell index get FastOR index
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 );
184 if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx)) return kTRUE;
188 //________________________________________________________________________________________________
189 Bool_t AliEMCALTriggerMappingV1::GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const
191 // Trigger mapping method, from FASTOR index get cell index
193 Int_t iSM=-1, iEta=-1, iPhi=-1;
194 if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, 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);
207 //________________________________________________________________________________________________
208 Bool_t AliEMCALTriggerMappingV1::GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const
210 // STU mapping: TRU# 0 and 16 are missing
212 if (id > 31 || id < 0) {
213 AliError(Form("TRU index out of range: %d",id));
217 idx = GetTRUIndexFromSTUIndex(id);
221 //________________________________________________________________________________________________
222 Int_t AliEMCALTriggerMappingV1::GetTRUIndexFromSTUIndex(const Int_t id) const
224 // STU mapping: TRU# 0 and 16 are missing
226 if (id > 31 || id < 0) {
227 AliError(Form("TRU index out of range: %d",id));
229 return (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1;
232 //________________________________________________________________________________________________
233 Bool_t AliEMCALTriggerMappingV1::GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx) const
235 //Trigger mapping method, from STU index get TRU index
237 idx = GetOnlineIndexFromTRUIndex(id);
238 if (idx > fNTRU - 1 || idx < 0) {
239 AliError(Form("TRU index out of range: %d",idx));
245 //________________________________________________________________________________________________
246 Int_t AliEMCALTriggerMappingV1::GetTRUIndexFromOnlineIndex(const Int_t id) const
248 //Trigger mapping method, from STU index get TRU index
250 if (id > fNTRU - 1 || id < 0) {
251 AliError(Form("TRU index out of range: %d",id));
257 //jump 4 TRUs for DCAL
259 if(id > 31) tmp = id+4;
261 Int_t idx = ((tmp% 6) < 3) ? 6 * int(tmp/ 6) + 2 * (tmp% 3) : 6 * int(tmp/ 6) + 2 * (2 - (tmp% 3)) + 1;
266 //________________________________________________________________________________________________
267 Bool_t AliEMCALTriggerMappingV1::GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx) const
269 //Trigger mapping method, from STU index get TRU index
271 idx = GetOnlineIndexFromTRUIndex(id);
272 if (idx > fNTRU-1 || idx < 0)
274 AliError(Form("TRU index out of range: %d",idx));
279 //________________________________________________________________________________________________
280 Int_t AliEMCALTriggerMappingV1::GetOnlineIndexFromTRUIndex(const Int_t id) const
282 //Trigger mapping method, from STU index get TRU index
284 if (id > fNTRU-1 || id < 0)
286 AliError(Form("TRU index out of range: %d",id));
292 //jump 4 TRUs for DCAL
294 if(id > 31) tmp = id+4;
296 Int_t idx = (tmp % 2) ? int((6 - (tmp % 6)) / 2) + 3 * (2 * int(tmp / 6) + 1) : 3 * int(tmp / 6) + int(tmp / 2);
301 //________________________________________________________________________________________________
302 Bool_t AliEMCALTriggerMappingV1::GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const
304 //Trigger mapping method, from L0 index get FastOR index
306 if (size <= 0 || size > 4) {
307 AliError("Size not supported!");
311 Int_t motif[4] = {0, 1, 4, 5};
313 case 1: // Cosmic trigger
314 if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[1])) return kFALSE;
317 for (Int_t k = 0; k < 4; k++) {
318 Int_t iADC = motif[k] + 4 * int(id / 3) + (id % 3);
320 if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE;