ATLAS Offline Software
Loading...
Searching...
No Matches
TGCPatchPanel.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
10#include "TrigT1TGC/TGCASDOut.h"
12#include <iostream>
13#include <string>
14
16
17
18namespace LVL1TGCTrigger {
19
21{
22 MsgStream log(Athena::getMessageSvc(), "LVL1TGCTrigger::TGCPatchPanel");
23
24 int i,j,k;
25 if(m_hasASDOut){
26 log << MSG::INFO
27 << "#PP I "<<getTypeName(m_type)<<" Rgn: "<<(m_region==TGCRegionType::FORWARD?"FWD":"END")<<" PPID: "<<m_id
28 << endmsg;
29 for( i=0; i<MaxNumberOfConnector; i+=1){
30 for( j=0; j<NChOfPPOutputConnector; j+=1){
31 if(m_ASDOut[j][i]!=0){
32 log << MSG::INFO <<"\t "
33 <<m_ASDOut[j][i]->GetSignalType()<<" "
34 <<m_ASDOut[j][i]->GetTGCReadoutIndex().GetLayerNumber()<<" "
35 <<m_ASDOut[j][i]->GetTGCReadoutIndex().GetRNumber()<<" "
36 <<m_ASDOut[j][i]->GetHitID()<<" "
37 <<m_id<<" "<<i<<" "<<j;
38 }
39 }
40 }
41 log << endmsg;
42 }
43
44 if(m_hasBIDOut){
45 log << MSG::INFO
46 <<"#PP B "<<getTypeName(m_type)<<" Rgn: "<<(m_region==TGCRegionType::FORWARD?"FWD":"END")<<" PPID: "<<m_id;
47 for( i=0; i<MaxNumberOfConnector; i+=1){
48 for( j=0; j<NChOfPPOutputConnector; j+=1)
49 if(m_BIDOut[j][i][0]!=0) log <<"\t con: "<<i<<" ch: "<<j;
50 }
51 log << endmsg;
52 }
53
54 if(m_nHit>0){ // 18-Jan-01 Added by KH
55 log << MSG::INFO
56 << "#PP O "<< getTypeName(m_type)<<" Rgn: "<<(m_region==TGCRegionType::FORWARD?"FWD":"END")<<" PPID: "<<m_id;
57 for( i=0; i<NumberOfPatchPanelOut; i+=1) {
58 if(m_PPOut[i]!=0){
59 for( k=0; k<NumberOfConnectorPerPPOut; k+=1) {
60 const TGCHitPattern* pattern = std::as_const(m_PPOut[i])->getHitPattern(k);
61 if(pattern!=0){
62 int nCh = m_connectionInPP
63 ->getNumberOfChannel(NumberOfConnectorPerPPOut*i+k);
64 for( j=0; j<nCh; j+=1)
65 if(pattern->getChannel(j))
66 log <<"\t con: "<<NumberOfConnectorPerPPOut*i+k<<" ch: "<<j;
67 pattern = 0;
68 }
69 }
70 }
71 }
72 log << endmsg;
73 } else {
74 log << MSG::INFO
75 << "#PP O " << getTypeName(m_type)
76 << " Rgn: " << (m_region == TGCRegionType::FORWARD ? "FWD" : "END")
77 << " PPID: "<< m_id
78 << " NO HIT " << endmsg;
79 }
80}
81
82
83std::string TGCPatchPanel::getTypeName(int /*typeIn*/) const
84{
85 if(m_type==TGCSector::WTPP) return "WT";
86 if(m_type==TGCSector::WDPP) return "WD";
87 if(m_type==TGCSector::STPP) return "ST";
88 if(m_type==TGCSector::SDPP) return "SD";
89 if(m_type==TGCSector::WIPP) return "WI";
90 if(m_type==TGCSector::SIPP) return "SI";
91 return "NOT DEF";
92}
93
96 m_bunchCounter(0), m_hasASDOut(false), m_hasBIDOut(false), m_nHit(0), m_tgcArgs(tgcargs)
97{
98 for(int i=0; i<NumberOfPatchPanelOut; i+=1) {
99 m_idSlaveBoard[i] = 0;
100 m_PPOut[i]=0;
101 }
102 for(int i=0; i<NChOfPPOutputConnector; i+=1){
103 for(int j=0; j<MaxNumberOfConnector; j+=1){
104 m_ASDOut[i][j]=0;
105 for(int k=0; k<NumberOfBunchKeptInPP; k+=1){
106 m_BIDOut[i][j][k] = 0;
107 }
108 }
109 }
110 for(int i=0; i<2; i+=1) m_PPAdj[i] = 0;
112}
113
115{
116}
117
120{
121 if (this != &right) {
122 m_nHit = right.m_nHit;
123 m_tgcArgs = right.m_tgcArgs;
124 m_id = right.m_id;
125 m_type = right.m_type;
126 m_region = right.m_region;
128 m_hasASDOut = right.m_hasASDOut;
129 m_hasBIDOut = right.m_hasBIDOut;
130
131 for(int i=0; i<NumberOfPatchPanelOut; i+=1){
132 m_idSlaveBoard[i] = right.m_idSlaveBoard[i];
133 if ( m_PPOut[i] != 0 ) delete m_PPOut[i];
134 m_PPOut[i] = new TGCPatchPanelOut(*right.m_PPOut[i]);
135 }
136
137 for(int i=0; i<NChOfPPOutputConnector; i+=1){
138 for(int j=0; j<MaxNumberOfConnector; j+=1){
139 if (m_ASDOut[i][j] !=0) delete m_ASDOut[i][j];
140 m_ASDOut[i][j] = new TGCASDOut(*right.m_ASDOut[i][j]);
141 for(int k=0; k<NumberOfBunchKeptInPP; k+=1){
142 if(m_BIDOut[i][j][k]!=0) delete m_BIDOut[i][j][k];
143 m_BIDOut[i][j][k] = new TGCBIDOut(*right.m_BIDOut[i][j][k]);
144 }
145 }
146 }
147
148 for(int i=0; i<2; i+=1) m_PPAdj[i] = right.m_PPAdj[i];
149
152 }
153 return *this;
154}
155
157{
158 for(int i=0; i<NumberOfPatchPanelOut; i+=1){
159 if ( m_PPOut[i] != 0 ) delete m_PPOut[i];
160 m_PPOut[i] = 0;
161 }
162
163 for(int i=0; i<NChOfPPOutputConnector; i+=1)
164 for(int j=0; j<MaxNumberOfConnector; j+=1){
165 if (m_ASDOut[i][j] !=0) delete m_ASDOut[i][j];
166 m_ASDOut[i][j] = 0;
167 for(int k=0; k<NumberOfBunchKeptInPP; k+=1){
168 if(m_BIDOut[i][j][k]!=0) delete m_BIDOut[i][j][k];
169 m_BIDOut[i][j][k] = 0;
170 }
171 }
172
173 for(int i=0; i<2; i+=1) m_PPAdj[i] = 0;
174
177}
178
180{
181#ifdef TGCDEBUG
182 std::cout << " Clock In " << getTypeName(m_type) << " " << m_id << std::endl;
183#endif
184
185 if(!m_connectionInPP){
186 // Check if this PatchPanel is registered in TGCDatabaseManager
187 if(db) m_connectionInPP = db->getConnectionInPP(this);
188 // If this PatchPanel is not found in TGCDatabaseManager, create new TGCConnectionInPP
189 if(!m_connectionInPP) {
191 m_connectionInPP->readConnectionTable(this);
192 // Register PatchPanel and ConnectionInPP in TGCDatabaseManager
193 //note: Input _should_ be checked against sensible limits.
194 //coverity[TAINTED_SCALAR]
195 if(db) db->addConnectionInPP(this, m_connectionInPP);
196 }
197 }
198
199 if(m_bunchCounter!=bunch){
200 m_bunchCounter = bunch;
202 if(m_hasASDOut){
203 doBID();
204#ifdef TGCDEBUG
205 showResult();
206#endif
207 clearASDOut();
208 return;
209 }
210 }else{
212 if(m_connectionInPP->existOredSignal()) m_nHit+=doOrLogic();
213 // 18-Jan-01 Fixed by KH
214 if( tgcArgs()->MSGLEVEL()<=MSG::DEBUG && ( (m_nHit>0) || m_hasBIDOut || m_hasASDOut) ) showResult();
215
216#ifdef TGCDEBUG
217 if ( (m_nHit>0) || m_hasBIDOut || m_hasASDOut) showResult();
218#endif
219
220 }
221}
222
223
225{
226 int i,j,l;
227
228 for( i=0; i<MaxNumberOfConnector; i+=1)
229 for( j=0; j<NChOfPPOutputConnector; j+=1){
230 for ( l=0; l<NumberOfBunchKeptInPP; l+=1){
231 if(m_BIDOut[j][i][l]!=0){
232 delete m_BIDOut[j][i][l];
233 m_BIDOut[j][i][l]=0;
234 }
235 }
236 }
237
238 m_hasBIDOut=false;
239}
240
242{
243 int i,j;
244
245 for( i=0; i<MaxNumberOfConnector; i+=1)
246 for( j=0; j<NChOfPPOutputConnector; j+=1)
247 m_ASDOut[j][i]=0;
248 m_hasASDOut=false;
249}
250
252{
253 int i;
254 for( i=0; i<NumberOfPatchPanelOut; i+=1)
255 if(m_PPOut[i]!=0) m_PPOut[i]->print();
256}
257
259{
260 if(m_PPOut[i]!=0) m_PPOut[i]->print();
261}
262
264{
265 std::cout<<" PPID= "<<m_id<<" type= "<<m_type<<" Region= "<< (m_region==TGCRegionType::FORWARD?"FWD":"END");
266 int i;
267 for( i=0; i<NumberOfPatchPanelOut; i+=1)
268 std::cout<<" SBID["<<i<<"]= "<<m_idSlaveBoard[i];
269 std::cout<<std::endl;
270}
271
273{
274 int i,j,k,l,con;
275 int nCount=0;
276
277 for( i=0; i<NumberOfPatchPanelOut; i+=1){
278 if ( m_PPOut[i] != 0 ) delete m_PPOut[i];
279 m_PPOut[i] = 0;
280 }
281
282 for( i=0; i<NumberOfPatchPanelOut; i+=1) {
283 for ( k=0; k<NumberOfConnectorPerPPOut; k+=1) {
285 int nCh = m_connectionInPP->getNumberOfChannel(con);
286 for( l=0; l<NumberOfBunchKeptInPP; l+=1){
287 for( j=0; j<nCh; j+=1){
288 if(m_connectionInPP->getPPIn(con,j)!=0){
289 if(m_connectionInPP->getPPIn(con,j)
290 ->getBIDOut(m_connectionInPP->getChannelIn(con,j)
291 ,m_connectionInPP->getConnectorIn(con,j),l)!=0){
292 if(m_PPOut[i]==0){
294 m_PPOut[i]->setOrigin(this);
295 m_PPOut[i]->setBid(m_bunchCounter);
296 }
297 if(m_PPOut[i]->getHitPattern(k)==0){
298 m_PPOut[i]->setHitPattern(k,nCh);
299 }
300 m_PPOut[i]->getHitPattern(k)->onChannel(j);
301#ifdef TGCDEBUG
302 m_PPOut[i]->getHitPattern(k)->print(64);
303#endif
304 nCount+=1;
305 } else {
306#ifdef TGCDEBUG
307 std::cerr << "NO BID OUT" << std::endl;
308#endif
309 }
310 } else {
311#ifdef TGCDEBUG
312 std::cerr << "NO PP IN" << std::endl;
313#endif
314 }
315 }
316 }
317 }
318 }
319 return nCount;
320}
321
323{
324 int i,j,k,l,con;
325 int nCount=0;
326
327 for( i=0; i<NumberOfPatchPanelOut; i+=1) {
328 for ( k=0; k<NumberOfConnectorPerPPOut; k+=1) {
329 con=2*i+k;
330 int nCh = m_connectionInPP->getNumberOfChannel(con);
331 for ( l=0; l<NumberOfBunchKeptInPP; l+=1){
332 for ( j=0; j<nCh; j+=1)
333 if(m_connectionInPP->getOredPPIn(con,j)!=0){
334 if(m_connectionInPP->getOredPPIn(con,j)
335 ->getBIDOut(m_connectionInPP->getOredChannelIn(con,j)
336 ,m_connectionInPP->getOredConnectorIn(con,j),l)!=0){
337#ifdef TGCDEBUG_CONNECTION
338 std::cout << "#PP Oring:PPOutID= " << i
339 << " ConID= " << con << " ChID= " << j
340 << " ORConID= " << m_connectionInPP->getOredConnectorIn(con,j)
341 << " ORChID= " << m_connectionInPP->getOredChannelIn(con,j)
342 << std::endl;
343#endif
344 if(m_PPOut[i]==0){
345 m_PPOut[i] = new TGCPatchPanelOut;
346 m_PPOut[i]->setOrigin(this);
347 m_PPOut[i]->setBid(m_bunchCounter);
348 }
349 if(m_PPOut[i]->getHitPattern(k)==0){
350 m_PPOut[i]->setHitPattern(k,nCh);
351 }
352 m_PPOut[i]->getHitPattern(k)->onChannel(j);
353 nCount+=1;
354 }
355 }
356 }
357 }
358 }
359 return nCount;
360}
361
362TGCBIDOut* TGCPatchPanel::getBIDOut(int ch, int connector, int bunch)
363{
364 int index = getInputConnectorIndex(connector);
365
366#ifdef TGCDEBUG
367 // if(m_BIDOut[ch][index][bunch]!=0){
368 // std::cout <<"getBIDOut: ch = "<<ch<<" index = "<<index<<" bunch = "<<bunch<<std::endl;
369 // }
370#endif
371 return m_BIDOut[ch][index][bunch];
372}
373
375{
376 int i,j;
377 for ( i=0; i<NChOfPPOutputConnector; i+=1)
378 for( j=0; j<MaxNumberOfConnector; j+=1){
379
380 if(m_BIDOut[i][j][0]!=0) delete m_BIDOut[i][j][0];
381 m_BIDOut[i][j][0]=0;
382
383 if(m_ASDOut[i][j]!=0){
384 m_BIDOut[i][j][0] = new TGCBIDOut (m_ASDOut[i][j]);
385 m_hasBIDOut=true;
386 m_BIDOut[i][j][0]->setBid(m_bunchCounter);
387 }
388 }
389}
390
392{
393 return m_idSlaveBoard[port];
394}
395
396void TGCPatchPanel::setIdSlaveBoard(int port, int idIn)
397{
398 m_idSlaveBoard[port] = idIn;
399}
400
402{
403 return m_id;
404}
405
407{
408 m_id = idIn;
409}
410
412{
413 int i;
414 for( i=0; i<NumberOfPatchPanelOut; i+=1){
415 if( m_idSlaveBoard[i]==SBId )
416 return m_PPOut[i];
417 }
418 std::cerr << "TGCPatchPanel::getOutput: illeagal SBID "<< SBId << std::endl;
419 return 0;
420}
421
423{
424 int i;
425 for( i=0; i<NumberOfPatchPanelOut; i+=1)
426 if ( m_idSlaveBoard[i]==SBId )
427 m_PPOut[i]=0;
428}
429
430void TGCPatchPanel::setASDOut(int ch, int connector, const TGCASDOut* asdOut)
431{
432#ifdef TGCDEBUG
433 std::cout << "TGCPatchPanel::setASDOut "
434 <<"#PP B "<<getTypeName(m_type)<<" Rgn: "<<m_region<<" PPID: "<<m_id
435 << std::endl;
436 std::cout <<"setASDOut0: ch= "<<ch<<" con= "<<connector
437 <<" index= "<<getInputConnectorIndex(connector)<<std::endl;
438 if(m_ASDOut[ch][getInputConnectorIndex(connector)]!=0) {
439 std::cout<<"setASDOut: Double Count.";
440 }
441#endif
442
443 m_hasASDOut=true;
444 m_ASDOut[ch][getInputConnectorIndex(connector)] = (TGCASDOut*)asdOut;
445
446}
447
448// Input Output
449//lower/upper
450//----------------------
451// 3/1 0,1(8)->0
452// 8
453// 2/0 2,3 ->1
454//----------------------
455// 7/5 4,5(8)->2
456//
457// 6/4 6,7 ->3
458//----------------------
459int TGCPatchPanel::getInputConnectorIndex(const int connectorId) const
460{
461 return connectorId;
462}
463
465{
466 m_PPAdj[side]=PP;
467#ifdef TGCDEBUG
468 std::cout<<"TGCPatchPanel::setAdjacentPP: connect PP(type="<<PP->getType()<<",ID="<<PP->getId()<<")to Side"<<side<<" PP(type="<<this->getType()<<",ID="<<this->getId()<<")"<<std::endl;
469#endif
470}
471
472} //end of namespace bracket
#define endmsg
TGCPatchPanelOut * m_PPOut[NumberOfPatchPanelOut]
int m_idSlaveBoard[NumberOfPatchPanelOut]
const TGCArguments * tgcArgs() const
void setASDOut(int ch, int connector, const TGCASDOut *asdOut)
TGCBIDOut * m_BIDOut[NChOfPPOutputConnector][MaxNumberOfConnector][NumberOfBunchKeptInPP]
TGCPatchPanelOut * getOutput(int SBId)
TGCConnectionInPP * m_connectionInPP
std::string getTypeName(int typeIn) const
void setIdSlaveBoard(int port, int id)
const TGCASDOut * m_ASDOut[NChOfPPOutputConnector][MaxNumberOfConnector]
void setAdjacentPP(int side, TGCPatchPanel *PP)
TGCBIDOut * getBIDOut(int ch, int connector, int bunch)
int getIdSlaveBoard(int port) const
int getInputConnectorIndex(const int connectorId) const
void clockIn(int bunch, TGCDatabaseManager *db=0)
TGCPatchPanel & operator=(const TGCPatchPanel &right)
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
const int NumberOfBunchKeptInPP
const int NumberOfConnectorPerPPOut
const int NumberOfPatchPanelOut
const int MaxNumberOfConnector
const int NChOfPPOutputConnector
Definition index.py:1