ATLAS Offline Software
Loading...
Searching...
No Matches
TGCCableInSLB.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10namespace MuonTGC_Cabling {
11
12std::unique_ptr<TGCChannelId> TGCCableInSLB::getChannel(
13 const TGCChannelId& channelId, bool orChannel) const {
14 if (channelId.getChannelIdType() == TGCChannelId::ChannelIdType::SLBIn) {
15 return getChannelOut(channelId, orChannel);
16 }
17 if (channelId.getChannelIdType() == TGCChannelId::ChannelIdType::SLBOut) {
18 return getChannelIn(channelId, orChannel);
19 }
20
21 return nullptr;
22}
23
24std::unique_ptr<TGCChannelId> TGCCableInSLB::getChannelIn(
25 const TGCChannelId& slbout, bool orChannel) const {
26 if (slbout.isValid() == false) {
27 return nullptr;
28 }
29
30 int channel = slbout.getChannel();
31 int block = slbout.getBlock();
32 TGCId::ModuleType moduleType = slbout.getModuleType();
33
34 int channelInBlock = TGCChannelSLBOut::getChannelInBlock(moduleType);
35 int numberOfLayer = TGCChannelSLBOut::getNumberOfLayer(moduleType);
36
37 int adjacentOfSLB = -1;
38 int channelInSLB = -1;
40 switch (moduleType) {
41 case TGCId::WD:
42 // channel SLBIn
43 // 2*n CellB n+block*16
44 // 2*n+1 CellA n+block*16
45 if (orChannel == false) {
46 if (channel % numberOfLayer == 1) {
47 cellType = TGCChannelSLBIn::CellA;
48 adjacentOfSLB =
49 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
50 channelInSLB =
51 (channel + block * channelInBlock) / numberOfLayer +
52 adjacentOfSLB;
53 }
54 if (channel % numberOfLayer == 0) {
55 cellType = TGCChannelSLBIn::CellB;
56 adjacentOfSLB =
57 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
58 channelInSLB =
59 (channel + block * channelInBlock) / numberOfLayer +
60 adjacentOfSLB;
61 }
62 }
63 if (orChannel == true) {
64 if (channel % numberOfLayer == 1) {
65 cellType = TGCChannelSLBIn::CellC;
66 adjacentOfSLB =
67 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
68 channelInSLB =
69 (channel + block * channelInBlock) / numberOfLayer +
70 adjacentOfSLB;
71 }
72 if (channel % numberOfLayer == 0) {
73 cellType = TGCChannelSLBIn::CellD;
74 adjacentOfSLB =
75 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
76 channelInSLB =
77 (channel + block * channelInBlock) / numberOfLayer +
78 adjacentOfSLB;
79 }
80 }
81 break;
82 case TGCId::SD:
83 // channel SLBIn
84 // 2*n CellB n+block*16
85 // 2*n+1 CellA n+block*16
86 if (orChannel == false) {
87 if (channel % numberOfLayer == 1) {
88 cellType = TGCChannelSLBIn::CellA;
89 adjacentOfSLB =
90 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
91 channelInSLB =
92 (channel + block * channelInBlock) / numberOfLayer +
93 adjacentOfSLB;
94 }
95 if (channel % numberOfLayer == 0) {
96 cellType = TGCChannelSLBIn::CellB;
97 adjacentOfSLB =
98 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
99 channelInSLB =
100 (channel + block * channelInBlock) / numberOfLayer +
101 adjacentOfSLB;
102 }
103 }
104 if (orChannel == true) {
105 if (channel % numberOfLayer == 1) {
106 cellType = TGCChannelSLBIn::CellC;
107 adjacentOfSLB =
108 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
109 channelInSLB =
110 (channel + block * channelInBlock) / numberOfLayer +
111 adjacentOfSLB;
112 }
113 if (channel % numberOfLayer == 0) {
114 cellType = TGCChannelSLBIn::CellD;
115 adjacentOfSLB =
116 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
117 channelInSLB =
118 (channel + block * channelInBlock) / numberOfLayer +
119 adjacentOfSLB;
120 }
121 }
122 break;
123 case TGCId::WT:
124 // channel SLBIn
125 // 3*n CellC n+block*16
126 // 3*n+1 CellB n+block*16
127 // 3*n+2 CellA n+block*16
128 if ((channel + block * channelInBlock) % numberOfLayer == 2) {
129 cellType = TGCChannelSLBIn::CellA;
130 adjacentOfSLB =
131 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
132 channelInSLB =
133 (channel + block * channelInBlock) / numberOfLayer +
134 adjacentOfSLB;
135 }
136 if ((channel + block * channelInBlock) % numberOfLayer == 1) {
137 cellType = TGCChannelSLBIn::CellB;
138 adjacentOfSLB =
139 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
140 channelInSLB =
141 (channel + block * channelInBlock) / numberOfLayer +
142 adjacentOfSLB;
143 }
144 if ((channel + block * channelInBlock) % numberOfLayer == 0) {
145 cellType = TGCChannelSLBIn::CellC;
146 adjacentOfSLB =
147 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
148 channelInSLB =
149 (channel + block * channelInBlock) / numberOfLayer +
150 adjacentOfSLB;
151 }
152 break;
153 case TGCId::ST:
154 case TGCId::WI:
155 case TGCId::SI:
156 // channel SLBIn
157 // 2*n CellB n+block*16
158 // 2*n+1 CellA n+block*16
159 if (orChannel == false) {
160 if (channel % numberOfLayer == 1) {
161 cellType = TGCChannelSLBIn::CellA;
162 adjacentOfSLB =
163 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
164 channelInSLB =
165 (channel + block * channelInBlock) / numberOfLayer +
166 adjacentOfSLB;
167 }
168 if (channel % numberOfLayer == 0) {
169 cellType = TGCChannelSLBIn::CellB;
170 adjacentOfSLB =
171 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
172 channelInSLB =
173 (channel + block * channelInBlock) / numberOfLayer +
174 adjacentOfSLB;
175 }
176 }
177 if (orChannel == true) {
178 if (channel % numberOfLayer == 1) {
179 cellType = TGCChannelSLBIn::CellC;
180 adjacentOfSLB =
181 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
182 channelInSLB =
183 (channel + block * channelInBlock) / numberOfLayer +
184 adjacentOfSLB;
185 }
186 if (channel % numberOfLayer == 0) {
187 cellType = TGCChannelSLBIn::CellD;
188 adjacentOfSLB =
189 TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
190 channelInSLB =
191 (channel + block * channelInBlock) / numberOfLayer +
192 adjacentOfSLB;
193 }
194 }
195 break;
196
197 default:
198 break;
199 }
200
201 if (channelInSLB != -1) {
202 int channelOfSLB = TGCChannelSLBIn::convertChannel(
203 slbout.getModuleType(), cellType, channelInSLB);
204 return std::make_unique<TGCChannelSLBIn>(
205 slbout.getSideType(), slbout.getModuleType(),
206 slbout.getRegionType(), slbout.getSector(), slbout.getId(),
207 channelOfSLB);
208 }
209 return nullptr;
210}
211
212std::unique_ptr<TGCChannelId> TGCCableInSLB::getChannelOut(
213 const TGCChannelId& slbin, bool orChannel) const {
214 if (slbin.isValid() == false) {
215 return nullptr;
216 }
217
220 if (cellType == TGCChannelSLBIn::NoCellType) {
221 return nullptr;
222 }
223
224 TGCId::ModuleType moduleType = slbin.getModuleType();
225 int channelInCell =
227 int channelInSLB = TGCChannelSLBIn::convertChannelInSLB(
228 moduleType, cellType, channelInCell);
229
230 int channelInBlock = TGCChannelSLBOut::getChannelInBlock(moduleType);
231 int numberOfLayer = TGCChannelSLBOut::getNumberOfLayer(moduleType);
232 int adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType, cellType);
233
234 int channel = -1;
235 int block = -1;
236 switch (moduleType) {
237 case TGCId::WD:
238 if (orChannel == false) {
239 if (cellType == TGCChannelSLBIn::CellA) {
240 channel =
241 (channelInSLB - adjacentOfSLB) * numberOfLayer + 1;
242 }
243 if (cellType == TGCChannelSLBIn::CellB) {
244 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer;
245 }
246 block = channel / channelInBlock;
247 channel = channel % channelInBlock;
248 }
249 if (orChannel == true) {
250 if (cellType == TGCChannelSLBIn::CellC) {
251 channel =
252 (channelInSLB - adjacentOfSLB) * numberOfLayer + 1;
253 }
254 if (cellType == TGCChannelSLBIn::CellD) {
255 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer;
256 }
257 block = channel / channelInBlock;
258 channel = channel % channelInBlock;
259 }
260 break;
261 case TGCId::SD:
262 if (orChannel == false) {
263 if (cellType == TGCChannelSLBIn::CellA) {
264 channel =
265 (channelInSLB - adjacentOfSLB) * numberOfLayer + 1;
266 }
267 if (cellType == TGCChannelSLBIn::CellB) {
268 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer;
269 }
270 block = channel / channelInBlock;
271 channel = channel % channelInBlock;
272 }
273 if (orChannel == true) {
274 if (cellType == TGCChannelSLBIn::CellC) {
275 channel =
276 (channelInSLB - adjacentOfSLB) * numberOfLayer + 1;
277 }
278 if (cellType == TGCChannelSLBIn::CellD) {
279 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer;
280 }
281 block = channel / channelInBlock;
282 channel = channel % channelInBlock;
283 }
284 break;
285 case TGCId::WT:
286 if (cellType == TGCChannelSLBIn::CellA) {
287 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer + 2;
288 }
289 if (cellType == TGCChannelSLBIn::CellB) {
290 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer + 1;
291 }
292 if (cellType == TGCChannelSLBIn::CellC) {
293 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer;
294 }
295 block = channel / channelInBlock;
296 channel = channel % channelInBlock;
297 break;
298 case TGCId::ST:
299 case TGCId::WI:
300 case TGCId::SI:
301 if (cellType == TGCChannelSLBIn::CellA ||
302 cellType == TGCChannelSLBIn::CellB) {
303 if (cellType == TGCChannelSLBIn::CellA) {
304 channel =
305 (channelInSLB - adjacentOfSLB) * numberOfLayer + 1;
306 }
307 if (cellType == TGCChannelSLBIn::CellB) {
308 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer;
309 }
310 block = channel / channelInBlock;
311 channel = channel % channelInBlock;
312 }
313 if (cellType == TGCChannelSLBIn::CellC ||
314 cellType == TGCChannelSLBIn::CellD) {
315 if (cellType == TGCChannelSLBIn::CellC) {
316 channel =
317 (channelInSLB - adjacentOfSLB) * numberOfLayer + 1;
318 }
319 if (cellType == TGCChannelSLBIn::CellD) {
320 channel = (channelInSLB - adjacentOfSLB) * numberOfLayer;
321 }
322 block = channel / channelInBlock;
323 channel = channel % channelInBlock;
324 }
325 break;
326 default:
327 break;
328 }
329
330 if (block != -1 && channel != -1) {
331 return std::make_unique<TGCChannelSLBOut>(
332 slbin.getSideType(), slbin.getModuleType(), slbin.getRegionType(),
333 slbin.getSector(), slbin.getId(), block, channel);
334 }
335
336 return nullptr;
337}
338
339} // namespace MuonTGC_Cabling
std::unique_ptr< TGCChannelId > getChannel(const TGCChannelId &channelId, bool orChannel=false) const
std::unique_ptr< TGCChannelId > getChannelIn(const TGCChannelId &slbout, bool orChannel=false) const
std::unique_ptr< TGCChannelId > getChannelOut(const TGCChannelId &slbin, bool orChannel=false) const
virtual bool isValid() const
static int convertChannelInSLB(TGCId::ModuleType moduleType, CellType cellType, int channel)
static int convertChannelInCell(int channel)
static CellType convertCellType(int channel)
static int getAdjacentOfSLB(TGCId::ModuleType moduleType, CellType cellType)
static int convertChannel(TGCId::ModuleType moduleType, CellType cellType, int channelInSLB)
static int getNumberOfLayer(TGCId::ModuleType moduleType)
static int getChannelInBlock(TGCId::ModuleType moduleType)
ModuleType getModuleType() const
Definition TGCId.h:137
RegionType getRegionType() const
Definition TGCId.h:146
virtual int getSector() const
Definition TGCId.h:156
SideType getSideType() const
Definition TGCId.h:134
int getId() const
Definition TGCId.h:162