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 if (moduleId) {
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 nullptr;
56}
57
59 if (ssw->isValid() == false) {
60 return nullptr;
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 = nullptr;
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 TGCModuleSLB* slb = new TGCModuleSLB(
108 ssw->getSideType(), module[type], region[type],
109 psector, id, psbLoc, pslbAddr);
110
111 if (mapId == nullptr) {
112 mapId = new TGCModuleMap();
113 }
114 mapId->insert(pblock, slb);
115 }
116
117 } else if (module[type] == TGCId::SI) {
118 // EI/FI
119 // wire(TGCId::WI) and strip(TGCId::SI) of a chamber
120 // use the same SLB chip
121
122 // do nothing
123
124 } else {
125 if (region[type] == TGCId::Endcap) {
126 sector += ssw->getReadoutSector() *
128 } else {
129 sector += ssw->getReadoutSector() *
131 }
132 int id = databaseP[type]->getEntry(i, 1);
133 int sbLoc = databaseP[type]->getEntry(i, 2);
134 int slbAddr = databaseP[type]->getEntry(i, 3);
135 int block = databaseP[type]->getEntry(i, 5);
136 TGCModuleSLB* slb = new TGCModuleSLB(
137 ssw->getSideType(), module[type], region[type], sector,
138 id, sbLoc, slbAddr);
139
140 if (mapId == nullptr) {
141 mapId = new TGCModuleMap();
142 }
143 mapId->insert(block, slb);
144 }
145 }
146 }
147 }
148
149 return mapId;
150}
151
153 if (slb->isValid() == false) {
154 return nullptr;
155 }
156
157 const int slbId = slb->getId();
158 const int sector = slb->getSectorInReadout();
159 int readoutSector = slb->getReadoutSector();
160
161 TGCModuleMap* mapId = nullptr;
162
163 TGCDatabase* databaseP =
164 m_database[slb->getRegionType()][slb->getModuleType()].get();
165 const int MaxEntry = databaseP->getMaxEntry();
166 if (slb->getModuleType() == TGCId::WI ||
167 slb->getModuleType() == TGCId::SI) {
168 // inner
169 for (int i = 0; i < MaxEntry; i++) {
170 if (databaseP->getEntry(i, 0) == sector &&
171 databaseP->getEntry(i, 1) == slbId) {
172
173 int sswSectorRO = readoutSector - (readoutSector % 3) + 1;
174 int id = databaseP->getEntry(i, 4);
175 int block = databaseP->getEntry(i, 5) + 4 * (readoutSector % 3);
176
177 TGCModuleSSW* ssw =
178 new TGCModuleSSW(slb->getSideType(), sswSectorRO, id);
179 mapId = new TGCModuleMap();
180 mapId->insert(block, ssw);
181 break;
182 }
183 }
184
185 } else {
186 for (int i = 0; i < MaxEntry; i++) {
187 if (databaseP->getEntry(i, 0) == sector &&
188 databaseP->getEntry(i, 1) == slbId) {
189
190 int id = databaseP->getEntry(i, 4);
191 int block = databaseP->getEntry(i, 5);
192 TGCModuleSSW* ssw =
193 new TGCModuleSSW(slb->getSideType(), readoutSector, id);
194 mapId = new TGCModuleMap();
195 mapId->insert(block, ssw);
196 break;
197 }
198 }
199 }
200 return mapId;
201}
202
203} // namespace MuonTGC_Cabling
virtual TGCModuleMap * getModule(const TGCModuleId *moduleId) const
virtual TGCModuleMap * getModuleIn(const TGCModuleId *ssw) const
std::array< std::array< std::unique_ptr< TGCDatabase >, MaxModuleType >, TGCId::MaxRegionType > m_database
virtual TGCModuleMap * getModuleOut(const TGCModuleId *slb) const
TGCCable(CableType type=NoCableType)
Definition TGCCable.h:31
virtual int getMaxEntry(void) const
virtual int getEntry(int entry, int column) const
ModuleType getModuleType(void) const
Definition TGCId.h:137
static constexpr int NUM_ENDCAP_SECTOR
Definition TGCId.h:41
RegionType getRegionType(void) const
Definition TGCId.h:146
static constexpr int N_RODS
Definition TGCId.h:44
int getSectorInReadout(void) const
Definition TGCId.cxx:26
SideType getSideType(void) const
Definition TGCId.h:134
int getId() const
Definition TGCId.h:162
static constexpr int NUM_FORWARD_SECTOR
Definition TGCId.h:42
virtual bool isValid(void) const
Definition TGCModuleId.h:38
ModuleIdType getModuleIdType(void) const
Definition TGCModuleId.h:34
void insert(int connector, TGCModuleId *moduleId)