ATLAS Offline Software
Loading...
Searching...
No Matches
TGCConnectionPPToSL.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <fstream>
8#include <sstream>
9#include <string>
10
12
13namespace LVL1TGCTrigger {
14
21
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 //coverity[TAINTED_SCALAR]
74 m_HPBToSL.setNumber(itype, board_number);
75 for (int j=0; j < board_number; j++) {
76 inputfile.getline(buf, BufferSize);
77 std::istringstream infileStr2(buf);
78 int id, port;
79 infileStr2 >> id >> port;
80 m_HPBToSL.setId(itype, j, id);
81 //coverity[TAINTED_SCALAR]
82 m_HPBToSL.setSLPortToHPB(itype, id, port);
83 }
84 }
85 }
86
87 // read entries for SlaveBoard
88 if (inputfile.getline(buf, BufferSize)) {
89 std::istringstream infileStr(buf);
90 std::string boardName;
91 infileStr >> boardName;
92
93 for (int itype=0; itype < m_SBToHPB.getNumberOfType(); itype++) {
94 // No HPT board for Inner
95 if (itype == WISB || itype == SISB) continue;
96 int board_number{0};
97 infileStr >> board_number;
98 //coverity[TAINTED_SCALAR]
99 m_SBToHPB.setNumber(itype, board_number);
100 for (int j=0; j < board_number; j++) {
101 inputfile.getline(buf, BufferSize);
102 std::istringstream infileStr2(buf);
103 int id, idHPB, port;
104 infileStr2 >> id >> idHPB >> port;
105 if (id < 0 || idHPB < 0 || port < 0) continue;
106 m_SBToHPB.setId(itype, j, id); // BoardType, Number in a type, id
107 //coverity[TAINTED_SCALAR]
108 m_SBToHPB.setHPBIdToSB(itype, id, idHPB);
109 m_SBToHPB.setHPBPortToSB(itype, id, port);
110 }
111 }
112 }
113
114 // read entries for PatchPanel
115 if (inputfile.getline(buf, BufferSize)) {
116 std::istringstream infileStr(buf);
117 std::string boardName;
118 infileStr >> boardName;
119
120 for (int itype=0; itype < m_PPToSB.getNumberOfType(); itype++) {
121 int board_number{0};
122 infileStr >> board_number;
123 //coverity[TAINTED_SCALAR]
124 m_PPToSB.setNumber(itype, board_number);
125 for(int j=0; j<board_number; j++) {
126 inputfile.getline(buf, BufferSize);
127 std::istringstream infileStr2(buf);
128 int id{0}; // PP ID
129 int idSB1{0}; // SB ID for Part0
130 int idSB2{0}; // SB ID for Part1
131 infileStr2 >> id >> idSB1 >> idSB2;
132 m_PPToSB.setId(itype, j, id);
133 m_PPToSB.setSBIdToPP(itype, 0, j, idSB1);
134 m_PPToSB.setSBIdToPP(itype, 1, j, idSB2);
135 }
136 }
137 }
138
139 return true;
140}
141
142} // end of namespace
TGCConnectionPPToSL & operator=(const TGCConnectionPPToSL &)
static std::string getFilename(int type)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)