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