9 #include <framework/logging/Logger.h>
11 #include <arich/dbobjects/ARICHBiasChannelsMapping.h>
17 ARICHBiasChannelsMapping::ARICHBiasChannelsMapping()
21 int ARICHBiasChannelsMapping::getPinID(std::vector<int> channel)
const
23 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
24 return std::get<0>(pinProp);
26 int ARICHBiasChannelsMapping::getConnectionID(std::vector<int> channel)
const
28 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
29 return std::get<1>(pinProp);
31 int ARICHBiasChannelsMapping::getInnerID(std::vector<int> channel)
const
33 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
34 return std::get<2>(pinProp);
36 std::string ARICHBiasChannelsMapping::getType(std::vector<int> channel)
const
38 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
39 return std::get<3>(pinProp);
43 std::tuple<int, int, std::string> ARICHBiasChannelsMapping::getInnerConnection(std::vector<int> channel)
const
47 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
48 return std::make_tuple(std::get<1>(pinProp), std::get<2>(pinProp), std::get<3>(pinProp));
51 int ARICHBiasChannelsMapping::getChannelID(
int crate,
int slot,
int connectionID,
int innerID,
const std::string& type)
const
53 if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING(
"ARICHBiasChannelsMapping::getChannelID: Inner ID " << innerID <<
" not valid!"); }
55 vector<int> channel{ -2, -2, -2};
56 for (
auto& i : m_channel2type) {
57 if ((std::get<1>(i.second) == connectionID) && (std::get<2>(i.second) == innerID) && (std::get<3>(i.second) == type)
58 && ((i.first)[0] == crate) && ((i.first)[1] == slot)) channel = i.first;
62 std::vector<int> ARICHBiasChannelsMapping::getChannelValues(
int connectionID,
int innerID,
const std::string& type)
const
64 if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING(
"ARICHBiasChannelsMapping::getChannelID: Inner ID " << innerID <<
" not valid!"); }
66 vector<int> channel{ -2, -2, -2};
67 for (
auto& i : m_channel2type) {
68 if ((std::get<1>(i.second) == connectionID) && (std::get<2>(i.second) == innerID)
69 && (std::get<3>(i.second) == type)) channel = i.first;
75 void ARICHBiasChannelsMapping::addMapping(
int crate,
int slot,
int channelID,
int pinID,
int connectionID,
int innerID,
76 const std::string& type)
79 if (channelID > 47 || channelID < 0) { B2WARNING(
"ARICHBiasChannelsMapping::addMapping: Channel ID number " << channelID <<
" not valid!"); }
80 if (pinID > 46 || pinID < -2 || pinID == 0) { B2WARNING(
"ARICHBiasChannelsMapping::addMapping: Pin ID number " << pinID <<
" not valid!"); }
81 if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING(
"ARICHBiasChannelsMapping::addMapping: Inner ID " << innerID <<
" not valid!"); }
83 auto pinProp = std::make_tuple(pinID, connectionID, innerID, type);
84 std::vector<int> channelMap{crate, slot, channelID};
85 m_channel2type.insert(std::pair<std::vector<int>, std::tuple<int, int, int, std::string>>(channelMap, pinProp));
89 void ARICHBiasChannelsMapping::print()
const
92 for (
int crate = 0; crate < 3 ; crate++) {
93 for (
int slot = 0; slot < 15 ; slot++) {
94 for (
int channelID = 0; channelID < N_BIASCHANNELS; channelID++) {
95 std::vector<int> channel{crate, slot, channelID};
96 cout <<
" Channel " << channelID <<
" (crate " << crate <<
", slot " << slot <<
"): pinID " << getPinID(
97 channel) <<
", inner pin " << std::get<0>(getInnerConnection(channel)) <<
", inner type " << std::get<1>(getInnerConnection(
Abstract base class for different kinds of events.