ATLAS Offline Software
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 
11 namespace{
12  void
13  checkCellType(MuonTGC_Cabling::TGCChannelSLBIn::CellType cellType, const std::string & funcName){
14  if (cellType == MuonTGC_Cabling::TGCChannelSLBIn::CellType::NoCellType or cellType == MuonTGC_Cabling::TGCChannelSLBIn::CellType::MaxCellType){
15  const std::string msg = "cellType out of range in " + funcName;
16  throw std::out_of_range(msg);
17  }
18  }
19 
20 }
21 
22 namespace 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(),
45  getModuleType(),
46  getRegionType(),
47  getSector(),
48  getId()));
49 }
50 
51 bool TGCChannelSLBIn::isValid(void) const
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
71 const int TGCChannelSLBIn::s_lengthCell[] = {40, 36, 36, 44, 44};
72 const int TGCChannelSLBIn::s_offsetCell[] = { 0, 40, 76,112,156};
73 const int TGCChannelSLBIn::s_lengthWD[] = {40, 36, 36, 44, 44};
74 const int TGCChannelSLBIn::s_lengthSD[] = {40, 32, 32, 32, 32};
75 const int TGCChannelSLBIn::s_lengthWT[] = {40, 36, 36, 36, 36};
76 const int TGCChannelSLBIn::s_lengthST[] = {40, 32, 32, 32, 32};
77 const int TGCChannelSLBIn::s_adjacentCell[]= { 0, 2, 2, 6, 6};
78 const int TGCChannelSLBIn::s_adjacentWD[] = { 0, 2, 2, 6, 6};
79 const int TGCChannelSLBIn::s_adjacentSD[] = { 0, 0, 0, 0, 0};
80 const int TGCChannelSLBIn::s_adjacentWT[] = { 0, 2, 2, 2, 2};
81 const 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 
148  }
151  return channel-getOffsetOfCell(CellA);
152  }
155  return channel-getOffsetOfCell(CellB);
156  }
159  return channel-getOffsetOfCell(CellC);
160  }
163  return channel-getOffsetOfCell(CellD);
164  }
165  return -1;
166 }
167 
171  return CellTrig;
172  }
175  return CellA;
176  }
179  return CellB;
180  }
183  return CellC;
184  }
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 
220 void TGCChannelSLBIn::setChannel(int vchannel) {
221  TGCChannelId::setChannel(vchannel);
222  m_cellType = convertCellType(vchannel);
225  getChannelInCell());
226 }
227 
228 
229 } // end of namespace
MuonTGC_Cabling::TGCId::MaxModuleType
@ MaxModuleType
Definition: TGCId.h:48
MuonTGC_Cabling::TGCChannelSLBIn::s_adjacentST
static const int s_adjacentST[]
Definition: TGCChannelSLBIn.h:75
MuonTGC_Cabling::TGCId::setRegionType
void setRegionType(RegionType region)
Definition: TGCId.h:148
MuonTGC_Cabling::TGCChannelSLBIn::setChannel
virtual void setChannel(int channel)
Definition: TGCChannelSLBIn.cxx:220
MuonTGC_Cabling::TGCId::SI
@ SI
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelSLBIn::s_lengthWD
static const int s_lengthWD[]
Definition: TGCChannelSLBIn.h:67
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
MuonTGC_Cabling::TGCId::getSideType
SideType getSideType(void) const
Definition: TGCId.h:122
MuonTGC_Cabling::TGCChannelSLBIn::CellB
@ CellB
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCChannelSLBIn::getAdjacentOfCell
static int getAdjacentOfCell(CellType cellType)
Definition: TGCChannelSLBIn.cxx:116
MuonTGC_Cabling::TGCId::getRegionType
RegionType getRegionType(void) const
Definition: TGCId.h:126
MuonTGC_Cabling::TGCChannelSLBIn::convertChannelInSLB
static int convertChannelInSLB(TGCId::ModuleType moduleType, CellType cellType, int channel)
Definition: TGCChannelSLBIn.cxx:192
MuonTGC_Cabling::TGCChannelSLBIn::CellC
@ CellC
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCChannelSLBIn::s_adjacentCell
static const int s_adjacentCell[]
Definition: TGCChannelSLBIn.h:71
MuonTGC_Cabling::TGCChannelSLBIn::getChannelInCell
virtual int getChannelInCell(void) const
Definition: TGCChannelSLBIn.cxx:212
MuonTGC_Cabling::TGCId::setId
void setId(int id)
Definition: TGCId.h:156
MuonTGC_Cabling::TGCId::setSector
virtual void setSector(int vsector)
Definition: TGCId.cxx:122
MuonTGC_Cabling::TGCModuleSLB
Definition: TGCModuleSLB.h:14
MuonTGC_Cabling::TGCId::setModuleType
void setModuleType(ModuleType module)
Definition: TGCId.cxx:66
MuonTGC_Cabling::TGCId::ModuleType
ModuleType
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::getModuleType
ModuleType getModuleType(void) const
Definition: TGCId.h:123
MuonTGC_Cabling::TGCChannelSLBIn::getLengthOfCell
static int getLengthOfCell(CellType cellType)
Definition: TGCChannelSLBIn.cxx:84
MuonTGC_Cabling::TGCId::MaxSideType
@ MaxSideType
Definition: TGCId.h:46
MuonTGC_Cabling::TGCId::setSideType
void setSideType(SideType side)
Definition: TGCId.h:144
MuonTGC_Cabling::TGCChannelSLBIn::s_adjacentSD
static const int s_adjacentSD[]
Definition: TGCChannelSLBIn.h:73
MuonTGC_Cabling::TGCId::SD
@ SD
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelSLBIn::s_lengthCell
static const int s_lengthCell[]
Definition: TGCChannelSLBIn.h:65
MuonTGC_Cabling::TGCChannelSLBIn::isValid
virtual bool isValid(void) const
Definition: TGCChannelSLBIn.cxx:51
MuonTGC_Cabling::TGCChannelSLBIn::m_cellType
CellType m_cellType
Definition: TGCChannelSLBIn.h:61
MuonTGC_Cabling::TGCChannelSLBIn::s_lengthST
static const int s_lengthST[]
Definition: TGCChannelSLBIn.h:70
MuonTGC_Cabling::TGCChannelSLBIn::m_channelInCell
int m_channelInCell
Definition: TGCChannelSLBIn.h:62
MuonTGC_Cabling::TGCChannelSLBIn::convertChannelInCell
static int convertChannelInCell(int channel)
Definition: TGCChannelSLBIn.cxx:144
MuonTGC_Cabling::TGCId::getOctant
int getOctant() const
Definition: TGCId.h:129
MuonTGC_Cabling::TGCId::WT
@ WT
Definition: TGCId.h:47
MuonTGC_Cabling
Definition: TGCCable.h:13
MuonTGC_Cabling::TGCChannelSLBIn::m_channelInSLB
int m_channelInSLB
Definition: TGCChannelSLBIn.h:63
MuonTGC_Cabling::TGCId::getId
int getId() const
Definition: TGCId.h:132
MuonTGC_Cabling::TGCChannelSLBIn::NoCellType
@ NoCellType
Definition: TGCChannelSLBIn.h:32
MuonTGC_Cabling::TGCId::WD
@ WD
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::WI
@ WI
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelSLBIn::convertChannel
static int convertChannel(TGCId::ModuleType moduleType, CellType cellType, int channelInSLB)
Definition: TGCChannelSLBIn.cxx:202
MuonTGC_Cabling::TGCChannelSLBIn::getModule
virtual TGCModuleId * getModule(void) const
Definition: TGCChannelSLBIn.cxx:42
MuonTGC_Cabling::TGCChannelSLBIn::CellA
@ CellA
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCChannelSLBIn::convertCellType
static CellType convertCellType(int channel)
Definition: TGCChannelSLBIn.cxx:168
MuonTGC_Cabling::TGCChannelId::ChannelIdType
ChannelIdType
Definition: TGCChannelId.h:17
MuonTGC_Cabling::TGCId::MaxRegionType
@ MaxRegionType
Definition: TGCId.h:54
MuonTGC_Cabling::TGCId::NoRegionType
@ NoRegionType
Definition: TGCId.h:53
MuonTGC_Cabling::TGCId::NoModuleType
@ NoModuleType
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelSLBIn::s_offsetCell
static const int s_offsetCell[]
Definition: TGCChannelSLBIn.h:66
MuonTGC_Cabling::TGCChannelSLBIn::getAdjacentOfSLB
static int getAdjacentOfSLB(TGCId::ModuleType moduleType, CellType cellType)
Definition: TGCChannelSLBIn.cxx:121
MuonTGC_Cabling::TGCId::ST
@ ST
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::getSector
virtual int getSector() const
Definition: TGCId.h:130
MuonTGC_Cabling::TGCId::NoSideType
@ NoSideType
Definition: TGCId.h:45
MuonTGC_Cabling::TGCChannelId
Definition: TGCChannelId.h:15
TGCChannelSLBIn.h
MuonTGC_Cabling::TGCChannelSLBIn::s_lengthWT
static const int s_lengthWT[]
Definition: TGCChannelSLBIn.h:69
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
MuonTGC_Cabling::TGCChannelSLBIn::CellType
CellType
Definition: TGCChannelSLBIn.h:32
MuonTGC_Cabling::TGCChannelSLBIn::TGCChannelSLBIn
TGCChannelSLBIn(void)
Definition: TGCChannelSLBIn.h:77
MuonTGC_Cabling::TGCChannelSLBIn::CellD
@ CellD
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCChannelSLBIn::getOffsetOfCell
static int getOffsetOfCell(CellType cellType)
Definition: TGCChannelSLBIn.cxx:89
MuonTGC_Cabling::TGCChannelSLBIn::getCellType
virtual CellType getCellType(void) const
Definition: TGCChannelSLBIn.h:50
MuonTGC_Cabling::TGCChannelId::setChannel
virtual void setChannel(int channel)
Definition: TGCChannelId.cxx:71
MuonTGC_Cabling::TGCChannelSLBIn::getLengthOfSLB
static int getLengthOfSLB(TGCId::ModuleType moduleType, CellType cellType)
Definition: TGCChannelSLBIn.cxx:94
MuonTGC_Cabling::TGCId::RegionType
RegionType
Definition: TGCId.h:53
MuonTGC_Cabling::TGCChannelSLBIn::getChannelInSLB
virtual int getChannelInSLB(void) const
Definition: TGCChannelSLBIn.cxx:216
MuonTGC_Cabling::TGCModuleId
Definition: TGCModuleId.h:13
MuonTGC_Cabling::TGCId::SideType
SideType
Definition: TGCId.h:45
TGCModuleSLB.h
MuonTGC_Cabling::TGCChannelSLBIn::s_adjacentWD
static const int s_adjacentWD[]
Definition: TGCChannelSLBIn.h:72
MuonTGC_Cabling::TGCChannelId::getChannel
int getChannel() const
Definition: TGCChannelId.cxx:29
MuonTGC_Cabling::TGCChannelSLBIn::s_adjacentWT
static const int s_adjacentWT[]
Definition: TGCChannelSLBIn.h:74
MuonTGC_Cabling::TGCChannelSLBIn::CellTrig
@ CellTrig
Definition: TGCChannelSLBIn.h:33
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
MuonTGC_Cabling::TGCChannelSLBIn::s_lengthSD
static const int s_lengthSD[]
Definition: TGCChannelSLBIn.h:68