ATLAS Offline Software
TGCCablePPToSLB.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 
12 
13 namespace MuonTGC_Cabling {
14 
15 // Constructor & Destructor
17  : TGCCable(TGCCable::PPToSLB)
18 {
20  new TGCDatabasePPToSL(filename,"PP EWT");
22  new TGCDatabasePPToSL(filename,"PP EWD");
24  new TGCDatabasePPToSL(filename,"PP EST");
26  new TGCDatabasePPToSL(filename,"PP ESD");
28  new TGCDatabasePPToSL(filename,"PP EWI");
30  new TGCDatabasePPToSL(filename,"PP ESI");
32  new TGCDatabasePPToSL(filename,"PP FWT");
34  new TGCDatabasePPToSL(filename,"PP FWD");
36  new TGCDatabasePPToSL(filename,"PP FST");
38  new TGCDatabasePPToSL(filename,"PP FSD");
40  new TGCDatabasePPToSL(filename,"PP FWI");
42  new TGCDatabasePPToSL(filename,"PP FSI");
43 }
44 
46  {
59  }
60 
61 
63  bool orChannel) const {
64  if(channelId){
65  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::PPOut)
66  return getChannelOut(channelId,orChannel);
67  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::SLBIn)
68  return getChannelIn(channelId,orChannel);
69  }
70  return nullptr;
71 }
72 
74  if(moduleId){
75  if(moduleId->getModuleIdType()==TGCModuleId::PP)
76  return getModuleOut(moduleId);
77  if(moduleId->getModuleIdType()==TGCModuleId::SLB)
78  return getModuleIn(moduleId);
79  }
80  return nullptr;
81 }
82 
84  bool orChannel) const {
85  if(orChannel) return nullptr;
86  if(slbin->isValid()==false) return nullptr;
87  TGCChannelPPOut* ppout = nullptr;
88 
89  // SLB channel
90  const TGCChannelSLBIn* slbIn = nullptr;
92  slbIn = dynamic_cast<const TGCChannelSLBIn*>(slbin);
93  }
94  if(!slbIn) {
95  return nullptr;
96  }
97 
98  // SLB module
99  TGCModuleId* slb = slbIn->getModule();
100  if(!slb) return nullptr;
101 
102  // SLB -> PP module connection
103  TGCModuleMap* mapId = getModule(slb);
104  delete slb;
105  if(!mapId) return nullptr;
106 
107  // PP module
108  int port = mapId->connector(0);
109  TGCModuleId* pp = mapId->popModuleId(0);
110  delete mapId;
111  if(!pp) return nullptr;
112 
113  // SLB ->PP channel connection
114  int block = -1;
115  int channel = -1;
116  TGCChannelSLBIn::CellType cellType = slbIn->getCellType();
117  if(cellType==TGCChannelSLBIn::NoCellType){
118  delete pp;
119  return nullptr;
120  }
121 
122  if(cellType==TGCChannelSLBIn::CellA) {
123  block = 1+2*port;
124  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slbIn->getModuleType(),
126  channel = lengthOfSLB+slbIn->getChannelInSLB();
127  }
128  if(cellType==TGCChannelSLBIn::CellB) {
129  block = 1+2*port;
130  channel = slbIn->getChannelInSLB();
131  }
132  if(cellType==TGCChannelSLBIn::CellC) {
133  block = 0+2*port;
134  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slbIn->getModuleType(),
136  channel = lengthOfSLB+slbIn->getChannelInSLB();
137  }
138  if(cellType==TGCChannelSLBIn::CellD) {
139  block = 0+2*port;
140  channel = slbIn->getChannelInSLB();
141  }
142  ppout = new TGCChannelPPOut(pp->getSideType(),
143  pp->getModuleType(),
144  pp->getRegionType(),
145  pp->getSector(),
146  pp->getId(),
147  block,
148  channel);
149 
150  delete pp;
151  return ppout;
152 }
153 
154 
156  bool orChannel) const {
157  if(orChannel) return nullptr;
158  if(ppout->isValid()==false) return nullptr;
159 
160  const int ppoutBlock = ppout->getBlock();
161 
162  TGCChannelSLBIn* slbin = nullptr;
163 
164  // PP module
165  TGCModuleId* pp = ppout->getModule();
166  if(!pp) return nullptr;
167 
168  // PP -> SLB module connection
169  TGCModuleMap* mapId = getModule(pp);
170  delete pp;
171  if(!mapId) return nullptr;
172 
173  // SLB module
174  TGCModuleId* slb = nullptr;
175  const int size = mapId->size();
176  for(int i=0;i<size;i++){
177  if(mapId->connector(i)==ppoutBlock/2){
178  slb = mapId->popModuleId(i);
179  break;
180  }
181  }
182  delete mapId;
183  if(!slb) return nullptr;
184 
185  // PP ->SLB channel connection
187  int channelInSLB = -1;
188  if(ppoutBlock%2==0){//D,C
189  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slb->getModuleType(),
191  if(ppout->getChannel()<lengthOfSLB){
192  cellType = TGCChannelSLBIn::CellD;
193  channelInSLB = ppout->getChannel();
194  } else {
195  cellType = TGCChannelSLBIn::CellC;
196  channelInSLB = ppout->getChannel()-lengthOfSLB;
197  }
198  } else {//B,A
199  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slb->getModuleType(),
201  if(ppout->getChannel()<lengthOfSLB){
202  cellType = TGCChannelSLBIn::CellB;
203  channelInSLB = ppout->getChannel();
204  } else {
205  cellType = TGCChannelSLBIn::CellA;
206  channelInSLB = ppout->getChannel()-lengthOfSLB;
207  }
208  }
209 
211  cellType,channelInSLB);
212  slbin = new TGCChannelSLBIn(slb->getSideType(),
213  slb->getModuleType(),
214  slb->getRegionType(),
215  slb->getSector(),
216  slb->getId(),
217  channel);
218  delete slb;
219 
220  return slbin;
221 }
222 
224  if(slb->isValid()==false) return nullptr;
225 
226  const int slbId = slb->getId();
227 
228  TGCDatabase* databaseP =m_database[slb->getRegionType()][slb->getModuleType()];
229  TGCModuleMap* mapId = nullptr;
230  const int MaxEntry = databaseP->getMaxEntry();
231  for(int i=0; i<MaxEntry; i++){
232  if(databaseP->getEntry(i,1)==slbId){
233  int id = databaseP->getEntry(i,0);
234  TGCModulePP* pp = new TGCModulePP(slb->getSideType(),
235  slb->getModuleType(),
236  slb->getRegionType(),
237  slb->getSector(),
238  id);
239 
240  mapId = new TGCModuleMap();
241  mapId->insert(0,pp);
242  break;
243  }
244  if(databaseP->getEntry(i,2)==slbId) {
245  int id = databaseP->getEntry(i,0);
246  TGCModulePP* pp = new TGCModulePP(slb->getSideType(),
247  slb->getModuleType(),
248  slb->getRegionType(),
249  slb->getSector(),
250  id);
251 
252  mapId = new TGCModuleMap();
253  mapId->insert(1,pp);
254  break;
255  }
256  }
257 
258  return mapId;
259 }
260 
262  if(pp->isValid()==false) return nullptr;
263 
264  const int ppId = pp->getId();
265 
266  TGCDatabase* databaseP = m_database[pp->getRegionType()][pp->getModuleType()];
267  TGCModuleMap* mapId = nullptr;
268  const int MaxEntry = databaseP->getMaxEntry();
269  for(int i=0; i<MaxEntry; i++){
270  if(databaseP->getEntry(i,0)==ppId)
271  {
272  int id=-1;
273  TGCModuleSLB* slb=nullptr;
274  mapId = new TGCModuleMap();
275 
276  id = databaseP->getEntry(i,1);
277  if(id!=-1){
278  slb = new TGCModuleSLB(pp->getSideType(),
279  pp->getModuleType(),
280  pp->getRegionType(),
281  pp->getSector(),
282  id);
283 
284  mapId->insert(0,slb);
285  }
286 
287  id = databaseP->getEntry(i,2);
288  if(id!=-1){
289  slb = new TGCModuleSLB(pp->getSideType(),
290  pp->getModuleType(),
291  pp->getRegionType(),
292  pp->getSector(),
293  id);
294 
295  mapId->insert(1,slb);
296  }
297  break;
298  }
299  }
300 
301  return mapId;
302 }
303 
304 } //end of namespace
MuonTGC_Cabling::TGCModulePP
Definition: TGCModulePP.h:14
MuonTGC_Cabling::TGCModuleId::getModuleIdType
ModuleIdType getModuleIdType(void) const
Definition: TGCModuleId.h:30
MuonTGC_Cabling::TGCChannelId::isValid
virtual bool isValid() const
Definition: TGCChannelId.h:34
MuonTGC_Cabling::TGCId::SI
@ SI
Definition: TGCId.h:47
MuonTGC_Cabling::TGCChannelPPOut
Definition: TGCChannelPPOut.h:14
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::CellC
@ CellC
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCCablePPToSLB::getModule
virtual TGCModuleMap * getModule(const TGCModuleId *moduleId) const
Definition: TGCCablePPToSLB.cxx:73
MuonTGC_Cabling::TGCModuleSLB
Definition: TGCModuleSLB.h:14
MuonTGC_Cabling::TGCModuleId::SLB
@ SLB
Definition: TGCModuleId.h:16
MuonTGC_Cabling::TGCId::getModuleType
ModuleType getModuleType(void) const
Definition: TGCId.h:123
MuonTGC_Cabling::TGCChannelId::getChannelIdType
ChannelIdType getChannelIdType() const
Definition: TGCChannelId.cxx:26
MuonTGC_Cabling::TGCCablePPToSLB::TGCCablePPToSLB
TGCCablePPToSLB(void)
Definition: TGCCablePPToSLB.h:31
MuonTGC_Cabling::TGCModuleMap::connector
int connector(int entry)
Definition: TGCModuleMap.cxx:14
MuonTGC_Cabling::TGCChannelId::getModule
virtual TGCModuleId * getModule(void) const
Definition: TGCChannelId.h:30
TGCChannelPPOut.h
MuonTGC_Cabling::TGCModuleMap
Definition: TGCModuleMap.h:16
MuonTGC_Cabling::TGCCablePPToSLB::getChannelOut
virtual TGCChannelId * getChannelOut(const TGCChannelId *ppout, bool orChannel=false) const
Definition: TGCCablePPToSLB.cxx:155
MuonTGC_Cabling::TGCId::SD
@ SD
Definition: TGCId.h:47
TGCModulePP.h
MuonTGC_Cabling::TGCChannelId::getBlock
int getBlock() const
Definition: TGCChannelId.cxx:28
MuonTGC_Cabling::TGCModuleId::PP
@ PP
Definition: TGCModuleId.h:16
MuonTGC_Cabling::TGCChannelId::ChannelIdType::SLBIn
@ SLBIn
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
MuonTGC_Cabling::TGCDatabase
Definition: TGCDatabase.h:15
MuonTGC_Cabling::TGCCablePPToSLB::getChannel
virtual TGCChannelId * getChannel(const TGCChannelId *channelId, bool orChannel=false) const
Definition: TGCCablePPToSLB.cxx:62
MuonTGC_Cabling::TGCDatabase::getEntry
virtual int getEntry(int entry, int column) const
Definition: TGCDatabase.cxx:28
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonTGC_Cabling::TGCId::WT
@ WT
Definition: TGCId.h:47
MuonTGC_Cabling
Definition: TGCCable.h:13
MuonTGC_Cabling::TGCDatabase::getMaxEntry
virtual int getMaxEntry(void) const
Definition: TGCDatabase.cxx:36
MuonTGC_Cabling::TGCId::getId
int getId() const
Definition: TGCId.h:132
MuonTGC_Cabling::TGCCablePPToSLB::getChannelIn
virtual TGCChannelId * getChannelIn(const TGCChannelId *slbin, bool orChannel=false) const
Definition: TGCCablePPToSLB.cxx:83
MuonTGC_Cabling::TGCChannelSLBIn::NoCellType
@ NoCellType
Definition: TGCChannelSLBIn.h:32
MuonTGC_Cabling::TGCCablePPToSLB::~TGCCablePPToSLB
virtual ~TGCCablePPToSLB(void)
Definition: TGCCablePPToSLB.cxx:45
MuonTGC_Cabling::TGCCable
Definition: TGCCable.h:16
MuonTGC_Cabling::TGCId::WD
@ WD
Definition: TGCId.h:47
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
TGCDatabasePPToSL.h
MuonTGC_Cabling::TGCId::Endcap
@ Endcap
Definition: TGCId.h:53
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::TGCModuleMap::insert
void insert(int connector, TGCModuleId *moduleId)
Definition: TGCModuleMap.cxx:34
MuonTGC_Cabling::TGCCablePPToSLB::getModuleIn
virtual TGCModuleMap * getModuleIn(const TGCModuleId *slb) const
Definition: TGCCablePPToSLB.cxx:223
TGCCablePPToSLB.h
MuonTGC_Cabling::TGCModuleMap::popModuleId
TGCModuleId * popModuleId(int entry)
Definition: TGCModuleMap.cxx:26
MuonTGC_Cabling::TGCChannelSLBIn
Definition: TGCChannelSLBIn.h:14
MuonTGC_Cabling::TGCCablePPToSLB::getModuleOut
virtual TGCModuleMap * getModuleOut(const TGCModuleId *pp) const
Definition: TGCCablePPToSLB.cxx:261
MuonTGC_Cabling::TGCId::ST
@ ST
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::getSector
virtual int getSector() const
Definition: TGCId.h:130
MuonTGC_Cabling::TGCChannelId::ChannelIdType::PPOut
@ PPOut
MuonTGC_Cabling::TGCChannelId
Definition: TGCChannelId.h:15
TGCChannelSLBIn.h
MuonTGC_Cabling::TGCChannelSLBIn::CellType
CellType
Definition: TGCChannelSLBIn.h:32
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
MuonTGC_Cabling::TGCChannelSLBIn::CellD
@ CellD
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCModuleMap::size
int size(void)
Definition: TGCModuleMap.cxx:48
MuonTGC_Cabling::TGCChannelSLBIn::getCellType
virtual CellType getCellType(void) const
Definition: TGCChannelSLBIn.h:50
MuonTGC_Cabling::TGCDatabasePPToSL
Definition: TGCDatabasePPToSL.h:14
MuonTGC_Cabling::TGCChannelSLBIn::getLengthOfSLB
static int getLengthOfSLB(TGCId::ModuleType moduleType, CellType cellType)
Definition: TGCChannelSLBIn.cxx:94
MuonTGC_Cabling::TGCChannelSLBIn::getChannelInSLB
virtual int getChannelInSLB(void) const
Definition: TGCChannelSLBIn.cxx:216
MuonTGC_Cabling::TGCModuleId
Definition: TGCModuleId.h:13
TGCModuleSLB.h
MuonTGC_Cabling::TGCId::Forward
@ Forward
Definition: TGCId.h:53
MuonTGC_Cabling::TGCModuleId::isValid
virtual bool isValid(void) const
Definition: TGCModuleId.h:34
MuonTGC_Cabling::TGCChannelId::getChannel
int getChannel() const
Definition: TGCChannelId.cxx:29
MuonTGC_Cabling::TGCCablePPToSLB::m_database
TGCDatabase * m_database[TGCId::MaxRegionType][TGCId::MaxModuleType]
Definition: TGCCablePPToSLB.h:38