ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1CaloUtils
src
CrateEnergy.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
/***************************************************************************
5
CrateEnergy.h - description
6
-------------------
7
begin : 06/09/2007
8
email : Alan.Watson@cern.ch
9
***************************************************************************/
10
11
12
#include "
TrigT1CaloUtils/CrateEnergy.h
"
13
#include <iostream>
14
#include <stdexcept>
15
16
namespace
LVL1
{
17
18
CrateEnergy::CrateEnergy
(
unsigned
int
crate
,
const
DataVector<ModuleEnergy>
* JEMs, uint32_t maskXE, uint32_t maskTE,
bool
restricted
):
19
m_crate
(
crate
),
20
m_crateEt
(0),
21
m_crateEx
(0),
22
m_crateEy
(0),
23
m_overflowT
(0),
24
m_overflowX
(0),
25
m_overflowY
(0),
26
m_restricted
(
restricted
),
27
m_debug
(false)
28
{
30
if
(
m_crate
> 1)
return
;
31
33
if
((maskXE&0xff) != 0xff || (maskTE&0xff) != 0xff)
m_restricted
=
true
;
34
40
42
unsigned
int
eT[2] = {0,0};
43
unsigned
int
eX[2] = {0,0};
44
unsigned
int
eY[2] = {0,0};
45
for
(
const
ModuleEnergy
* jem : *JEMs ) {
46
int
moduleInQuad = jem->module() % 8;
47
if
(jem->crate() ==
m_crate
) {
48
int
quad = ( jem->module() < 8 ? 0 : 1 );
49
if
((maskTE>>moduleInQuad)&1) {
50
eT[quad] += jem->et();
51
if
( jem->et() >=
m_jemEtSaturation
)
m_overflowT
= 1;
52
}
53
if
((maskXE>>moduleInQuad)&1) {
54
eX[quad] += jem->ex();
55
eY[quad] += jem->ey();
56
if
( jem->ex() >=
m_jemEtSaturation
)
m_overflowX
= 1;
57
if
( jem->ey() >=
m_jemEtSaturation
)
m_overflowY
= 1;
58
}
59
}
// Right crate?
60
}
// Loop over JEMs
61
63
const
unsigned
int
mask = (1U <<
m_sumBits
) - 1U;
64
const
int
overflowValue = -
static_cast<
int
>
(mask + 1U);
67
m_crateEt
= eT[0] + eT[1];
68
if
(
m_crateEt
>= mask){
69
m_overflowT
= 1;
70
m_crateEt
= mask;
71
}
72
73
74
if
(!
m_overflowX
) {
75
m_crateEx
=
static_cast<
int
>
(eX[0]) -
static_cast<
int
>
(eX[1]);
76
}
else
{
77
m_crateEx
= overflowValue;
78
}
79
80
if
(!
m_overflowY
) {
81
m_crateEy
=
static_cast<
int
>
(eY[0]) -
static_cast<
int
>
(eY[1]);
82
}
else
{
83
m_crateEy
= overflowValue;
84
}
85
86
87
if
(
m_debug
) {
88
std::cout <<
"CrateEnergy: crate "
<<
m_crate
<<
" results "
89
<<
"\n Et "
<<
m_crateEt
<<
" overflow "
<<
m_overflowT
90
<<
"\n Ex "
<<
m_crateEx
<<
" overflow "
<<
m_overflowX
91
<<
"\n Ey "
<<
m_crateEy
<<
" overflow "
<<
m_overflowY
<< std::endl;
92
93
}
94
95
}
96
97
CrateEnergy::CrateEnergy
(
unsigned
int
crate
,
const
DataVector<EnergyCMXData>
* JEMs, uint32_t maskXE, uint32_t maskTE,
bool
restricted
):
98
m_crate
(
crate
),
99
m_crateEt
(0),
100
m_crateEx
(0),
101
m_crateEy
(0),
102
m_overflowT
(0),
103
m_overflowX
(0),
104
m_overflowY
(0),
105
m_restricted
(
restricted
),
106
m_debug
(false)
107
{
109
if
(
m_crate
> 1)
return
;
110
112
if
((maskXE&0xff) != 0xff || (maskTE&0xff) != 0xff)
m_restricted
=
true
;
113
119
121
unsigned
int
eT[2] = {0,0};
122
unsigned
int
eX[2] = {0,0};
123
unsigned
int
eY[2] = {0,0};
124
for
(
const
EnergyCMXData
* jem : *JEMs ) {
125
int
moduleInQuad = jem->module() % 8;
126
if
((
unsigned
int
)jem->crate() ==
m_crate
) {
127
int
quad = ( jem->module() < 8 ? 0 : 1 );
128
129
if
((maskTE>>moduleInQuad)&1) {
130
eT[quad] += jem->Et();
131
if
( jem->Et() >=
m_jemEtSaturation
)
m_overflowT
= 1;
132
}
133
if
((maskXE>>moduleInQuad)&1) {
134
eX[quad] += jem->Ex();
135
eY[quad] += jem->Ey();
136
if
( jem->Ex() >=
m_jemEtSaturation
)
m_overflowX
= 1;
137
if
( jem->Ey() >=
m_jemEtSaturation
)
m_overflowY
= 1;
138
}
139
}
140
}
141
143
unsigned
int
mask = (1<<
m_sumBits
) - 1;
144
145
148
m_crateEt
= eT[0] + eT[1];
149
if
(
m_crateEt
>= mask){
150
m_overflowT
= 1;
151
m_crateEt
= mask;
152
}
153
154
if
(!
m_overflowX
){
155
m_crateEx
= eX[0] - eX[1];
156
}
else
{
157
if
(std::in_range<int>(-(
static_cast<
int
>
(mask) + 1)))
m_crateEx
= -(
static_cast<
int
>
(mask) + 1);
158
else
throw
std::out_of_range(
"m_crateEx set value is out of integer range"
);
159
}
160
if
(!
m_overflowY
){
161
m_crateEy
= eY[0] - eY[1];
162
}
else
{
163
if
(std::in_range<int>(-(
static_cast<
int
>
(mask) + 1)))
m_crateEy
= -(
static_cast<
int
>
(mask) + 1);
164
else
throw
std::out_of_range(
"m_crateEy set value is out of integer range"
);
165
}
166
167
if
(
m_debug
) {
168
std::cout <<
"CrateEnergy: crate "
<<
m_crate
<<
" results "
169
<<
"\n Et "
<<
m_crateEt
<<
" overflow "
<<
m_overflowT
170
<<
"\n Ex "
<<
m_crateEx
<<
" overflow "
<<
m_overflowX
171
<<
"\n Ey "
<<
m_crateEy
<<
" overflow "
<<
m_overflowY
<< std::endl;
172
173
}
174
175
}
176
177
CrateEnergy::CrateEnergy
(
unsigned
int
crate
,
unsigned
int
et
,
unsigned
int
exTC
,
178
unsigned
int
eyTC
,
unsigned
int
overflowT,
unsigned
int
overflowX,
179
unsigned
int
overflowY,
bool
restricted
) :
180
m_crate
(
crate
),
181
m_crateEt
(0),
182
m_crateEx
(0),
183
m_crateEy
(0),
184
m_overflowT
(0),
185
m_overflowX
(0),
186
m_overflowY
(0),
187
m_restricted
(
restricted
),
188
m_debug
(false)
189
{
191
if
(
m_crate
> 1)
return
;
192
m_crateEt
=
et
;
193
m_crateEx
=
decodeTC
(
exTC
);
194
m_crateEy
=
decodeTC
(
eyTC
);
195
m_overflowT
= overflowT;
196
m_overflowX
= overflowX;
197
m_overflowY
= overflowY;
198
199
if
(
m_debug
) {
200
std::cout <<
"CrateEnergy: crate "
<<
m_crate
<<
" results "
201
<<
"\n Et "
<<
m_crateEt
<<
" overflow "
<<
m_overflowT
202
<<
"\n Ex "
<<
m_crateEx
<<
" overflow "
<<
m_overflowX
203
<<
"\n Ey "
<<
m_crateEy
<<
" overflow "
<<
m_overflowY
<< std::endl;
204
205
}
206
}
207
208
209
CrateEnergy::~CrateEnergy
(){
210
}
211
213
unsigned
int
CrateEnergy::crate
()
const
{
214
return
m_crate
;
215
}
216
218
int
CrateEnergy::et
()
const
{
219
return
m_crateEt
;
220
}
221
223
int
CrateEnergy::ex
()
const
{
224
return
m_crateEx
;
225
}
226
228
int
CrateEnergy::ey
()
const
{
229
return
m_crateEy
;
230
}
231
233
unsigned
int
CrateEnergy::etOverflow
()
const
{
234
return
m_overflowT
;
235
}
236
238
unsigned
int
CrateEnergy::exOverflow
()
const
{
239
return
m_overflowX
;
240
}
241
243
unsigned
int
CrateEnergy::eyOverflow
()
const
{
244
return
m_overflowY
;
245
}
246
248
bool
CrateEnergy::restricted
()
const
{
249
return
m_restricted
;
250
}
251
253
unsigned
int
CrateEnergy::exTC
()
const
{
254
return
encodeTC
(
m_crateEx
);
255
}
256
258
unsigned
int
CrateEnergy::eyTC
()
const
{
259
return
encodeTC
(
m_crateEy
);
260
}
261
263
unsigned
int
CrateEnergy::encodeTC
(
int
input)
const
{
264
unsigned
int
value;
265
266
if
(input > 0) {
267
value = input;
268
}
269
else
{
270
value = (1<<
m_sumBitsTC
) + input;
271
}
272
273
int
mask = (1<<
m_sumBitsTC
) - 1;
274
return
value&mask ;
275
}
276
278
int
CrateEnergy::decodeTC
(
unsigned
int
input)
const
{
279
280
int
mask = (1<<
m_sumBitsTC
) - 1;
281
int
value = input&mask;
282
283
if
((value >> (
m_sumBitsTC
- 1))) {
284
value += (~0U) <<
m_sumBitsTC
;
285
}
286
287
return
value;
288
}
289
}
// end of ns
CrateEnergy.h
DataVector
Derived DataVector<T>.
Definition
DataVector.h:795
LVL1::CrateEnergy::crate
unsigned int crate() const
return crate number
Definition
CrateEnergy.cxx:213
LVL1::CrateEnergy::ex
int ex() const
return crate Ex
Definition
CrateEnergy.cxx:223
LVL1::CrateEnergy::m_overflowT
unsigned int m_overflowT
Definition
CrateEnergy.h:60
LVL1::CrateEnergy::ey
int ey() const
return crate Ey
Definition
CrateEnergy.cxx:228
LVL1::CrateEnergy::et
int et() const
return et, ex, ey sums
Definition
CrateEnergy.cxx:218
LVL1::CrateEnergy::m_sumBits
static const unsigned int m_sumBits
Definition
CrateEnergy.h:66
LVL1::CrateEnergy::m_restricted
bool m_restricted
Definition
CrateEnergy.h:63
LVL1::CrateEnergy::m_crateEx
int m_crateEx
Definition
CrateEnergy.h:58
LVL1::CrateEnergy::exOverflow
unsigned int exOverflow() const
Overflow bits.
Definition
CrateEnergy.cxx:238
LVL1::CrateEnergy::m_overflowY
unsigned int m_overflowY
Definition
CrateEnergy.h:62
LVL1::CrateEnergy::restricted
bool restricted() const
Full or restricted eta range?
Definition
CrateEnergy.cxx:248
LVL1::CrateEnergy::eyOverflow
unsigned int eyOverflow() const
return Ey overflow bit
Definition
CrateEnergy.cxx:243
LVL1::CrateEnergy::m_crate
unsigned int m_crate
Definition
CrateEnergy.h:56
LVL1::CrateEnergy::etOverflow
unsigned int etOverflow() const
return Et overflow bit
Definition
CrateEnergy.cxx:233
LVL1::CrateEnergy::CrateEnergy
CrateEnergy(unsigned int crate, const DataVector< ModuleEnergy > *modules, uint32_t maskXE=0xff, uint32_t maskTE=0xff, bool restricted=false)
Definition
CrateEnergy.cxx:18
LVL1::CrateEnergy::encodeTC
unsigned int encodeTC(int input) const
encode int as 15-bit twos-complement format (hardware Ex/Ey format)
Definition
CrateEnergy.cxx:263
LVL1::CrateEnergy::decodeTC
int decodeTC(unsigned int input) const
decode 15-bit twos-complement format (hardware Ex/Ey format) as int
Definition
CrateEnergy.cxx:278
LVL1::CrateEnergy::m_sumBitsTC
static const unsigned int m_sumBitsTC
Definition
CrateEnergy.h:65
LVL1::CrateEnergy::m_crateEy
int m_crateEy
Definition
CrateEnergy.h:59
LVL1::CrateEnergy::exTC
unsigned int exTC() const
15 bit twos-complement format
Definition
CrateEnergy.cxx:253
LVL1::CrateEnergy::m_crateEt
unsigned int m_crateEt
Definition
CrateEnergy.h:57
LVL1::CrateEnergy::~CrateEnergy
~CrateEnergy()
Definition
CrateEnergy.cxx:209
LVL1::CrateEnergy::eyTC
unsigned int eyTC() const
return crate Ey in 15-bit twos-complement format (hardware format)
Definition
CrateEnergy.cxx:258
LVL1::CrateEnergy::m_debug
bool m_debug
Definition
CrateEnergy.h:64
LVL1::CrateEnergy::m_overflowX
unsigned int m_overflowX
Definition
CrateEnergy.h:61
LVL1::CrateEnergy::m_jemEtSaturation
static const unsigned int m_jemEtSaturation
Definition
CrateEnergy.h:67
LVL1::EnergyCMXData
The EnergyCMXData object contains the data transferred from the JEM to the EnergySum CMX in the crate...
Definition
EnergyCMXData.h:24
LVL1::ModuleEnergy
This is an internal class, used in the Energy trigger.
Definition
ModuleEnergy.h:41
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition
IZdcDataAccess.h:13
Generated on
for ATLAS Offline Software by
1.17.0