9#include <framework/logging/Logger.h>
11#include <arich/dbobjects/ARICHMergerMapping.h>
21 m_isMapped.assign(N_MERGERS * N_FEB2MERGER, 0);
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);
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;
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;
47 unsigned mergerSN =
m_mergerID.find(mergerID)->second;
53 unsigned mergerID = 99;
54 for (
auto& i :
m_mergerID) {
if (i.second == mergerSN) mergerID = i.first; }
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;
68 m_mergerID.insert(std::pair<unsigned, unsigned>(mergerID, mergerSN));
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++) {
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++) {
87 else std::cout <<
" FEB slot " << j <<
" not connected" << std::endl;
unsigned getMergerIDfromSN(unsigned mergerSN) const
Get ID of merger from serial number.
unsigned getModuleID(unsigned mergerID, unsigned febSlot) const
Get ID of module connected to merger at FEB slot.
std::vector< uint16_t > m_module2merger
map of modules to mergers
ARICHMergerMapping()
Default constructor.
std::vector< bool > m_isMapped
vector of mapped modules
std::vector< uint16_t > m_merger2module
map of mergers to modules
void addMapping(unsigned moduleID, unsigned mergerID, unsigned febSlot, unsigned mergerSN)
Add mapping entry.
unsigned getMergerID(unsigned moduleID) const
Get ID of merger to which module is connected.
unsigned getMergerSN(unsigned mergerID) const
Get serial number of marger from its ID.
void print() const
Pring mapping.
unsigned getFEBSlot(unsigned moduleID) const
Get FEB slot to which module is connected.
std::map< unsigned, unsigned > m_mergerID
map mergers ID to SN
Abstract base class for different kinds of events.