ATLAS Offline Software
TGCStripHighPtBoard.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <iostream>
7 #include <cstdlib>
8 
9 namespace LVL1TGCTrigger {
10 
13 {
14  m_maxDev = 15;
15  m_maxDevOred = 20;
16  m_nChOfTSBOut = 64;
18  m_nChOfDSBOut = 64;
21 }
22 
23 
25 {
30 
34 
38  m_decoderInTSB[ChipA][3] = 0;
39 
42  m_decoderInTSB[ChipB][2] = 0;
43  m_decoderInTSB[ChipB][3] = 0;
44 
45  }
46 
48  m_decoderInDSB[ChipA][0] = 0;
50  m_decoderInDSB[ChipA][2] = 0;
51 
52  m_decoderInDSB[ChipB][0] = 0;
53  m_decoderInDSB[ChipB][1] = 0;
54  m_decoderInDSB[ChipB][2] = 0;
55 
56 
57  m_decoderInTSB[ChipA][0] = 0;
59  m_decoderInTSB[ChipA][2] = 0;
60  m_decoderInTSB[ChipA][3] = 0;
61 
62  m_decoderInTSB[ChipB][0] = 0;
63  m_decoderInTSB[ChipB][1] = 0;
64  m_decoderInTSB[ChipB][2] = 0;
65  m_decoderInTSB[ChipB][3] = 0;
66 
67  }
68 }
69 
71 {
73  if(m_decoderInTSB[ChipA][0]) delete m_decoderInTSB[ChipA][0];
74  if(m_decoderInTSB[ChipA][1]) delete m_decoderInTSB[ChipA][1];
75  if(m_decoderInTSB[ChipA][2]) delete m_decoderInTSB[ChipA][2];
76  if(m_decoderInTSB[ChipB][0]) delete m_decoderInTSB[ChipB][0];
77  if(m_decoderInTSB[ChipB][1]) delete m_decoderInTSB[ChipB][1];
78  }
79  int chip,j;
80  for( chip=0; chip<NumberOfChip; chip+=1){
81  for( j=0; j<NDecoderInTSB; j+=1) m_decoderInTSB[chip][j]=0;
82  for( j=0; j<NDecoderInDSB; j+=1) m_decoderInDSB[chip][j]=0;
83  }
84 }
85 
87  TGCSlaveBoardOut* SBOut)
88 {
89  // divide output of TripletSlaveBoard to distribute to decoder channels.
90  // SBOut out
91  // a -> (iSet=0)
92  // b -> (iSet=0)
93  // c -> (iSet=0)
94  // d -> (iSet=0)
95  // a -> (iSet=1)
96  // b -> (iSet=1)
97  // c -> (iSet=1)
98  // d -> (iSet=1)
99 
100  if(SBOut!=0)
101  {
103  new TGCSlaveBoardOut(SBOut->getOrigin(), SBOut->getBid());
104  int nData = SBOut->getNumberOfData();// total number of block
105  out->setNumberOfData(nData/2);
106 
107  int i;
108  for( i=0; i< out->getNumberOfData(); i+=1)
109  {
110  out->setDev(i,SBOut->getDev((nData/2)*iSet+i));
111  out->setPos(i,SBOut->getPos((nData/2)*iSet+i));
112  out->setHit(i,SBOut->getHit((nData/2)*iSet+i));
113  out->setbPos(i,SBOut->getPos((nData/2)*iSet+i));
114  }
115  return out;
116  }
117  else
118  {
119  return 0;
120  }
121 }
122 
123 
125  TGCHitPattern* tHit,
126  TGCHitPattern* dHit)
127 {
128  int block,j,ch;
129  // input from TripletSlaveBoard
130 #ifdef TGCCOUT
131  std::cout << "#--Strip decodeSlaveBoardOut()" << std::endl;
132  std::cout << "Triplet" << std::endl;
133 #endif
134 
135  for( j=0; j<NDecoderInSTSB; j+=1) {
136  if(m_decoderInTSB[chip][j]!=0) {
137 #ifdef TGCCOUT
138  std::cout << "index:" << j << "/" << NDecoderInSTSB-1 << " in a chip ";
139  std::cout<<"SHPB:decoderInTSB["<<chip<<"]["<<j<<"]:";
140  m_decoderInTSB[chip][j]->print();
141 #endif
142  for( block=0; block<m_decoderInTSB[chip][j]->getNumberOfData(); block+=1) {
143  if(m_decoderInTSB[chip][j]->getHit(block)) {
144  // input to the 2nd Decoder.
145  if(j>0) {
146  ch=(j-1)*m_nChOfTSBOut+block*m_nChInTSBRegion
147  +m_decoderInTSB[chip][j]->getPos(block);
148  if((ch>=0)&&(ch<m_nChOfTSBHit))
149  tHit->onChannel(ch);
150 #ifdef TGCCOUT
151  else
152  std::cout<<"decodeSlaveBoardOut ch= "<<ch<<std::endl;
153 #endif
154  }
155 
156  // input to the 2nd Decoder.
158  +m_decoderInTSB[chip][j]->getPos(block);
159  if((ch>=0)&&(ch<m_nChOfTSBHit))
160  tHit->onChannel(ch);
161 #ifdef TGCCOUT
162  else
163  std::cout<<"decodeSlaveBoardOut ch= "<<ch<<std::endl;
164 #endif
165  // input to the 1st Decoder.
166  if(j<NDecoderInSTSB){
167  ch=(j+1)*m_nChOfTSBOut+block*m_nChInTSBRegion
168  +m_decoderInTSB[chip][j]->getPos(block);
169  if((ch>=0)&&(ch<m_nChOfTSBHit))
170  tHit->onChannel(ch);
171 #ifdef TGCCOUT
172  else
173  std::cout<<"decodeSlaveBoardOut ch= "<<ch<<std::endl;
174 #endif
175  }
176  }
177  }
178  }
179  }
180 
181  // input from DoubletSlaveBoard.
182 #ifdef TGCCOUT
183  std::cout << "Doublet" << std::endl;
184 #endif
185  for( j=0; j<NDecoderInDSB; j+=1){
186  if(m_decoderInDSB[chip][j]!=0) {
187 #ifdef TGCCOUT
188  std::cout << "index:" << j << "/" << NDecoderInDSB-1 << " in a chip ";
189  std::cout<<"SHPB:decoderInDSB["<<chip<<"]["<<j<<"]:";
190  m_decoderInDSB[chip][j]->print();
191 #endif
192  for( block=0; block<m_decoderInDSB[chip][j]->getNumberOfData(); block+=1) {
193  if(m_decoderInDSB[chip][j]->getHit(block))
194  dHit->onChannel(j*m_nChOfDSBOut+m_nChOfDSBOut/2*block
195  +m_decoderInDSB[chip][j]->getPos(block));
196  }
197  }
198  }
199 }
200 
202  int block,
203  const TGCHitPattern* tHit,
204  const TGCHitPattern* dHit)
205 {
206  int nChUnitOfDSBHit=m_nChOfDSBHit/NBlockOfDSBChannel;
207  int maxTSBCh=(block+1)*nChUnitOfDSBHit;
208  int minTSBCh=block*nChUnitOfDSBHit;
209 #ifdef TGCCOUT
210  std::cout << "# Strip doCoincidenceMatrix() chip:" << chip << " block:" << block << std::endl;
211 #endif
212  for(int dev=0; dev<=m_maxDev; dev+=1) {
213  // convert Nonlinear dPhi
214  int dp = getNonLinearDelta(dev);
215  if (dp<0) continue;
216 
217  int Oring, DevOrg;
218  int DSBCh, TSBCh;
219  for (int isgn=1; isgn >-2; isgn-=2) {
220  if ( (dev==0) && (isgn==-1) ) continue;
221  for(int i=0; i<nChUnitOfDSBHit; i+=1) {
222  //total ch from doublet in a block
223  if(dev>2*m_maxDev-m_maxDevOred){
224  Oring = 1;
225  DevOrg = 2*m_maxDev-m_maxDevOred + (dev - (2*m_maxDev-m_maxDevOred))*2 - 1;
226  } else {
227  Oring = 0;
228  DevOrg = dev;
229  }
230  for(int ior = 0; ior <= Oring; ior++) {
231  DSBCh = nChUnitOfDSBHit*block + i;
232  TSBCh = DSBCh + isgn*m_priorSign*(DevOrg + ior);
233  if ( ((isgn>0) && ( (block%2==0)||((block%2==1)&&(TSBCh<maxTSBCh)) ) ) || // dphi>=0
234  ((isgn<0) && ( (block%2==1)||((block%2==0)&&(TSBCh>=minTSBCh)) ) ) ){ // dphi<0
235  if(tHit->getChannel(TSBCh) && dHit->getChannel(DSBCh)) {
236 #ifdef TGCDEBUG
237  std::cout<< "HighPt" << std::endl
238  << " th&&dh==1 priorSign*dev:" << m_priorSign
239  << "*" << dev
240  << " DSBCh:" << DSBCh
241  << " TSBCh:" << TSBCh << std::endl;
242 #endif
243  m_highPtBoardOut->setPt(chip,block,PtHigh);
244  m_highPtBoardOut->setHit(chip,block,true);
245  m_highPtBoardOut->setDev(chip,block,isgn*m_priorSign*dp);
246  // assume that a unit of position is quarter of nch of DSB.
247  m_highPtBoardOut->setPos(chip,block,i/(m_nChOfDSBOut/4)); // !
248  return;
249  }
250  }
251  } // loop ior
252  } // loop i
253  } //loop isgn
254 
255  } //loop dev
256  m_highPtBoardOut->setHit(chip,block,false);
257 }
258 
260 {
261  int iblock;
262  int highPt1stBlock, highPt2ndBlock;
263  int lowPt1stBlock, lowPt2ndBlock;
264  int pos, dev;
265  // Get 1st, 2nd candidate block for High-PT
266  highPt1stBlock = -1;
267  highPt2ndBlock = -1;
268  for(iblock=0;iblock<NBlockOfDSBChannel;iblock+=1){
269  switch (m_highPtBoardOut->getSel(chip,iblock)){
270  case 0: // No Hit
271  break;
272  case 1: // 1st candidate
273  highPt1stBlock = iblock;
274  break;
275  case 2: // 2nd candidate
276  highPt2ndBlock = iblock;
277  break;
278  default:
279  break;
280  }
281  }
282  // Get 1st, 2nd candidate block for Low-PT
283  lowPt1stBlock = -1;
284  lowPt2ndBlock = -1;
285  for(iblock=0;iblock<NBlockOfDSBChannel;iblock+=1){
286  switch (m_lowPtBoardOut->getSel(chip,iblock)){
287  case 0: // No Hit
288  break;
289  case 1: // 1st candidate
290  lowPt1stBlock = iblock;
291  break;
292  case 2: // 2nd candidate
293  lowPt2ndBlock = iblock;
294  break;
295  default:
296  break;
297  }
298  }
299 
300  if (highPt1stBlock < 0){ //No HPT Matrix Output
301  if (lowPt1stBlock >= 0){
302  // LPT 1st
303  pos=m_lowPtBoardOut->getPos(chip,lowPt1stBlock);
304  dev=m_lowPtBoardOut->getDev(chip,lowPt1stBlock);
309  m_highPtChipOut->setHitID(chip,FirstCandidate,lowPt1stBlock);
310  }
311  if (lowPt2ndBlock >= 0){
312  // LPT 2nd
313  pos=m_lowPtBoardOut->getPos(chip,lowPt2ndBlock);
314  dev=m_lowPtBoardOut->getDev(chip,lowPt2ndBlock);
319  m_highPtChipOut->setHitID(chip,SecondCandidate,lowPt2ndBlock);
320  }
321  return;
322  } else if (highPt2ndBlock < 0){ // 1 HPT Matrix Output
323  // HPT 1st
324  pos=m_highPtBoardOut->getPos(chip,highPt1stBlock);
325  dev=m_highPtBoardOut->getDev(chip,highPt1stBlock);
326  if ((dev>-8) && (dev<8)) { // check if |dev|<8
331  m_highPtChipOut->setHitID(chip,FirstCandidate,highPt1stBlock);
332  }
333 
334  if ((lowPt1stBlock >= 0) &&
335  !((lowPt1stBlock == highPt1stBlock) && ((m_lowPtBoardOut->getPos(chip,lowPt1stBlock)) == (m_highPtBoardOut->getPos(chip,highPt1stBlock))))
336  ){ //for vi }
337  // LPT 1st (as 2nd candidate)
338  pos=m_lowPtBoardOut->getPos(chip,lowPt1stBlock);
339  dev=m_lowPtBoardOut->getDev(chip,lowPt1stBlock);
344  m_highPtChipOut->setHitID(chip,SecondCandidate,lowPt1stBlock);
345  return;
346  } else if ((lowPt2ndBlock >= 0) &&
347  !((lowPt2ndBlock == highPt1stBlock) && ((m_lowPtBoardOut->getPos(chip,lowPt2ndBlock)) == (m_highPtBoardOut->getPos(chip,highPt1stBlock))))
348  ){
349 
350  // LPT 2nd (as 2nd candidate)
351  pos=m_lowPtBoardOut->getPos(chip,lowPt2ndBlock);
352  dev=m_lowPtBoardOut->getDev(chip,lowPt2ndBlock);
357  m_highPtChipOut->setHitID(chip,SecondCandidate,lowPt2ndBlock);
358  return;
359  }
360  } else { // 2 HPT Matrix Outputs
361  // HPT 1st
362  pos=m_highPtBoardOut->getPos(chip,highPt1stBlock);
363  dev=m_highPtBoardOut->getDev(chip,highPt1stBlock);
364  if ((dev>-8) && (dev<8)) { // check if |dev|<8
369  m_highPtChipOut->setHitID(chip,FirstCandidate,highPt1stBlock);
370  }
371  // HPT 2nd
372  pos=m_highPtBoardOut->getPos(chip,highPt2ndBlock);
373  dev=m_highPtBoardOut->getDev(chip,highPt2ndBlock);
374  if ((dev>-8) && (dev<8)) { // check if |dev|<8
379  m_highPtChipOut->setHitID(chip,SecondCandidate,highPt2ndBlock);
380  }
381  }
382 }
383 
385 {
386  if (dev >=12) return 8; // set dev=8 in case of out of range
387  else if (dev >=10) return 7;
388  else if (dev >=8) return 6;
389  else if (dev >=6) return 5;
390  else if (dev >=4) return 4;
391  else return dev;
392 }
393 
394 } //end of namespace bracket
LVL1TGCTrigger::TGCHighPtChipOut::setHitID
void setHitID(int chip, int iCandidate, int hitIdIn)
Definition: TGCHighPtChipOut.h:72
LVL1TGCTrigger::TGCHighPtBoardOut::setDev
void setDev(int chip, int iData, int devIn)
Definition: TGCHighPtBoardOut.h:66
LVL1TGCTrigger::TGCStripHighPtBoard::decodeSlaveBoardOut
virtual void decodeSlaveBoardOut(int chip, TGCHitPattern *tHit, TGCHitPattern *dHit)
Definition: TGCStripHighPtBoard.cxx:124
LVL1TGCTrigger::TGCRegionType::ENDCAP
@ ENDCAP
LVL1TGCTrigger::PtHigh
const int PtHigh
Definition: TGCHighPtBoard.h:17
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
LVL1TGCTrigger::TGCHighPtChipOut::setPos
void setPos(int chip, int iCandidate, int posIn)
Definition: TGCHighPtChipOut.h:66
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
LVL1TGCTrigger::TGCSlaveBoardOut::getDev
int getDev(int iData) const
Definition: TGCSlaveBoardOut.h:119
LVL1TGCTrigger::TGCSlaveBoardOut::getBid
int getBid() const
Definition: TGCSlaveBoardOut.h:137
TGCStripHighPtBoard.h
LVL1TGCTrigger::TGCHighPtBoard::m_DSBOut
TGCSlaveBoardOut * m_DSBOut[NumberOfChip][s_NumberOfDSBOut]
Definition: TGCHighPtBoard.h:94
LVL1TGCTrigger::TGCStripHighPtBoard::TGCStripHighPtBoard
TGCStripHighPtBoard()
Definition: TGCStripHighPtBoard.cxx:11
LVL1TGCTrigger::NDecoderInSTSB
const int NDecoderInSTSB
Definition: TGCHighPtBoard.h:24
LVL1TGCTrigger::TGCHighPtBoard::m_nChOfTSBOut
int m_nChOfTSBOut
Definition: TGCHighPtBoard.h:110
LVL1TGCTrigger::TGCHighPtBoardOut::getDev
int getDev(int chip, int iData) const
Definition: TGCHighPtBoardOut.h:93
LVL1TGCTrigger::NDecoderInDSB
const int NDecoderInDSB
Definition: TGCHighPtBoard.h:23
LVL1TGCTrigger::TGCHighPtBoard::m_decoderInTSB
TGCSlaveBoardOut * m_decoderInTSB[NumberOfChip][NDecoderInTSB]
Definition: TGCHighPtBoard.h:97
LVL1TGCTrigger::TGCHighPtBoard::m_nChOfDSBOut
int m_nChOfDSBOut
Definition: TGCHighPtBoard.h:111
LVL1TGCTrigger::TGCHighPtBoard::m_highPtChipOut
TGCHighPtChipOut * m_highPtChipOut
Definition: TGCHighPtBoard.h:87
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LVL1TGCTrigger::TGCSlaveBoardOut::getNumberOfData
int getNumberOfData() const
Definition: TGCSlaveBoardOut.h:155
LVL1TGCTrigger::TGCRegionType::FORWARD
@ FORWARD
LVL1TGCTrigger::ChipB
@ ChipB
Definition: TGCHighPtBoard.h:26
LVL1TGCTrigger::TGCHighPtBoard::m_nChOfDSBHit
int m_nChOfDSBHit
Definition: TGCHighPtBoard.h:112
LVL1TGCTrigger::TGCSlaveBoardOut::getPos
int getPos(int iData) const
Definition: TGCSlaveBoardOut.h:125
LVL1TGCTrigger::TGCHighPtBoard::m_nChInTSBRegion
int m_nChInTSBRegion
Definition: TGCHighPtBoard.h:114
LVL1TGCTrigger::TGCHitPattern::onChannel
void onChannel(int iChannel)
Definition: TGCHitPattern.h:55
LVL1TGCTrigger::NumberOfChip
const int NumberOfChip
Definition: TGCHighPtBoard.h:20
LVL1TGCTrigger::PtLow
const int PtLow
Definition: TGCHighPtBoard.h:16
LVL1TGCTrigger::TGCHighPtBoard::m_priorSign
int m_priorSign
Definition: TGCHighPtBoard.h:106
LVL1TGCTrigger::TGCHighPtBoardOut::setPos
void setPos(int chip, int iData, int posIn)
Definition: TGCHighPtBoardOut.h:73
LVL1TGCTrigger::TGCHighPtBoard::m_nChOfTSBHit
int m_nChOfTSBHit
Definition: TGCHighPtBoard.h:113
LVL1TGCTrigger::TGCStripHighPtBoard::clearDecoderIn
virtual void clearDecoderIn()
Definition: TGCStripHighPtBoard.cxx:70
lumiFormat.i
int i
Definition: lumiFormat.py:85
LVL1TGCTrigger::TGCHighPtBoard::m_decoderInDSB
TGCSlaveBoardOut * m_decoderInDSB[NumberOfChip][NDecoderInDSB]
Definition: TGCHighPtBoard.h:98
LVL1TGCTrigger::TGCHighPtBoardOut::getSel
int getSel(int chip, int iData) const
Definition: TGCHighPtBoardOut.h:129
LVL1TGCTrigger::TGCHighPtBoard::m_region
TGCRegionType m_region
Definition: TGCHighPtBoard.h:104
LVL1TGCTrigger::NDecoderInTSB
const int NDecoderInTSB
Definition: TGCHighPtBoard.h:22
LVL1TGCTrigger::TGCSlaveBoardOut
Definition: TGCSlaveBoardOut.h:20
LVL1TGCTrigger::TGCStripHighPtBoard::divideTSBOut
TGCSlaveBoardOut * divideTSBOut(int iSet, TGCSlaveBoardOut *SBOut)
Definition: TGCStripHighPtBoard.cxx:86
LVL1TGCTrigger::TGCHitPattern::getChannel
bool getChannel(int iChannel) const
Definition: TGCHitPattern.cxx:64
LVL1TGCTrigger::FirstCandidate
@ FirstCandidate
Definition: TGCHighPtChipOut.h:13
LVL1TGCTrigger::TGCHighPtChipOut::setDev
void setDev(int chip, int iCandidate, int devIn)
Definition: TGCHighPtChipOut.h:60
LVL1TGCTrigger::TGCHighPtChipOut::setPt
void setPt(int chip, int iCandidate, int ptIn)
Definition: TGCHighPtChipOut.h:78
LVL1TGCTrigger
Definition: LVL1TGCTrigger.cxx:47
LVL1TGCTrigger::TGCSlaveBoardOut::getHit
bool getHit(int iData) const
Definition: TGCSlaveBoardOut.h:131
LVL1TGCTrigger::TGCHitPattern
Definition: TGCHitPattern.h:11
LVL1TGCTrigger::TGCStripHighPtBoard::setDecoderIn
virtual void setDecoderIn()
Definition: TGCStripHighPtBoard.cxx:24
LVL1TGCTrigger::TGCHighPtBoardOut::getPos
int getPos(int chip, int iData) const
Definition: TGCHighPtBoardOut.h:99
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LVL1TGCTrigger::TGCStripHighPtBoard::doCoincidenceMatrix
virtual void doCoincidenceMatrix(int chip, int block, const TGCHitPattern *tHit, const TGCHitPattern *dHit)
Definition: TGCStripHighPtBoard.cxx:201
LVL1TGCTrigger::TGCSlaveBoardOut::getOrigin
const TGCSlaveBoard * getOrigin() const
Definition: TGCSlaveBoardOut.h:113
LVL1TGCTrigger::TGCHighPtBoard::m_maxDevOred
int m_maxDevOred
Definition: TGCHighPtBoard.h:109
LVL1TGCTrigger::TGCHighPtBoard::m_lowPtBoardOut
TGCHighPtBoardOut * m_lowPtBoardOut
Definition: TGCHighPtBoard.h:90
LVL1TGCTrigger::TGCHighPtBoard
Definition: TGCHighPtBoard.h:34
LVL1TGCTrigger::NBlockOfDSBChannel
const int NBlockOfDSBChannel
Definition: TGCHighPtBoard.h:21
LVL1TGCTrigger::ChipA
@ ChipA
Definition: TGCHighPtBoard.h:26
LVL1TGCTrigger::TGCHighPtBoardOut::setPt
void setPt(int chip, int iData, int ptIn)
Definition: TGCHighPtBoardOut.h:80
LVL1TGCTrigger::TGCHighPtBoard::m_TSBOut
TGCSlaveBoardOut * m_TSBOut[NumberOfChip][s_NumberOfTSBOut]
Definition: TGCHighPtBoard.h:95
LVL1TGCTrigger::TGCHighPtChipOut::setSel
void setSel(int chip, int iCandidate, int selIn)
Definition: TGCHighPtChipOut.h:127
LVL1TGCTrigger::TGCSlaveBoardOut::print
void print() const
Definition: TGCSlaveBoardOut.cxx:193
LVL1TGCTrigger::TGCStripHighPtBoard::highLowSelector
virtual void highLowSelector(int chip)
Definition: TGCStripHighPtBoard.cxx:259
LVL1TGCTrigger::TGCHighPtBoard::m_highPtBoardOut
TGCHighPtBoardOut * m_highPtBoardOut
Definition: TGCHighPtBoard.h:89
LVL1TGCTrigger::SecondCandidate
@ SecondCandidate
Definition: TGCHighPtChipOut.h:13
LVL1TGCTrigger::TGCHighPtBoard::m_maxDev
int m_maxDev
Definition: TGCHighPtBoard.h:108
LVL1TGCTrigger::TGCStripHighPtBoard::getNonLinearDelta
int getNonLinearDelta(int dev) const
Definition: TGCStripHighPtBoard.cxx:384
LVL1TGCTrigger::TGCHighPtBoardOut::setHit
void setHit(int chip, int iData, bool hitIn)
Definition: TGCHighPtBoardOut.h:123