Belle II Software  release-05-01-25
ARICHHvCablesMapping.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/ARICHHvCablesMapping.h>
14 #include <iostream>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 ARICHHvCablesMapping::ARICHHvCablesMapping()
20 {
21 }
22 
23 int ARICHHvCablesMapping::getModuleID(int sectorID, int cableID, int innerID) const
24 {
25  if (sectorID > 6 || sectorID < 1) { B2WARNING("ARICHHvCablesMapping::getcableID: Sector number " << sectorID << " not valid!"); return 0;}
26  if (cableID > 4 || cableID < 1) { B2WARNING("ARICHHvCablesMapping::getcableID: Cable number " << cableID << " not valid!"); return 0;}
27  if (innerID > 20 || innerID < 2) { B2WARNING("ARICHHvCablesMapping::getcableID: Inner cable number " << innerID << " not valid!"); return 0;}
28 
29  int module = 0;
30  std::vector<int> position{sectorID, cableID, innerID};
31  for (auto& i : m_module2cable) {
32  if (i.second == position) module = i.first;
33  }
34  return module;
35 }
36 
37 int ARICHHvCablesMapping::getSectorID(int moduleID) const
38 {
39  if (moduleID > 420 || moduleID < 1) { B2WARNING("ARICHHvCablesMapping::getcableID: Module number " << moduleID << " not valid!"); return 0;}
40  std::vector<int> sector = m_module2cable.find(moduleID)->second;
41  return (int)sector[0];
42 }
43 
44 int ARICHHvCablesMapping::getCableID(int moduleID) const
45 {
46  if (moduleID > 420 || moduleID < 1) { B2WARNING("ARICHHvCablesMapping::getcableID: Module number " << moduleID << " not valid!"); return 0;}
47  std::vector<int> cable = m_module2cable.find(moduleID)->second;
48  return (int)cable[1];
49 }
50 
51 int ARICHHvCablesMapping::getInnerID(int moduleID) const
52 {
53  if (moduleID > 420 || moduleID < 1) { B2WARNING("ARICHHvCablesMapping::getcableID: Module number " << moduleID << " not valid!"); return 0;}
54  std::vector<int> inner = m_module2cable.find(moduleID)->second;
55  return (int)inner[2];
56 }
57 
58 void ARICHHvCablesMapping::addMapping(int moduleID, int sectorID, int cableID, int innerID)
59 {
60 
61  if (moduleID > 420 || moduleID < 1) { B2WARNING("ARICHHvCablesMapping::addMapping: Module number " << moduleID << " not valid!"); }
62  if (sectorID > 6 || sectorID < 1) { B2WARNING("ARICHHvCablesMapping::addMapping: Sector number " << sectorID << " not valid!"); }
63  if (cableID > 8 || cableID < 1) { B2WARNING("ARICHHvCablesMapping::addMapping: Cable number " << cableID << " not valid!"); }
64  if (innerID > 20 || innerID < 2) { B2WARNING("ARICHHvCablesMapping::addMapping: Inner cable number " << innerID << " not valid!"); }
65 
66  std::vector<int> cableMap{sectorID, cableID, innerID};
67  m_module2cable.insert(std::pair<int, std::vector<int>>(moduleID, cableMap));
68 
69 }
70 
71 void ARICHHvCablesMapping::print() const
72 {
73 
74  for (int moduleID = 1; moduleID < N_MODULES + 1; moduleID++) {
75  cout << " Module " << moduleID << ": sector " << getSectorID(moduleID) << ", cable " << getCableID(
76  moduleID) << ", inner " << getInnerID(moduleID) << endl;
77  }
78 
79  cout << endl;
80  cout << "Moving to finding module number... " << endl;
81  int l = 0;
82 
83  for (int i = 1; i < 7 ; i++) {
84  for (int j = 1; j < 5 ; j++) {
85  for (int k = 2; k < 21; k++) {
86  if (k == 7) continue;
87  if ((j == 1 || j == 4) && k == 20) continue;
88  std::cout << " Module: " << getModuleID(i, j, k) << ": sector " << i << ", cable " << j << ", inner " << k << std::endl;
89  l++;
90  }
91  }
92  }
93 
94  cout << "number of modules = " << l << endl;
95 
96 }
97 
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19