Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TGCCablePPToSLB.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 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  m_database[TGCId::Endcap][TGCId::WT] = std::make_unique<TGCDatabasePPToSL>(filename,"PP EWT");
19  m_database[TGCId::Endcap][TGCId::WD] = std::make_unique<TGCDatabasePPToSL>(filename,"PP EWD");
20  m_database[TGCId::Endcap][TGCId::ST] = std::make_unique<TGCDatabasePPToSL>(filename,"PP EST");
21  m_database[TGCId::Endcap][TGCId::SD] = std::make_unique<TGCDatabasePPToSL>(filename,"PP ESD");
22  m_database[TGCId::Endcap][TGCId::WI] = std::make_unique<TGCDatabasePPToSL>(filename,"PP EWI");
23  m_database[TGCId::Endcap][TGCId::SI] = std::make_unique<TGCDatabasePPToSL>(filename,"PP ESI");
24  m_database[TGCId::Forward][TGCId::WT] = std::make_unique<TGCDatabasePPToSL>(filename,"PP FWT");
25  m_database[TGCId::Forward][TGCId::WD] = std::make_unique<TGCDatabasePPToSL>(filename,"PP FWD");
26  m_database[TGCId::Forward][TGCId::ST] = std::make_unique<TGCDatabasePPToSL>(filename,"PP FST");
27  m_database[TGCId::Forward][TGCId::SD] = std::make_unique<TGCDatabasePPToSL>(filename,"PP FSD");
28  m_database[TGCId::Forward][TGCId::WI] = std::make_unique<TGCDatabasePPToSL>(filename,"PP FWI");
29  m_database[TGCId::Forward][TGCId::SI] = std::make_unique<TGCDatabasePPToSL>(filename,"PP FSI");
30 }
31 
32 
34  bool orChannel) const {
35  if(channelId){
36  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::PPOut)
37  return getChannelOut(channelId,orChannel);
38  if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::SLBIn)
39  return getChannelIn(channelId,orChannel);
40  }
41  return nullptr;
42 }
43 
45  if(moduleId){
46  if(moduleId->getModuleIdType()==TGCModuleId::PP)
47  return getModuleOut(moduleId);
48  if(moduleId->getModuleIdType()==TGCModuleId::SLB)
49  return getModuleIn(moduleId);
50  }
51  return nullptr;
52 }
53 
55  bool orChannel) const {
56  if(orChannel) return nullptr;
57  if(slbin->isValid()==false) return nullptr;
58  TGCChannelPPOut* ppout = nullptr;
59 
60  // SLB channel
61  const TGCChannelSLBIn* slbIn = nullptr;
63  slbIn = dynamic_cast<const TGCChannelSLBIn*>(slbin);
64  }
65  if(!slbIn) {
66  return nullptr;
67  }
68 
69  // SLB module
70  TGCModuleId* slb = slbIn->getModule();
71  if(!slb) return nullptr;
72 
73  // SLB -> PP module connection
74  TGCModuleMap* mapId = getModule(slb);
75  delete slb;
76  if(!mapId) return nullptr;
77 
78  // PP module
79  int port = mapId->connector(0);
80  TGCModuleId* pp = mapId->popModuleId(0);
81  delete mapId;
82  if(!pp) return nullptr;
83 
84  // SLB ->PP channel connection
85  int block = -1;
86  int channel = -1;
87  TGCChannelSLBIn::CellType cellType = slbIn->getCellType();
88  if(cellType==TGCChannelSLBIn::NoCellType){
89  delete pp;
90  return nullptr;
91  }
92 
93  if(cellType==TGCChannelSLBIn::CellA) {
94  block = 1+2*port;
95  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slbIn->getModuleType(),
97  channel = lengthOfSLB+slbIn->getChannelInSLB();
98  }
99  if(cellType==TGCChannelSLBIn::CellB) {
100  block = 1+2*port;
101  channel = slbIn->getChannelInSLB();
102  }
103  if(cellType==TGCChannelSLBIn::CellC) {
104  block = 0+2*port;
105  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slbIn->getModuleType(),
107  channel = lengthOfSLB+slbIn->getChannelInSLB();
108  }
109  if(cellType==TGCChannelSLBIn::CellD) {
110  block = 0+2*port;
111  channel = slbIn->getChannelInSLB();
112  }
113  ppout = new TGCChannelPPOut(pp->getSideType(),
114  pp->getModuleType(),
115  pp->getRegionType(),
116  pp->getSector(),
117  pp->getId(),
118  block,
119  channel);
120 
121  delete pp;
122  return ppout;
123 }
124 
125 
127  bool orChannel) const {
128  if(orChannel) return nullptr;
129  if(ppout->isValid()==false) return nullptr;
130 
131  const int ppoutBlock = ppout->getBlock();
132 
133  TGCChannelSLBIn* slbin = nullptr;
134 
135  // PP module
136  TGCModuleId* pp = ppout->getModule();
137  if(!pp) return nullptr;
138 
139  // PP -> SLB module connection
140  TGCModuleMap* mapId = getModule(pp);
141  delete pp;
142  if(!mapId) return nullptr;
143 
144  // SLB module
145  TGCModuleId* slb = nullptr;
146  const int size = mapId->size();
147  for(int i=0;i<size;i++){
148  if(mapId->connector(i)==ppoutBlock/2){
149  slb = mapId->popModuleId(i);
150  break;
151  }
152  }
153  delete mapId;
154  if(!slb) return nullptr;
155 
156  // PP ->SLB channel connection
158  int channelInSLB = -1;
159  if(ppoutBlock%2==0){//D,C
160  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slb->getModuleType(),
162  if(ppout->getChannel()<lengthOfSLB){
163  cellType = TGCChannelSLBIn::CellD;
164  channelInSLB = ppout->getChannel();
165  } else {
166  cellType = TGCChannelSLBIn::CellC;
167  channelInSLB = ppout->getChannel()-lengthOfSLB;
168  }
169  } else {//B,A
170  int lengthOfSLB = TGCChannelSLBIn::getLengthOfSLB(slb->getModuleType(),
172  if(ppout->getChannel()<lengthOfSLB){
173  cellType = TGCChannelSLBIn::CellB;
174  channelInSLB = ppout->getChannel();
175  } else {
176  cellType = TGCChannelSLBIn::CellA;
177  channelInSLB = ppout->getChannel()-lengthOfSLB;
178  }
179  }
180 
182  cellType,channelInSLB);
183  slbin = new TGCChannelSLBIn(slb->getSideType(),
184  slb->getModuleType(),
185  slb->getRegionType(),
186  slb->getSector(),
187  slb->getId(),
188  channel);
189  delete slb;
190 
191  return slbin;
192 }
193 
195  if(slb->isValid()==false) return nullptr;
196 
197  const int slbId = slb->getId();
198 
199  TGCDatabase* databaseP = m_database[slb->getRegionType()][slb->getModuleType()].get();
200  TGCModuleMap* mapId = nullptr;
201  const int MaxEntry = databaseP->getMaxEntry();
202  for(int i=0; i<MaxEntry; i++){
203  if(databaseP->getEntry(i,1)==slbId){
204  int id = databaseP->getEntry(i,0);
205  TGCModulePP* pp = new TGCModulePP(slb->getSideType(),
206  slb->getModuleType(),
207  slb->getRegionType(),
208  slb->getSector(),
209  id);
210 
211  mapId = new TGCModuleMap();
212  mapId->insert(0,pp);
213  break;
214  }
215  if(databaseP->getEntry(i,2)==slbId) {
216  int id = databaseP->getEntry(i,0);
217  TGCModulePP* pp = new TGCModulePP(slb->getSideType(),
218  slb->getModuleType(),
219  slb->getRegionType(),
220  slb->getSector(),
221  id);
222 
223  mapId = new TGCModuleMap();
224  mapId->insert(1,pp);
225  break;
226  }
227  }
228 
229  return mapId;
230 }
231 
233  if(pp->isValid()==false) return nullptr;
234 
235  const int ppId = pp->getId();
236 
237  TGCDatabase* databaseP = m_database[pp->getRegionType()][pp->getModuleType()].get();
238  TGCModuleMap* mapId = nullptr;
239  const int MaxEntry = databaseP->getMaxEntry();
240  for(int i=0; i<MaxEntry; i++){
241  if(databaseP->getEntry(i,0)==ppId) {
242  int id=-1;
243  TGCModuleSLB* slb=nullptr;
244  mapId = new TGCModuleMap();
245 
246  id = databaseP->getEntry(i,1);
247  if(id!=-1){
248  slb = new TGCModuleSLB(pp->getSideType(),
249  pp->getModuleType(),
250  pp->getRegionType(),
251  pp->getSector(),
252  id);
253 
254  mapId->insert(0,slb);
255  }
256 
257  id = databaseP->getEntry(i,2);
258  if(id!=-1){
259  slb = new TGCModuleSLB(pp->getSideType(),
260  pp->getModuleType(),
261  pp->getRegionType(),
262  pp->getSector(),
263  id);
264 
265  mapId->insert(1,slb);
266  }
267  break;
268  }
269  }
270 
271  return mapId;
272 }
273 
274 } //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:121
MuonTGC_Cabling::TGCChannelSLBIn::CellB
@ CellB
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCId::getRegionType
RegionType getRegionType(void) const
Definition: TGCId.h:125
MuonTGC_Cabling::TGCChannelSLBIn::CellC
@ CellC
Definition: TGCChannelSLBIn.h:33
MuonTGC_Cabling::TGCCablePPToSLB::getModule
virtual TGCModuleMap * getModule(const TGCModuleId *moduleId) const
Definition: TGCCablePPToSLB.cxx:44
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:122
MuonTGC_Cabling::TGCChannelId::getChannelIdType
ChannelIdType getChannelIdType() const
Definition: TGCChannelId.cxx:26
MuonTGC_Cabling::TGCCablePPToSLB::TGCCablePPToSLB
TGCCablePPToSLB(void)
Definition: TGCCablePPToSLB.h:29
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:126
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:33
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:131
MuonTGC_Cabling::TGCCablePPToSLB::getChannelIn
virtual TGCChannelId * getChannelIn(const TGCChannelId *slbin, bool orChannel=false) const
Definition: TGCCablePPToSLB.cxx:54
MuonTGC_Cabling::TGCChannelSLBIn::NoCellType
@ NoCellType
Definition: TGCChannelSLBIn.h:32
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::TGCCablePPToSLB::m_database
std::array< std::array< std::unique_ptr< TGCDatabase >, TGCId::MaxModuleType >, TGCId::MaxRegionType > m_database
Definition: TGCCablePPToSLB.h:37
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:194
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:232
MuonTGC_Cabling::TGCId::ST
@ ST
Definition: TGCId.h:47
MuonTGC_Cabling::TGCId::getSector
virtual int getSector() const
Definition: TGCId.h:129
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::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