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#include <iostream>
13
14using namespace std;
15using namespace Belle2;
16
18{
19}
20
21std::vector<int> ARICHHvChannelsMapping::getChannelValues(int connectionID, int pinID) const
22{
23
24 vector<int> channel{ -2, -2, -2};
25 for (auto& i : m_channel2type) {
26 if (((i.second)[0] == connectionID) && ((i.second)[1] == pinID)) channel = i.first;
27 }
28 return channel;
29}
30
31int ARICHHvChannelsMapping::getPinID(std::vector<int> channel) const
32{
33 std::vector<int> pinProp = m_channel2type.find(channel)->second;
34 return pinProp[1];
35}
36
37int ARICHHvChannelsMapping::getConnectionID(std::vector<int> channel) const
38{
39 std::vector<int> pinProp = m_channel2type.find(channel)->second;
40 return pinProp[0];
41}
42
43int ARICHHvChannelsMapping::getCrate(int connectionID, int pinID) const
44{
45 return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[0];
46}
47
48int ARICHHvChannelsMapping::getSlot(int connectionID, int pinID) const
49{
50 return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[1];
51}
52
53int ARICHHvChannelsMapping::getChannel(int connectionID, int pinID) const
54{
55 return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[2];
56}
57
58void ARICHHvChannelsMapping::addMapping(int crate, int slot, int channelID, int connectionID, int pinID)
59{
60
61 if (crate > 6 || crate < 3) { B2WARNING("ARICHHvChannelsMapping::addMapping: Crate ID number " << crate << " not valid!"); }
62 if (slot > 12 || slot < 0 || slot % 2 != 0) { B2WARNING("ARICHHvChannelsMapping::addMapping: Slot ID number " << slot << " not valid!"); }
63
64 std::vector<int> pinProp{connectionID, pinID};
65 std::vector<int> channelMap{crate, slot, channelID};
66 m_channel2type.insert(std::pair<std::vector<int>, std::vector<int>>(channelMap, pinProp));
67
68}
69
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 suply 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.