ATLAS Offline Software
TGCConnectionPPToSL.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <fstream>
8 #include <sstream>
9 #include <string>
10 
12 
13 namespace LVL1TGCTrigger {
14 
16  m_PPToSB(),
17  m_SBToHPB(),
18  m_HPBToSL()
19 {
20 }
21 
23  m_PPToSB(right.m_PPToSB),
24  m_SBToHPB(right.m_SBToHPB),
25  m_HPBToSL(right.m_HPBToSL)
26 {
27 }
28 
29 
31 {
32  if (this != &right) {
33  m_PPToSB = right.m_PPToSB;
34  m_SBToHPB = right.m_SBToHPB;
35  m_HPBToSL = right.m_HPBToSL;
36  }
37  return *this;
38 }
39 
41 {
42  std::string fn = TGCDatabaseManager::getFilename(2); // PP2SL.db
43  std::string fullpath = PathResolver::find_file(fn, "PWD");
44  if (fullpath.length() == 0)
45  fullpath = PathResolver::find_file(fn, "DATAPATH");
46  std::ifstream inputfile(fullpath.c_str(), std::ios::in);
47 
48  static constexpr int BufferSize = 512;
49  char buf[BufferSize];
50 
51  // find entries match in region type
52  bool isMatched = false;
53  while (inputfile && inputfile.getline(buf,BufferSize)) {
54  std::istringstream line(buf);
55 
56  std::string region;
57  line >> region ;
58  isMatched = (region == "Endcap" && type == TGCRegionType::ENDCAP) ||
59  (region == "Forward" && type == TGCRegionType::FORWARD);
60  if (isMatched) break;
61  }
62  if (!isMatched) return false;
63 
64  // read entries for HighPtBoard
65  if (inputfile.getline(buf, BufferSize)) {
66  std::istringstream infileStr(buf);
67  std::string boardName;
68  infileStr >> boardName;
69 
70  for (int itype=0; itype < m_HPBToSL.getNumberOfType(); itype++) {
71  int board_number{0};
72  infileStr >> board_number;
73  m_HPBToSL.setNumber(itype, board_number);
74  for (int j=0; j < board_number; j++) {
75  inputfile.getline(buf, BufferSize);
76  std::istringstream infileStr2(buf);
77  int id, port;
78  infileStr2 >> id >> port;
79  m_HPBToSL.setId(itype, j, id);
80  m_HPBToSL.setSLPortToHPB(itype, id, port);
81  }
82  }
83  }
84 
85  // read entries for SlaveBoard
86  if (inputfile.getline(buf, BufferSize)) {
87  std::istringstream infileStr(buf);
88  std::string boardName;
89  infileStr >> boardName;
90 
91  for (int itype=0; itype < m_SBToHPB.getNumberOfType(); itype++) {
92  // No HPT board for Inner
93  if (itype == WISB || itype == SISB) continue;
94  int board_number{0};
95  infileStr >> board_number;
96  m_SBToHPB.setNumber(itype, board_number);
97  for (int j=0; j < board_number; j++) {
98  inputfile.getline(buf, BufferSize);
99  std::istringstream infileStr2(buf);
100  int id, idHPB, port;
101  infileStr2 >> id >> idHPB >> port;
102  if (id < 0 || idHPB < 0 || port < 0) continue;
103  m_SBToHPB.setId(itype, j, id); // BoardType, Number in a type, id
104  m_SBToHPB.setHPBIdToSB(itype, id, idHPB);
105  m_SBToHPB.setHPBPortToSB(itype, id, port);
106  }
107  }
108  }
109 
110  // read entries for PatchPanel
111  if (inputfile.getline(buf, BufferSize)) {
112  std::istringstream infileStr(buf);
113  std::string boardName;
114  infileStr >> boardName;
115 
116  for (int itype=0; itype < m_PPToSB.getNumberOfType(); itype++) {
117  int board_number{0};
118  infileStr >> board_number;
119  m_PPToSB.setNumber(itype, board_number);
120  for(int j=0; j<board_number; j++) {
121  inputfile.getline(buf, BufferSize);
122  std::istringstream infileStr2(buf);
123  int id{0}; // PP ID
124  int idSB1{0}; // SB ID for Part0
125  int idSB2{0}; // SB ID for Part1
126  infileStr2 >> id >> idSB1 >> idSB2;
127  m_PPToSB.setId(itype, j, id);
128  m_PPToSB.setSBIdToPP(itype, 0, j, idSB1);
129  m_PPToSB.setSBIdToPP(itype, 1, j, idSB2);
130  }
131  }
132  }
133 
134  return true;
135 }
136 
137 } // end of namespace
LVL1TGCTrigger::TGCRegionType::ENDCAP
@ ENDCAP
checkFileSG.line
line
Definition: checkFileSG.py:75
LVL1TGCTrigger::TGCBoardConnection::setNumber
void setNumber(const unsigned int type, int nBoard)
Definition: TGCBoardConnection.cxx:27
StateLessPT_NewConfig.BufferSize
BufferSize
Definition: StateLessPT_NewConfig.py:370
LVL1TGCTrigger::SISB
@ SISB
Definition: TGCNumbering.h:57
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
LVL1TGCTrigger::TGCConnectionPPToSL::TGCConnectionPPToSL
TGCConnectionPPToSL()
Definition: TGCConnectionPPToSL.cxx:15
InDetSecVtxTruthMatchUtils::isMatched
bool isMatched(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:48
LVL1TGCTrigger::TGCRegionType::FORWARD
@ FORWARD
LVL1TGCTrigger::TGCConnectionPPToSL::m_SBToHPB
TGCConnectionSBToHPB m_SBToHPB
Definition: TGCConnectionPPToSL.h:31
TGCDatabaseManager.h
LVL1TGCTrigger::TGCConnectionPPToSL
Definition: TGCConnectionPPToSL.h:16
LVL1TGCTrigger::TGCBoardConnection::getNumberOfType
int getNumberOfType() const
Definition: TGCBoardConnection.h:21
LVL1TGCTrigger::TGCDatabaseManager::getFilename
static std::string getFilename(int type)
Definition: TGCDatabaseManager.cxx:239
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:65
LVL1TGCTrigger::TGCConnectionPPToSL::m_HPBToSL
TGCConnectionHPBToSL m_HPBToSL
Definition: TGCConnectionPPToSL.h:32
LVL1TGCTrigger::WISB
@ WISB
Definition: TGCNumbering.h:57
LVL1TGCTrigger::TGCBoardConnection::setId
void setId(const unsigned int type, const unsigned int board, int idIn)
Definition: TGCBoardConnection.cxx:36
LVL1TGCTrigger::TGCConnectionPPToSB::setSBIdToPP
void setSBIdToPP(int type, int port, int index, int idIn)
Definition: TGCConnectionPPToSB.h:40
LVL1TGCTrigger
Definition: LVL1TGCTrigger.cxx:47
LVL1TGCTrigger::TGCConnectionSBToHPB::setHPBPortToSB
void setHPBPortToSB(int type, int index, int port)
Definition: TGCConnectionSBToHPB.h:38
PathResolver.h
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
LVL1TGCTrigger::TGCConnectionSBToHPB::setHPBIdToSB
void setHPBIdToSB(int type, int index, int id)
Definition: TGCConnectionSBToHPB.h:49
LVL1TGCTrigger::TGCRegionType
TGCRegionType
Definition: TGCNumbering.h:49
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
FullCPAlgorithmsTest_CA.inputfile
dictionary inputfile
Definition: FullCPAlgorithmsTest_CA.py:62
TGCConnectionPPToSL.h
LVL1TGCTrigger::TGCConnectionHPBToSL::setSLPortToHPB
void setSLPortToHPB(int type, int index, int port)
Definition: TGCConnectionHPBToSL.h:36
LVL1TGCTrigger::TGCConnectionPPToSL::operator=
TGCConnectionPPToSL & operator=(const TGCConnectionPPToSL &)
Definition: TGCConnectionPPToSL.cxx:30
LVL1TGCTrigger::TGCConnectionPPToSL::readData
bool readData(TGCRegionType type)
Definition: TGCConnectionPPToSL.cxx:40
LVL1TGCTrigger::TGCConnectionPPToSL::m_PPToSB
TGCConnectionPPToSB m_PPToSB
Definition: TGCConnectionPPToSL.h:30
beamspotman.fullpath
string fullpath
Definition: beamspotman.py:1039