ATLAS Offline Software
Loading...
Searching...
No Matches
TGCCableInPP.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
11
12namespace MuonTGC_Cabling {
13
14// Constructor & Destructor
15TGCCableInPP::TGCCableInPP(const std::string& filename)
17 m_database{{{nullptr}}}
18{
19 m_database[TGCId::Endcap][TGCId::WD] = std::make_unique<TGCDatabaseInPP>(filename, "EWD");
20 m_database[TGCId::Endcap][TGCId::WT] = std::make_unique<TGCDatabaseInPP>(filename, "EWT");
21 m_database[TGCId::Endcap][TGCId::SD] = std::make_unique<TGCDatabaseInPP>(filename, "ESD");
22 m_database[TGCId::Endcap][TGCId::ST] = std::make_unique<TGCDatabaseInPP>(filename, "EST");
23 m_database[TGCId::Endcap][TGCId::WI] = std::make_unique<TGCDatabaseInPP>(filename, "EWI");
24 m_database[TGCId::Endcap][TGCId::SI] = std::make_unique<TGCDatabaseInPP>(filename, "ESI");
25 m_database[TGCId::Forward][TGCId::WD] = std::make_unique<TGCDatabaseInPP>(filename, "FWD");
26 m_database[TGCId::Forward][TGCId::WT] = std::make_unique<TGCDatabaseInPP>(filename, "FWT");
27 m_database[TGCId::Forward][TGCId::SD] = std::make_unique<TGCDatabaseInPP>(filename, "FSD");
28 m_database[TGCId::Forward][TGCId::ST] = std::make_unique<TGCDatabaseInPP>(filename, "FST");
29 m_database[TGCId::Forward][TGCId::WI] = std::make_unique<TGCDatabaseInPP>(filename, "FWI");
30 m_database[TGCId::Forward][TGCId::SI] = std::make_unique<TGCDatabaseInPP>(filename, "FSI");
31}
32
33
34TGCCableInPP::~TGCCableInPP() = default;
35
36
38 const bool orChannel) const {
39 if(channelId){
40 if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::PPIn)
41 return getChannelOut(channelId, orChannel);
42 if(channelId->getChannelIdType()==TGCChannelId::ChannelIdType::PPOut)
43 return getChannelIn(channelId, orChannel);
44 }
45 return nullptr;
46}
47
49 const bool orChannel) const {
50 if(ppout->isValid()==false) return nullptr;
51
52 TGCId::ModuleType moduleType = ppout->getModuleType();
53
54 int ndatabaseP = 1;
55 TGCDatabase* databaseP[2];
56 databaseP[0] = m_database[ppout->getRegionType()][moduleType].get();
57 // EI/FI
58 // wire(TGCId::WI) and strip(TGCId::SI) of a chamber
59 // use the same SLB chip
60 // The SLB chip is treated as TGCId::WI in TGCCableSLBToSSW.cxx
61 if(moduleType==TGCId::WI) {
62 databaseP[1] = m_database[ppout->getRegionType()][TGCId::SI].get();
63 ndatabaseP = 2;
64 }
65
66 int id=-1, block=-1, channel=-1;
67 bool found = false;
68
69 for(int idatabaseP=0; idatabaseP<ndatabaseP; idatabaseP++) {
70 // EI/FI
71 // wire(TGCId::WI) and strip(TGCId::SI) of a chamber
72 // use the same SLB chip
73 // The SLB chip is treated as TGCId::WI in TGCCableSLBToSSW.cxx
74 if(idatabaseP==1) {
75 moduleType = TGCId::SI;
76 }
77
78 int indexIn[TGCDatabaseInPP::NIndexIn] =
79 {ppout->getId(), ppout->getBlock(), ppout->getChannel()};
80 int i = databaseP[idatabaseP]->getIndexDBIn(indexIn);
81 if(i<0) continue;
82
83 if(orChannel==false){
84 // first channel
85 id = databaseP[idatabaseP]->getEntry(i,3);
86 block = databaseP[idatabaseP]->getEntry(i,4);
87 channel = databaseP[idatabaseP]->getEntry(i,5);
88 if(id==-1 && block==-1 && channel==-1) continue;
89 found = true;
90 break;
91 } else {
92 // ored channel
93 if(databaseP[idatabaseP]->getEntrySize(i)==9) {
94 id = databaseP[idatabaseP]->getEntry(i,6);
95 block = databaseP[idatabaseP]->getEntry(i,7);
96 channel = databaseP[idatabaseP]->getEntry(i,8);
97 found = true;
98 }
99 }
100 }
101
102 if(!found) return nullptr;
103
104 TGCChannelPPIn* ppin =
105 new TGCChannelPPIn(ppout->getSideType(),
106 moduleType,
107 ppout->getRegionType(),
108 ppout->getSector(),
109 id,
110 block,
111 channel);
112
113 return ppin;
114}
115
117 const bool orChannel) const {
118 if(ppin->isValid()==false) return nullptr;
119
120 const int ppinChannel = ppin->getChannel();
121 const int ppinBlock = ppin->getBlock();
122 const int ppinId = ppin->getId();
123
124 TGCDatabase* databaseP =
125 m_database[ppin->getRegionType()][ppin->getModuleType()].get();
126
127 TGCChannelPPOut* ppout = nullptr;
128 const int MaxEntry = databaseP->getMaxEntry();
129 for(int i=0; i<MaxEntry; i++){
130 bool cond1 = (databaseP->getEntry(i,5)==ppinChannel)&&
131 (databaseP->getEntry(i,4)==ppinBlock)&&
132 (databaseP->getEntry(i,3)==ppinId);
133
134 bool cond2 = (databaseP->getEntrySize(i)==9)&&
135 (databaseP->getEntry(i,8)==ppinChannel)&&
136 (databaseP->getEntry(i,7)==ppinBlock)&&
137 (databaseP->getEntry(i,6)==ppinId);
138
139 if(cond1 || cond2) {
140 int id = databaseP->getEntry(i,0);
141 int block = databaseP->getEntry(i,1);
142 int channel = databaseP->getEntry(i,2);
143
144 //TGCChannelSLBIn::CellType cellType = TGCChannelSLBIn::NoCellType;
145 int channelInSLB = -1;
146 bool adjacent = false;
147 TGCId::ModuleType moduleType = ppin->getModuleType();
148 if(block==0||block==2){//C,D
149 int lengthOfC = TGCChannelSLBIn::getLengthOfSLB(moduleType,
151 int lengthOfD = TGCChannelSLBIn::getLengthOfSLB(moduleType,
153 if(channel<lengthOfD){
154 int adjacentOfD = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,
156 //cellType = TGCChannelSLBIn::CellD;
157 channelInSLB = channel;
158 if(channelInSLB<adjacentOfD||channelInSLB>=lengthOfD-adjacentOfD)
159 adjacent = true;
160 } else {
161 int adjacentOfC = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,
163 //cellType = TGCChannelSLBIn::CellC;
164 channelInSLB = channel-lengthOfD;
165 if(channelInSLB<adjacentOfC||channelInSLB>=lengthOfC-adjacentOfC)
166 adjacent = true;
167 }
168 }
169 if(block==1||block==3){//A,B
170 int lengthOfA = TGCChannelSLBIn::getLengthOfSLB(moduleType,
172 int lengthOfB = TGCChannelSLBIn::getLengthOfSLB(moduleType,
174 if(channel<lengthOfB){
175 int adjacentOfB = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,
177 //cellType = TGCChannelSLBIn::CellB;
178 channelInSLB = channel;
179 if(channelInSLB<adjacentOfB||channelInSLB>=lengthOfB-adjacentOfB)
180 adjacent = true;
181 } else {
182 int adjacentOfA = TGCChannelSLBIn::getAdjacentOfSLB(moduleType,
184 //cellType = TGCChannelSLBIn::CellA;
185 channelInSLB = channel-lengthOfB;
186 if(channelInSLB<adjacentOfA||channelInSLB>=lengthOfA-adjacentOfA)
187 adjacent = true;
188 }
189 }
190
191 if((moduleType == TGCId::SD) &&
192 (ppin->getRegionType() == TGCId::Endcap)){
193 // Strips of Middle doublets are ORed to the adjacent chamber
194 adjacent = cond2;
195 }
196
197 if(adjacent==orChannel){
198 ppout = new TGCChannelPPOut(ppin->getSideType(),
199 ppin->getModuleType(),
200 ppin->getRegionType(),
201 ppin->getSector(),
202 id,
203 block,
204 channel);
205 break;
206 }
207 }
208 }
209
210 return ppout;
211}
212
213} //end of namespace
virtual TGCChannelId * getChannelOut(const TGCChannelId *ppin, const bool orChannel=false) const
std::array< std::array< std::unique_ptr< TGCDatabase >, TGCId::MaxModuleType >, TGCId::MaxRegionType > m_database
virtual TGCChannelId * getChannel(const TGCChannelId *channelId, const bool orChannel=false) const
virtual TGCChannelId * getChannelIn(const TGCChannelId *ppout, const bool orChannel=false) const
TGCCable(CableType type=NoCableType)
Definition TGCCable.h:24
virtual bool isValid() const
static int getAdjacentOfSLB(TGCId::ModuleType moduleType, CellType cellType)
static int getLengthOfSLB(TGCId::ModuleType moduleType, CellType cellType)
virtual int getIndexDBIn(int *indexIn) const
virtual int getMaxEntry(void) const
virtual int getEntry(int entry, int column) const
virtual int getEntrySize(int entry) const
ModuleType getModuleType(void) const
Definition TGCId.h:122
RegionType getRegionType(void) const
Definition TGCId.h:125
virtual int getSector() const
Definition TGCId.h:129
SideType getSideType(void) const
Definition TGCId.h:121
int getId() const
Definition TGCId.h:131