ATLAS Offline Software
Loading...
Searching...
No Matches
TGCCableSLBToSSW.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11namespace MuonTGC_Cabling {
12
13TGCCableSLBToSSW::TGCCableSLBToSSW(const std::string& filename)
14 : TGCCable(TGCCable::SLBToSSW), m_database{{{nullptr}}} {
15 m_database[TGCId::Endcap][TGCId::WT] =
16 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB EWT");
17 m_database[TGCId::Endcap][TGCId::WD] =
18 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB EWD");
19 m_database[TGCId::Endcap][TGCId::ST] =
20 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB EST");
21 m_database[TGCId::Endcap][TGCId::SD] =
22 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB ESD");
23 m_database[TGCId::Endcap][TGCId::WI] =
24 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB EWI");
25 m_database[TGCId::Endcap][TGCId::SI] =
26 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB ESI");
27 m_database[TGCId::Endcap][SL] =
28 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB ESL");
29
30 m_database[TGCId::Forward][TGCId::WT] =
31 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB FWT");
32 m_database[TGCId::Forward][TGCId::WD] =
33 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB FWD");
34 m_database[TGCId::Forward][TGCId::ST] =
35 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB FST");
36 m_database[TGCId::Forward][TGCId::SD] =
37 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB FSD");
38 m_database[TGCId::Forward][TGCId::WI] =
39 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB FWI");
40 m_database[TGCId::Forward][TGCId::SI] =
41 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB FSI");
42 m_database[TGCId::Forward][SL] =
43 std::make_unique<TGCDatabaseSLBToROD>(filename, "SLB FSL");
44}
45
46TGCCableSLBToSSW::~TGCCableSLBToSSW() = default;
47
49
50 if (moduleId.getModuleIdType() == TGCModuleId::SLB) {
51 return getModuleOut(moduleId);
52 }
53 if (moduleId.getModuleIdType() == TGCModuleId::SSW) {
54 return getModuleIn(moduleId);
55 }
56
57 return TGCModuleMap{};
58}
59
61 if (ssw.isValid() == false) {
62 return TGCModuleMap{};
63 }
64
65 const int sswId = ssw.getId();
66
70 for (int i = 0; i < TGCId::MaxRegionType; i++) {
71 for (int j = 0; j < MaxModuleType; j++) {
72 databaseP[i * MaxModuleType + j] = m_database[i][j].get();
73 region[i * MaxModuleType + j] = static_cast<TGCId::RegionType>(i);
74 module[i * MaxModuleType + j] = static_cast<TGCId::ModuleType>(j);
75 }
76 }
77
78 TGCModuleMap mapId{};
79 for (int type = 0; type < TGCId::MaxRegionType * MaxModuleType; type++) {
80 const int MaxEntry = databaseP[type]->getMaxEntry();
81 for (int i = 0; i < MaxEntry; i++) {
82
83 if (databaseP[type]->getEntry(i, 4) == sswId) {
84 int sector = databaseP[type]->getEntry(i, 0);
85
86 // Inner
87 if (module[type] == TGCId::WI) {
88 // EI/FI
89 // wire(TGCId::WI) and strip(TGCId::SI) of a chamber
90 // use the same SLB chip
91
92 int sswSector = ssw.getReadoutSector();
93 // one ROD (rodId = 2,5,8,11) covers 6 Inner sectors
94 if (sswSector % 3 != 1) {
95 continue;
96 }
97 sswSector -= 1;
98
99 sector += sswSector * 2;
100 int id = databaseP[type]->getEntry(i, 1);
101 int block = databaseP[type]->getEntry(i, 5);
102 int sbLoc = databaseP[type]->getEntry(i, 2);
103 int slbAddr = databaseP[type]->getEntry(i, 3);
104 for (int ip = 0; ip < 3; ip++) {
105 int psector = sector + ip * 2;
106 int pblock = block + ip * 4;
107 int psbLoc = sbLoc + ip * 4;
108 int pslbAddr = slbAddr + ip * 2;
109 auto slb = std::make_unique<TGCModuleSLB>(
110 ssw.getSideType(), module[type], region[type],
111 psector, id, psbLoc, pslbAddr);
112
113 mapId.insert(pblock, std::move(slb));
114 }
115
116 } else if (module[type] == TGCId::SI) {
117 // EI/FI
118 // wire(TGCId::WI) and strip(TGCId::SI) of a chamber
119 // use the same SLB chip
120
121 // do nothing
122
123 } else {
124 if (region[type] == TGCId::Endcap) {
125 sector += ssw.getReadoutSector() *
127 } else {
128 sector += ssw.getReadoutSector() *
130 }
131 int id = databaseP[type]->getEntry(i, 1);
132 int sbLoc = databaseP[type]->getEntry(i, 2);
133 int slbAddr = databaseP[type]->getEntry(i, 3);
134 int block = databaseP[type]->getEntry(i, 5);
135 auto slb = std::make_unique<TGCModuleSLB>(
136 ssw.getSideType(), module[type], region[type], sector,
137 id, sbLoc, slbAddr);
138
139 mapId.insert(block, std::move(slb));
140 }
141 }
142 }
143 }
144
145 return mapId;
146}
147
149 if (slb.isValid() == false) {
150 return TGCModuleMap{};
151 }
152
153 const int slbId = slb.getId();
154 const int sector = slb.getSectorInReadout();
155 int readoutSector = slb.getReadoutSector();
156
157 TGCModuleMap mapId{};
158
159 TGCDatabase* databaseP =
160 m_database[slb.getRegionType()][slb.getModuleType()].get();
161 const int MaxEntry = databaseP->getMaxEntry();
162 if (slb.getModuleType() == TGCId::WI || slb.getModuleType() == TGCId::SI) {
163 // inner
164 for (int i = 0; i < MaxEntry; i++) {
165 if (databaseP->getEntry(i, 0) == sector &&
166 databaseP->getEntry(i, 1) == slbId) {
167
168 int sswSectorRO = readoutSector - (readoutSector % 3) + 1;
169 int id = databaseP->getEntry(i, 4);
170 int block = databaseP->getEntry(i, 5) + 4 * (readoutSector % 3);
171
172 auto ssw = std::make_unique<TGCModuleSSW>(slb.getSideType(),
173 sswSectorRO, id);
174
175 mapId.insert(block, std::move(ssw));
176 break;
177 }
178 }
179
180 } else {
181 for (int i = 0; i < MaxEntry; i++) {
182 if (databaseP->getEntry(i, 0) == sector &&
183 databaseP->getEntry(i, 1) == slbId) {
184
185 int id = databaseP->getEntry(i, 4);
186 int block = databaseP->getEntry(i, 5);
187 auto ssw = std::make_unique<TGCModuleSSW>(slb.getSideType(),
188 readoutSector, id);
189
190 mapId.insert(block, std::move(ssw));
191 break;
192 }
193 }
194 }
195 return mapId;
196}
197
198} // namespace MuonTGC_Cabling
std::array< std::array< std::unique_ptr< TGCDatabase >, MaxModuleType >, TGCId::MaxRegionType > m_database
TGCModuleMap getModuleOut(const TGCModuleId &slb) const
TGCModuleMap getModule(const TGCModuleId &moduleId) const
TGCModuleMap getModuleIn(const TGCModuleId &ssw) const
TGCCable(CableType type=NoCableType)
Definition TGCCable.h:31
virtual int getMaxEntry() const
virtual int getEntry(int entry, int column) const
int getSectorInReadout() const
Definition TGCId.cxx:26
ModuleType getModuleType() const
Definition TGCId.h:141
static constexpr int NUM_ENDCAP_SECTOR
Definition TGCId.h:41
RegionType getRegionType() const
Definition TGCId.h:150
static constexpr int N_RODS
Definition TGCId.h:44
SideType getSideType() const
Definition TGCId.h:135
int getId() const
Definition TGCId.h:163
static constexpr int NUM_FORWARD_SECTOR
Definition TGCId.h:42
ModuleIdType getModuleIdType() const
Definition TGCModuleId.h:32
virtual bool isValid() const
Definition TGCModuleId.h:36
void insert(int connector, std::unique_ptr< TGCModuleId > moduleId)