ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1CaloFEX
L1CaloFEXSim
src
jFEXCompression.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
jFEXCompression.cxx - description
6
-------------------
7
begin : 07-02-2019
8
email : Alan.Watson@cern.ch antonio.jacques.costa@cern.ch
9
***************************************************************************/
10
11
#include "
L1CaloFEXSim/jFEXCompression.h
"
12
#include <cmath>
13
14
namespace
LVL1
{
15
16
const
int
jFEXCompression::s_steps
[] = {25, 50, 100, 200, 400};
17
const
int
jFEXCompression::s_minET
[] = {-3150, 6400, 25600, 102400, 409600};
18
const
int
jFEXCompression::s_minCode
[] = {2, 384, 768, 1536, 3072};
19
20
unsigned
int
jFEXCompression::Compress
(
float
floatEt,
bool
empty
) {
21
22
//If all Scells are masked, then send empty/data not available
23
if
(
empty
)
return
s_NoData
;
24
25
int
Et = std::round(floatEt);
26
27
// Check for overflow
28
if
(Et >=
s_maxET
)
return
s_LArOverflow
;
29
30
// Find which range the ET value is in
31
int
range = -1;
32
for
(
unsigned
int
i = 0; i <
s_nRanges
; i++) {
33
if
(Et <
s_minET
[i])
break
;
34
range = i;
35
}
36
37
// Calculate code
38
unsigned
int
code = 0;
39
40
if
(range < 0) {
41
// Below minimum value
42
code =
s_LArUnderflow
;
43
}
44
else
{
45
// Lies inside one of the value ranges
46
int
steps = std::round( (Et -
s_minET
[range])/
s_steps
[range] );
47
code =
static_cast<
int
>
(
s_minCode
[range] + steps);
48
}
49
50
return
code;
51
}
52
53
int
jFEXCompression::Expand
(
unsigned
int
code) {
54
55
// Deal with special codes first:
56
if
(code ==
s_NoData
)
return
0;
57
if
(code ==
s_LArInvalid
)
return
0;
58
if
(code >
s_LArOverflow
&& code <
s_LArInvalid
)
return
s_error
;
59
if
(code ==
s_LArOverflow
)
return
s_maxET
;
60
63
int
range = 0;
64
for
(
unsigned
int
i = 0; i <
s_nRanges
-1; ++i) {
65
if
(code < (
unsigned
int
)
s_minCode
[i+1])
break
;
66
range++;
67
}
69
int
minEt =
s_minET
[range];
70
int
valEt = (code-
s_minCode
[range])*
s_steps
[range];
71
72
int
Et = minEt+valEt;
73
return
Et;
74
}
75
76
77
unsigned
int
jFEXCompression::Threshold
(
unsigned
int
code,
int
threshold
) {
78
80
unsigned
int
cut =
jFEXCompression::Compress
(
threshold
);
81
83
if
(code < cut) code = 0;
84
85
return
code;
86
}
87
88
89
unsigned
int
jFEXCompression::Linearize
(
unsigned
int
code,
int
threshold
) {
90
92
if
(
threshold
< 0)
threshold
= 0;
93
code =
jFEXCompression::Threshold
(code,
threshold
);
94
96
int
Et =
jFEXCompression::Expand
(code);
97
98
// Check for overflow
99
if
(Et >=
s_maxET
)
return
s_jFEXOverflow
;
100
102
unsigned
int
jFexET = Et/
s_jFEXstep
;
103
return
jFexET;
104
}
105
106
}
// end of namespace bracket
empty
static const Attributes_t empty
Definition
XmlStreamer.cxx:16
LVL1::jFEXCompression::s_minET
static const int s_minET[s_nRanges]
Minimum ET values in each range, MeV.
Definition
jFEXCompression.h:50
LVL1::jFEXCompression::s_NoData
static const int s_NoData
Indicates no data present.
Definition
jFEXCompression.h:54
LVL1::jFEXCompression::s_maxET
static const int s_maxET
Maximum ET value that can be encoded.
Definition
jFEXCompression.h:44
LVL1::jFEXCompression::Expand
static int Expand(unsigned int code)
Uncompress data.
Definition
jFEXCompression.cxx:53
LVL1::jFEXCompression::Linearize
static unsigned int Linearize(unsigned int code, int threshold=0)
Linearize LAr code to jFEX internal format.
Definition
jFEXCompression.cxx:89
LVL1::jFEXCompression::s_error
static const int s_error
Error return value.
Definition
jFEXCompression.h:68
LVL1::jFEXCompression::s_nRanges
static const unsigned int s_nRanges
Number of ranges.
Definition
jFEXCompression.h:46
LVL1::jFEXCompression::Threshold
static unsigned int Threshold(unsigned int code, int threshold=-800)
Apply threshold to compressed data.
Definition
jFEXCompression.cxx:77
LVL1::jFEXCompression::s_LArInvalid
static const unsigned int s_LArInvalid
Invalid code value.
Definition
jFEXCompression.h:62
LVL1::jFEXCompression::s_LArUnderflow
static const unsigned int s_LArUnderflow
LAr underflow code.
Definition
jFEXCompression.h:56
LVL1::jFEXCompression::s_minCode
static const int s_minCode[s_nRanges]
Minimum code value in each range.
Definition
jFEXCompression.h:52
LVL1::jFEXCompression::s_steps
static const int s_steps[s_nRanges]
Step sizes in each range, MeV.
Definition
jFEXCompression.h:48
LVL1::jFEXCompression::s_jFEXstep
static const unsigned int s_jFEXstep
L1Calo ET digit step.
Definition
jFEXCompression.h:64
LVL1::jFEXCompression::s_jFEXOverflow
static const unsigned int s_jFEXOverflow
L1Calo saturated/overflow.
Definition
jFEXCompression.h:66
LVL1::jFEXCompression::s_LArOverflow
static const unsigned int s_LArOverflow
LAr overflow code.
Definition
jFEXCompression.h:58
LVL1::jFEXCompression::Compress
static unsigned int Compress(float floatEt, bool empty=false)
Compress data.
Definition
jFEXCompression.cxx:20
jFEXCompression.h
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition
IZdcDataAccess.h:13
threshold
Definition
chainparser.cxx:74
Generated on
for ATLAS Offline Software by
1.17.0