Belle II Software development
ARICHBiasChannelsMapping.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/logging/Logger.h>
10
11#include <arich/dbobjects/ARICHBiasChannelsMapping.h>
12#include <iostream>
13
14using namespace std;
15using namespace Belle2;
16
18{
19}
20
21int ARICHBiasChannelsMapping::getPinID(std::vector<int> channel) const
22{
23 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
24 return std::get<0>(pinProp);
25}
26int ARICHBiasChannelsMapping::getConnectionID(std::vector<int> channel) const
27{
28 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
29 return std::get<1>(pinProp);
30}
31int ARICHBiasChannelsMapping::getInnerID(std::vector<int> channel) const
32{
33 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
34 return std::get<2>(pinProp);
35}
36std::string ARICHBiasChannelsMapping::getType(std::vector<int> channel) const
37{
38 std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
39 return std::get<3>(pinProp);
40}
41
42
43std::tuple<int, int, std::string> ARICHBiasChannelsMapping::getInnerConnection(std::vector<int> channel) const
44{
45 // connection ID, inner ID, type
46
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));
49}
50
51int ARICHBiasChannelsMapping::getChannelID(int crate, int slot, int connectionID, int innerID, const std::string& type) const
52{
53 if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING("ARICHBiasChannelsMapping::getChannelID: Inner ID " << innerID << " not valid!"); }
54
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;
59 }
60 return channel[2];
61}
62std::vector<int> ARICHBiasChannelsMapping::getChannelValues(int connectionID, int innerID, const std::string& type) const
63{
64 if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING("ARICHBiasChannelsMapping::getChannelID: Inner ID " << innerID << " not valid!"); }
65
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;
70 }
71 return channel;
72}
73
74
75void ARICHBiasChannelsMapping::addMapping(int crate, int slot, int channelID, int pinID, int connectionID, int innerID,
76 const std::string& type)
77{
78
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!"); }
82
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));
86
87}
88
90{
91
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(
98 channel)) << endl;
99 }
100 }
101 }
102
103}
104
std::vector< int > getChannelValues(int connectionID, int innerID, const std::string &type) const
Get bias power supply cratem slot and channel ID from inner cable type and ID.
int getConnectionID(std::vector< int > channel) const
Get inner cable pin ID from bias power supply channel ID.
int getInnerID(std::vector< int > channel) const
Get inner cable pin ID from bias power supply channel ID.
std::string getType(std::vector< int > channel) const
Get bias/guard type from channel.
int getChannelID(int crate, int slot, int connectionID, int innerID, const std::string &type) const
Get bias power supply channel ID from inner cable type and ID.
std::tuple< int, int, std::string > getInnerConnection(std::vector< int > channel) const
Get inner cable ID and type, connected to bias channel.
int getPinID(std::vector< int > channelID) const
Get inner cable pin ID from bias power supply channel ID.
void addMapping(int crate, int slot, int channelID, int pinID, int connectionID, int innerID, const std::string &type)
Add new entry to the mapping table.
void print() const
Print properties.
std::map< std::vector< int >, std::tuple< int, int, int, std::string > > m_channel2type
power suply channel ID link to inner cable
Abstract base class for different kinds of events.
STL namespace.