Belle II Software  release-05-01-25
ARICHBiasChannelsMapping.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/ARICHBiasChannelsMapping.h>
14 #include <iostream>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 ARICHBiasChannelsMapping::ARICHBiasChannelsMapping()
20 {
21 }
22 
23 int ARICHBiasChannelsMapping::getPinID(std::vector<int> channel) const
24 {
25  std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
26  return std::get<0>(pinProp);
27 }
28 int ARICHBiasChannelsMapping::getConnectionID(std::vector<int> channel) const
29 {
30  std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
31  return std::get<1>(pinProp);
32 }
33 int ARICHBiasChannelsMapping::getInnerID(std::vector<int> channel) const
34 {
35  std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
36  return std::get<2>(pinProp);
37 }
38 std::string ARICHBiasChannelsMapping::getType(std::vector<int> channel) const
39 {
40  std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
41  return std::get<3>(pinProp);
42 }
43 
44 
45 std::tuple<int, int, std::string> ARICHBiasChannelsMapping::getInnerConnection(std::vector<int> channel) const
46 {
47  // connection ID, inner ID, type
48 
49  std::tuple<int, int, int, std::string> pinProp = m_channel2type.find(channel)->second;
50  return std::make_tuple(std::get<1>(pinProp), std::get<2>(pinProp), std::get<3>(pinProp));
51 }
52 
53 int ARICHBiasChannelsMapping::getChannelID(int crate, int slot, int connectionID, int innerID, const std::string& type) const
54 {
55  if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING("ARICHBiasChannelsMapping::getChannelID: Inner ID " << innerID << " not valid!"); }
56 
57  vector<int> channel{ -2, -2, -2};
58  for (auto& i : m_channel2type) {
59  if ((std::get<1>(i.second) == connectionID) && (std::get<2>(i.second) == innerID) && (std::get<3>(i.second) == type)
60  && ((i.first)[0] == crate) && ((i.first)[1] == slot)) channel = i.first;
61  }
62  return channel[2];
63 }
64 std::vector<int> ARICHBiasChannelsMapping::getChannelValues(int connectionID, int innerID, const std::string& type) const
65 {
66  if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING("ARICHBiasChannelsMapping::getChannelID: Inner ID " << innerID << " not valid!"); }
67 
68  vector<int> channel{ -2, -2, -2};
69  for (auto& i : m_channel2type) {
70  if ((std::get<1>(i.second) == connectionID) && (std::get<2>(i.second) == innerID)
71  && (std::get<3>(i.second) == type)) channel = i.first;
72  }
73  return channel;
74 }
75 
76 
77 void ARICHBiasChannelsMapping::addMapping(int crate, int slot, int channelID, int pinID, int connectionID, int innerID,
78  const std::string& type)
79 {
80 
81  if (channelID > 47 || channelID < 0) { B2WARNING("ARICHBiasChannelsMapping::addMapping: Channel ID number " << channelID << " not valid!"); }
82  if (pinID > 46 || pinID < -2 || pinID == 0) { B2WARNING("ARICHBiasChannelsMapping::addMapping: Pin ID number " << pinID << " not valid!"); }
83  if (innerID > 9 || innerID < -2 || innerID == 0) { B2WARNING("ARICHBiasChannelsMapping::addMapping: Inner ID " << innerID << " not valid!"); }
84 
85  auto pinProp = std::make_tuple(pinID, connectionID, innerID, type);
86  std::vector<int> channelMap{crate, slot, channelID};
87  m_channel2type.insert(std::pair<std::vector<int>, std::tuple<int, int, int, std::string>>(channelMap, pinProp));
88 
89 }
90 
91 void ARICHBiasChannelsMapping::print() const
92 {
93 
94  for (int crate = 0; crate < 3 ; crate++) {
95  for (int slot = 0; slot < 15 ; slot++) {
96  for (int channelID = 0; channelID < N_BIASCHANNELS; channelID++) {
97  std::vector<int> channel{crate, slot, channelID};
98  cout << " Channel " << channelID << " (crate " << crate << ", slot " << slot << "): pinID " << getPinID(
99  channel) << ", inner pin " << std::get<0>(getInnerConnection(channel)) << ", inner type " << std::get<1>(getInnerConnection(
100  channel)) << endl;
101  }
102  }
103  }
104 
105 }
106 
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19