ATLAS Offline Software
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 
10 namespace MuonTGC_Cabling {
11 
13  bool orChannel) const {
14  if(channelId){
15  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::SLBIn)
16  return getChannelOut(channelId,orChannel);
17  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::SLBOut)
18  return getChannelIn(channelId,orChannel);
19  }
20  return nullptr;
21 }
22 
24  bool orChannel) const {
25  if(slbout->isValid()==false) return nullptr;
26 
27  int channel = slbout->getChannel();
28  int block = slbout->getBlock();
29  TGCId::ModuleType moduleType = slbout->getModuleType();
30 
31  int channelInBlock = TGCChannelSLBOut::getChannelInBlock(moduleType);
32  int numberOfLayer = TGCChannelSLBOut::getNumberOfLayer(moduleType);
33 
34  int adjacentOfSLB = -1;
35  int channelInSLB = -1;
37  switch(moduleType){
38  case TGCId::WD:
39  // channel SLBIn
40  // 2*n CellB n+block*16
41  // 2*n+1 CellA n+block*16
42  if(orChannel==false){
43  if(channel%numberOfLayer==1){
44  cellType = TGCChannelSLBIn::CellA;
45  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
46  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
47  +adjacentOfSLB;
48  }
49  if(channel%numberOfLayer==0){
50  cellType = TGCChannelSLBIn::CellB;
51  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
52  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
53  +adjacentOfSLB;
54  }
55  }
56  if(orChannel==true){
57  if(channel%numberOfLayer==1){
58  cellType = TGCChannelSLBIn::CellC;
59  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
60  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
61  +adjacentOfSLB;
62  }
63  if(channel%numberOfLayer==0){
64  cellType = TGCChannelSLBIn::CellD;
65  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
66  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
67  +adjacentOfSLB;
68  }
69  }
70  break;
71  case TGCId::SD:
72  // channel SLBIn
73  // 2*n CellB n+block*16
74  // 2*n+1 CellA n+block*16
75  if(orChannel==false){
76  if(channel%numberOfLayer==1){
77  cellType = TGCChannelSLBIn::CellA;
78  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
79  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
80  +adjacentOfSLB;
81  }
82  if(channel%numberOfLayer==0){
83  cellType = TGCChannelSLBIn::CellB;
84  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
85  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
86  +adjacentOfSLB;
87  }
88  }
89  if(orChannel==true){
90  if(channel%numberOfLayer==1){
91  cellType = TGCChannelSLBIn::CellC;
92  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
93  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
94  +adjacentOfSLB;
95  }
96  if(channel%numberOfLayer==0){
97  cellType = TGCChannelSLBIn::CellD;
98  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
99  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
100  +adjacentOfSLB;
101  }
102  }
103  break;
104  case TGCId::WT:
105  // channel SLBIn
106  // 3*n CellC n+block*16
107  // 3*n+1 CellB n+block*16
108  // 3*n+2 CellA n+block*16
109  if((channel+block*channelInBlock)%numberOfLayer==2){
110  cellType = TGCChannelSLBIn::CellA;
111  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
112  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
113  +adjacentOfSLB;
114  }
115  if((channel+block*channelInBlock)%numberOfLayer==1){
116  cellType = TGCChannelSLBIn::CellB;
117  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
118  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
119  +adjacentOfSLB;
120  }
121  if((channel+block*channelInBlock)%numberOfLayer==0){
122  cellType = TGCChannelSLBIn::CellC;
123  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
124  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
125  +adjacentOfSLB;
126  }
127  break;
128  case TGCId::ST:
129  case TGCId::WI:
130  case TGCId::SI:
131  // channel SLBIn
132  // 2*n CellB n+block*16
133  // 2*n+1 CellA n+block*16
134  if(orChannel==false){
135  if(channel%numberOfLayer==1){
136  cellType = TGCChannelSLBIn::CellA;
137  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
138  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
139  +adjacentOfSLB;
140  }
141  if(channel%numberOfLayer==0){
142  cellType = TGCChannelSLBIn::CellB;
143  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
144  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
145  +adjacentOfSLB;
146  }
147  }
148  if(orChannel==true){
149  if(channel%numberOfLayer==1){
150  cellType = TGCChannelSLBIn::CellC;
151  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
152  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
153  +adjacentOfSLB;
154  }
155  if(channel%numberOfLayer==0){
156  cellType = TGCChannelSLBIn::CellD;
157  adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
158  channelInSLB = (channel+block*channelInBlock)/numberOfLayer
159  +adjacentOfSLB;
160  }
161  }
162  break;
163 
164  default:
165  break;
166  }
167 
168  TGCChannelSLBIn* slbin = nullptr;
169  if(channelInSLB!=-1){
170  int channelOfSLB = TGCChannelSLBIn::convertChannel(slbout->getModuleType(),
171  cellType,channelInSLB);
172  slbin = new TGCChannelSLBIn(slbout->getSideType(),
173  slbout->getModuleType(),
174  slbout->getRegionType(),
175  slbout->getSector(),
176  slbout->getId(),
177  channelOfSLB);
178 
179  }
180  return slbin;
181 }
182 
184  bool orChannel) const {
185  if(slbin->isValid()==false) return nullptr;
186 
187  TGCChannelSLBIn::CellType cellType =
189  if(cellType==TGCChannelSLBIn::NoCellType) return nullptr;
190 
191  TGCId::ModuleType moduleType = slbin->getModuleType();
192  int channelInCell =
194  int channelInSLB =
195  TGCChannelSLBIn::convertChannelInSLB(moduleType,cellType,channelInCell);
196 
197  int channelInBlock = TGCChannelSLBOut::getChannelInBlock(moduleType);
198  int numberOfLayer = TGCChannelSLBOut::getNumberOfLayer(moduleType);
199  int adjacentOfSLB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,cellType);
200 
201  int channel = -1;
202  int block = -1;
203  switch(moduleType){
204  case TGCId::WD:
205  if(orChannel==false){
206  if(cellType==TGCChannelSLBIn::CellA)
207  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+1;
208  if(cellType==TGCChannelSLBIn::CellB)
209  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer;
210  block = channel/channelInBlock;
211  channel = channel%channelInBlock;
212  }
213  if(orChannel==true){
214  if(cellType==TGCChannelSLBIn::CellC)
215  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+1;
216  if(cellType==TGCChannelSLBIn::CellD)
217  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer;
218  block = channel/channelInBlock;
219  channel = channel%channelInBlock;
220  }
221  break;
222  case TGCId::SD:
223  if(orChannel==false){
224  if(cellType==TGCChannelSLBIn::CellA)
225  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+1;
226  if(cellType==TGCChannelSLBIn::CellB)
227  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer;
228  block = channel/channelInBlock;
229  channel = channel%channelInBlock;
230  }
231  if(orChannel==true){
232  if(cellType==TGCChannelSLBIn::CellC)
233  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+1;
234  if(cellType==TGCChannelSLBIn::CellD)
235  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer;
236  block = channel/channelInBlock;
237  channel = channel%channelInBlock;
238  }
239  break;
240  case TGCId::WT:
241  if(cellType==TGCChannelSLBIn::CellA)
242  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+2;
243  if(cellType==TGCChannelSLBIn::CellB)
244  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+1;
245  if(cellType==TGCChannelSLBIn::CellC)
246  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer;
247  block = channel/channelInBlock;
248  channel = channel%channelInBlock;
249  break;
250  case TGCId::ST:
251  case TGCId::WI:
252  case TGCId::SI:
253  if(cellType== TGCChannelSLBIn::CellA||cellType== TGCChannelSLBIn::CellB){
254  if(cellType==TGCChannelSLBIn::CellA)
255  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+1;
256  if(cellType==TGCChannelSLBIn::CellB)
257  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer;
258  block = channel/channelInBlock;
259  channel = channel%channelInBlock;
260  }
261  if(cellType== TGCChannelSLBIn::CellC||cellType== TGCChannelSLBIn::CellD){
262  if(cellType==TGCChannelSLBIn::CellC)
263  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer+1;
264  if(cellType==TGCChannelSLBIn::CellD)
265  channel = (channelInSLB-adjacentOfSLB)*numberOfLayer;
266  block = channel/channelInBlock;
267  channel = channel%channelInBlock;
268  }
269  break;
270  default:
271  break;
272  }
273 
274  TGCChannelSLBOut* slbout = nullptr;
275  if(block!=-1&&channel!=-1)
276  slbout = new TGCChannelSLBOut(slbin->getSideType(),
277  slbin->getModuleType(),
278  slbin->getRegionType(),
279  slbin->getSector(),
280  slbin->getId(),
281  block,
282  channel);
283 
284  return slbout;
285 }
286 
287 } //end of namespace
MuonTGC_Cabling::TGCChannelId::isValid
virtual bool isValid() const
Definition: TGCChannelId.h:34
MuonTGC_Cabling::TGCId::SI
@ SI
Definition: TGCId.h:47
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::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::TGCId::ModuleType
ModuleType
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::getModuleType
ModuleType getModuleType(void) const
Definition: TGCId.h:123
MuonTGC_Cabling::TGCChannelSLBOut
Definition: TGCChannelSLBOut.h:14
TGCCableInSLB.h
MuonTGC_Cabling::TGCId::SD
@ SD
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelId::getBlock
int getBlock() const
Definition: TGCChannelId.cxx:28
MuonTGC_Cabling::TGCChannelId::ChannelIdType::SLBIn
@ SLBIn
MuonTGC_Cabling::TGCCableInSLB::getChannelOut
virtual TGCChannelId * getChannelOut(const TGCChannelId *slbin, bool orChannel=false) const
Definition: TGCCableInSLB.cxx:183
MuonTGC_Cabling::TGCChannelSLBIn::convertChannelInCell
static int convertChannelInCell(int channel)
Definition: TGCChannelSLBIn.cxx:144
MuonTGC_Cabling::TGCId::WT
@ WT
Definition: TGCId.h:47
MuonTGC_Cabling
Definition: TGCCable.h:13
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
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
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::CellA
@ CellA
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCCableInSLB::getChannelIn
virtual TGCChannelId * getChannelIn(const TGCChannelId *slbout, bool orChannel=false) const
Definition: TGCCableInSLB.cxx:23
MuonTGC_Cabling::TGCChannelSLBIn::convertCellType
static CellType convertCellType(int channel)
Definition: TGCChannelSLBIn.cxx:168
MuonTGC_Cabling::TGCChannelSLBIn
Definition: TGCChannelSLBIn.h:14
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
TGCChannelSLBOut.h
MuonTGC_Cabling::TGCId::getSector
virtual int getSector() const
Definition: TGCId.h:130
MuonTGC_Cabling::TGCChannelId
Definition: TGCChannelId.h:15
TGCChannelSLBIn.h
MuonTGC_Cabling::TGCChannelSLBIn::CellType
CellType
Definition: TGCChannelSLBIn.h:32
MuonTGC_Cabling::TGCChannelSLBIn::CellD
@ CellD
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCChannelSLBOut::getNumberOfLayer
static int getNumberOfLayer(TGCId::ModuleType moduleType)
Definition: TGCChannelSLBOut.cxx:88
MuonTGC_Cabling::TGCCableInSLB::getChannel
virtual TGCChannelId * getChannel(const TGCChannelId *channelId, bool orChannel=false) const
Definition: TGCCableInSLB.cxx:12
MuonTGC_Cabling::TGCChannelSLBOut::getChannelInBlock
static int getChannelInBlock(TGCId::ModuleType moduleType)
Definition: TGCChannelSLBOut.cxx:104
MuonTGC_Cabling::TGCChannelId::ChannelIdType::SLBOut
@ SLBOut
MuonTGC_Cabling::TGCChannelId::getChannel
int getChannel() const
Definition: TGCChannelId.cxx:29