Belle II Software  release-08-01-10
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 
14 using namespace std;
15 using namespace Belle2;
16 
17 ARICHHvChannelsMapping::ARICHHvChannelsMapping()
18 {
19 }
20 
21 std::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 
31 int ARICHHvChannelsMapping::getPinID(std::vector<int> channel) const
32 {
33  std::vector<int> pinProp = m_channel2type.find(channel)->second;
34  return pinProp[1];
35 }
36 
37 int ARICHHvChannelsMapping::getConnectionID(std::vector<int> channel) const
38 {
39  std::vector<int> pinProp = m_channel2type.find(channel)->second;
40  return pinProp[0];
41 }
42 
43 int ARICHHvChannelsMapping::getCrate(int connectionID, int pinID) const
44 {
45  return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[0];
46 }
47 
48 int ARICHHvChannelsMapping::getSlot(int connectionID, int pinID) const
49 {
50  return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[1];
51 }
52 
53 int ARICHHvChannelsMapping::getChannel(int connectionID, int pinID) const
54 {
55  return (ARICHHvChannelsMapping::getChannelValues(connectionID, pinID))[2];
56 }
57 
58 void 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 
Abstract base class for different kinds of events.