Belle II Software  release-08-01-10
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 #include <iostream>
13 
14 using namespace std;
15 using namespace Belle2;
16 
17 ARICHBiasCrateCableMapping::ARICHBiasCrateCableMapping()
18 {
19 }
20 
21 int ARICHBiasCrateCableMapping::getSector(int connectionID) const
22 {
23  if (connectionID < 1) { B2WARNING("ARICHBiasCrateCableMapping::getSector: connectionID " << connectionID << " not valid!"); return 0;}
24  std::vector<int> sectorCable = m_connection2cable.find(connectionID)->second;
25  return sectorCable[0];
26 }
27 
28 int ARICHBiasCrateCableMapping::getCable(int connectionID) const
29 {
30  if (connectionID < 1) { B2WARNING("ARICHBiasCrateCableMapping::getCable: connectionID " << connectionID << " not valid!"); return 0;}
31  std::vector<int> sectorCable = m_connection2cable.find(connectionID)->second;
32  return sectorCable[1];
33 }
34 
35 int ARICHBiasCrateCableMapping::getConnectionID(const std::vector<int>& sectorCable) const
36 {
37  int connectionID = -2;
38  for (auto& i : m_connection2cable) {
39  if (i.second == sectorCable) connectionID = i.first;
40  }
41  return connectionID;
42 }
43 
44 
45 void ARICHBiasCrateCableMapping::addMapping(int connectionID, std::vector<int> sectorCable)
46 {
47  m_connection2cable.insert(std::pair<int, std::vector<int>>(connectionID, sectorCable));
48 }
49 
50 void ARICHBiasCrateCableMapping::print() const
51 {
52  for (auto const& x : m_connection2cable) {
53  int connectionID = x.first;
54  std::vector<int> cables = x.second;
55  B2INFO("Connection " << connectionID << ": sector " << cables[0] << ", cable " << cables[1]);
56  }
57 }
58 
Abstract base class for different kinds of events.