ATLAS Offline Software
TGCSlaveBoard.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 #include <iostream>
10 #include <iomanip>
11 #include <cstdlib>
12 #include <string>
13 
14 namespace LVL1TGCTrigger {
15 
17  : m_lengthOfCoincidenceOut(0),m_coincidenceOut(0),
18  m_slaveBoardOut(0),
19  m_id(0), m_bid(-1),m_idHighPtBoard(0),
20  m_type(0), m_region(TGCRegionType::FORWARD),
21  m_patchPanel(0), m_patchPanelOut(0)
22 {
23 }
24 
26 {
27  if( m_coincidenceOut!=0) delete m_coincidenceOut;
28  if( m_slaveBoardOut!=0) delete m_slaveBoardOut;
29 
32  m_patchPanel=0;
33 
35 }
36 
37 void TGCSlaveBoard::clockIn(int bidIn)
38 {
39  m_bid = bidIn;
40  collectInput();
41 
42  m_slbin.reset();
43 
44 #ifdef TGCDEBUG
45  int i;
46  std::cout << "#SB: BID= " << m_bid;
47  std::cout << " Rgn= " << m_region;
48  std::cout << " Typ= " << getTypeName(m_type);
49  std::cout << " ID= " << m_id << std::endl;
50  if(m_patchPanelOut!=0){
51  for( i=0; i<NumberOfConnectorPerPPOut; i+=1)
53  std::cout<<"#SB I: BID= "<<m_bid;
54  if(m_patchPanelOut->getOrigin()!=0){
55  std::cout << " Typ= " <<m_patchPanelOut->getOrigin()->getType();
56  std::cout << " Rgn= " <<m_patchPanelOut->getOrigin()->getRegion();
57  std::cout << " PPID= "<<m_patchPanelOut->getOrigin()->getId()<<" ";
58  std::cout << " port= "<<i;
59  std::cout << "" <<m_id;
60  }
61  std::cout << ":";
63  }
64  } else {
65  std::cout << "NO PP IN" << std::endl;
66  }
67 #endif
68 
69  // delete m_slaveBoardOut and m_coincidenceOut
70  if( m_coincidenceOut!=0) delete m_coincidenceOut;
71  if( m_slaveBoardOut!=0) delete m_slaveBoardOut;
72  m_coincidenceOut = 0;
73  m_slaveBoardOut = 0;
74 
75  if(m_patchPanelOut!=0){
77 
78  storeSlbIn();
79 
80  doCoincidence();
81  if(m_coincidenceOut!=0) {
82 #ifdef TGCDEBUG_VISUAL
83  std::cout << "TGCSlaveBoard::clockIn: after doCoincidence()\n";
85 #endif
86 #ifdef TGCDEBUG
87  std::cout << "#SB C: BID= " << m_bid << ":";
89 #endif
90  }
91  doDecluster();
92 #ifdef TGCDEBUG_VISUAL
93  if(m_coincidenceOut!=0) {
94  std::cout << "TGCSlaveBoard::clockIn: after doDecluster()\n";
96  }
97 #endif
99 
100 #ifdef TGCDEBUG
101  showResult();
102 #endif
103 
105  if(m_coincidenceOut!=0){
106  delete m_coincidenceOut;
108  }
109  }
110 }
111 
113 {
114  // store SlaveBoard input for readout
115  const TGCHitPattern* inner = m_patchPanelOut->getHitPattern(0);
116  const TGCHitPattern* pivot = m_patchPanelOut->getHitPattern(1);
117  int i;
118  if(pivot!=0){
119  for(i=0; i<s_pLength[m_type]; i++){
120  m_slbin.set(40+i+s_pOffset[m_type], pivot->getChannel(i+s_pLength[m_type]));
121  m_slbin.set(40+36+i+s_pOffset[m_type], pivot->getChannel(i));
122  }
123  }
124  if(inner!=0){
125  for(i=0; i<s_iLength[m_type]; i++){
126  if(inner->getLength()>s_iLength[m_type])//WTSB
127  m_slbin.set(40+36+36+i+s_iOffset[m_type], inner->getChannel(i+s_iLength[m_type]));
128  m_slbin.set(40+36+36+44+i+s_iOffset[m_type], inner->getChannel(i));
129  }
130  }
131 }
132 
134 {
135 
136  int i;
137  if(m_patchPanelOut!=0){
138  for( i=0; i<NumberOfConnectorPerPPOut; i+=1)
139  if(std::as_const(m_patchPanelOut)->getHitPattern(i)!=0){
140  std::cout<<"#SB I: BID= "<<m_bid;
141  if(m_patchPanelOut->getOrigin()!=0){
142  std::cout << " Typ= " << m_patchPanelOut->getOrigin()->getType();
143  std::cout << " Rgn= " << (m_patchPanelOut->getOrigin()->getRegion() == TGCRegionType::FORWARD ? "FORWARD" : "ENDCAP");
144  std::cout << " PPID= "<< m_patchPanelOut->getOrigin()->getId()<<" ";
145  std::cout << " port= "<< i;
146  std::cout << "" << m_id;
147  }
148  std::cout << ":";
149  std::as_const(m_patchPanelOut)->getHitPattern(i)->print();
150  }
151  }
152 
153  if(m_slaveBoardOut!=0){
154  if(m_coincidenceOut!=0){
155  std::cout << "#SB O: BID= " << m_bid;
156  std::cout << " Rgn= " << (m_region == TGCRegionType::FORWARD ? "FORWARD" : "ENDCAP");
157  std::cout << " Typ= " << getTypeName(m_type);
158  std::cout << " ID= " << m_id << ":";
159  for( i=0; i<m_slaveBoardOut->getNumberOfData(); i++){
160  if(m_slaveBoardOut->getHit(i)){
161  std::cout << " i= " << i;
162  std::cout << " x= " << m_slaveBoardOut->getPos(i);
163  if((m_type==1)||(m_type==3))// doublet
164  std::cout << " d= " << m_slaveBoardOut->getDev(i);
165  }
166  }
167  std::cout<<std::endl;
168  std::cout<<"Destination HPBID= "<<m_idHighPtBoard<<std::endl;
169  }
170  }
171 }
172 
173 std::string TGCSlaveBoard::getTypeName(int /*typeIn*/) const
174 {
175  if(m_type==WTSB) return "WT";//0
176  if(m_type==WDSB) return "WD";//1
177  if(m_type==STSB) return "ST";//2
178  if(m_type==SDSB) return "SD";//3
179  if(m_type==WISB) return "WI";//4
180  if(m_type==SISB) return "SI";//5
181  return "";
182 }
183 
185 {
186  if( m_patchPanelOut!=0 ) delete m_patchPanelOut;
187  m_patchPanelOut=0;
188 }
189 
191 {
192  int i;
193  bool A, B, C, D;
194 
195  if(m_coincidenceOut!=0){
197  int length = out->getLength();
198  for( i=2; i<length-1; i+=1) {
200  B = m_coincidenceOut->getChannel(i-1);
202  D = m_coincidenceOut->getChannel(i+1);
203  out->setChannel(i,( !B & C & !D )|( !A & B & C ));
204  }
205 
206  A = false;
207  B = false;
210  out->setChannel(0,( !B & C & !D )|( !A & B & C ));
211 
212  A = false;
216  out->setChannel(1,( !B & C & !D )|( !A & B & C ));
217 
221  D = false;
222  out->setChannel(length-1,( !B & C & !D )|( !A & B & C ));
223 
224  delete m_coincidenceOut;
226  out=0;
227  }
228 }
229 
231 {
232  m_slaveBoardOut=0;
233 }
234 
236 {
237  m_patchPanel = PPIn;
238 }
239 
241 {
242 #ifdef TGCDEBUG
243  std::cout << "#SB: BID= " << m_bid;
244  std::cout << " Rgn= " << m_region;
245  std::cout << " Typ= " << getTypeName(m_type);
246  std::cout << " ID= " << m_id << std::endl;
248 #endif
249 
250  if(m_patchPanel!=0){
252 #ifdef TGCDEBUG
254 #endif
256 
257  }
258 }
259 
261 {
262  return m_idHighPtBoard;
263 }
264 
266 {
267  m_idHighPtBoard = idIn;
268 }
269 
270 } // namespace LVL1TGCTrigger
LVL1TGCTrigger::TGCSlaveBoard::setIdHighPtBoard
void setIdHighPtBoard(int m_id)
Definition: TGCSlaveBoard.cxx:265
LVL1TGCTrigger::TGCPatchPanelOut::getOrigin
const TGCPatchPanel * getOrigin() const
Definition: TGCPatchPanelOut.h:58
LVL1TGCTrigger::TGCSlaveBoard::storeSlbIn
void storeSlbIn()
Definition: TGCSlaveBoard.cxx:112
LVL1TGCTrigger::TGCSlaveBoard::m_bid
int m_bid
Definition: TGCSlaveBoard.h:77
LVL1TGCTrigger::TGCSlaveBoard::collectInput
void collectInput()
Definition: TGCSlaveBoard.cxx:240
LVL1TGCTrigger::TGCPatchPanel::getId
int getId() const
Definition: TGCPatchPanel.cxx:399
LVL1TGCTrigger::TGCSlaveBoardOut::getDev
int getDev(int iData) const
Definition: TGCSlaveBoardOut.h:119
LVL1TGCTrigger::SISB
@ SISB
Definition: TGCNumbering.h:57
TGCPatchPanelOut.h
LVL1TGCTrigger::TGCHitPattern::print
void print(int unit) const
Definition: TGCHitPattern.cxx:111
LVL1TGCTrigger::TGCSlaveBoard::s_iOffset
static constexpr int s_iOffset[6]
Definition: TGCSlaveBoard.h:26
LVL1TGCTrigger::TGCSlaveBoard::showResult
void showResult() const
Definition: TGCSlaveBoard.cxx:133
LVL1TGCTrigger::TGCSlaveBoard::m_id
int m_id
Definition: TGCSlaveBoard.h:76
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LVL1TGCTrigger::TGCSlaveBoard::doCoincidence
virtual void doCoincidence()=0
LVL1TGCTrigger::TGCSlaveBoard::getTypeName
std::string getTypeName(int typeIn) const
Definition: TGCSlaveBoard.cxx:173
LVL1TGCTrigger::TGCSlaveBoard::doDecluster
void doDecluster()
Definition: TGCSlaveBoard.cxx:190
LVL1TGCTrigger::TGCSlaveBoardOut::getNumberOfData
int getNumberOfData() const
Definition: TGCSlaveBoardOut.h:155
LVL1TGCTrigger::SDSB
@ SDSB
Definition: TGCNumbering.h:57
LVL1TGCTrigger::TGCSlaveBoard::s_iLength
static constexpr int s_iLength[6]
Definition: TGCSlaveBoard.h:28
LVL1TGCTrigger::TGCRegionType::FORWARD
@ FORWARD
LVL1TGCTrigger::TGCSlaveBoard::s_pLength
static constexpr int s_pLength[6]
Definition: TGCSlaveBoard.h:27
LVL1TGCTrigger::TGCHitPattern::getLength
int getLength() const
Definition: TGCHitPattern.h:49
LVL1TGCTrigger::TGCSlaveBoardOut::getPos
int getPos(int iData) const
Definition: TGCSlaveBoardOut.h:125
LVL1TGCTrigger::TGCSlaveBoard::clockIn
void clockIn(int bidIn)
Definition: TGCSlaveBoard.cxx:37
LVL1TGCTrigger::TGCSlaveBoard::m_slbin
std::bitset< 200 > m_slbin
Definition: TGCSlaveBoard.h:84
TGCSlaveBoard.h
LVL1TGCTrigger::TGCPatchPanel::eraseOutput
void eraseOutput(int SBId)
Definition: TGCPatchPanel.cxx:420
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
A
LVL1TGCTrigger::WDSB
@ WDSB
Definition: TGCNumbering.h:57
LVL1TGCTrigger::TGCSlaveBoard::s_pOffset
static constexpr int s_pOffset[6]
Definition: TGCSlaveBoard.h:25
LVL1TGCTrigger::TGCSlaveBoard::eraseOutput
void eraseOutput()
Definition: TGCSlaveBoard.cxx:230
LVL1TGCTrigger::TGCSlaveBoard::m_region
TGCRegionType m_region
Definition: TGCSlaveBoard.h:80
lumiFormat.i
int i
Definition: lumiFormat.py:85
LVL1TGCTrigger::TGCSlaveBoard::m_idHighPtBoard
int m_idHighPtBoard
Definition: TGCSlaveBoard.h:78
LVL1TGCTrigger::WTSB
@ WTSB
Definition: TGCNumbering.h:57
FORWARD
#define FORWARD
Definition: ALFA_SvdCalc.h:34
LVL1TGCTrigger::TGCSlaveBoard::doMaskOperation
void doMaskOperation()
Definition: TGCSlaveBoard.h:65
LVL1TGCTrigger::STSB
@ STSB
Definition: TGCNumbering.h:57
LVL1TGCTrigger::WISB
@ WISB
Definition: TGCNumbering.h:57
LVL1TGCTrigger::TGCSlaveBoard::m_type
int m_type
Definition: TGCSlaveBoard.h:79
LVL1TGCTrigger::TGCHitPattern::getChannel
bool getChannel(int iChannel) const
Definition: TGCHitPattern.cxx:64
LVL1TGCTrigger::TGCPatchPanel::getOutput
TGCPatchPanelOut * getOutput(int SBId)
Definition: TGCPatchPanel.cxx:409
LVL1TGCTrigger::NumberOfConnectorPerPPOut
const int NumberOfConnectorPerPPOut
Definition: TGCPatchPanelOut.h:13
LVL1TGCTrigger::TGCSlaveBoard::m_slaveBoardOut
TGCSlaveBoardOut * m_slaveBoardOut
Definition: TGCSlaveBoard.h:74
LVL1TGCTrigger
Definition: LVL1TGCTrigger.cxx:47
LVL1TGCTrigger::TGCSlaveBoardOut::getHit
bool getHit(int iData) const
Definition: TGCSlaveBoardOut.h:131
LVL1TGCTrigger::TGCSlaveBoard::setPatchPanel
void setPatchPanel(TGCPatchPanel *PPIn)
Definition: TGCSlaveBoard.cxx:235
LVL1TGCTrigger::TGCPatchPanelOut::print
void print() const
Definition: TGCPatchPanelOut.cxx:46
LVL1TGCTrigger::TGCHitPattern
Definition: TGCHitPattern.h:11
LVL1TGCTrigger::TGCSlaveBoard::deletePatchPanelOut
void deletePatchPanelOut()
Definition: TGCSlaveBoard.cxx:184
LVL1TGCTrigger::TGCPatchPanel::getType
int getType() const
Definition: TGCPatchPanel.h:64
LVL1TGCTrigger::TGCPatchPanel
Definition: TGCPatchPanel.h:38
LVL1TGCTrigger::TGCSlaveBoard::createSlaveBoardOut
virtual void createSlaveBoardOut()=0
LVL1TGCTrigger::TGCSlaveBoard::getIdHighPtBoard
int getIdHighPtBoard() const
Definition: TGCSlaveBoard.cxx:260
LVL1TGCTrigger::TGCSlaveBoard::TGCSlaveBoard
TGCSlaveBoard()
Definition: TGCSlaveBoard.cxx:16
LVL1TGCTrigger::TGCRegionType
TGCRegionType
Definition: TGCNumbering.h:49
LVL1TGCTrigger::TGCPatchPanelOut::getHitPattern
const TGCHitPattern * getHitPattern(int connector) const
Definition: TGCPatchPanelOut.h:46
LVL1TGCTrigger::TGCPatchPanel::getRegion
TGCRegionType getRegion() const
Definition: TGCPatchPanel.h:66
LVL1TGCTrigger::TGCSlaveBoard::m_patchPanel
TGCPatchPanel * m_patchPanel
Definition: TGCSlaveBoard.h:82
LVL1TGCTrigger::TGCSlaveBoard::m_patchPanelOut
TGCPatchPanelOut * m_patchPanelOut
Definition: TGCSlaveBoard.h:83
LVL1TGCTrigger::TGCSlaveBoard::~TGCSlaveBoard
virtual ~TGCSlaveBoard()
Definition: TGCSlaveBoard.cxx:25
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
LVL1TGCTrigger::TGCHitPattern::visual
void visual(int Cycle, int Width, int Tag) const
Definition: TGCHitPattern.cxx:232
TGCPatchPanel.h
LVL1TGCTrigger::TGCPatchPanel::showProperty
void showProperty()
Definition: TGCPatchPanel.cxx:261
LVL1TGCTrigger::TGCSlaveBoard::m_coincidenceOut
TGCHitPattern * m_coincidenceOut
Definition: TGCSlaveBoard.h:73