ATLAS Offline Software
Loading...
Searching...
No Matches
TGCPatchPanel.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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 if(db) db->addConnectionInPP(this, m_connectionInPP);
194 }
195 }
196
197 if(m_bunchCounter!=bunch){
198 m_bunchCounter = bunch;
200 if(m_hasASDOut){
201 doBID();
202#ifdef TGCDEBUG
203 showResult();
204#endif
205 clearASDOut();
206 return;
207 }
208 }else{
210 if(m_connectionInPP->existOredSignal()) m_nHit+=doOrLogic();
211 // 18-Jan-01 Fixed by KH
212 if( tgcArgs()->MSGLEVEL()<=MSG::DEBUG && ( (m_nHit>0) || m_hasBIDOut || m_hasASDOut) ) showResult();
213
214#ifdef TGCDEBUG
215 if ( (m_nHit>0) || m_hasBIDOut || m_hasASDOut) showResult();
216#endif
217
218 }
219}
220
221
223{
224 int i,j,l;
225
226 for( i=0; i<MaxNumberOfConnector; i+=1)
227 for( j=0; j<NChOfPPOutputConnector; j+=1){
228 for ( l=0; l<NumberOfBunchKeptInPP; l+=1){
229 if(m_BIDOut[j][i][l]!=0){
230 delete m_BIDOut[j][i][l];
231 m_BIDOut[j][i][l]=0;
232 }
233 }
234 }
235
236 m_hasBIDOut=false;
237}
238
240{
241 int i,j;
242
243 for( i=0; i<MaxNumberOfConnector; i+=1)
244 for( j=0; j<NChOfPPOutputConnector; j+=1)
245 m_ASDOut[j][i]=0;
246 m_hasASDOut=false;
247}
248
250{
251 int i;
252 for( i=0; i<NumberOfPatchPanelOut; i+=1)
253 if(m_PPOut[i]!=0) m_PPOut[i]->print();
254}
255
257{
258 if(m_PPOut[i]!=0) m_PPOut[i]->print();
259}
260
262{
263 std::cout<<" PPID= "<<m_id<<" type= "<<m_type<<" Region= "<< (m_region==TGCRegionType::FORWARD?"FWD":"END");
264 int i;
265 for( i=0; i<NumberOfPatchPanelOut; i+=1)
266 std::cout<<" SBID["<<i<<"]= "<<m_idSlaveBoard[i];
267 std::cout<<std::endl;
268}
269
271{
272 int i,j,k,l,con;
273 int nCount=0;
274
275 for( i=0; i<NumberOfPatchPanelOut; i+=1){
276 if ( m_PPOut[i] != 0 ) delete m_PPOut[i];
277 m_PPOut[i] = 0;
278 }
279
280 for( i=0; i<NumberOfPatchPanelOut; i+=1) {
281 for ( k=0; k<NumberOfConnectorPerPPOut; k+=1) {
283 int nCh = m_connectionInPP->getNumberOfChannel(con);
284 for( l=0; l<NumberOfBunchKeptInPP; l+=1){
285 for( j=0; j<nCh; j+=1){
286 if(m_connectionInPP->getPPIn(con,j)!=0){
287 if(m_connectionInPP->getPPIn(con,j)
288 ->getBIDOut(m_connectionInPP->getChannelIn(con,j)
289 ,m_connectionInPP->getConnectorIn(con,j),l)!=0){
290 if(m_PPOut[i]==0){
292 m_PPOut[i]->setOrigin(this);
293 m_PPOut[i]->setBid(m_bunchCounter);
294 }
295 if(m_PPOut[i]->getHitPattern(k)==0){
296 m_PPOut[i]->setHitPattern(k,nCh);
297 }
298 m_PPOut[i]->getHitPattern(k)->onChannel(j);
299#ifdef TGCDEBUG
300 m_PPOut[i]->getHitPattern(k)->print(64);
301#endif
302 nCount+=1;
303 } else {
304#ifdef TGCDEBUG
305 std::cerr << "NO BID OUT" << std::endl;
306#endif
307 }
308 } else {
309#ifdef TGCDEBUG
310 std::cerr << "NO PP IN" << std::endl;
311#endif
312 }
313 }
314 }
315 }
316 }
317 return nCount;
318}
319
321{
322 int i,j,k,l,con;
323 int nCount=0;
324
325 for( i=0; i<NumberOfPatchPanelOut; i+=1) {
326 for ( k=0; k<NumberOfConnectorPerPPOut; k+=1) {
327 con=2*i+k;
328 int nCh = m_connectionInPP->getNumberOfChannel(con);
329 for ( l=0; l<NumberOfBunchKeptInPP; l+=1){
330 for ( j=0; j<nCh; j+=1)
331 if(m_connectionInPP->getOredPPIn(con,j)!=0){
332 if(m_connectionInPP->getOredPPIn(con,j)
333 ->getBIDOut(m_connectionInPP->getOredChannelIn(con,j)
334 ,m_connectionInPP->getOredConnectorIn(con,j),l)!=0){
335#ifdef TGCDEBUG_CONNECTION
336 std::cout << "#PP Oring:PPOutID= " << i
337 << " ConID= " << con << " ChID= " << j
338 << " ORConID= " << m_connectionInPP->getOredConnectorIn(con,j)
339 << " ORChID= " << m_connectionInPP->getOredChannelIn(con,j)
340 << std::endl;
341#endif
342 if(m_PPOut[i]==0){
343 m_PPOut[i] = new TGCPatchPanelOut;
344 m_PPOut[i]->setOrigin(this);
345 m_PPOut[i]->setBid(m_bunchCounter);
346 }
347 if(m_PPOut[i]->getHitPattern(k)==0){
348 m_PPOut[i]->setHitPattern(k,nCh);
349 }
350 m_PPOut[i]->getHitPattern(k)->onChannel(j);
351 nCount+=1;
352 }
353 }
354 }
355 }
356 }
357 return nCount;
358}
359
360TGCBIDOut* TGCPatchPanel::getBIDOut(int ch, int connector, int bunch)
361{
362 int index = getInputConnectorIndex(connector);
363
364#ifdef TGCDEBUG
365 // if(m_BIDOut[ch][index][bunch]!=0){
366 // std::cout <<"getBIDOut: ch = "<<ch<<" index = "<<index<<" bunch = "<<bunch<<std::endl;
367 // }
368#endif
369 return m_BIDOut[ch][index][bunch];
370}
371
373{
374 int i,j;
375 for ( i=0; i<NChOfPPOutputConnector; i+=1)
376 for( j=0; j<MaxNumberOfConnector; j+=1){
377
378 if(m_BIDOut[i][j][0]!=0) delete m_BIDOut[i][j][0];
379 m_BIDOut[i][j][0]=0;
380
381 if(m_ASDOut[i][j]!=0){
382 m_BIDOut[i][j][0] = new TGCBIDOut (m_ASDOut[i][j]);
383 m_hasBIDOut=true;
384 m_BIDOut[i][j][0]->setBid(m_bunchCounter);
385 }
386 }
387}
388
390{
391 return m_idSlaveBoard[port];
392}
393
394void TGCPatchPanel::setIdSlaveBoard(int port, int idIn)
395{
396 m_idSlaveBoard[port] = idIn;
397}
398
400{
401 return m_id;
402}
403
405{
406 m_id = idIn;
407}
408
410{
411 int i;
412 for( i=0; i<NumberOfPatchPanelOut; i+=1){
413 if( m_idSlaveBoard[i]==SBId )
414 return m_PPOut[i];
415 }
416 std::cerr << "TGCPatchPanel::getOutput: illeagal SBID "<< SBId << std::endl;
417 return 0;
418}
419
421{
422 int i;
423 for( i=0; i<NumberOfPatchPanelOut; i+=1)
424 if ( m_idSlaveBoard[i]==SBId )
425 m_PPOut[i]=0;
426}
427
428void TGCPatchPanel::setASDOut(int ch, int connector, const TGCASDOut* asdOut)
429{
430#ifdef TGCDEBUG
431 std::cout << "TGCPatchPanel::setASDOut "
432 <<"#PP B "<<getTypeName(m_type)<<" Rgn: "<<m_region<<" PPID: "<<m_id
433 << std::endl;
434 std::cout <<"setASDOut0: ch= "<<ch<<" con= "<<connector
435 <<" index= "<<getInputConnectorIndex(connector)<<std::endl;
436 if(m_ASDOut[ch][getInputConnectorIndex(connector)]!=0) {
437 std::cout<<"setASDOut: Double Count.";
438 }
439#endif
440
441 m_hasASDOut=true;
442 m_ASDOut[ch][getInputConnectorIndex(connector)] = (TGCASDOut*)asdOut;
443
444}
445
446// Input Output
447//lower/upper
448//----------------------
449// 3/1 0,1(8)->0
450// 8
451// 2/0 2,3 ->1
452//----------------------
453// 7/5 4,5(8)->2
454//
455// 6/4 6,7 ->3
456//----------------------
457int TGCPatchPanel::getInputConnectorIndex(const int connectorId) const
458{
459 return connectorId;
460}
461
463{
464 m_PPAdj[side]=PP;
465#ifdef TGCDEBUG
466 std::cout<<"TGCPatchPanel::setAdjacentPP: connect PP(type="<<PP->getType()<<",ID="<<PP->getId()<<")to Side"<<side<<" PP(type="<<this->getType()<<",ID="<<this->getId()<<")"<<std::endl;
467#endif
468}
469
470} //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