Project
Loading...
Searching...
No Matches
TriggerMappingV2.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "EMCALBase/Geometry.h"
15
17
18using namespace o2::emcal;
19
21{
22 reset_arrays();
23 init_TRU_offset();
24 init_SM_offset();
25}
26
28{
29 reset_arrays();
30 init_TRU_offset();
31 init_SM_offset();
32}
33
34void TriggerMappingV2::reset_arrays()
35{
36 std::fill(mTRUFastOROffsetX.begin(), mTRUFastOROffsetX.end(), 0);
37 std::fill(mTRUFastOROffsetY.begin(), mTRUFastOROffsetY.end(), 0);
38 std::fill(mNFastORInTRUPhi.begin(), mNFastORInTRUPhi.end(), 0);
39 std::fill(mNFastORInTRUEta.begin(), mNFastORInTRUEta.end(), 0);
40
41 std::fill(mSMFastOROffsetX.begin(), mSMFastOROffsetX.end(), 0);
42 std::fill(mSMFastOROffsetY.begin(), mSMFastOROffsetY.end(), 0);
43 std::fill(mNFastORInSMPhi.begin(), mNFastORInSMPhi.end(), 0);
44 std::fill(mNFastORInSMEta.begin(), mNFastORInSMEta.end(), 0);
45
46 std::fill(mNModuleInEMCALPhi.begin(), mNModuleInEMCALPhi.end(), 0);
47}
48
49void TriggerMappingV2::init_TRU_offset()
50{
51 mTRUFastOROffsetX[0] = 0;
52 mTRUFastOROffsetY[0] = 0;
53 IndexTRU currentTRU = 0;
54
55 enum class TRUType_t {
56 STANDARD_TRU,
57 EXT_TRU
58 };
59
60 for (IndexSupermodule supermoduleID = 0; supermoduleID < SUPERMODULES; supermoduleID++) {
61 auto smtype = getSupermoduleType(supermoduleID);
62 auto isCside = isSupermoduleOnCSide(supermoduleID);
63 TRUType_t trutype = TRUType_t::STANDARD_TRU;
64
65 //===================
66 // TRU ieta/iphi size
67 auto nTRU_inSM = TRUSSUPERMODULE;
68 auto nTRU_inSM_phi = TRUSPHISM;
69 auto nTRU_inSM_eta = TRUSETASM;
70 auto nModule_inTRU_phi = FASTORSPHITRU;
71 auto nModule_inTRU_eta = FASTORSETATRU;
72 if (smtype == EMCAL_THIRD || smtype == DCAL_EXT) {
73 nTRU_inSM = static_cast<unsigned int>(static_cast<float>(nTRU_inSM) / 3.);
74 nTRU_inSM_eta = static_cast<unsigned int>(static_cast<float>(nTRU_inSM_eta) / 3.);
75 nModule_inTRU_phi = static_cast<unsigned int>(static_cast<float>(nModule_inTRU_phi) / 3.);
76 nModule_inTRU_eta = nModule_inTRU_eta * 3;
77 }
78
79 //===================
80 // TRU ieta/iphi offset calculation
81 for (IndexTRU truInSupermodule = 0; truInSupermodule < nTRU_inSM; truInSupermodule++) {
82 mNFastORInTRUPhi[currentTRU] = nModule_inTRU_phi;
83 mNFastORInTRUEta[currentTRU] = nModule_inTRU_eta;
84 if (isCside) {
85 mTRUIsCside.set(currentTRU, true);
86 } else {
87 mTRUIsCside.set(currentTRU, false);
88 }
89
90 if ((currentTRU + 1) >= ALLTRUS) {
91 break;
92 }
93
94 trutype = TRUType_t::STANDARD_TRU;
95 if (truInSupermodule == nTRU_inSM - 1 && isCside) { // last TRU in SM
96 trutype = TRUType_t::EXT_TRU; // right
97 }
98
99 // calculate offset for the next TRU in supermodule (if any)
100 switch (trutype) {
101 case TRUType_t::STANDARD_TRU:
102 mTRUFastOROffsetX[currentTRU + 1] = mTRUFastOROffsetX[currentTRU] + nModule_inTRU_eta;
103 mTRUFastOROffsetY[currentTRU + 1] = mTRUFastOROffsetY[currentTRU];
104 break;
105 case TRUType_t::EXT_TRU:
106 mTRUFastOROffsetX[currentTRU + 1] = 0;
107 mTRUFastOROffsetY[currentTRU + 1] = mTRUFastOROffsetY[currentTRU] + nModule_inTRU_phi;
108 break;
109 };
110 currentTRU++;
111 } // TRU loop
112 } // SM loop
113}
114
116void TriggerMappingV2::init_SM_offset()
117{
118 mSMFastOROffsetX[0] = 0;
119 mSMFastOROffsetY[0] = 0;
120 mNModuleInEMCALPhi[0] = 0;
121 int iB = 0;
122
123 EMCALSMType currentSMtype = NOT_EXISTENT;
124 for (IndexSupermodule supermoduleID = 0; supermoduleID < SUPERMODULES; supermoduleID++) {
125 auto smtype = getSupermoduleType(supermoduleID);
126 auto isCside = isSupermoduleOnCSide(supermoduleID);
127
128 IndexRowPhi nModule_inSM_phi = FASTORSPHISM;
129 IndexColumnEta nModule_inSM_eta = FASTORSETASM;
130
131 if (smtype == EMCAL_THIRD || smtype == DCAL_EXT) {
132 nModule_inSM_phi = static_cast<IndexRowPhi>(static_cast<float>(nModule_inSM_phi) / 3.);
133 }
134
135 mNFastORInSMPhi[supermoduleID] = nModule_inSM_phi;
136 mNFastORInSMEta[supermoduleID] = nModule_inSM_eta;
137
138 if (!isCside) {
139 if (currentSMtype == smtype) {
140 mNModuleInEMCALPhi[iB] += nModule_inSM_phi;
141 } else {
142 mNModuleInEMCALPhi[iB + 1] = mNModuleInEMCALPhi[iB] + nModule_inSM_phi;
143 iB++;
144 }
145 currentSMtype = smtype;
146 }
147
148 if ((supermoduleID + 1) >= SUPERMODULES) {
149 break;
150 }
151
152 // initialize offsets for next supermodule (if any)
153 if (isCside) { // right SM
154 mSMFastOROffsetX[supermoduleID + 1] = 0;
155 mSMFastOROffsetY[supermoduleID + 1] = mSMFastOROffsetY[supermoduleID] + nModule_inSM_phi;
156 } else { // left SM
157 mSMFastOROffsetX[supermoduleID + 1] = mSMFastOROffsetX[supermoduleID] + nModule_inSM_eta;
158 mSMFastOROffsetY[supermoduleID + 1] = mSMFastOROffsetY[supermoduleID];
159 }
160 } // SM loop
161}
162
164{
165 if (truIndex >= ALLTRUS) {
166 throw TRUIndexException(truIndex);
167 }
168 if (positionInTRU >= FASTORSTRU) {
169 throw FastORIndexException(positionInTRU);
170 }
171
172 // invert index on C-side
173 IndexFastOR fastorIndexInverted = (mTRUIsCside.test(truIndex)) ? (FASTORSTRU - positionInTRU - 1) : positionInTRU;
174 IndexColumnEta columnInTRU = mTRUFastOROffsetX[truIndex] + IndexFastOR(fastorIndexInverted / mNFastORInTRUPhi[truIndex]);
175 IndexRowPhi rowInTRU = mTRUFastOROffsetY[truIndex] + mNFastORInTRUPhi[truIndex] - 1 - IndexFastOR(fastorIndexInverted % mNFastORInTRUPhi[truIndex]);
176
177 IndexFastOR id = rowInTRU * FASTORSETA + columnInTRU;
178 id = rotateAbsFastOrIndexEtaToPhi(id);
179
180 return id;
181}
182
184{
185 if (truIndex >= ALLTRUS) {
186 throw TRUIndexException(truIndex);
187 }
188 if (etaColumn > mNFastORInTRUEta[truIndex] - 1 ||
189 phiRow > mNFastORInTRUPhi[truIndex] - 1) {
190 throw FastORPositionExceptionTRU(truIndex, etaColumn, phiRow);
191 }
192
193 IndexColumnEta etatmp = etaColumn; // XXX
194 IndexRowPhi phitmp = phiRow; // XXX
195
196 // unsigned int etatmp = ( mTRUIsCside[ iTRU])? (fnFastORInTRUEta[truIndex] - 1 - etaColumn) : etaColumn ;
197 // unsigned int phitmp = (!mTRUIsCside.test(truIndex))? (fnFastORInTRUPhi[truIndex] - 1 - phiRow) : phiRow ;
198
199 IndexColumnEta x = mTRUFastOROffsetX[truIndex] + etatmp;
200 IndexRowPhi y = mTRUFastOROffsetY[truIndex] + phitmp;
201
202 IndexFastOR id = y * FASTORSETA + x;
203 id = rotateAbsFastOrIndexEtaToPhi(id);
204 return id;
205}
206
208{
209 if (supermoduleID >= SUPERMODULES) {
210 throw SupermoduleIndexException(supermoduleID, SUPERMODULES);
211 }
212 if (
213 etaColumn >= mNFastORInSMEta[supermoduleID] ||
214 phiRow >= mNFastORInSMPhi[supermoduleID]) {
215 throw FastORPositionExceptionSupermodule(supermoduleID, etaColumn, phiRow);
216 }
217
218 // Int_t iEtatmp = (GetSMIsCside(iSM) && GetSMType(iSM) == kDCAL_Standard)?(iEta + 8):iEta ;
219 // Int_t x = fSMFastOROffsetX[iSM] + iEtatmp ;
220
221 IndexColumnEta x = mSMFastOROffsetX[supermoduleID] + etaColumn;
222 IndexRowPhi y = mSMFastOROffsetY[supermoduleID] + phiRow;
223
224 IndexFastOR id = y * FASTORSETA + x;
225 id = rotateAbsFastOrIndexEtaToPhi(id);
226 return id;
227}
228
230{
231 if (
232 etaColumn >= FASTORSETA ||
233 phiRow >= FASTORSPHI) {
234 throw FastORPositionExceptionEMCAL(etaColumn, phiRow);
235 }
236
237 IndexFastOR id = phiRow * FASTORSETA + etaColumn;
238 id = rotateAbsFastOrIndexEtaToPhi(id);
239 return id;
240}
241
243{
244 if (phosRegionID > 35) {
245 throw PHOSRegionException(phosRegionID);
246 }
247
248 IndexColumnEta absColumnEta = 16 + 4 * IndexColumnEta(phosRegionID % 4);
249 IndexRowPhi absRowPhi = 64 + 4 * IndexRowPhi(phosRegionID / 4);
250
251 return getAbsFastORIndexFromPositionInEMCAL(absColumnEta, absRowPhi);
252}
253
254std::tuple<TriggerMappingV2::IndexTRU, TriggerMappingV2::IndexFastOR> TriggerMappingV2::getTRUFromAbsFastORIndex(IndexFastOR fastOrAbsID) const
255{
256 IndexFastOR convertedFastorIndex = rotateAbsFastOrIndexPhiToEta(fastOrAbsID);
257
258 auto fastorInfo = getInfoFromAbsFastORIndex(convertedFastorIndex);
259 return std::make_tuple(fastorInfo.mTRUID, fastorInfo.mFastORIDTRU);
260}
261
262std::tuple<TriggerMappingV2::IndexTRU, TriggerMappingV2::IndexColumnEta, TriggerMappingV2::IndexRowPhi> TriggerMappingV2::getPositionInTRUFromAbsFastORIndex(IndexFastOR fastOrAbsID) const
263{
264
265 IndexFastOR convertedFastorIndex = rotateAbsFastOrIndexPhiToEta(fastOrAbsID);
266
267 auto fastorInfo = getInfoFromAbsFastORIndex(convertedFastorIndex);
268 return std::make_tuple(fastorInfo.mTRUID, fastorInfo.mColumnEtaTRU, fastorInfo.mRowPhiTRU);
269}
270
271std::tuple<TriggerMappingV2::IndexSupermodule, TriggerMappingV2::IndexColumnEta, TriggerMappingV2::IndexRowPhi> TriggerMappingV2::getPositionInSupermoduleFromAbsFastORIndex(IndexFastOR fastOrAbsID) const
272{
273 IndexFastOR convertedFastorIndex = rotateAbsFastOrIndexPhiToEta(fastOrAbsID);
274
275 auto fastorInfo = getInfoFromAbsFastORIndex(convertedFastorIndex);
276 return std::make_tuple(fastorInfo.mSupermoduleID, fastorInfo.mColumnEtaSupermodule, fastorInfo.mRowPhiSupermodule);
277}
278
279std::tuple<TriggerMappingV2::IndexColumnEta, TriggerMappingV2::IndexRowPhi> TriggerMappingV2::getPositionInEMCALFromAbsFastORIndex(IndexFastOR fastorAbsID) const
280{
281 if (fastorAbsID >= ALLFASTORS) {
282 throw FastORIndexException(fastorAbsID);
283 }
284
285 IndexFastOR convertedFastorIndex = rotateAbsFastOrIndexPhiToEta(fastorAbsID);
286 TriggerMappingV2::IndexColumnEta column = convertedFastorIndex % FASTORSETA;
287 TriggerMappingV2::IndexRowPhi row = convertedFastorIndex / FASTORSETA;
288 return std::make_tuple(column, row);
289}
290
292{
293 if (!mGeometry) {
295 }
296 auto [supermoduleID, moduleId, cellPhiModule, cellEtaModule] = mGeometry->GetCellIndex(cellindex);
297
298 auto [cellPhiSupermodule, cellEtaSupermodule] = mGeometry->GetCellPhiEtaIndexInSModule(supermoduleID, moduleId, cellPhiModule, cellEtaModule);
299
300 // ietam:0-31 for DCAL Cside
301 auto cellEta = cellEtaSupermodule, cellPhi = cellPhiSupermodule;
302 if (getSupermoduleType(supermoduleID) == DCAL_STANDARD && (supermoduleID % 2) == 1) {
303 auto [cellPhiShifted, cellEtaShifted] = mGeometry->ShiftOfflineToOnlineCellIndexes(supermoduleID, cellPhiSupermodule, cellEtaSupermodule);
304 cellEta = cellEtaShifted;
305 cellPhi = cellPhiShifted;
306 }
307
308 // ietam:16-47 for DCAL Cside
309 IndexRowPhi moduleRow = static_cast<IndexRowPhi>(cellPhi / 2);
310 IndexColumnEta moduleColumn = static_cast<IndexColumnEta>(cellEta / 2);
311 return getAbsFastORIndexFromPositionInSupermodule(supermoduleID, moduleColumn, moduleRow);
312}
313
314std::array<TriggerMappingV2::IndexCell, 4> TriggerMappingV2::getCellIndexFromAbsFastORIndex(IndexFastOR fastORAbsID) const
315{
316 if (!mGeometry) {
318 }
319 auto [supermoduleID, etaColumnSM, phiRowSM] = getPositionInSupermoduleFromAbsFastORIndex(fastORAbsID);
320 IndexColumnEta cellEtaColumnSupermodule = 2 * etaColumnSM;
321 IndexRowPhi cellPhiRowSupermodule = 2 * phiRowSM;
322
323 // Shift index in case the module is a DCAL standard C-side module
324 if (getSupermoduleType(supermoduleID) == DCAL_STANDARD) {
325 if (supermoduleID % 2 == 1) {
326 auto [cellPhiRowShifted, cellEtaColumnShifted] = mGeometry->ShiftOnlineToOfflineCellIndexes(supermoduleID, cellPhiRowSupermodule, cellEtaColumnSupermodule);
327 cellEtaColumnSupermodule = cellEtaColumnShifted;
328 cellPhiRowSupermodule = cellPhiRowShifted;
329 }
330 }
331 std::array<IndexCell, 4> cells = {{static_cast<IndexCell>(mGeometry->GetAbsCellIdFromCellIndexes(supermoduleID, cellPhiRowSupermodule, cellEtaColumnSupermodule)),
332 static_cast<IndexCell>(mGeometry->GetAbsCellIdFromCellIndexes(supermoduleID, cellPhiRowSupermodule, cellEtaColumnSupermodule + 1)),
333 static_cast<IndexCell>(mGeometry->GetAbsCellIdFromCellIndexes(supermoduleID, cellPhiRowSupermodule + 1, cellEtaColumnSupermodule)),
334 static_cast<IndexCell>(mGeometry->GetAbsCellIdFromCellIndexes(supermoduleID, cellPhiRowSupermodule + 1, cellEtaColumnSupermodule + 1))}};
335 return cells;
336}
337
339{
340 if ((truIndexSTU > 31 && detector == DetType_t::DET_EMCAL) || (truIndexSTU > 13 && detector == DetType_t::DET_DCAL)) {
341 throw TRUIndexException(truIndexSTU);
342 }
343
344 if (detector == DetType_t::DET_EMCAL) {
345 return truIndexSTU;
346 } else {
347 return 32 + ((int)(truIndexSTU / 4) * 6) + ((truIndexSTU % 4 < 2) ? (truIndexSTU % 4) : (truIndexSTU % 4 + 2));
348 }
349}
350
352{
353 if (truIndexTRU < 32) {
354 return truIndexTRU;
355 } else {
356 IndexTRU truIndexSTU = truIndexTRU;
357 if (truIndexSTU >= 48) {
358 truIndexSTU -= 2;
359 }
360 if (truIndexSTU >= 42) {
361 truIndexSTU -= 2;
362 }
363 if (truIndexSTU >= 36) {
364 truIndexSTU -= 2;
365 }
366 truIndexSTU -= 32;
367
368 return truIndexSTU;
369 }
370}
371
372TriggerMappingV2::IndexTRU TriggerMappingV2::getTRUIndexFromOnlineHardareAddree(int hardwareAddress, unsigned int ddlID, unsigned int supermoduleID) const
373{
374 // 1/3 SMs
375
376 if (supermoduleID == 10) {
377 return 30;
378 }
379 if (supermoduleID == 11) {
380 return 31;
381 }
382 if (supermoduleID == 18) {
383 return 50;
384 }
385 if (supermoduleID == 19) {
386 return 51;
387 }
388
389 // Standard EMCal/DCal SMs
390
391 unsigned short branch = (hardwareAddress >> 11) & 0x1; // 0/1
392
393 IndexTRU truIndex = (((ddlID % 2) << 1) | branch) - 1; // 0..2
394
395 truIndex = (supermoduleID % 2) ? 2 - truIndex : truIndex;
396
397 if (supermoduleID < 10) {
398 truIndex += 3 * supermoduleID; // EMCal
399 } else {
400 truIndex += (3 * supermoduleID - 4); // DCal
401 }
402
403 if (truIndex >= ALLTRUS) {
404 throw TRUIndexException(truIndex);
405 }
406
407 return truIndex;
408}
409
410std::array<unsigned int, 4> TriggerMappingV2::getFastORIndexFromL0Index(IndexTRU truIndex, IndexFastOR l0index, int l0size) const
411{
412 if (l0size <= 0 || l0size > 4) {
413 throw L0sizeInvalidException(l0size);
414 }
415
416 int motif[4];
417 motif[0] = 0;
418 motif[2] = 1;
419 motif[1] = mNFastORInTRUPhi[truIndex];
420 motif[3] = mNFastORInTRUPhi[truIndex] + 1;
421
422 std::array<unsigned int, 4> fastorIndex;
423 std::fill(fastorIndex.begin(), fastorIndex.end(), 0);
424 switch (l0size) {
425 case 1: // Cosmic trigger
426 fastorIndex[0] = getAbsFastORIndexFromIndexInTRU(truIndex, l0index);
427 break;
428 case 4: // Standard L0 patch
429 for (int index = 0; index < 4; index++) {
430 IndexFastOR fastorInTRU = mNFastORInTRUPhi[truIndex] * int(l0index / (mNFastORInTRUPhi[truIndex] - 1)) + (l0index % (mNFastORInTRUPhi[truIndex] - 1)) + motif[index];
431 fastorIndex[index] = getAbsFastORIndexFromIndexInTRU(truIndex, fastorInTRU);
432 }
433 break;
434 default:
435 break;
436 }
437
438 return fastorIndex;
439}
441 IndexFastOR fastOrAbsID) const
442{
443 if (fastOrAbsID >= ALLFASTORS) {
444 throw FastORIndexException(fastOrAbsID);
445 }
446 unsigned int fastorIndexTRU;
447
448 IndexFastOR convertedFastorIndex = rotateAbsFastOrIndexEtaToPhi(fastOrAbsID);
449
450 IndexTRU truIndex = convertedFastorIndex / FASTORSTRU;
451 fastorIndexTRU = convertedFastorIndex % FASTORSTRU;
452 if (truIndex >= ALLTRUS) {
453 throw TRUIndexException(truIndex);
454 }
455
456 IndexColumnEta etaColumnTRU = fastorIndexTRU / mNFastORInTRUPhi[truIndex];
457 IndexRowPhi phiRowTRU = fastorIndexTRU % mNFastORInTRUPhi[truIndex];
458 fastorIndexTRU = mNFastORInTRUPhi[truIndex] * ((mTRUIsCside[truIndex]) ? (mNFastORInTRUEta[truIndex] - 1 - etaColumnTRU) : etaColumnTRU) + ((!mTRUIsCside[truIndex]) ? (mNFastORInTRUPhi[truIndex] - 1 - phiRowTRU) : phiRowTRU);
459
460 IndexColumnEta etaColumnGlobal = fastOrAbsID % FASTORSETA;
461 IndexRowPhi rowPhiGlobal = fastOrAbsID / FASTORSETA;
462
463 Int_t idtmp = (rowPhiGlobal < mNModuleInEMCALPhi[2]) ? fastOrAbsID : (fastOrAbsID + FASTORSTRU * 4);
464
465 IndexSupermodule supermoduleID = 2 * (int)(idtmp / (2 * FASTORSETASM * FASTORSPHISM)) + (int)(mTRUIsCside[truIndex]);
466 if (supermoduleID >= SUPERMODULES) {
467 throw SupermoduleIndexException(supermoduleID, SUPERMODULES);
468 }
469
470 IndexColumnEta etaColumnSupermodule = etaColumnGlobal % mNFastORInSMEta[supermoduleID];
471 IndexRowPhi phiRowSupermodule = convertedFastorIndex % mNFastORInSMPhi[supermoduleID];
472 return {
473 truIndex,
474 fastorIndexTRU,
475 etaColumnTRU,
476 phiRowTRU,
477 supermoduleID,
478 etaColumnSupermodule,
479 phiRowSupermodule};
480}
481
482TriggerMappingV2::IndexFastOR TriggerMappingV2::rotateAbsFastOrIndexEtaToPhi(IndexFastOR fastorIndexInEta) const
483{
484 Int_t det_phi = int(fastorIndexInEta / FASTORSETA);
485 Int_t nModule_inSM_phi = FASTORSPHISM; // number of modules in current supermodule
486 Int_t fastOrIndexInPhi = 0;
487 // Calculate FastOR offset relative to previous SM type
488 for (int i = 1; i < 5; i++) {
489 if (det_phi < mNModuleInEMCALPhi[i]) {
490 fastOrIndexInPhi = FASTORSETA * mNModuleInEMCALPhi[i - 1];
491 if (i == 2 || i == 4) {
492 nModule_inSM_phi /= 3;
493 }
494 break;
495 }
496 }
497 // fastOrIndexInPhi := Number of FastORs of the previous range with same SM type
498
499 Int_t fastorInSMType = fastorIndexInEta - fastOrIndexInPhi;
500 Int_t sectorInSMType = (int)(fastorInSMType / (FASTORSETA * nModule_inSM_phi));
501 Int_t fastOrInSector = (int)(fastorInSMType % (FASTORSETA * nModule_inSM_phi));
502
503 fastOrIndexInPhi += sectorInSMType * (FASTORSETA * nModule_inSM_phi); // Add back number of FastORs in previous tracking sectors of the same type
504 // rotate arrangement from eta to phi
505 fastOrIndexInPhi += (int)(fastOrInSector % FASTORSETA) * nModule_inSM_phi; // Add full colums in sector
506 fastOrIndexInPhi += (int)(fastOrInSector / FASTORSETA); // Add FastORs in the last column
507
508 return fastOrIndexInPhi;
509}
510
511TriggerMappingV2::IndexFastOR TriggerMappingV2::rotateAbsFastOrIndexPhiToEta(IndexFastOR fastOrIndexInPhi) const
512{
513 Int_t det_phi = int(fastOrIndexInPhi / FASTORSETA);
514 Int_t fastorIndexInEta = 0;
515 Int_t nModule_inSM_phi = FASTORSPHISM;
516 // Calculate FastOR offset relative to previous SM type
517 for (int i = 1; i < 5; i++) {
518 if (det_phi < mNModuleInEMCALPhi[i]) {
519 fastorIndexInEta = FASTORSETA * mNModuleInEMCALPhi[i - 1];
520 if (i == 2 || i == 4) {
521 nModule_inSM_phi /= 3;
522 }
523 break;
524 }
525 }
526 // fastorIndexInEta := Number of FastORs of the previous range with same SM type
527
528 Int_t fastorInSMType = fastOrIndexInPhi - fastorIndexInEta;
529 Int_t sectorInSMType = (int)(fastorInSMType / (FASTORSETA * nModule_inSM_phi));
530 Int_t fastOrInSector = (int)(fastorInSMType % (FASTORSETA * nModule_inSM_phi));
531
532 Int_t columnInSector = fastOrInSector / nModule_inSM_phi;
533 Int_t rowInSector = fastOrInSector % nModule_inSM_phi;
534
535 fastorIndexInEta += sectorInSMType * (FASTORSETA * nModule_inSM_phi); // Add back number of FastORs in previous tracking sectors of the same type
536 // rotate arrangement from phi to eta
537 fastorIndexInEta += rowInSector * FASTORSETA + columnInSector;
538
539 return fastorIndexInEta;
540}
541
542std::tuple<TriggerMappingV2::IndexTRU, TriggerMappingV2::IndexFastOR> TriggerMappingV2::convertFastORIndexSTUtoTRU(IndexTRU truIndexSTU, IndexFastOR fastOrIndexSTU, DetType_t detector) const
543{
544 if (fastOrIndexSTU >= FASTORSTRU) {
545 throw FastORIndexException(fastOrIndexSTU);
546 }
547 IndexTRU truIndexTRU = convertTRUIndexSTUtoTRU(truIndexSTU, detector);
548 IndexColumnEta etaSTU = fastOrIndexSTU % mNFastORInTRUEta[truIndexTRU];
549 IndexRowPhi phiSTU = fastOrIndexSTU / mNFastORInTRUEta[truIndexTRU];
550
551 // Rotate position on C-side as indices in TRU scheme are rotated on C-side with respect to A-side
552 IndexColumnEta etaTRU = (mTRUIsCside[truIndexTRU]) ? (mNFastORInTRUEta[truIndexTRU] - etaSTU - 1) : etaSTU;
553 IndexRowPhi phiTRU = (mTRUIsCside[truIndexTRU]) ? phiSTU : (mNFastORInTRUPhi[truIndexTRU] - phiSTU - 1);
554 IndexFastOR fastorIndexTRU = etaTRU * mNFastORInTRUPhi[truIndexTRU] + phiTRU;
555
556 return std::make_tuple(truIndexTRU, fastorIndexTRU);
557}
558
559std::tuple<TriggerMappingV2::IndexTRU, TriggerMappingV2::IndexColumnEta, TriggerMappingV2::IndexRowPhi> TriggerMappingV2::convertFastORPositionSTUtoTRU(IndexTRU truIndexSTU, IndexColumnEta truEtaSTU, IndexRowPhi truPhiSTU, DetType_t detector) const
560{
561 auto truIndexTRU = convertTRUIndexSTUtoTRU(truIndexSTU, detector);
562 if (truEtaSTU >= mNFastORInTRUEta[truIndexTRU] || truPhiSTU >= mNFastORInTRUPhi[truIndexTRU]) {
563 throw FastORPositionExceptionTRU(truIndexTRU, truEtaSTU, truPhiSTU);
564 }
565 // Rotate position on C-side as indices in TRU scheme are rotated on C-side with respect to A-side
566 IndexColumnEta truEtaTRU = (mTRUIsCside[truIndexTRU]) ? (mNFastORInTRUEta[truIndexTRU] - truEtaSTU - 1) : truEtaSTU;
567 IndexRowPhi truPhiTRU = (mTRUIsCside[truIndexTRU]) ? truPhiSTU : (mNFastORInTRUPhi[truIndexTRU] - truPhiSTU - 1);
568
569 return std::make_tuple(truIndexTRU, truEtaTRU, truPhiTRU);
570}
571
572std::tuple<TriggerMappingV2::IndexTRU, TriggerMappingV2::IndexFastOR> TriggerMappingV2::convertFastORIndexTRUtoSTU(IndexTRU truIndexTRU, IndexFastOR fastorIndexTRU) const
573{
574 if (truIndexTRU >= FASTORSTRU) {
575 throw FastORIndexException(truIndexTRU);
576 }
577 IndexColumnEta etaTRU = fastorIndexTRU / mNFastORInTRUPhi[truIndexTRU];
578 IndexRowPhi phiTRU = fastorIndexTRU % mNFastORInTRUPhi[truIndexTRU];
579 // Rotate position on C-side as indices in TRU scheme are rotated on C-side with respect to A-side
580 IndexColumnEta etaSTU = (mTRUIsCside[truIndexTRU]) ? (mNFastORInTRUEta[truIndexTRU] - etaTRU - 1) : etaTRU;
581 IndexRowPhi phiSTU = (mTRUIsCside[truIndexTRU]) ? phiTRU : (mNFastORInTRUPhi[truIndexTRU] - phiTRU - 1);
582
583 IndexTRU truIndexSTU = convertTRUIndexTRUtoSTU(truIndexTRU);
584 IndexFastOR fastorIndexSTU = phiSTU * mNFastORInTRUEta[truIndexTRU] + etaSTU;
585
586 return std::tuple(truIndexSTU, fastorIndexSTU);
587}
588
589std::tuple<TriggerMappingV2::IndexTRU, TriggerMappingV2::IndexColumnEta, TriggerMappingV2::IndexRowPhi> TriggerMappingV2::convertFastORPositionTRUtoSTU(IndexTRU truIndexTRU, IndexColumnEta truEtaTRU, IndexRowPhi truPhiTRU) const
590{
591 IndexTRU truIndexSTU = convertTRUIndexTRUtoSTU(truIndexTRU);
592 if (truEtaTRU >= mNFastORInTRUEta[truIndexTRU] || truPhiTRU >= mNFastORInTRUPhi[truIndexTRU]) {
593 throw FastORPositionExceptionTRU(truIndexTRU, truEtaTRU, truPhiTRU);
594 }
595 // Rotate position on C-side as indices in TRU scheme are rotated on C-side with respect to A-side
596 IndexColumnEta truEtaSTU = (mTRUIsCside[truIndexTRU]) ? (mNFastORInTRUEta[truIndexTRU] - truEtaTRU - 1) : truEtaTRU;
597 IndexRowPhi truPhiSTU = (mTRUIsCside[truIndexTRU]) ? truPhiTRU : (mNFastORInTRUPhi[truIndexTRU] - truPhiTRU - 1);
598 return std::make_tuple(truIndexSTU, truEtaSTU, truPhiSTU);
599}
int32_t i
ClassImp(o2::emcal::TriggerMappingV2)
Error handling of faulty FastOR indices.
Handling of invalid positions of a FastOR in the detector.
Handling of invalid positions of a FastOR within a supermodule.
Handling of invalid positions of a FastOR within a TRU.
Handling cases where the geometry is required but not defined.
EMCAL geometry definition.
Definition Geometry.h:40
std::tuple< int, int > GetCellPhiEtaIndexInSModule(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const
Get eta-phi indexes of cell in SM.
std::tuple< int, int, int, int > GetCellIndex(Int_t absId) const
Get cell SM, module numbers from absolute ID number.
std::tuple< int, int > ShiftOnlineToOfflineCellIndexes(Int_t supermoduleID, Int_t iphi, Int_t ieta) const
Adapt cell indices in supermodule to online indexing.
Int_t GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
Transition from super module number (nSupMod) and cell indexes (ieta,iphi) to cell absolute ID number...
Definition Geometry.cxx:791
std::tuple< int, int > ShiftOfflineToOnlineCellIndexes(Int_t supermoduleID, Int_t iphi, Int_t ieta) const
Adapt cell indices in supermodule to offline indexing.
Handlig access of L0 index mapping with invalid patch size.
Handling of invalid PHOS regions.
Handling error due to invalid supermodule.
Error handling of faulty TRU indices.
Trigger mapping starting from Run2.
static constexpr unsigned int FASTORSPHITRU
Number of FastOR/TRU in Phi.
static constexpr unsigned int FASTORSTRU
Number of FastOR/TRU.
std::tuple< IndexColumnEta, IndexRowPhi > getPositionInEMCALFromAbsFastORIndex(IndexFastOR fastORAbsID) const
Get the position in the Detector from the absolute FastOR ID.
IndexTRU convertTRUIndexSTUtoTRU(IndexTRU truIndexSTU, DetType_t detector) const
Convert the TRU index from the STU numbering scheme into the TRU numbering scheme.
std::tuple< IndexTRU, IndexColumnEta, IndexRowPhi > convertFastORPositionSTUtoTRU(IndexTRU truIndexSTU, IndexColumnEta truEtaSTU, IndexRowPhi truPhiSTU, DetType_t detector) const
Convert TRU and FastOR position in TRU from STU number scheme to TRU number scheme.
IndexFastOR getAbsFastORIndexFromPositionInEMCAL(IndexColumnEta etaColumn, IndexRowPhi phiRow) const
Get the absolute index of the FastOR from the geometric position in EMCAL.
std::tuple< IndexTRU, IndexColumnEta, IndexRowPhi > getPositionInTRUFromAbsFastORIndex(IndexFastOR fastORAbsID) const
Get the position of a FastOR inside the TRU from the absolute FastOR ID.
IndexFastOR getAbsFastORIndexFromIndexInTRU(IndexTRU truIndex, IndexFastOR fastorIndexTRU) const
Get the absolute index of the FastOr from the index in the TRU.
IndexFastOR getAbsFastORIndexFromPHOSSubregion(unsigned int phosRegionID) const
std::tuple< IndexTRU, IndexColumnEta, IndexRowPhi > convertFastORPositionTRUtoSTU(IndexTRU truIndexTRU, IndexColumnEta etaTRU, IndexRowPhi phiTRU) const
Convert TRU and FastOR position in TRU from TRU number scheme to STU number scheme.
IndexTRU convertTRUIndexTRUtoSTU(IndexTRU truIndexTRU) const
static constexpr unsigned int TRUSETASM
Number of TRUs/SM in Eta.
TriggerMappingV2()
Default constructor.
static constexpr unsigned int TRUSPHISM
Number of TRUs/SM in Phi.
IndexFastOR getAbsFastORIndexFromPositionInTRU(IndexTRU truIndex, IndexColumnEta etaColumn, IndexRowPhi phiRow) const
Get the absolute index of the FastOr from geometric position in TRU.
std::tuple< IndexSupermodule, IndexColumnEta, IndexRowPhi > getPositionInSupermoduleFromAbsFastORIndex(IndexFastOR fastORAbsID) const
Get the position inside the supermodule from the absolute FastOR ID.
IndexFastOR getAbsFastORIndexFromPositionInSupermodule(IndexSupermodule supermoduleID, IndexColumnEta etaColumn, IndexRowPhi phiRow) const
Get the absolute index of the FastOr from the geometric position in the supermodule.
static constexpr unsigned int FASTORSPHI
Number of FastOR/EMCALs in Phi.
static constexpr unsigned int FASTORSETATRU
Number of FastOR/TRU in Eta.
static constexpr unsigned int FASTORSETA
EMCAL+DCAL region eta size.
static constexpr unsigned int SUPERMODULES
Total number of supermodules in EMCAL.
static constexpr unsigned int FASTORSPHISM
Number of FastOR/SM in Phi.
static constexpr unsigned int FASTORSETASM
Number of FastOR/SM in Eta.
std::tuple< IndexTRU, IndexFastOR > convertFastORIndexTRUtoSTU(IndexTRU truIndexTRU, IndexFastOR fastorIndexTRU) const
Convert TRU and FastOR index in TRU from TRU number scheme to STU number scheme.
static constexpr unsigned int TRUSSUPERMODULE
Number of TRUs/SM.
std::array< IndexCell, 4 > getCellIndexFromAbsFastORIndex(IndexFastOR fastORAbsID) const
Get the indices of the cells in the module of a given FastOR.
IndexTRU getTRUIndexFromOnlineHardareAddree(int hardwareAddress, unsigned int ddlID, unsigned int supermoduleID) const
Get the TRU Index from the hardware address of the ALTRO channel (TRU rawdata)
std::tuple< IndexTRU, IndexFastOR > convertFastORIndexSTUtoTRU(IndexTRU truIndexSTU, IndexFastOR fastOrIndexSTU, DetType_t detector) const
Convert TRU and FastOR index in TRU from STU number scheme to TRU number scheme.
FastORInformation getInfoFromAbsFastORIndex(IndexFastOR absFastORID) const
IndexFastOR getAbsFastORIndexFromCellIndex(IndexCell cellIndex) const
Get the absolute FastOR index of the module containing a given cell.
std::array< unsigned int, 4 > getFastORIndexFromL0Index(IndexTRU iTRU, IndexFastOR l0index, int size) const
static constexpr unsigned int ALLFASTORS
Number of FastOR/EMCALs.
std::tuple< IndexTRU, IndexFastOR > getTRUFromAbsFastORIndex(IndexFastOR fastOrAbsID) const
Get the TRU index and FastOR index in TRU from the absolute FastOR ID.
static constexpr unsigned int ALLTRUS
Total number of TRUs in EMCAL.
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint index
Definition glcorearb.h:781
GLuint id
Definition glcorearb.h:650
std::vector< Cell > cells
std::vector< int > row