ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace LVL1TGCTrigger {
14
22
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){
35 if(m_coincidenceOut->getChannel(m_nChAdj+m_nChInBlock*block+i)){
36 m_slaveBoardOut->setPos(block,i);
37 m_slaveBoardOut->setHit(block,true);
38 break;
39 }
40 }// block 0:A 1:B
41 m_slaveBoardOut->setbPos(block, m_slaveBoardOut->getPos(block));
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;
58 m_slaveBoardOut->clear();
59 m_slaveBoardOut->setNumberOfData(NumberOfDoubletSBData);
60
61 if(LCOut!=0){
62 // Coincidence matrix
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());
218 m_coincidenceOut->clear();
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)){
256 m_coincidenceOut->onChannel(pCh);
257 }
258 }else{//block B
260 m_coincidenceOut->onChannel(pCh);
261 }
262 }
263 }
264 oredHit |= hit;
265 }
266 }
267 if(oredHit){
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)){
302 m_coincidenceOut->onChannel(pCh);
303 }
304 }else{//block B
306 m_coincidenceOut->onChannel(pCh);
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
332bool 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
virtual void doCoincidenceInSubMatrix(const int block, TGCHitPattern **LCOut)
void do3outof4Coincedence(TGCHitPattern **LCOut)
bool element(bool A, bool B, bool C, bool D)
TGCHitPattern ** doLocalCoincidence(const TGCPatchPanelOut *PPOut)
bool getChannel(int iChannel) const
void setChannel(int iChannel, bool pattern)
const TGCHitPattern * getHitPattern(int connector) const
TGCSlaveBoardOut * m_slaveBoardOut
TGCPatchPanelOut * m_patchPanelOut
struct color C
const int NumberOfDoubletSBData
hold the test vectors and ease the comparison