Belle II Software  release-05-01-25
ARICHBiasCrateCableMapping.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Manca Mrvar *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/logging/Logger.h>
12 
13 #include <arich/dbobjects/ARICHBiasCrateCableMapping.h>
14 #include <iostream>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 ARICHBiasCrateCableMapping::ARICHBiasCrateCableMapping()
20 {
21 }
22 
23 int ARICHBiasCrateCableMapping::getSector(int connectionID) const
24 {
25  if (connectionID < 1) { B2WARNING("ARICHBiasCrateCableMapping::getSector: connectionID " << connectionID << " not valid!"); return 0;}
26  std::vector<int> sectorCable = m_connection2cable.find(connectionID)->second;
27  return sectorCable[0];
28 }
29 
30 int ARICHBiasCrateCableMapping::getCable(int connectionID) const
31 {
32  if (connectionID < 1) { B2WARNING("ARICHBiasCrateCableMapping::getCable: connectionID " << connectionID << " not valid!"); return 0;}
33  std::vector<int> sectorCable = m_connection2cable.find(connectionID)->second;
34  return sectorCable[1];
35 }
36 
37 int ARICHBiasCrateCableMapping::getConnectionID(const std::vector<int>& sectorCable) const
38 {
39  int connectionID = -2;
40  for (auto& i : m_connection2cable) {
41  if (i.second == sectorCable) connectionID = i.first;
42  }
43  return connectionID;
44 }
45 
46 
47 void ARICHBiasCrateCableMapping::addMapping(int connectionID, std::vector<int> sectorCable)
48 {
49  m_connection2cable.insert(std::pair<int, std::vector<int>>(connectionID, sectorCable));
50 }
51 
52 void ARICHBiasCrateCableMapping::print() const
53 {
54  for (auto const& x : m_connection2cable) {
55  int connectionID = x.first;
56  std::vector<int> cables = x.second;
57  B2INFO("Connection " << connectionID << ": sector " << cables[0] << ", cable " << cables[1]);
58  }
59 }
60 
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19