ATLAS Offline Software
SectorL.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <cmath>
8 #include <fstream>
9 #include <iostream>
10 #include <stdexcept>
11 
13 #include "TrigT1RPChardware/Pad.h"
14 
15 using namespace std;
16 
17 //--------------------------------------------------------------------//
18 SectorL::SectorL(int run, int event, CMAword /*debug*/, ubit16 subsys, ubit16 sect, uint NOBXS) : BaseObject(Hardware, "SectorLogic") {
19  ubit16 i, j, k;
20  m_padData = 7;
21  m_maxNumPads = 10;
22  m_nBunMax = NOBXS;
23 
24  for (i = 0; i < m_nBunMax; i++) { m_numOfPads[i] = 0; }
25 
26  m_run = run;
27  m_event = event;
28  m_subsystem = subsys;
29  m_sector = sect;
30 
31  for (i = 0; i < m_nBunMax; i++) {
32  m_numberOfRoIs[i] = 0;
33  m_sectorOutput[i] = 0;
34  for (k = 0; k < 10; k++) { m_sectorOut[i][k] = 0; }
35  for (k = 0; k < 2; k++) {
36  m_pTArray[i][k][0] = 0;
37  m_pTArray[i][k][1] = 0;
38  } // end-of-for(k
39  for (j = 0; j < m_maxNumPads; j++) {
40  for (k = 0; k < m_padData; k++) { m_sectorInput[i][j][k] = 0; } // end-of-for(k
41  }
42  }
43 } // end-of-SectorL::SectorL
44 //--------------------------------------------------------------------//
45 SectorL::~SectorL() {} // end-of-SectorL::~SectorL
46 //-------------------------------------------------------------------//
47 void SectorL::load(ubit16 padAdd, ubit16 BX, ubit16 RoIAdd, ubit16 pT, ubit16 OPL, ubit16 overlapPhi, ubit16 overlapEta,
48  ubit16 RoIAmbiguity, ubit16 BCIDcounter) {
49  if (padAdd < 10 && RoIAdd < 4 && pT < 7 && OPL < 2 && overlapPhi < 2 && overlapEta < 2 && RoIAmbiguity < 2) {
50  m_sectorInput[BX][m_numOfPads[BX]][0] = padAdd;
51  m_sectorInput[BX][m_numOfPads[BX]][1] = RoIAdd;
52  m_sectorInput[BX][m_numOfPads[BX]][2] = pT;
53  m_sectorInput[BX][m_numOfPads[BX]][3] = OPL;
54  m_sectorInput[BX][m_numOfPads[BX]][4] = overlapPhi;
55  m_sectorInput[BX][m_numOfPads[BX]][5] = overlapEta;
56  m_sectorInput[BX][m_numOfPads[BX]][6] = RoIAmbiguity;
57  m_sectorInput[BX][m_numOfPads[BX]][7] = BCIDcounter;
58  m_numOfPads[BX]++;
59  } else {
60  throw std::out_of_range("problems loading Pad Output Data");
61  }
62 } // end-of-SectorL::load
63 //-------------------------------------------------------------------//
65  //
66  // temporary code to fill at least partially the output
67  // buffer of the sector logic
68  //
69  ubit16 i, j, k;
70  for (i = 0; i < m_nBunMax; i++) {
71  for (j = 0; j < m_numOfPads[i]; j++) {
72  if (m_sectorInput[i][j][2]) m_numberOfRoIs[i]++;
73  // if(m_sectorInput[i][j][2]) {
74  // cout<<" Bunch "<<i<<" PadInd "<<j<<" PT "<<m_sectorInput[i][j][2]
75  // <<endl;
76  // }//end-of-if(m_sectorInput[i][j][2]
77  for (k = 0; k < 2; k++) {
78  if (m_sectorInput[i][j][2] > m_pTArray[i][k][0]) {
79  storePT(i, j, k);
80  break;
81  } // end-of-if(m_sector
82  } // end-of-for(k
83  } // end-of-for(j
84  } // end-of-for(i
85  //
86  // for(i=0; i<m_nBunMax; i++) {
87  // cout<<" pTArray[0] pT= "<<m_pTArray[i][0][0]
88  // <<" padInd= "<<m_pTArray[i][0][1]<<endl
89  // <<" pTArray[1] pT= "<<m_pTArray[i][1][0]
90  // <<" padInd= "<<m_pTArray[i][1][1]<<endl
91  // <<" number of RoIs= "<<m_numberOfRoIs[i]<<endl;
92  //}
93  //
94  // now fill the output buffer
95  //
96  for (i = 0; i < m_nBunMax; i++) {
97  // TEMP: use m_sectorOut[i][8] and [9] to store OVL1 and OVL2
98 
99  m_sectorOut[i][8] = 0;
100  m_sectorOut[i][9] = 0;
101 
102  if (m_numberOfRoIs[i] > 2) m_sectorOut[i][0] = 1;
103  if (m_numberOfRoIs[i]) {
104  ubit16 padInd = m_pTArray[i][0][1];
105  m_sectorOut[i][1] = 4 * m_sectorInput[i][padInd][0] + m_sectorInput[i][padInd][1] + 1;
106  m_sectorOut[i][3] = m_sectorInput[i][padInd][2];
107  m_sectorOut[i][8] = m_sectorInput[i][padInd][4] + 2 * m_sectorInput[i][padInd][5];
108 
109  if (m_numberOfRoIs[i] > 1) {
110  ubit16 padInd = m_pTArray[i][1][1];
111  m_sectorOut[i][2] = 4 * m_sectorInput[i][padInd][0] + m_sectorInput[i][padInd][1] + 1;
112  m_sectorOut[i][4] = m_sectorInput[i][padInd][2];
113  m_sectorOut[i][9] = m_sectorInput[i][padInd][4] + 2 * m_sectorInput[i][padInd][5];
114 
115  } // end-of-if(m_numberOfRoIs[i]>1)
116  } // end-of-if(m_numberOfRoIs[i])
117  m_sectorOut[i][5] = 0; //>1 Candidate ROI1
118  m_sectorOut[i][6] = 0; //>1 Candidate ROI2
119  m_sectorOut[i][7] = 0; // BCID
120  // m_sectorOut[i][8] = 0;//candidate1 sign
121  // m_sectorOut[i][9] = 0;//candidate2 sign
122  if (!m_sectorOut[i][3]) m_sectorOut[i][3] = 7;
123  if (!m_sectorOut[i][4]) m_sectorOut[i][4] = 7;
124 
125  // cout<<" Bunch ID "<<i<<endl
126  // <<" >2 Candidates in a sector "<<m_sectorOut[i][0]<<endl
127  // <<" ROI 1 "<<m_sectorOut[i][1]<<endl
128  // <<" ROI 2 "<<m_sectorOut[i][2]<<endl
129  // <<" PT1 "<<m_sectorOut[i][3]<<endl
130  // <<" PT2 "<<m_sectorOut[i][4]<<endl
131  // <<" >1 Candidate ROI1 "<<m_sectorOut[i][5]<<endl
132  // <<" >1 Candidate ROI2 "<<m_sectorOut[i][6]<<endl
133  // <<" BCID counter "<<m_sectorOut[i][7]<<endl
134  // <<" Candidate1 sign "<<m_sectorOut[i][8]<<endl
135  // <<" Candidate2 sign "<<m_sectorOut[i][9]<<endl;
136  //
137  // now fille the Sector Logic Output word
138  //
139  m_sectorOutput[i] = m_sectorOut[i][0];
140  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][1] << 1); // ROI1
141  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][2] << 10); // ROI2
142  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][3] << 19); // PT1
143  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][4] << 22); // PT2
144  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][5] << 25); // more than 1 _1
145  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][6] << 26); // more than 1 _2
146  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][7] << 27); // BX
147  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][8] << 8); // OVL1
148  m_sectorOutput[i] = m_sectorOutput[i] | (m_sectorOut[i][9] << 17); // OVL2
149  }
150 } // end-of-SectorL::execute
151 //-------------------------------------------------------------------//
152 void SectorL::storePT(ubit16 bunch, ubit16 padInd, ubit16 modeInd) {
153  if (!modeInd) {
154  m_pTArray[bunch][1][0] = m_pTArray[bunch][0][0]; // copy pT
155  m_pTArray[bunch][1][1] = m_pTArray[bunch][0][1]; // copy padAdd
156  m_pTArray[bunch][0][0] = m_sectorInput[bunch][padInd][2];
157  m_pTArray[bunch][0][1] = padInd;
158  } else {
159  m_pTArray[bunch][1][0] = m_sectorInput[bunch][padInd][2];
160  m_pTArray[bunch][1][1] = padInd;
161  }
162 }
163 //-------------------------------------------------------------------//
165  if (i < m_nBunMax) {
166  return m_sectorOutput[i];
167  } else {
168  return 0xffffffff;
169  }
170 }
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
SectorL::m_run
int m_run
array lengths were dependant on NOBXS were updated to assume this is at most 8
Definition: SectorL.h:21
SectorL::output
CMAword output(ubit16 i)
Definition: SectorL.cxx:164
SectorL::m_pTArray
ubit16 m_pTArray[8][2][2]
Definition: SectorL.h:36
SectorL::m_padData
ubit16 m_padData
Definition: SectorL.h:32
SectorL::load
void load(ubit16 padAdd, ubit16 BX, ubit16 RoIAdd, ubit16 pT, ubit16 OPL, ubit16 overlapPhi, ubit16 overlapEta, ubit16 RoiAmbiguity, ubit16 BCIDcounter)
Definition: SectorL.cxx:47
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
SectorL::m_sectorOutput
CMAword m_sectorOutput[8]
Definition: SectorL.h:37
SectorL.h
SectorL::m_subsystem
ubit16 m_subsystem
Definition: SectorL.h:28
SectorL::~SectorL
~SectorL()
Definition: SectorL.cxx:45
Matrix.h
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
SectorL::m_sectorInput
ubit16 m_sectorInput[8][10][8]
Definition: SectorL.h:33
SectorL::m_sector
ubit16 m_sector
Definition: SectorL.h:29
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:92
SectorL::m_numOfPads
ubit16 m_numOfPads[8]
Definition: SectorL.h:31
SectorL::execute
void execute()
Definition: SectorL.cxx:64
SectorL::m_nBunMax
ubit16 m_nBunMax
Definition: SectorL.h:27
run
Definition: run.py:1
Hardware
@ Hardware
Definition: BaseObject.h:11
SectorL::storePT
void storePT(ubit16 i, ubit16 j, ubit16 k)
Definition: SectorL.cxx:152
BaseObject
Definition: BaseObject.h:13
SectorL::m_maxNumPads
ubit16 m_maxNumPads
Definition: SectorL.h:30
CMAword
uint32_t CMAword
Definition: Lvl1Def.h:17
Pad.h
SectorL::m_numberOfRoIs
ubit16 m_numberOfRoIs[8]
Definition: SectorL.h:34
SectorL::m_event
int m_event
Definition: SectorL.h:26
SectorL::SectorL
SectorL(int run, int event, CMAword debug, ubit16 subsys, ubit16 sect, uint NOBXS)
Definition: SectorL.cxx:18
SectorL::m_sectorOut
ubit16 m_sectorOut[8][10]
Definition: SectorL.h:35
ubit16
unsigned short int ubit16
Definition: RpcByteStreamEncoder.h:20
fitman.k
k
Definition: fitman.py:528