Belle II Software development
ARICHBiasCrateCableMapping.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/ARICHBiasCrateCableMapping.h>
12
13using namespace std;
14using namespace Belle2;
15
17{
18}
19
20int ARICHBiasCrateCableMapping::getSector(int connectionID) const
21{
22 if (connectionID < 1) { B2WARNING("ARICHBiasCrateCableMapping::getSector: connectionID " << connectionID << " not valid!"); return 0;}
23 std::vector<int> sectorCable = m_connection2cable.find(connectionID)->second;
24 return sectorCable[0];
25}
26
27int ARICHBiasCrateCableMapping::getCable(int connectionID) const
28{
29 if (connectionID < 1) { B2WARNING("ARICHBiasCrateCableMapping::getCable: connectionID " << connectionID << " not valid!"); return 0;}
30 std::vector<int> sectorCable = m_connection2cable.find(connectionID)->second;
31 return sectorCable[1];
32}
33
34int ARICHBiasCrateCableMapping::getConnectionID(const std::vector<int>& sectorCable) const
35{
36 int connectionID = -2;
37 for (auto& i : m_connection2cable) {
38 if (i.second == sectorCable) connectionID = i.first;
39 }
40 return connectionID;
41}
42
43
44void ARICHBiasCrateCableMapping::addMapping(int connectionID, std::vector<int> sectorCable)
45{
46 m_connection2cable.insert(std::pair<int, std::vector<int>>(connectionID, sectorCable));
47}
48
50{
51 for (auto const& x : m_connection2cable) {
52 int connectionID = x.first;
53 std::vector<int> cables = x.second;
54 B2INFO("Connection " << connectionID << ": sector " << cables[0] << ", cable " << cables[1]);
55 }
56}
57
void addMapping(int connectionID, std::vector< int > sectorCable)
Add new entry to the mapping table.
int getCable(int connectionID) const
Get cable ID.
std::map< int, std::vector< int > > m_connection2cable
map of crates to cables
int getSector(int connectionID) const
Get sector ID.
void print() const
Print mapping parameters.
int getConnectionID(const std::vector< int > &sectorCable) const
Get connection ID.
Abstract base class for different kinds of events.
STL namespace.