Belle II Software development
ARICHHvChannelsMapping.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/ARICHHvChannelsMapping.h>
12
13using namespace std;
14using namespace Belle2;
15
17{
18}
19
20std::vector<int> ARICHHvChannelsMapping::getChannelValues(int connectionID, int pinID) const
21{
22
23 vector<int> channel{ -2, -2, -2};
24 for (auto& i : m_channel2type) {
25 if (((i.second)[0] == connectionID) && ((i.second)[1] == pinID)) channel = i.first;
26 }
27 return channel;
28}
29
30int ARICHHvChannelsMapping::getPinID(std::vector<int> channel) const
31{
32 std::vector<int> pinProp = m_channel2type.find(channel)->second;
33 return pinProp[1];
34}
35
36int ARICHHvChannelsMapping::getConnectionID(std::vector<int> channel) const
37{
38 std::vector<int> pinProp = m_channel2type.find(channel)->second;
39 return pinProp[0];
40}
41
42int ARICHHvChannelsMapping::getCrate(int connectionID, int pinID) const
43{
44 return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[0];
45}
46
47int ARICHHvChannelsMapping::getSlot(int connectionID, int pinID) const
48{
49 return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[1];
50}
51
52int ARICHHvChannelsMapping::getChannel(int connectionID, int pinID) const
53{
54 return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[2];
55}
56
57void ARICHHvChannelsMapping::addMapping(int crate, int slot, int channelID, int connectionID, int pinID)
58{
59
60 if (crate > 6 || crate < 3) { B2WARNING("ARICHHvChannelsMapping::addMapping: Crate ID number " << crate << " not valid!"); }
61 if (slot > 12 || slot < 0 || slot % 2 != 0) { B2WARNING("ARICHHvChannelsMapping::addMapping: Slot ID number " << slot << " not valid!"); }
62
63 std::vector<int> pinProp{connectionID, pinID};
64 std::vector<int> channelMap{crate, slot, channelID};
65 m_channel2type.insert(std::pair<std::vector<int>, std::vector<int>>(channelMap, pinProp));
66
67}
68
std::vector< int > getChannelValues(int connectionID, int pinID) const
Get bias power supply channel ID from inner cable type and ID.
std::map< std::vector< int >, std::vector< int > > m_channel2type
power supply channel ID link to inner cable
int getPinID(std::vector< int > channel) const
Get inner cable pin ID from hv power supply channel ID.
int getConnectionID(std::vector< int > channel) const
Get connection ID from hv power supply channel ID.
int getSlot(int connectionID, int pinID) const
Get connection ID from hv power supply channel ID.
ARICHHvChannelsMapping()
Default constructor.
int getCrate(int connectionID, int pinID) const
Get connection ID from hv power supply channel ID.
int getChannel(int connectionID, int pinID) const
Get connection ID from hv power supply channel ID.
void addMapping(int crate, int slot, int channelID, int connectionID, int pinID)
Add new entry to the mapping table.
Abstract base class for different kinds of events.
STL namespace.