ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1CaloFEX
L1CaloFEXSim
src
gFEXCompression.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
//***************************************************************************
5
// gFEXCompression - Energy encoder/decoder for gFEX
6
// -------------------
7
// begin : 01 04 2021
8
// email : cecilia.tosciri@cern.ch
9
//***************************************************************************
10
#include "
L1CaloFEXSim/gFEXCompression.h
"
11
#include <cmath>
12
13
namespace
LVL1
{
14
15
const
int
gFEXCompression::s_steps
[] = {12800, 50, 25, 50, 100, 25600};
//MeV
16
const
int
gFEXCompression::s_minET
[] = {-101200, -50000, -12800, 12800, 51200, 200000};
//MeV
17
const
int
gFEXCompression::s_minCode
[] = {2, 6, 750, 1774, 2542, 4030};
18
19
20
unsigned
int
gFEXCompression::compress
(
float
floatEt) {
21
22
int
Et = std::round(floatEt);
23
24
// Check for overflow
25
if
(Et >=
s_maxET
)
return
s_LArOverflow
;
26
27
// Find which range the ET value is in
28
int
range = -1;
29
for
(
unsigned
int
i = 0; i <
s_nRanges
; i++) {
30
if
(Et <
s_minET
[i])
break
;
31
range = i;
32
}
33
34
// Calculate code
35
unsigned
int
code = 0;
36
37
if
(range < 0) {
38
// Below minimum value
39
code =
s_LArUnderflow
;
40
}
41
else
{
42
// Lies inside one of the value ranges
43
int
steps = (Et -
s_minET
[range])/
s_steps
[range];
44
code =
s_minCode
[range] + steps;
45
}
46
47
return
code;
48
}
49
50
int
gFEXCompression::expand
(
unsigned
int
code) {
51
52
// Deal with special codes first:
53
if
(code ==
s_NoData
)
return
0;
54
if
(code ==
s_LArInvalid
|| (code >
s_LArReserved_min
&& code <
s_LArReserved_max
) || code >
s_LArMaxCode
)
return
s_error
;
55
if
(code ==
s_LArOverflow
)
return
s_maxET
;
56
59
int
range = 0;
60
for
(
unsigned
int
i = 0; i <
s_nRanges
-1; ++i) {
61
if
(code < (
unsigned
int
)
s_minCode
[i+1])
break
;
62
range++;
63
}
65
int
Et =
s_minET
[range] + (code-
s_minCode
[range])*
s_steps
[range];
66
67
return
Et;
68
}
69
70
71
unsigned
int
gFEXCompression::threshold
(
unsigned
int
code,
int
threshold
) {
72
74
unsigned
int
cut =
gFEXCompression::compress
(
threshold
);
75
77
if
(code < cut) code = 0;
78
79
return
code;
80
}
81
82
83
unsigned
int
gFEXCompression::linearize
(
unsigned
int
code,
int
threshold
) {
84
86
if
(
threshold
< 0)
threshold
= 0;
87
code =
gFEXCompression::threshold
(code,
threshold
);
88
90
int
Et =
gFEXCompression::expand
(code);
91
92
// Check for overflow
93
if
(Et >=
s_maxET
)
return
s_gFEXOverflow
;
94
96
unsigned
int
gFexET = Et/
s_gFEXstep
;
97
return
gFexET;
98
}
99
100
}
// end of namespace bracket
LVL1::gFEXCompression::s_LArOverflow
static const unsigned int s_LArOverflow
LAr overflow code.
Definition
gFEXCompression.h:54
LVL1::gFEXCompression::s_minET
static const int s_minET[s_nRanges]
Minimum ET values in each range, MeV.
Definition
gFEXCompression.h:46
LVL1::gFEXCompression::linearize
static unsigned int linearize(unsigned int code, int threshold=0)
Linearize LAr code to eFEX internal format.
Definition
gFEXCompression.cxx:83
LVL1::gFEXCompression::s_LArReserved_max
static const unsigned int s_LArReserved_max
Reserved code max value.
Definition
gFEXCompression.h:58
LVL1::gFEXCompression::s_LArUnderflow
static const unsigned int s_LArUnderflow
LAr underflow code.
Definition
gFEXCompression.h:52
LVL1::gFEXCompression::expand
static int expand(unsigned int code)
Uncompress data.
Definition
gFEXCompression.cxx:50
LVL1::gFEXCompression::threshold
static unsigned int threshold(unsigned int code, int threshold=-101200)
Apply threshold to compressed data.
Definition
gFEXCompression.cxx:71
LVL1::gFEXCompression::s_minCode
static const int s_minCode[s_nRanges]
Minimum code value in each range.
Definition
gFEXCompression.h:48
LVL1::gFEXCompression::s_error
static const int s_error
Error return value.
Definition
gFEXCompression.h:70
LVL1::gFEXCompression::s_LArMaxCode
static const unsigned int s_LArMaxCode
LAr saturated code.
Definition
gFEXCompression.h:64
LVL1::gFEXCompression::s_maxET
static const int s_maxET
Maximum ET value that can be encoded.
Definition
gFEXCompression.h:40
LVL1::gFEXCompression::s_steps
static const int s_steps[s_nRanges]
Step sizes in each range, MeV.
Definition
gFEXCompression.h:44
LVL1::gFEXCompression::s_NoData
static const int s_NoData
Indicates no data present.
Definition
gFEXCompression.h:50
LVL1::gFEXCompression::s_gFEXOverflow
static const unsigned int s_gFEXOverflow
L1Calo saturated/overflow.
Definition
gFEXCompression.h:68
LVL1::gFEXCompression::compress
static unsigned int compress(float Energy)
Compress data.
Definition
gFEXCompression.cxx:20
LVL1::gFEXCompression::s_gFEXstep
static const unsigned int s_gFEXstep
L1Calo ET digit step.
Definition
gFEXCompression.h:66
LVL1::gFEXCompression::s_nRanges
static const unsigned int s_nRanges
Number of ranges.
Definition
gFEXCompression.h:42
LVL1::gFEXCompression::s_LArInvalid
static const unsigned int s_LArInvalid
Invalid code value.
Definition
gFEXCompression.h:60
LVL1::gFEXCompression::s_LArReserved_min
static const unsigned int s_LArReserved_min
Reserved code min value.
Definition
gFEXCompression.h:56
gFEXCompression.h
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