9 #include <framework/logging/Logger.h>
11 #include <arich/dbobjects/ARICHMergerMapping.h>
17 ARICHMergerMapping:: ARICHMergerMapping()
19 m_merger2module.assign(N_MERGERS * N_FEB2MERGER, 0);
20 m_module2merger.assign(N_MERGERS * N_FEB2MERGER, 0);
21 m_isMapped.assign(N_MERGERS * N_FEB2MERGER, 0);
24 unsigned ARICHMergerMapping::getModuleID(
unsigned mergerID,
unsigned febSlot)
const
26 if (!(mergerID > 0 && mergerID < N_MERGERS + 1 && febSlot > 0 && febSlot < N_FEB2MERGER + 1)) { B2ERROR(
"ARICHMergerMapping::getModuleID: invalid merger ID " << mergerID <<
" or febSlot " << febSlot);
return 0;}
27 unsigned id = (mergerID - 1) * N_FEB2MERGER + (febSlot - 1);
28 return (
unsigned)m_merger2module[id];
31 unsigned ARICHMergerMapping::getMergerID(
unsigned moduleID)
const
33 if (!m_isMapped[moduleID - 1]) { B2WARNING(
"ARICHMergerMapping::getMergerID: Module " << moduleID <<
" not not mapped to merger!");
return 0;}
34 unsigned id = (unsigned)m_module2merger[moduleID - 1] / N_FEB2MERGER + 1;
38 unsigned ARICHMergerMapping::getFEBSlot(
unsigned moduleID)
const
40 if (!m_isMapped[moduleID - 1]) { B2WARNING(
"ARICHMergerMapping::getMergerID: Module " << moduleID <<
" not not mapped to merger!");
return 0;}
41 unsigned id = (unsigned)m_module2merger[moduleID - 1] % N_FEB2MERGER + 1;
45 unsigned ARICHMergerMapping::getMergerSN(
unsigned mergerID)
const
47 unsigned mergerSN = m_mergerID.find(mergerID)->second;
51 unsigned ARICHMergerMapping::getMergerIDfromSN(
unsigned mergerSN)
const
53 unsigned mergerID = 99;
54 for (
auto& i : m_mergerID) {
if (i.second == mergerSN) mergerID = i.first; }
59 void ARICHMergerMapping::addMapping(
unsigned moduleID,
unsigned mergerID,
unsigned febSlot,
unsigned mergerSN)
64 m_module2merger[moduleID - 1] = (uint16_t)((mergerID - 1) * N_FEB2MERGER + (febSlot - 1));
65 m_merger2module[(mergerID - 1) * N_FEB2MERGER + (febSlot - 1)] = (uint16_t)moduleID;
66 m_isMapped[moduleID - 1] = 1;
68 m_mergerID.insert(std::pair<unsigned, unsigned>(mergerID, mergerSN));
71 void ARICHMergerMapping::print()
const
74 std::cout << std::endl;
75 std::cout <<
"Mapping of modules to mergers" << std::endl;
76 std::cout << std::endl;
77 for (
int i = 1; i < N_MERGERS + 1; i++) {
79 for (
int j = 1; j < N_FEB2MERGER + 1; j++) {
80 if (getModuleID(i, j)) { isUsed =
true;
break;}
83 if (!isUsed)
continue;
84 std::cout <<
" Modules connected to merger " << i <<
" (SN = " << getMergerSN(i) <<
")" << std::endl;
85 for (
int j = 1; j < N_FEB2MERGER + 1; j++) {
86 if (getModuleID(i, j)) std::cout <<
" FEB slot " << j <<
": " << getModuleID(i, j) << std::endl;
87 else std::cout <<
" FEB slot " << j <<
" not connected" << std::endl;
Abstract base class for different kinds of events.