ATLAS Offline Software
Loading...
Searching...
No Matches
eFEXCompression.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4/***************************************************************************
5 eFEXCompression.cxx - description
6 -------------------
7 begin : 07-02-2019
8 email : Alan.Watson@cern.ch antonio.jacques.costa@cern.ch
9 ***************************************************************************/
10
12
13namespace LVL1 {
14
15const int eFEXCompression::s_steps[] = {25, 50, 100, 400};
16const int eFEXCompression::s_minET[] = {-750, 5600, 18400, 44000};
17const int eFEXCompression::s_minCode[] = {2, 256, 512, 768};
18std::atomic<bool> eFEXCompression::s_disableNoiseCuts = false;
19
20unsigned int eFEXCompression::compress(int Et) {
21
22 // check for saturation
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
50int eFEXCompression::expand(unsigned int code) {
51
52 // Deal with special codes first:
53 if (code == s_NoData) return 0;
54 else if (code == s_LArInvalid || code == s_LArReserved || code > s_LArMaxCode) return s_error;
55 else if (code == s_LArOverflow) return s_maxET;
56 else if (code == s_LArSaturated) return s_eFEXOverflow*s_eFEXstep;
57
60 int range = 0;
61 for (unsigned int i = 0; i < s_nRanges-1; ++i) {
62 if (code < (unsigned int)s_minCode[i+1]) break;
63 range++;
64 }
66 int Et = s_minET[range] + (code-s_minCode[range])*s_steps[range];
67
68 return Et;
69}
70
71bool eFEXCompression::noiseCut(unsigned int code, int layer, bool ignoreDisable) {
72 // Check if noise cut is passed - one cut per layer
73 bool pass=true;
74
75 if(!ignoreDisable && s_disableNoiseCuts) return pass;
76
77 switch(layer){
78 case 0:
79 if(code<m_noisecutPS){ pass = false; }
80 break;
81 case 1:
82 if(code<m_noisecutL1){ pass = false; }
83 break;
84 case 2:
85 if(code<m_noisecutL2){ pass = false; }
86 break;
87 case 3:
88 if(code<m_noisecutL3){ pass = false; }
89 break;
90 case 4:
91 if(code<m_noisecutHad){ pass = false; }
92 break;
93 default:
94 pass = false;
95 break;
96 }
97
98 return pass;
99}
100
101
102unsigned int eFEXCompression::threshold(unsigned int code, int threshold) {
103
105 unsigned int cut = eFEXCompression::compress(threshold);
106
108 if (code < cut) code = 0;
109
110 return code;
111}
112
113int eFEXCompression::decode(int EtVal, int layer, bool ignoreDisable) {
114
115 // Calculate code
116 unsigned int tcode = eFEXCompression::compress(EtVal);
117
119 unsigned int code = 0; // corresponds to 0 GeV
120 if (eFEXCompression::noiseCut(tcode,layer,ignoreDisable)) {
121 code = tcode;
122 }
123
125 int Et = eFEXCompression::expand(code);
126
128 return Et/s_eFEXstep;
129}
130
131} // end of namespace bracket
static const unsigned int m_noisecutPS
Noise Cuts per layer.
static const unsigned int s_LArMaxCode
Maximum code value.
static const int s_steps[s_nRanges]
Step sizes in each range, MeV.
static const unsigned int s_nRanges
Number of ranges.
static const unsigned int s_LArReserved
Reserved code value.
static const int s_maxET
Maximum ET value that can be encoded.
static const unsigned int m_noisecutL2
static const unsigned int s_LArSaturated
LAr saturated code.
static const unsigned int s_eFEXOverflow
L1Calo saturated/overflow.
static const unsigned int s_LArUnderflow
LAr underflow code.
static const int s_minCode[s_nRanges]
Minimum code value in each range.
static const int s_NoData
Indicates no data present.
static unsigned int threshold(unsigned int code, int threshold=-800)
Apply threshold to compressed data.
static const unsigned int s_LArOverflow
LAr overflow code.
static const int s_minET[s_nRanges]
Minimum ET values in each range, MeV.
static const unsigned int m_noisecutL1
static std::atomic< bool > s_disableNoiseCuts
static bool noiseCut(unsigned int code, int layer, bool ignoreDisable=false)
Apply supercell noise cut.
static int decode(int EtVal, int layer, bool ignoreDisable=false)
Full sequence.
static int expand(unsigned int code)
Uncompress data.
static const unsigned int s_LArInvalid
Invalid code value.
static const unsigned int m_noisecutHad
static const int s_error
Error return value.
static const unsigned int m_noisecutL3
static const unsigned int s_eFEXstep
L1Calo ET digit step.
static unsigned int compress(int Et)
Compress data.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...