ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1RPChardware
src
SectorLogicReadOut.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigT1RPChardware/SectorLogicReadOut.h
"
6
7
#include <cstring>
8
#include <fstream>
9
#include <iomanip>
10
#include <iostream>
11
#include <stdexcept>
12
13
#include "
MuonCablingTools/BaseObject.h
"
14
15
using namespace
std
;
16
17
//----------------------------------------------------------------------------//
18
SectorLogicReadOut::SectorLogicReadOut
() :
BaseObject
(
Hardware
,
"SectorLogicReadOut"
) {
initialize
(); }
// end-of-SectorLogicReadOut
19
//----------------------------------------------------------------------------//
20
SectorLogicReadOut::SectorLogicReadOut
(
const
SectorLogicReadOut
&SLROOrig) :
BaseObject
(
Hardware
,
"SectorLogicReadOut"
) {
21
//
22
// copy constructor
23
//
24
m_Header
= SLROOrig.
m_Header
;
25
m_Footer
= SLROOrig.
m_Footer
;
26
m_numberOfWordsInFrag
= SLROOrig.
m_numberOfWordsInFrag
;
27
m_numberOfWordsInBody
= SLROOrig.
m_numberOfWordsInBody
;
28
m_numberOfWordsInCounters
= SLROOrig.
m_numberOfWordsInCounters
;
29
m_numberOfWordsInSLHits
= SLROOrig.
m_numberOfWordsInSLHits
;
30
m_counter32ok
= SLROOrig.
m_counter32ok
;
31
m_hitok
= SLROOrig.
m_hitok
;
32
for
(
ubit16
i = 0; i <
s_numberOfDataCounters
; i++) {
m_counter16
[i] = SLROOrig.
m_counter16
[i]; }
33
for
(
ubit16
i = 0; i <
s_numberOfDecodedCounters
; i++) {
m_counter32
[i] = SLROOrig.
m_counter32
[i]; }
34
for
(
int
i = 0; i <
s_nLinks
; ++i) {
35
for
(
int
j = 0; j <
s_nGates
; ++j) {
m_hit
[i][j] = SLROOrig.
m_hit
[i][j]; }
36
}
37
//
38
// Copy Dynamic structure
39
//
40
SLROData
*q = 0;
41
SLROData
*
r
= 0;
42
SLROData
*p = SLROOrig.
m_Body
;
43
ubit16
cnter = 0;
44
while
(p) {
45
q =
new
SLROData
;
46
q->hit = p->hit;
47
q->next = 0;
48
if
(!cnter) {
49
m_Body
= q;
50
// if(cnter==(nGates*nLinks)) m_BodyCounter = q;
51
}
else
52
r
->next = q;
53
cnter++;
54
r
= q;
55
p = p->next;
56
}
// end-of-while
57
m_BodyLast
=
r
;
58
}
// end-of-SectorLogicReadOut
59
//----------------------------------------------------------------------------//
60
SectorLogicReadOut::~SectorLogicReadOut
() {
61
//
62
// delete the SLROData dynamic structure used to describe Body part
63
// of the event fragment.
64
//
65
deleteSLBody
();
66
}
67
//----------------------------------------------------------------------------//
68
void
SectorLogicReadOut::deleteSLBody
() {
69
SLROData
*p{
nullptr
}, *q{
nullptr
};
70
p =
m_Body
;
71
while
(p) {
72
q = p;
73
p = p->next;
74
delete
q;
75
}
// end-of-while
76
m_Body
= 0;
77
m_BodyLast
= 0;
78
m_BodyCurr
= 0;
79
m_BodyCounter
= 0;
80
m_numberOfWordsInBody
= 0;
81
}
// end-of-deleteSLBody
82
//----------------------------------------------------------------------------//
83
void
SectorLogicReadOut::initialize
() {
84
// initialize check flags
85
//
86
m_numberOfWordsInCounters
=
s_numberOfDataCounters
;
87
for
(
int
i = 0; i <
s_nLinks
; ++i) {
88
for
(
int
j = 0; j <
s_nGates
; ++j) {
m_hit
[i][j] = 0; }
89
}
90
91
}
// end-of-initialize
92
//----------------------------------------------------------------------------//
93
void
SectorLogicReadOut::reset
() {
94
//
95
// reset the data structure to host a new fragment;
96
// first delete the dinamyc structure...
97
deleteSLBody
();
98
// then initialize the data members.
99
initialize
();
100
}
// end-of-SectorLogicReadOut::reset()
101
//----------------------------------------------------------------------------//
102
void
SectorLogicReadOut::writeRecord
(
ubit16
thisRecord,
bool
last) {
103
if
(
m_numberOfWordsInFrag
== 0) {
104
m_Header
= thisRecord;
105
}
else
if
(
m_numberOfWordsInFrag
&& !last) {
106
makeNewHit
(thisRecord);
107
}
else
{
108
m_Footer
= thisRecord;
109
}
110
m_numberOfWordsInFrag
++;
111
}
// end-of-void SectorLogicReadOut
112
//----------------------------------------------------------------------------//
113
void
SectorLogicReadOut::makeNewHit
(
ubit16
newHit) {
114
SLROData
*p;
115
p =
new
SLROData
;
116
p->hit = newHit;
117
p->next = 0;
118
if
(!
m_Body
) {
119
m_Body
= p;
120
}
else
{
121
m_BodyLast
->next = p;
122
}
// end-of-if
123
m_BodyLast
= p;
124
if
(!
m_numberOfWordsInBody
)
topSLBody
();
125
m_numberOfWordsInBody
++;
126
if
(
m_numberOfWordsInBody
>
m_numberOfWordsInCounters
)
m_numberOfWordsInSLHits
= (
m_numberOfWordsInBody
-
m_numberOfWordsInCounters
);
127
}
// end-of-SectorLogicReadOut::makeNewHit
128
//----------------------------------------------------------------------------//
129
ubit16
SectorLogicReadOut::readSLHitCurrent
() {
130
if
(
m_BodyCurr
) {
131
ubit16
hit
=
m_BodyCurr
->hit;
132
m_BodyCurr
=
m_BodyCurr
->next;
133
return
hit
;
134
}
else
{
135
return
0xefac;
136
}
137
}
// end-of-SectorLogicReadOut::readSLHitCurrent
138
//----------------------------------------------------------------------------//
139
ubit16
SectorLogicReadOut::readSLCounterCurrent
() {
140
if
(
m_Body
and !
m_BodyCounter
) {
141
SLROData
*
temp
=
m_Body
;
142
for
(
ubit16
i = 0; i <
numberOfHitWords
(); i++) {
143
if
(
temp
->next)
temp
=
temp
->next;
144
}
145
if
(
temp
)
m_BodyCounter
=
temp
;
146
m_BodyCurr
=
m_BodyCounter
;
147
}
148
//
149
if
(
m_BodyCurr
) {
150
ubit16
hit
=
m_BodyCurr
->hit;
151
m_BodyCurr
=
m_BodyCurr
->next;
152
return
hit
;
153
}
else
{
154
return
0xcafe;
155
}
156
}
// end-of-SectorLogicReadOut::readSLCounterCurrent
157
//----------------------------------------------------------------------------//
158
void
SectorLogicReadOut::doCounter32
() {
159
topSLBodyCounters
();
160
for
(
ubit16
i = 0; i <
m_numberOfWordsInCounters
; i++) {
m_counter16
[i] =
readSLCounterCurrent
() & 0x1fff; }
161
//
162
ubit16
j = 0;
163
for
(
ubit16
i = 0; i <
s_numberOfDecodedCounters
; i++) {
164
m_counter32
[i] = (
m_counter16
[j] | (
m_counter16
[j + 1] << 13) | (
m_counter16
[j + 2] << 26));
165
j += 3;
166
}
167
}
// end-of-SectorLogicReadOut::doCounter32()
168
//----------------------------------------------------------------------------//
169
RODword
SectorLogicReadOut::getCounter32
(
ubit16
index
) {
170
if
(!
m_counter32ok
) {
171
doCounter32
();
172
m_counter32ok
=
true
;
173
}
174
if
(
index
<
s_numberOfDecodedCounters
) {
175
return
m_counter32
[
index
];
176
}
else
{
177
throw
std::out_of_range(
"SectorLogicReadout::getCounter32: index="
+ std::to_string(
index
) +
" is larger than "
+
178
std::to_string(
s_numberOfDecodedCounters
));
179
}
180
}
181
//----------------------------------------------------------------------------//
182
float
SectorLogicReadOut::padTriggerRate
(
ubit16
padAddress) {
183
if
(!
m_counter32ok
)
doCounter32
();
184
//
185
// units are kHz
186
//
187
static
const
float
convertToTriggerRate = 160314.74 / 4.0;
// units are kHz
188
if
(padAddress < ((
s_numberOfDecodedCounters
- 3) / 2)) {
189
return
convertToTriggerRate * (float(
m_counter32
[padAddress * 2 + 1]) / float(
m_counter32
[padAddress * 2 + 0]));
190
}
else
{
191
throw
std::out_of_range(
"SectorLogicReadout::padTrigger: input padAddress="
+ std::to_string(padAddress) +
" is not possible"
);
192
}
193
}
194
//----------------------------------------------------------------------------//
195
void
SectorLogicReadOut::doHit
() {
196
topSLBody
();
197
for
(
ubit16
j = 0; j <
s_nGates
; j++) {
198
for
(
ubit16
i = 0; i <
s_nLinks
; i++) {
m_hit
[i][j] =
readSLHitCurrent
(); }
// end-of-for(ubit16 i
199
}
// end-of-for(ubit16 j
200
}
// end-of-SectorLogicReadOut::doHit()
201
//----------------------------------------------------------------------------//
202
ubit16
SectorLogicReadOut::cmadd
(
ubit16
indexLink,
ubit16
indexGate) {
203
if
(!
m_hitok
)
doHit
();
204
if
(indexLink <
s_nLinks
&& indexGate <
s_nGates
) {
205
return
(
m_hit
[indexLink][indexGate]) & 0x3;
206
}
else
{
207
throw
std::out_of_range(
"SectorLogicReadout::cmid: indexLink or indexGate out of range"
);
208
}
209
}
// end-of-SectorLogicReadOut::cmid(ubit16 indexLink, ubit16 indexGate)
210
//----------------------------------------------------------------------------//
211
ubit16
SectorLogicReadOut::ptid
(
ubit16
indexLink,
ubit16
indexGate) {
212
if
(!
m_hitok
)
doHit
();
213
if
(indexLink <
s_nLinks
&& indexGate <
s_nGates
) {
214
return
(
m_hit
[indexLink][indexGate] >> 2) & 0x7;
215
}
else
{
216
throw
std::out_of_range(
"SectorLogicReadout::ptid: indexLink or indexGate out of range"
);
217
}
218
}
// end-of-SectorLogicReadOut::ptid(ubit16 indexLink, ubit16 indexGate)
219
//----------------------------------------------------------------------------//
220
ubit16
SectorLogicReadOut::opl
(
ubit16
indexLink,
ubit16
indexGate) {
221
if
(!
m_hitok
)
doHit
();
222
if
(indexLink <
s_nLinks
&& indexGate <
s_nGates
) {
223
return
(
m_hit
[indexLink][indexGate] >> 5) & 0x1;
224
}
else
{
225
throw
std::out_of_range(
"SectorLogicReadout::opl: indexLink or indexGate out of range"
);
226
}
227
}
// end-of-SectorLogicReadOut::opl(ubit16 indexLink, ubit16 indexGate)
228
//----------------------------------------------------------------------------//
229
ubit16
SectorLogicReadOut::ovphi
(
ubit16
indexLink,
ubit16
indexGate) {
230
if
(!
m_hitok
)
doHit
();
231
if
(indexLink <
s_nLinks
&& indexGate <
s_nGates
) {
232
return
(
m_hit
[indexLink][indexGate] >> 6) & 0x1;
233
}
else
{
234
throw
std::out_of_range(
"SectorLogicReadout::ovphi: indexLink or indexGate out of range"
);
235
}
236
}
// end-of-SectorLogicReadOut::ovphi(ubit16 indexLink, ubit16 indexGate)
237
//----------------------------------------------------------------------------//
238
ubit16
SectorLogicReadOut::oveta
(
ubit16
indexLink,
ubit16
indexGate) {
239
if
(!
m_hitok
)
doHit
();
240
if
(indexLink <
s_nLinks
&& indexGate <
s_nGates
) {
241
return
(
m_hit
[indexLink][indexGate] >> 7) & 0x1;
242
}
else
{
243
throw
std::out_of_range(
"SectorLogicReadout::oveta: indexLink or indexGate out of range"
);
244
}
245
}
// end-of-SectorLogicReadOut::oveta(ubit16 indexLink, ubit16 indexGate)
246
//----------------------------------------------------------------------------//
247
ubit16
SectorLogicReadOut::res
(
ubit16
indexLink,
ubit16
indexGate) {
248
if
(!
m_hitok
)
doHit
();
249
if
(indexLink <
s_nLinks
&& indexGate <
s_nGates
) {
250
return
(
m_hit
[indexLink][indexGate] >> 8) & 0x1;
251
}
else
{
252
throw
std::out_of_range(
"SectorLogicReadout::res : indexLink or indexGate out of range"
);
253
}
254
}
// end-of-SectorLogicReadOut::res(ubit16 indexLink, ubit16 indexGate)
255
//----------------------------------------------------------------------------//
256
ubit16
SectorLogicReadOut::bcid
(
ubit16
indexLink,
ubit16
indexGate) {
257
if
(!
m_hitok
)
doHit
();
258
if
(indexLink <
s_nLinks
&& indexGate <
s_nGates
) {
259
return
(
m_hit
[indexLink][indexGate] >> 9) & 0x7;
260
}
else
{
261
throw
std::out_of_range(
"SectorLogicReadout::bcid: indexLink or indexGate out of range"
);
262
}
263
}
// end-of-SectorLogicReadOut::bcid(ubit16 indexLink, ubit16 indexGate)
264
//----------------------------------------------------------------------------//
265
void
SectorLogicReadOut::display
(std::ostream &stream) {
266
stream <<
" **** Sector Logic ReadOut Fragment ****"
<< std::endl;
267
stream <<
" SectorLogic: number of Hits :"
<<
m_numberOfWordsInSLHits
<< std::endl;
268
stream <<
" SectorLogic: number of Counters:"
<<
m_numberOfWordsInCounters
<< std::endl;
269
stream <<
" SectorLogic: Header "
<< std::hex <<
m_Header
<< std::dec << std::endl;
270
for
(
ubit16
i = 0; i <
m_numberOfWordsInSLHits
; i++) {
271
stream <<
" SectorLogic: hit "
<< (i + 1) <<
" ==> "
<< std::hex <<
readSLHitCurrent
() << std::dec << std::endl;
272
}
273
stream <<
" SectorLogic: Footer "
<< std::hex <<
m_Footer
<< std::dec << std::endl;
274
for
(
ubit16
i = 0; i <
m_numberOfWordsInCounters
; i++) {
275
stream <<
" SectorLogic: counter "
<< (i + 1) <<
" ==> "
<< std::hex <<
readSLCounterCurrent
() << std::dec << std::endl;
276
}
277
for
(
int
i = 0; i <
s_numberOfDecodedCounters
; i++) {
278
stream <<
" SectorLogic: Counter32 "
<< (i + 1) <<
" ==> "
279
<<
" = "
<< std::hex <<
getCounter32
(i) << std::dec << std::endl;
280
}
281
stream <<
" SectorLogic: Pad 0 trigger rate: "
<<
padTriggerRate
(0) <<
" kHz"
<< std::endl;
282
stream <<
" SectorLogic: Pad 1 trigger rate: "
<<
padTriggerRate
(1) <<
" kHz"
<< std::endl;
283
}
// end-of-void SectorLogicReadOut::display
284
//----------------------------------------------------------------------------//
285
bool
SectorLogicReadOut::checkFragment
() {
286
return
(
m_numberOfWordsInBody
== (
s_nGates
*
s_nLinks
+
s_numberOfDataCounters
));
287
}
// end-of-void SectorLogicReadOut::checkFragment()
BaseObject.h
Hardware
@ Hardware
Definition
BaseObject.h:11
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
RODword
uint32_t RODword
Definition
Lvl1Def.h:18
ubit16
unsigned short int ubit16
Definition
RpcByteStreamEncoder.h:20
SectorLogicReadOut.h
BaseObject::BaseObject
BaseObject(ObjectType, const std::string &)
Definition
BaseObject.cxx:7
SectorLogicReadOut::ptid
ubit16 ptid(ubit16 indexLink, ubit16 indexGate)
Definition
SectorLogicReadOut.cxx:211
SectorLogicReadOut::oveta
ubit16 oveta(ubit16 indexLink, ubit16 indexGate)
Definition
SectorLogicReadOut.cxx:238
SectorLogicReadOut::opl
ubit16 opl(ubit16 indexLink, ubit16 indexGate)
Definition
SectorLogicReadOut.cxx:220
SectorLogicReadOut::ovphi
ubit16 ovphi(ubit16 indexLink, ubit16 indexGate)
Definition
SectorLogicReadOut.cxx:229
SectorLogicReadOut::m_numberOfWordsInCounters
ubit16 m_numberOfWordsInCounters
Definition
SectorLogicReadOut.h:94
SectorLogicReadOut::m_BodyLast
SLROData * m_BodyLast
Definition
SectorLogicReadOut.h:73
SectorLogicReadOut::m_counter32
std::array< RODword, s_numberOfDecodedCounters > m_counter32
Definition
SectorLogicReadOut.h:84
SectorLogicReadOut::deleteSLBody
void deleteSLBody()
Definition
SectorLogicReadOut.cxx:68
SectorLogicReadOut::display
void display(std::ostream &stream)
Definition
SectorLogicReadOut.cxx:265
SectorLogicReadOut::m_Footer
ubit16 m_Footer
Definition
SectorLogicReadOut.h:89
SectorLogicReadOut::numberOfHitWords
ubit16 numberOfHitWords()
Definition
SectorLogicReadOut.h:29
SectorLogicReadOut::topSLBody
void topSLBody()
Definition
SectorLogicReadOut.h:31
SectorLogicReadOut::reset
void reset()
Definition
SectorLogicReadOut.cxx:93
SectorLogicReadOut::padTriggerRate
float padTriggerRate(ubit16 padAddress)
Definition
SectorLogicReadOut.cxx:182
SectorLogicReadOut::doCounter32
void doCounter32()
Definition
SectorLogicReadOut.cxx:158
SectorLogicReadOut::m_Header
ubit16 m_Header
Definition
SectorLogicReadOut.h:88
SectorLogicReadOut::cmadd
ubit16 cmadd(ubit16 indexLink, ubit16 indexGate)
Definition
SectorLogicReadOut.cxx:202
SectorLogicReadOut::bcid
ubit16 bcid(ubit16 indexLink, ubit16 indexGate)
Definition
SectorLogicReadOut.cxx:256
SectorLogicReadOut::checkFragment
bool checkFragment()
Definition
SectorLogicReadOut.cxx:285
SectorLogicReadOut::topSLBodyCounters
void topSLBodyCounters()
Definition
SectorLogicReadOut.h:32
SectorLogicReadOut::SectorLogicReadOut
SectorLogicReadOut()
Definition
SectorLogicReadOut.cxx:18
SectorLogicReadOut::getCounter32
RODword getCounter32(ubit16 index)
Definition
SectorLogicReadOut.cxx:169
SectorLogicReadOut::s_numberOfDataCounters
static const ubit16 s_numberOfDataCounters
Definition
SectorLogicReadOut.h:81
SectorLogicReadOut::m_counter16
std::array< ubit16, s_numberOfDataCounters > m_counter16
Definition
SectorLogicReadOut.h:83
SectorLogicReadOut::m_numberOfWordsInBody
ubit16 m_numberOfWordsInBody
Definition
SectorLogicReadOut.h:93
SectorLogicReadOut::m_numberOfWordsInFrag
ubit16 m_numberOfWordsInFrag
Definition
SectorLogicReadOut.h:92
SectorLogicReadOut::~SectorLogicReadOut
~SectorLogicReadOut()
Definition
SectorLogicReadOut.cxx:60
SectorLogicReadOut::s_nLinks
static constexpr ubit16 s_nLinks
Definition
SectorLogicReadOut.h:77
SectorLogicReadOut::m_BodyCurr
SLROData * m_BodyCurr
Definition
SectorLogicReadOut.h:74
SectorLogicReadOut::m_numberOfWordsInSLHits
ubit16 m_numberOfWordsInSLHits
Definition
SectorLogicReadOut.h:95
SectorLogicReadOut::m_hit
ubit16 m_hit[s_nLinks][s_nGates]
Definition
SectorLogicReadOut.h:79
SectorLogicReadOut::s_numberOfDecodedCounters
static const ubit16 s_numberOfDecodedCounters
Definition
SectorLogicReadOut.h:82
SectorLogicReadOut::makeNewHit
void makeNewHit(ubit16 newHit)
Definition
SectorLogicReadOut.cxx:113
SectorLogicReadOut::res
ubit16 res(ubit16 indexLink, ubit16 indexGate)
Definition
SectorLogicReadOut.cxx:247
SectorLogicReadOut::doHit
void doHit()
Definition
SectorLogicReadOut.cxx:195
SectorLogicReadOut::initialize
void initialize()
Definition
SectorLogicReadOut.cxx:83
SectorLogicReadOut::writeRecord
void writeRecord(ubit16 newHit, bool last)
Definition
SectorLogicReadOut.cxx:102
SectorLogicReadOut::s_nGates
static constexpr ubit16 s_nGates
Definition
SectorLogicReadOut.h:76
SectorLogicReadOut::readSLCounterCurrent
ubit16 readSLCounterCurrent()
Definition
SectorLogicReadOut.cxx:139
SectorLogicReadOut::m_hitok
bool m_hitok
Definition
SectorLogicReadOut.h:87
SectorLogicReadOut::m_counter32ok
bool m_counter32ok
Definition
SectorLogicReadOut.h:86
SectorLogicReadOut::m_Body
SLROData * m_Body
Definition
SectorLogicReadOut.h:90
SectorLogicReadOut::m_BodyCounter
SLROData * m_BodyCounter
Definition
SectorLogicReadOut.h:91
SectorLogicReadOut::readSLHitCurrent
ubit16 readSLHitCurrent()
Definition
SectorLogicReadOut.cxx:129
r
int r
Definition
globals.cxx:22
index
Definition
index.py:1
std
STL namespace.
SectorLogicReadOut::SLROData
Definition
SectorLogicReadOut.h:67
temp
Definition
JetEventDict.h:21
Generated on
for ATLAS Offline Software by
1.17.0