ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1CaloByteStream
src
JemRoiSubBlock.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
TrigT1CaloEvent/JEMRoI.h
"
7
8
#include "
JemRoiSubBlock.h
"
9
10
namespace
LVL1BS
{
11
12
// Constant definitions
13
14
const
int
JemRoiSubBlock::s_wordIdVal
;
15
16
const
int
JemRoiSubBlock::s_frames
;
17
const
int
JemRoiSubBlock::s_framesPerPin
;
18
const
int
JemRoiSubBlock::s_bunchCrossingPin
;
19
const
int
JemRoiSubBlock::s_hitsBits
;
20
const
int
JemRoiSubBlock::s_locationBits
;
21
const
int
JemRoiSubBlock::s_saturationBits
;
22
const
int
JemRoiSubBlock::s_bunchCrossingBits
;
23
const
int
JemRoiSubBlock::s_paddingBits
;
24
25
26
JemRoiSubBlock::JemRoiSubBlock
()
27
{
28
}
29
30
JemRoiSubBlock::~JemRoiSubBlock
()
31
{
32
}
33
34
// Clear all data
35
36
void
JemRoiSubBlock::clear
()
37
{
38
L1CaloSubBlock::clear
();
39
m_roiData
.clear();
40
}
41
42
// Store header
43
44
void
JemRoiSubBlock::setRoiHeader
(
const
int
version
,
const
int
crate
,
45
const
int
module
)
46
{
47
setHeader
(
s_wordIdVal
,
version
,
NEUTRAL
, 0,
crate
,
module
, 0, 1);
48
}
49
50
// Store RoI
51
52
void
JemRoiSubBlock::fillRoi
(
const
LVL1::JEMRoI
roi
)
53
{
54
const
LVL1::JEMRoI
roiTemp(
crate
(),
module
(), 0, 0, 0, 0, 0);
55
if
(
roi
.crate() == roiTemp.
crate
() &&
roi
.jem() == roiTemp.
jem
()) {
56
m_roiData
.resize(2*
s_frames
);
57
const
int
pos =
roi
.frame() +
roi
.forward()*
s_frames
;
58
m_roiData
[pos] =
roi
;
59
}
60
}
61
62
// Return RoI for given frame and forward
63
64
LVL1::JEMRoI
JemRoiSubBlock::roi
(
const
int
frame,
const
int
forward)
const
65
{
66
const
int
pos = frame + forward*
s_frames
;
67
if
(pos >= 0 && pos < 2*
s_frames
&& !
m_roiData
.empty()) {
68
return
m_roiData
[pos];
69
}
else
return
LVL1::JEMRoI
(0);
70
}
71
72
// Packing/Unpacking routines
73
74
bool
JemRoiSubBlock::pack
()
75
{
76
bool
rc
=
false
;
77
switch
(
version
()) {
78
case
1:
79
switch
(
format
()) {
80
case
NEUTRAL
:
81
rc
=
packNeutral
();
82
break
;
83
default
:
84
break
;
85
}
86
break
;
87
default
:
88
break
;
89
}
90
return
rc
;
91
}
92
93
bool
JemRoiSubBlock::unpack
()
94
{
95
bool
rc
=
false
;
96
switch
(
version
()) {
97
case
1:
98
switch
(
format
()) {
99
case
NEUTRAL
:
100
rc
=
unpackNeutral
();
101
break
;
102
default
:
103
setUnpackErrorCode
(
UNPACK_FORMAT
);
104
break
;
105
}
106
break
;
107
default
:
108
setUnpackErrorCode
(
UNPACK_VERSION
);
109
break
;
110
}
111
return
rc
;
112
}
113
114
// Pack neutral data
115
116
bool
JemRoiSubBlock::packNeutral
()
117
{
118
m_roiData
.resize(2*
s_frames
);
119
int
maxPin = 0;
120
// RoI data
121
for
(
int
pos = 0; pos < 2*
s_frames
; ++pos) {
122
const
LVL1::JEMRoI
&
roi
(
m_roiData
[pos]);
123
int
pin = pos/
s_framesPerPin
;
124
if
(pin >=
s_bunchCrossingPin
) ++pin;
// forward rois
125
packerNeutral
(pin,
roi
.hits(),
s_hitsBits
);
126
packerNeutral
(pin,
roi
.error(),
s_saturationBits
);
127
packerNeutral
(pin,
roi
.location(),
s_locationBits
);
128
maxPin = pin;
129
}
130
// Bunch Crossing number
131
packerNeutral
(
s_bunchCrossingPin
,
bunchCrossing
(),
s_bunchCrossingBits
);
132
packerNeutral
(
s_bunchCrossingPin
, 0,
s_paddingBits
);
133
// G-Link parity
134
for
(
int
pin = 0; pin <= maxPin; ++pin)
packerNeutralParity
(pin);
135
136
return
true
;
137
}
138
139
// Unpack neutral data
140
141
bool
JemRoiSubBlock::unpackNeutral
()
142
{
143
m_roiData
.resize(2*
s_frames
);
144
int
maxPin = 0;
145
int
forward = 0;
146
int
parity = 0;
147
// RoI data
148
for
(
int
pos = 0; pos < 2*
s_frames
; ++pos) {
149
int
pin = pos/
s_framesPerPin
;
150
if
(pin >=
s_bunchCrossingPin
) {
151
++pin;
152
forward = 1;
153
}
154
const
int
hits =
unpackerNeutral
(pin,
s_hitsBits
);
155
const
int
sat =
unpackerNeutral
(pin,
s_saturationBits
);
156
const
int
loc =
unpackerNeutral
(pin,
s_locationBits
);
157
const
int
err = (parity << 1) | sat;
158
m_roiData
[pos] =
LVL1::JEMRoI
(
crate
(),
module
(), pos%
s_frames
, loc,
159
forward, hits, err);
160
maxPin = pin;
161
}
162
// Bunch Crossing number
163
setBunchCrossing
(
unpackerNeutral
(
s_bunchCrossingPin
,
s_bunchCrossingBits
));
164
unpackerNeutral
(
s_bunchCrossingPin
,
s_paddingBits
);
165
// G-Link parity
166
parity = 1;
167
for
(
int
pin = 0; pin <= maxPin; ++pin) {
168
const
bool
error
=
unpackerNeutralParityError
(pin);
169
if
(pin ==
s_bunchCrossingPin
)
continue
;
170
if
(
error
) {
171
for
(
int
frame = 0; frame <
s_framesPerPin
; ++frame) {
172
int
pos = pin *
s_framesPerPin
+ frame;
173
if
(pin >
s_bunchCrossingPin
) pos -=
s_framesPerPin
;
174
const
LVL1::JEMRoI
roi
=
m_roiData
[pos];
175
const
int
err = (parity << 1) |
roi
.error();
176
m_roiData
[pos] =
LVL1::JEMRoI
(
roi
.crate(),
roi
.jem(),
roi
.frame(),
177
roi
.location(),
roi
.forward(),
178
roi
.hits(), err);
179
}
180
}
181
}
182
const
bool
rc
=
unpackerSuccess
();
183
if
(!
rc
)
setUnpackErrorCode
(
UNPACK_DATA_TRUNCATED
);
184
return
rc
;
185
}
186
187
}
// end namespace
JemRoiSubBlock.h
rc
static Double_t rc
Definition
LArPhysWaveHECTool.cxx:37
JEMRoI.h
LVL1BS::JemRoiSubBlock::s_framesPerPin
static const int s_framesPerPin
Definition
JemRoiSubBlock.h:53
LVL1BS::JemRoiSubBlock::pack
bool pack()
Pack data.
Definition
JemRoiSubBlock.cxx:74
LVL1BS::JemRoiSubBlock::m_roiData
std::vector< LVL1::JEMRoI > m_roiData
RoIs.
Definition
JemRoiSubBlock.h:67
LVL1BS::JemRoiSubBlock::s_bunchCrossingBits
static const int s_bunchCrossingBits
Definition
JemRoiSubBlock.h:58
LVL1BS::JemRoiSubBlock::packNeutral
bool packNeutral()
Pack neutral data.
Definition
JemRoiSubBlock.cxx:116
LVL1BS::JemRoiSubBlock::s_hitsBits
static const int s_hitsBits
Definition
JemRoiSubBlock.h:55
LVL1BS::JemRoiSubBlock::s_bunchCrossingPin
static const int s_bunchCrossingPin
Definition
JemRoiSubBlock.h:54
LVL1BS::JemRoiSubBlock::fillRoi
void fillRoi(LVL1::JEMRoI roi)
Store RoI.
Definition
JemRoiSubBlock.cxx:52
LVL1BS::JemRoiSubBlock::setRoiHeader
void setRoiHeader(int version, int crate, int module)
Store header.
Definition
JemRoiSubBlock.cxx:44
LVL1BS::JemRoiSubBlock::s_paddingBits
static const int s_paddingBits
Definition
JemRoiSubBlock.h:59
LVL1BS::JemRoiSubBlock::JemRoiSubBlock
JemRoiSubBlock()
Definition
JemRoiSubBlock.cxx:26
LVL1BS::JemRoiSubBlock::s_saturationBits
static const int s_saturationBits
Definition
JemRoiSubBlock.h:57
LVL1BS::JemRoiSubBlock::clear
void clear()
Clear all data.
Definition
JemRoiSubBlock.cxx:36
LVL1BS::JemRoiSubBlock::unpackNeutral
bool unpackNeutral()
Unpack neutral data.
Definition
JemRoiSubBlock.cxx:141
LVL1BS::JemRoiSubBlock::roi
LVL1::JEMRoI roi(int frame, int forward) const
Return RoI for given frame and forward.
Definition
JemRoiSubBlock.cxx:64
LVL1BS::JemRoiSubBlock::s_locationBits
static const int s_locationBits
Definition
JemRoiSubBlock.h:56
LVL1BS::JemRoiSubBlock::unpack
bool unpack()
Unpack data.
Definition
JemRoiSubBlock.cxx:93
LVL1BS::JemRoiSubBlock::~JemRoiSubBlock
~JemRoiSubBlock()
Definition
JemRoiSubBlock.cxx:30
LVL1BS::JemRoiSubBlock::s_frames
static const int s_frames
Definition
JemRoiSubBlock.h:52
LVL1BS::JemRoiSubBlock::s_wordIdVal
static const int s_wordIdVal
Header word ID.
Definition
JemRoiSubBlock.h:50
LVL1BS::L1CaloSubBlock::crate
int crate() const
Definition
L1CaloSubBlock.h:263
LVL1BS::L1CaloSubBlock::UNPACK_VERSION
@ UNPACK_VERSION
Definition
L1CaloSubBlock.h:38
LVL1BS::L1CaloSubBlock::UNPACK_FORMAT
@ UNPACK_FORMAT
Definition
L1CaloSubBlock.h:39
LVL1BS::L1CaloSubBlock::UNPACK_DATA_TRUNCATED
@ UNPACK_DATA_TRUNCATED
Definition
L1CaloSubBlock.h:40
LVL1BS::L1CaloSubBlock::NEUTRAL
@ NEUTRAL
Definition
L1CaloSubBlock.h:28
LVL1BS::L1CaloSubBlock::setUnpackErrorCode
void setUnpackErrorCode(int code)
Set the unpacking error code.
Definition
L1CaloSubBlock.h:338
LVL1BS::L1CaloSubBlock::unpackerSuccess
bool unpackerSuccess() const
Return unpacker success flag.
Definition
L1CaloSubBlock.h:354
LVL1BS::L1CaloSubBlock::setHeader
void setHeader(int wordId, int version, int format, int seqno, int crate, int module, int slices2, int slices1)
Store header data.
Definition
L1CaloSubBlock.cxx:99
LVL1BS::L1CaloSubBlock::unpackerNeutralParityError
bool unpackerNeutralParityError(int pin)
Unpack and test G-Link parity bit for given pin.
Definition
L1CaloSubBlock.cxx:464
LVL1BS::L1CaloSubBlock::clear
void clear()
Clear all data.
Definition
L1CaloSubBlock.cxx:82
LVL1BS::L1CaloSubBlock::packerNeutralParity
void packerNeutralParity(int pin)
Pack current G-Link parity bit for given pin.
Definition
L1CaloSubBlock.cxx:434
LVL1BS::L1CaloSubBlock::unpackerNeutral
uint32_t unpackerNeutral(int pin, int nbits)
Unpack given number of bits of neutral data for given pin.
Definition
L1CaloSubBlock.cxx:445
LVL1BS::L1CaloSubBlock::module
int module() const
Definition
L1CaloSubBlock.h:268
LVL1BS::L1CaloSubBlock::bunchCrossing
int bunchCrossing() const
Return the Bunch Crossing number (neutral format only).
Definition
L1CaloSubBlock.h:333
LVL1BS::L1CaloSubBlock::version
int version() const
Definition
L1CaloSubBlock.h:243
LVL1BS::L1CaloSubBlock::packerNeutral
void packerNeutral(int pin, uint32_t datum, int nbits)
Pack given neutral data from given pin.
Definition
L1CaloSubBlock.cxx:413
LVL1BS::L1CaloSubBlock::format
int format() const
Definition
L1CaloSubBlock.h:248
LVL1BS::L1CaloSubBlock::setBunchCrossing
void setBunchCrossing(int bc)
Set the Bunch Crossing number (neutral format only).
Definition
L1CaloSubBlock.h:328
LVL1::JEMRoI
JEM RoI data.
Definition
Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:19
LVL1::JEMRoI::jem
int jem() const
Return JEM number (0-15).
Definition
Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:92
LVL1::JEMRoI::crate
int crate() const
Return crate number (0-1).
Definition
Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JEMRoI.h:87
LVL1BS
Definition
ZdcModifySlices.h:10
error
Definition
IImpactPoint3dEstimator.h:72
Generated on
for ATLAS Offline Software by
1.17.0