ATLAS Offline Software
TGCDoubletSB.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include <iostream>
10 #include <cstdlib>
11 
12 
13 namespace LVL1TGCTrigger {
14 
16  : TGCSlaveBoard(),
17  m_priorSign(1),m_numberOfData(2),m_nChInBlock(32),
18  m_maxDev(0),m_posMaxDev(0),m_negMaxDev(0),m_nChAdj(0),m_iChBase(0),
19  m_MatrixOverlap(4), m_SType(WIRE)
20 {
21 }
22 
24 {
25 }
26 
28 {
29  if(m_coincidenceOut!=0){
30  int i,block;
31  for( block=0; block<NumberOfDoubletSBData; block+=1){
32  if(m_slaveBoardOut->getHit(block)){
33  m_slaveBoardOut->setHit(block,false);
34  for( i=0; i<m_nChInBlock; i+=1){
36  m_slaveBoardOut->setPos(block,i);
37  m_slaveBoardOut->setHit(block,true);
38  break;
39  }
40  }// block 0:A 1:B
42 #ifdef TGCCOUT
43  std::cout << " " << block << std::endl;
44  m_slaveBoardOut->getbPos(block)->printb();
45 #endif
46  }
47  }
48  }
49 }
50 
52 {
53  // Local coincidence
55 
56  if ( m_slaveBoardOut!= 0 ) delete m_slaveBoardOut;
60 
61  if(LCOut!=0){
62  // Coincidence matrix
63  do3outof4Coincedence(LCOut);
64 
65  delete LCOut[0];
66  delete LCOut[1];
67  delete LCOut[2];
68  delete LCOut[3];
69  delete [] LCOut;
70  }
71 }
72 
74 {
75  TGCHitPattern** LCOut = 0;
76  const TGCHitPattern* inner = PPOut->getHitPattern(0); // layer3,layer4
77  const TGCHitPattern* pivot = PPOut->getHitPattern(1); // layer5,lyaer6
78 
79  if((inner!=0)&&(pivot!=0)){
80  int iLength = inner->getLength();
81  int pLength = pivot->getLength();
82 
83  // rearrange bit pattern for coincidence.
84  bool* bi = new bool [iLength];
85  bool* bp = new bool [pLength];
86  int i;
87  for( i=0; i<iLength/2; i+=1){
88  bi[2*i]=inner->getChannel(i); // smaller in eta [i:Layer3]
89  bi[2*i+1]=inner->getChannel(i+iLength/2); // smaller in phi [i+iLength/2:Layer4]
90  }
91  for( i=0; i<pLength/2; i+=1){
92  bp[2*i]=pivot->getChannel(i); // smallest in eta [i:Layer5]
93  bp[2*i+1]=pivot->getChannel(i+pLength/2); // smaller in phi [i+pLength/2:Layer6]
94  }
95 
96  // LCOut[0:3] are correspond to A,B,C,D in L1Trigger TDR Fig 12-12 respectively.
97  LCOut = new TGCHitPattern* [4];
98  LCOut[0] = new TGCHitPattern (iLength); // inner 2 hit
99  LCOut[1] = new TGCHitPattern (iLength); // inner 1 hit
100  LCOut[2] = new TGCHitPattern (pLength); // pivot 1 hit
101  LCOut[3] = new TGCHitPattern (pLength); // pivot 2 hit
102  /*
103  Wire Strip bi[1] 0 bi[3] 1 bi[iLength-1]
104  C L4 L3 ┌──┐┌──┐┌──┐ ┌──┐ ->eta
105  └false └──┘└──┘ └──┘
106  D L3 L4 ┌──┐┌──┐ ┌──┐┌false [inner]
107  └──┘└──┘ └──┘└──┘
108  bi[0] 0 bi[2] 1 bi[iLength-2]
109  ^
110  ┌┐┌┐┌┐┌┐ ┌┐┌┐┌┐┌┐ |
111  └┘└┘└┘└┘ └┘└┘└┘└┘
112  0 1 2 3 iLength-1
113  */
114  i=0;
115  LCOut[0]->setChannel(i,false);
116  LCOut[1]->setChannel(i,(bi[i] & !bi[i+1]));
117 
118  for(i = 1; i<iLength-1; i+=1){
119  LCOut[0]->setChannel(i,(bi[i-1] & bi[i]));
120  LCOut[1]->setChannel(i,((!bi[i-1] & bi[i] & !bi[i+1]) |
121  (bi[i-1] & !bi[i] & bi[i+1])));
122  }
123  i=iLength-1;
124  LCOut[0]->setChannel(i,(bi[i-1] & bi[i]));
125  LCOut[1]->setChannel(i,(!bi[i-1] & bi[i]));
126 
127 #ifdef TGCDEBUG
128  int j ;
129  std::cout << "C,D i";
130  for(j = 0; j<iLength; j++){
131  if((j%10)+1==10){
132  std::cout << "-";
133  }else{
134  std::cout << (j%10)+1;
135  }
136  }
137  std::cout << std::endl << "2hit ";
138  LCOut[0]->printb();
139  std::cout << std::endl << "1hit ";
140  LCOut[1]->printb();
141  std::cout << std::endl;
142 #endif
143 
144  /*
145  L5 B A L6 ← ─── Wire [pivot]
146  L6 B A L5 ← Strip │
147  ┌┐ │ │
148  │false ↓ ↓
149  ┌┐││ ┌┐0
150  bp[0]││└┘ └┘
151  0 ││┌┐ ┌┐1┌┐0
152  └┘││bp[1] └┘ └┘
153  ┌┐││ 0 ┌┐2┌┐1
154  bp[2]││└┘ └┘ └┘
155  1 ││┌┐ ┌┐3┌┐2
156  └┘││bp[4] └┘ └┘
157  ││ 1
158  └┘
159  ┌┐
160  ││
161  ││┌┐ ┌┐ pLength-2
162  └┘││ └┘
163  ┌┐││ ┌┐ pLength-1
164  false│└┘ └┘
165  ││ ↑
166  └┘ └─ bp[pLength-1]
167 
168  */
169  LCOut[2]->setChannel(0, bp[0] & !bp[1]);
170  LCOut[3]->setChannel(0, bp[0] & bp[1]);
171  for( i=1; i<pLength-1; i+=1){
172  LCOut[2]->setChannel(i,((!bp[i-1] & bp[i] & !bp[i+1]) |
173  ( bp[i-1] & !bp[i] & bp[i+1])));
174  LCOut[3]->setChannel(i,(bp[i] & bp[i+1]));
175  }
176 
177  i=pLength-1;
178  LCOut[2]->setChannel(i,!bp[i-1] & bp[i]);
179  LCOut[3]->setChannel(i,false);
180 
181 #ifdef TGCDEBUG
182  std::cout << "A,B p";
183  for(j = 0; j<pLength; j++){
184  if((j%10)+1==10){
185  std::cout << "-";
186  }else{
187  std::cout << (j%10)+1;
188  }
189  }
190  std::cout << std::endl << "1hit ";
191  LCOut[2]->printb();
192  std::cout << std::endl << "2hit ";
193  LCOut[3]->printb();
194  std::cout << std::endl;
195 #endif
196 
197  delete [] bi;
198  delete [] bp;
199 
200  }
201 
202  return LCOut;
203 }
204 
206 {
207  if(((LCOut[0]!=0)||(LCOut[1]!=0))&&((LCOut[2]!=0)||(LCOut[3]!=0))){
208  if ( m_coincidenceOut != 0 ) delete m_coincidenceOut;
210 #ifdef TGCDEBUG
211  std::cout << "# DoubletSB [do3outof4Coincedence]" <<std::endl;
212  std::cout<<"#SB LCOut[0]: inner 2hit";LCOut[0]->print();
213  std::cout<<"#SB LCOut[1]: inner 1hit";LCOut[1]->print();
214  std::cout<<"#SB LCOut[2]: pivot 1hit";LCOut[2]->print();
215  std::cout<<"#SB LCOut[3]: pivot 2hit";LCOut[3]->print();
216 #endif
217  m_coincidenceOut->setLength(LCOut[2]->getLength());
219  int i;
220  for( i=0; i<NumberOfDoubletSBData; i+=1)
221  // select tracks in each submatrix.
223  }
224 }
225 
227 {
228  bool oredHit = false;
229  bool hit = false;
230  bool A, B, C, D;
231 
232  m_slaveBoardOut->setHit(block,false);
233  int dev,pCh,iCh;
234  for( dev=0; ( dev<=m_maxDev ) && !oredHit; dev+=1){
235  int i;
236  for(i = 0; i < m_nChAdj + m_nChInBlock + m_MatrixOverlap; i++){
237  pCh = (m_nChAdj + m_nChInBlock - m_MatrixOverlap)*block + i;
238  iCh = pCh + m_priorSign*dev + m_iChBase;
239  if(0 <= iCh){
240  if((0 <= iCh)&&(iCh < LCOut[0]->getLength())){
241  A = LCOut[0]->getChannel(iCh);
242  }else{A = false;}
243  if((0 <= iCh)&&(iCh < LCOut[1]->getLength())){
244  B = LCOut[1]->getChannel(iCh);
245  }else{B = false;}
246  if((0 <= pCh)&&(pCh < LCOut[2]->getLength())){
247  C = LCOut[2]->getChannel(pCh);
248  }else{C = false;}
249  if((0 <= pCh)&&(pCh < LCOut[3]->getLength())){
250  D = LCOut[3]->getChannel(pCh);
251  }else{D = false;}
252  hit = element(A, B, C, D);
253  if(hit){
254  if(block == 0){ //block A
255  if((0 <= i) && (i < m_nChAdj+m_nChInBlock)){
257  }
258  }else{//block B
261  }
262  }
263  }
264  oredHit |= hit;
265  }
266  }
267  if(oredHit){
268  if((m_priorSign*dev>=m_negMaxDev)&&(m_priorSign*dev<=m_posMaxDev)){
269  m_slaveBoardOut->setDev(block, m_priorSign*dev);
270  m_slaveBoardOut->setbDev(block, m_priorSign, dev);
271  m_slaveBoardOut->setHit(block, true);
272 #ifdef TGCDEBUG
273  std::cout << "# DoubletSB : delta =" << m_priorSign*dev
274  << " @pivot=" << pCh << " @onner="<< iCh << std::endl;
275 #endif
276  return;
277  } else {
278  oredHit = false;
279  }
280  } else if(dev!=0) {
281  // Opposite sign of dr,dphi
282  for(i = 0; i < m_nChAdj + m_nChInBlock + m_MatrixOverlap; i++){
283  pCh = (m_nChAdj + m_nChInBlock - m_MatrixOverlap)*block + i;
284  iCh = pCh - m_priorSign*dev + m_iChBase;
285  if(iCh>=0){
286  if((0 <= iCh)&&(iCh < LCOut[0]->getLength())){
287  A = LCOut[0]->getChannel(iCh);
288  }else{A = false;}
289  if((0 <= iCh)&&(iCh < LCOut[1]->getLength())){
290  B = LCOut[1]->getChannel(iCh);
291  }else{B = false;}
292  if((0 <= pCh)&&(pCh < LCOut[2]->getLength())){
293  C = LCOut[2]->getChannel(pCh);
294  }else{C = false;}
295  if((0 <= pCh)&&(pCh < LCOut[3]->getLength())){
296  D = LCOut[3]->getChannel(pCh);
297  }else{D = false;}
298  hit = element(A, B, C, D);
299  if(hit){
300  if(block == 0){ //block A
301  if((0 <= i) && (i < m_nChAdj+m_nChInBlock)){
303  }
304  }else{//block B
307  }
308  }
309  }
310  oredHit |= hit;
311  }
312  }
313  if(oredHit){
314  if((-m_priorSign*dev>=m_negMaxDev)&&(-m_priorSign*dev<=m_posMaxDev)){
315  m_slaveBoardOut->setDev(block,-m_priorSign*dev);
316  m_slaveBoardOut->setbDev(block, -m_priorSign, dev);
317  m_slaveBoardOut->setHit(block,true);
318 #ifdef TGCDEBUG
319  std::cout << "# DoubletSB : delta =" << -m_priorSign*dev
320  << " @pivot=" << pCh << " @onner="<< iCh << std::endl;
321 #endif
322  return;
323  } else {
324  oredHit = false;
325  }
326  }
327  }
328  }
329 }
330 
331 
332 bool TGCDoubletSB::element(bool A, bool B, bool C, bool D)
333 {
334  return ((A & C)|( A & D)|( B & D));
335 }
336 
337 
338 } //end of namespace bracket
339 
340 
LVL1TGCTrigger::TGCDoubletSB::do3outof4Coincedence
void do3outof4Coincedence(TGCHitPattern **LCOut)
Definition: TGCDoubletSB.cxx:205
LVL1TGCTrigger::TGCSlaveBoard::m_bid
int m_bid
Definition: TGCSlaveBoard.h:77
LVL1TGCTrigger::TGCSlaveBoardOut::clear
void clear()
Definition: TGCSlaveBoardOut.cxx:181
TGCPatchPanelOut.h
LVL1TGCTrigger::TGCHitPattern::print
void print(int unit) const
Definition: TGCHitPattern.cxx:111
LVL1TGCTrigger::TGCDoubletSB::createSlaveBoardOut
virtual void createSlaveBoardOut()
Definition: TGCDoubletSB.cxx:27
LVL1TGCTrigger::TGCDoubletSB::m_nChAdj
int m_nChAdj
Definition: TGCDoubletSB.h:39
LVL1TGCTrigger::TGCDoubletSB::TGCDoubletSB
TGCDoubletSB()
Definition: TGCDoubletSB.cxx:15
LVL1TGCTrigger::TGCSlaveBoardOut::setDev
void setDev(int iData, int devIn)
Definition: TGCSlaveBoardOut.h:97
LVL1TGCTrigger::TGCDoubletSB::m_MatrixOverlap
int m_MatrixOverlap
Definition: TGCDoubletSB.h:41
LVL1TGCTrigger::TGCDoubletSB::doCoincidence
virtual void doCoincidence()
Definition: TGCDoubletSB.cxx:51
LVL1TGCTrigger::TGCSlaveBoardOut::setbDev
void setbDev(int block, int sign, int dr)
Definition: TGCSlaveBoardOut.cxx:138
LVL1TGCTrigger::TGCSlaveBoardOut::getbPos
TGCHitPattern * getbPos(int iData)
Definition: TGCSlaveBoardOut.h:107
LVL1TGCTrigger::TGCHitPattern::getLength
int getLength() const
Definition: TGCHitPattern.h:49
LVL1TGCTrigger::TGCDoubletSB::m_priorSign
int m_priorSign
Definition: TGCDoubletSB.h:33
LVL1TGCTrigger::TGCSlaveBoardOut::getPos
int getPos(int iData) const
Definition: TGCSlaveBoardOut.h:125
LVL1TGCTrigger::TGCDoubletSB::doLocalCoincidence
TGCHitPattern ** doLocalCoincidence(const TGCPatchPanelOut *PPOut)
Definition: TGCDoubletSB.cxx:73
LVL1TGCTrigger::TGCDoubletSB::element
bool element(bool A, bool B, bool C, bool D)
Definition: TGCDoubletSB.cxx:332
LVL1TGCTrigger::TGCHitPattern::printb
void printb() const
Definition: TGCHitPattern.cxx:141
LVL1TGCTrigger::TGCDoubletSB::m_nChInBlock
int m_nChInBlock
Definition: TGCDoubletSB.h:35
TGCSlaveBoard.h
LVL1TGCTrigger::TGCSlaveBoard
Definition: TGCSlaveBoard.h:22
LVL1TGCTrigger::TGCHitPattern::onChannel
void onChannel(int iChannel)
Definition: TGCHitPattern.h:55
TGCHitPattern.h
LVL1TGCTrigger::TGCHitPattern::setLength
void setLength(int length)
Definition: TGCHitPattern.cxx:74
LVL1TGCTrigger::TGCSlaveBoardOut::setPos
void setPos(int iData, int posIn)
Definition: TGCSlaveBoardOut.cxx:171
A
LVL1TGCTrigger::TGCSlaveBoardOut::setHit
void setHit(int iData, bool hitIn)
Definition: TGCSlaveBoardOut.h:87
lumiFormat.i
int i
Definition: lumiFormat.py:85
TGCDoubletSB.h
LVL1TGCTrigger::WIRE
@ WIRE
Definition: TGCNumbering.h:52
LVL1TGCTrigger::TGCSlaveBoardOut
Definition: TGCSlaveBoardOut.h:20
LVL1TGCTrigger::TGCHitPattern::getChannel
bool getChannel(int iChannel) const
Definition: TGCHitPattern.cxx:64
LVL1TGCTrigger::TGCSlaveBoard::m_slaveBoardOut
TGCSlaveBoardOut * m_slaveBoardOut
Definition: TGCSlaveBoard.h:74
LVL1TGCTrigger::TGCHitPattern::clear
void clear()
Definition: TGCHitPattern.cxx:105
LVL1TGCTrigger
Definition: LVL1TGCTrigger.cxx:47
LVL1TGCTrigger::TGCSlaveBoardOut::getHit
bool getHit(int iData) const
Definition: TGCSlaveBoardOut.h:131
LVL1TGCTrigger::TGCHitPattern
Definition: TGCHitPattern.h:11
LVL1TGCTrigger::TGCHitPattern::setChannel
void setChannel(int iChannel, bool pattern)
Definition: TGCHitPattern.cxx:85
LVL1TGCTrigger::TGCDoubletSB::doCoincidenceInSubMatrix
virtual void doCoincidenceInSubMatrix(const int block, TGCHitPattern **LCOut)
Definition: TGCDoubletSB.cxx:226
LVL1TGCTrigger::TGCDoubletSB::m_posMaxDev
int m_posMaxDev
Definition: TGCDoubletSB.h:37
LVL1TGCTrigger::TGCSlaveBoardOut::setbPos
void setbPos(int block, int pos)
Definition: TGCSlaveBoardOut.h:74
LVL1TGCTrigger::TGCDoubletSB::m_maxDev
int m_maxDev
Definition: TGCDoubletSB.h:36
LVL1TGCTrigger::TGCPatchPanelOut::getHitPattern
const TGCHitPattern * getHitPattern(int connector) const
Definition: TGCPatchPanelOut.h:46
LVL1TGCTrigger::NumberOfDoubletSBData
const int NumberOfDoubletSBData
Definition: TGCDoubletSB.h:13
LVL1TGCTrigger::TGCSlaveBoard::m_patchPanelOut
TGCPatchPanelOut * m_patchPanelOut
Definition: TGCSlaveBoard.h:83
LVL1TGCTrigger::TGCSlaveBoardOut::setNumberOfData
void setNumberOfData(int nData)
Definition: TGCSlaveBoardOut.h:149
LVL1TGCTrigger::TGCDoubletSB::m_iChBase
int m_iChBase
Definition: TGCDoubletSB.h:40
LVL1TGCTrigger::TGCDoubletSB::~TGCDoubletSB
virtual ~TGCDoubletSB()
Definition: TGCDoubletSB.cxx:23
LVL1TGCTrigger::TGCDoubletSB::m_negMaxDev
int m_negMaxDev
Definition: TGCDoubletSB.h:38
LVL1TGCTrigger::TGCPatchPanelOut
Definition: TGCPatchPanelOut.h:17
LVL1TGCTrigger::TGCSlaveBoard::m_coincidenceOut
TGCHitPattern * m_coincidenceOut
Definition: TGCSlaveBoard.h:73