ATLAS Offline Software
Loading...
Searching...
No Matches
TGCChannelSLBIn.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
7#include <stdexcept>
8#include <string>
9
11
12namespace {
13void checkCellType(MuonTGC_Cabling::TGCChannelSLBIn::CellType cellType,
14 const std::string& funcName) {
17 const std::string msg = "cellType out of range in " + funcName;
18 throw std::out_of_range(msg);
19 }
20}
21
22} // namespace
23
24namespace MuonTGC_Cabling {
25
26// Constructor
28 TGCId::ModuleType vmodule,
29 TGCId::RegionType vregion, int vsector,
30 int vid, int vchannel)
32 setSideType(vside);
33 setModuleType(vmodule);
34 setRegionType(vregion);
35 setSector(vsector);
36 setId(vid);
38}
39
40std::unique_ptr<TGCModuleId> TGCChannelSLBIn::getModule() const {
41 return std::make_unique<TGCModuleSLB>(
43}
44
52 (getOctant() < 8) && (getId() >= 0) && (getChannel() >= 0) &&
54 (m_channelInSLB >= 0)) {
55 return true;
56 }
57 return false;
58}
59
60// Trig A B C D
61const int TGCChannelSLBIn::s_lengthCell[] = {40, 36, 36, 44, 44};
62const int TGCChannelSLBIn::s_offsetCell[] = {0, 40, 76, 112, 156};
63const int TGCChannelSLBIn::s_lengthWD[] = {40, 36, 36, 44, 44};
64const int TGCChannelSLBIn::s_lengthSD[] = {40, 32, 32, 32, 32};
65const int TGCChannelSLBIn::s_lengthWT[] = {40, 36, 36, 36, 36};
66const int TGCChannelSLBIn::s_lengthST[] = {40, 32, 32, 32, 32};
67const int TGCChannelSLBIn::s_adjacentCell[] = {0, 2, 2, 6, 6};
68const int TGCChannelSLBIn::s_adjacentWD[] = {0, 2, 2, 6, 6};
69const int TGCChannelSLBIn::s_adjacentSD[] = {0, 0, 0, 0, 0};
70const int TGCChannelSLBIn::s_adjacentWT[] = {0, 2, 2, 2, 2};
71const int TGCChannelSLBIn::s_adjacentST[] = {0, 0, 0, 0, 0};
72
74 checkCellType(cellType, __func__);
75 return s_lengthCell[cellType];
76}
77
79 checkCellType(cellType, __func__);
80 return s_offsetCell[cellType];
81}
82
84 CellType cellType) {
85 checkCellType(cellType, __func__);
86 switch (moduleType) {
87 case TGCId::WD:
88 return s_lengthWD[cellType];
89 case TGCId::SD:
90 return s_lengthSD[cellType];
91 case TGCId::WT:
92 return s_lengthWT[cellType];
93 case TGCId::ST:
94 return s_lengthST[cellType];
95 case TGCId::WI:
96 return s_lengthST[cellType];
97 case TGCId::SI:
98 return s_lengthST[cellType];
99 default:
100 break;
101 }
102 return -1;
103}
104
106 checkCellType(cellType, __func__);
107 return s_adjacentCell[cellType];
108}
109
111 CellType cellType) {
112 checkCellType(cellType, __func__);
113 switch (moduleType) {
114 case TGCId::WD:
115 return s_adjacentWD[cellType];
116 case TGCId::SD:
117 return s_adjacentSD[cellType];
118 case TGCId::WT:
119 return s_adjacentWT[cellType];
120 case TGCId::ST:
121 return s_adjacentST[cellType];
122 case TGCId::WI:
123 return s_adjacentST[cellType];
124 case TGCId::SI:
125 return s_adjacentST[cellType];
126 default:
127 break;
128 }
129 return -1;
130}
131
133 if (channel >= getOffsetOfCell(CellTrig) &&
135 return channel - getOffsetOfCell(CellTrig);
136 }
137 if (channel >= getOffsetOfCell(CellA) &&
139 return channel - getOffsetOfCell(CellA);
140 }
141 if (channel >= getOffsetOfCell(CellB) &&
143 return channel - getOffsetOfCell(CellB);
144 }
145 if (channel >= getOffsetOfCell(CellC) &&
147 return channel - getOffsetOfCell(CellC);
148 }
149 if (channel >= getOffsetOfCell(CellD) &&
151 return channel - getOffsetOfCell(CellD);
152 }
153 return -1;
154}
155
157 if (channel >= getOffsetOfCell(CellTrig) &&
159 return CellTrig;
160 }
161 if (channel >= getOffsetOfCell(CellA) &&
163 return CellA;
164 }
165 if (channel >= getOffsetOfCell(CellB) &&
167 return CellB;
168 }
169 if (channel >= getOffsetOfCell(CellC) &&
171 return CellC;
172 }
173 if (channel >= getOffsetOfCell(CellD) &&
175 return CellD;
176 }
177 return NoCellType;
178}
179
181 CellType cellType, int channel) {
182 const int adjacentSLB = getAdjacentOfSLB(moduleType, cellType);
183 if (adjacentSLB == -1) {
184 throw std::out_of_range(
185 "adjacentSLB is -1 in TGCChannelSLBIn::convertChannelInSLB");
186 }
187 int offset = getAdjacentOfCell(cellType) - adjacentSLB;
188 return channel - offset;
189}
190
192 CellType cellType, int channelInSLB) {
193 const int adjacentSLB = getAdjacentOfSLB(moduleType, cellType);
194 if (adjacentSLB == -1) {
195 throw std::out_of_range(
196 "adjacentSLB is -1 in TGCChannelSLBIn::convertChannel");
197 }
198 int offset = getAdjacentOfCell(cellType) - adjacentSLB;
199 return getOffsetOfCell(cellType) + offset + channelInSLB;
200}
201
205
209
217
218} // namespace MuonTGC_Cabling
virtual void setChannel(int channel)
TGCChannelId(ChannelIdType type=ChannelIdType::NoChannelIdType)
static int getLengthOfCell(CellType cellType)
static int convertChannelInSLB(TGCId::ModuleType moduleType, CellType cellType, int channel)
virtual CellType getCellType() const
static int convertChannelInCell(int channel)
static int getOffsetOfCell(CellType cellType)
virtual bool isValid() const override
static CellType convertCellType(int channel)
static int getAdjacentOfSLB(TGCId::ModuleType moduleType, CellType cellType)
virtual std::unique_ptr< TGCModuleId > getModule() const override
static int convertChannel(TGCId::ModuleType moduleType, CellType cellType, int channelInSLB)
static int getLengthOfSLB(TGCId::ModuleType moduleType, CellType cellType)
static int getAdjacentOfCell(CellType cellType)
virtual void setChannel(int channel) override
void setSideType(SideType side)
Definition TGCId.h:194
int getOctant() const
Definition TGCId.h:153
void setRegionType(RegionType region)
Definition TGCId.h:198
ModuleType getModuleType() const
Definition TGCId.h:137
void setId(int id)
Definition TGCId.h:206
RegionType getRegionType() const
Definition TGCId.h:146
virtual int getSector() const
Definition TGCId.h:156
virtual void setSector(int vsector)
Definition TGCId.cxx:127
SideType getSideType() const
Definition TGCId.h:134
int getId() const
Definition TGCId.h:162
void setModuleType(ModuleType module)
Definition TGCId.cxx:39
MsgStream & msg
Definition testRead.cxx:32