ATLAS Offline Software
Loading...
Searching...
No Matches
TGCCableSLBToSSW.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
47
48 if (moduleId.getModuleIdType() == TGCModuleId::SLB) {
49 return getModuleOut(moduleId);
50 }
51 if (moduleId.getModuleIdType() == TGCModuleId::SSW) {
52 return getModuleIn(moduleId);
53 }
54
55 return TGCModuleMap{};
56}
57
59 if (ssw.isValid() == false) {
60 return TGCModuleMap{};
61 }
62
63 const int sswId = ssw.getId();
64
68 for (int i = 0; i < TGCId::MaxRegionType; i++) {
69 for (int j = 0; j < MaxModuleType; j++) {
70 databaseP[i * MaxModuleType + j] = m_database[i][j].get();
71 region[i * MaxModuleType + j] = static_cast<TGCId::RegionType>(i);
72 module[i * MaxModuleType + j] = static_cast<TGCId::ModuleType>(j);
73 }
74 }
75
76 TGCModuleMap mapId{};
77 for (int type = 0; type < TGCId::MaxRegionType * MaxModuleType; type++) {
78 const int MaxEntry = databaseP[type]->getMaxEntry();
79 for (int i = 0; i < MaxEntry; i++) {
80
81 if (databaseP[type]->getEntry(i, 4) == sswId) {
82 int sector = databaseP[type]->getEntry(i, 0);
83
84 // Inner
85 if (module[type] == TGCId::WI) {
86 // EI/FI
87 // wire(TGCId::WI) and strip(TGCId::SI) of a chamber
88 // use the same SLB chip
89
90 int sswSector = ssw.getReadoutSector();
91 // one ROD (rodId = 2,5,8,11) covers 6 Inner sectors
92 if (sswSector % 3 != 1) {
93 continue;
94 }
95 sswSector -= 1;
96
97 sector += sswSector * 2;
98 int id = databaseP[type]->getEntry(i, 1);
99 int block = databaseP[type]->getEntry(i, 5);
100 int sbLoc = databaseP[type]->getEntry(i, 2);
101 int slbAddr = databaseP[type]->getEntry(i, 3);
102 for (int ip = 0; ip < 3; ip++) {
103 int psector = sector + ip * 2;
104 int pblock = block + ip * 4;
105 int psbLoc = sbLoc + ip * 4;
106 int pslbAddr = slbAddr + ip * 2;
107 auto slb = std::make_unique<TGCModuleSLB>(
108 ssw.getSideType(), module[type], region[type],
109 psector, id, psbLoc, pslbAddr);
110
111 mapId.insert(pblock, std::move(slb));
112 }
113
114 } else if (module[type] == TGCId::SI) {
115 // EI/FI
116 // wire(TGCId::WI) and strip(TGCId::SI) of a chamber
117 // use the same SLB chip
118
119 // do nothing
120
121 } else {
122 if (region[type] == TGCId::Endcap) {
123 sector += ssw.getReadoutSector() *
125 } else {
126 sector += ssw.getReadoutSector() *
128 }
129 int id = databaseP[type]->getEntry(i, 1);
130 int sbLoc = databaseP[type]->getEntry(i, 2);
131 int slbAddr = databaseP[type]->getEntry(i, 3);
132 int block = databaseP[type]->getEntry(i, 5);
133 auto slb = std::make_unique<TGCModuleSLB>(
134 ssw.getSideType(), module[type], region[type], sector,
135 id, sbLoc, slbAddr);
136
137 mapId.insert(block, std::move(slb));
138 }
139 }
140 }
141 }
142
143 return mapId;
144}
145
147 if (slb.isValid() == false) {
148 return TGCModuleMap{};
149 }
150
151 const int slbId = slb.getId();
152 const int sector = slb.getSectorInReadout();
153 int readoutSector = slb.getReadoutSector();
154
155 TGCModuleMap mapId{};
156
157 TGCDatabase* databaseP =
158 m_database[slb.getRegionType()][slb.getModuleType()].get();
159 const int MaxEntry = databaseP->getMaxEntry();
160 if (slb.getModuleType() == TGCId::WI || slb.getModuleType() == TGCId::SI) {
161 // inner
162 for (int i = 0; i < MaxEntry; i++) {
163 if (databaseP->getEntry(i, 0) == sector &&
164 databaseP->getEntry(i, 1) == slbId) {
165
166 int sswSectorRO = readoutSector - (readoutSector % 3) + 1;
167 int id = databaseP->getEntry(i, 4);
168 int block = databaseP->getEntry(i, 5) + 4 * (readoutSector % 3);
169
170 auto ssw = std::make_unique<TGCModuleSSW>(slb.getSideType(),
171 sswSectorRO, id);
172
173 mapId.insert(block, std::move(ssw));
174 break;
175 }
176 }
177
178 } else {
179 for (int i = 0; i < MaxEntry; i++) {
180 if (databaseP->getEntry(i, 0) == sector &&
181 databaseP->getEntry(i, 1) == slbId) {
182
183 int id = databaseP->getEntry(i, 4);
184 int block = databaseP->getEntry(i, 5);
185 auto ssw = std::make_unique<TGCModuleSSW>(slb.getSideType(),
186 readoutSector, id);
187
188 mapId.insert(block, std::move(ssw));
189 break;
190 }
191 }
192 }
193 return mapId;
194}
195
196} // 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:137
static constexpr int NUM_ENDCAP_SECTOR
Definition TGCId.h:41
RegionType getRegionType() const
Definition TGCId.h:146
static constexpr int N_RODS
Definition TGCId.h:44
SideType getSideType() const
Definition TGCId.h:134
int getId() const
Definition TGCId.h:162
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)