ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1::L1METvalue Class Reference

L1METvalue encoding is used for transmission of ET/Ex/Ey sums from JEM to CMM. More...

#include <L1METvalue.h>

Collaboration diagram for LVL1::L1METvalue:

Public Member Functions

void calcL1MET (int Ex, int Ey, int &MET, unsigned int &Range, bool &Overflow)
 Return MET value as output by MET LUT (7 bit value + 2 bit range)
void calcL1MET (int Ex, int Ey, float &MET, bool &Overflow)
 Return MET value at floating point precision used in threshold calculation.
void calcL1METQ (int Ex, int Ey, int &METQ, bool &Overflow)
 Return MET**2 value at precision used in threshold calculation.
void calcL1METSig (int Ex, int Ey, int SumET, float a, float b, int XEmin, int XEmax, int sqrtTEmin, int sqrtTEmax, float &XS, int &OutOfRange)
 Return MET value at floating point precision used in threshold calculation.
void calcL1METSig (int MET, unsigned int Range, int SumET, float a, float b, int XEmin, int XEmax, int sqrtTEmin, int sqrtTEmax, float &XS, int &OutOfRange)

Static Private Attributes

static const unsigned int m_nBits = 6
 Number of bits in range.
static const unsigned int m_nRanges = 4
 Number of ET ranges to encode in.
static const unsigned int m_mask = 0x3F
 Mask to select Ex/Ey bits.
static const unsigned int m_valueMask = 0x7F
 Masks for integer MET word setting.
static const unsigned int m_rangeMask = 0x180
static const int m_xsXEmax = 127
 Limits on inputs to XS LUT.
static const int m_xsSqrtTEmax = 63

Detailed Description

L1METvalue encoding is used for transmission of ET/Ex/Ey sums from JEM to CMM.

This class compresses/uncompresses 8 bit ET (JEM energy sums) to/from quad linear scale

Todo
this should probably be a static class.

Definition at line 21 of file L1METvalue.h.

Member Function Documentation

◆ calcL1MET() [1/2]

void LVL1::L1METvalue::calcL1MET ( int Ex,
int Ey,
float & MET,
bool & Overflow )

Return MET value at floating point precision used in threshold calculation.

Definition at line 57 of file L1METvalue.cxx.

57 {
58 int METQ;
59 calcL1METQ(Ex, Ey, METQ, Overflow);
60 MET = sqrt(static_cast<float>(METQ));
61}
void calcL1METQ(int Ex, int Ey, int &METQ, bool &Overflow)
Return MET**2 value at precision used in threshold calculation.

◆ calcL1MET() [2/2]

void LVL1::L1METvalue::calcL1MET ( int Ex,
int Ey,
int & MET,
unsigned int & Range,
bool & Overflow )

Return MET value as output by MET LUT (7 bit value + 2 bit range)

Greater of 2 values determines range of bits used

If Ex/Ey overflows the LUT input range, trigger fires all thresholds. Indicate this with overflow flag and an out of range ETmiss value

Otherwise, emulate precision by checking which ET range we are in and zeroing bits below that.

Definition at line 63 of file L1METvalue.cxx.

63 {
64
66 unsigned int absEx = std::abs(Ex);
67 unsigned int absEy = std::abs(Ey);
68 int max = (absEx > absEy ? absEx : absEy);
69
72 if ( max >= (1<<(m_nBits+m_nRanges-1)) ) {
73 MET = m_rangeMask + m_valueMask; // 7 bit ET + 2 bit range, all bits set
74 Overflow = true;
75 }
78 else {
79 Range = 0;
80 for (unsigned int range = 0; range < m_nRanges; ++range) {
81 if ( max < (1<<(m_nBits+range)) ) {
82 absEx &= (m_mask<<range);
83 absEy &= (m_mask<<range);
84 Range = range;
85 break;
86 }
87 }
88 // Shift Ex/Ey values to lowest 6 bits
89 absEx = (absEx >> Range);
90 absEy = (absEy >> Range);
91 // Calculate 7 bit MET value, rounded up to the ceiling
92 int METQ = absEx*absEx + absEy*absEy;
93 MET = ceil(sqrt(static_cast<float>(METQ)));
94 Overflow = false;
95 }
96
97}
#define max(a, b)
Definition cfImp.cxx:41
static const unsigned int m_nRanges
Number of ET ranges to encode in.
Definition L1METvalue.h:42
static const unsigned int m_mask
Mask to select Ex/Ey bits.
Definition L1METvalue.h:44
static const unsigned int m_valueMask
Masks for integer MET word setting.
Definition L1METvalue.h:46
static const unsigned int m_nBits
Number of bits in range.
Definition L1METvalue.h:40
static const unsigned int m_rangeMask
Definition L1METvalue.h:47

◆ calcL1METQ()

void LVL1::L1METvalue::calcL1METQ ( int Ex,
int Ey,
int & METQ,
bool & Overflow )

Return MET**2 value at precision used in threshold calculation.

Greater of 2 values determines range of bits used

If Ex/Ey overflows the LUT input range, trigger fires all thresholds. Indicate this with overflow flag and an out of range ETmiss value

Otherwise, emulate precision by checking which ET range we are in and zeroing bits below that.

Definition at line 28 of file L1METvalue.cxx.

28 {
29
31 unsigned int absEx = std::abs(Ex);
32 unsigned int absEy = std::abs(Ey);
33 int max = (absEx > absEy ? absEx : absEy);
34
37 if ( max >= (1<<(m_nBits+m_nRanges-1)) ) {
38 METQ = 16777216; // 4096**2
39 Overflow = true;
40 }
43 else {
44 for (unsigned int range = 0; range < m_nRanges; ++range) {
45 if ( max < (1<<(m_nBits+range)) ) {
46 absEx &= (m_mask<<range);
47 absEy &= (m_mask<<range);
48 break;
49 }
50 }
51 METQ = absEx*absEx + absEy*absEy;
52 Overflow = false;
53 }
54
55}

◆ calcL1METSig() [1/2]

void LVL1::L1METvalue::calcL1METSig ( int Ex,
int Ey,
int SumET,
float a,
float b,
int XEmin,
int XEmax,
int sqrtTEmin,
int sqrtTEmax,
float & XS,
int & OutOfRange )

Return MET value at floating point precision used in threshold calculation.

Calculate MET value with correct precision and format

Use that plus provided SumET and coefficients to calculate METSig

Definition at line 99 of file L1METvalue.cxx.

100 {
101
103 bool overflow = false;
104 int MET = 0;
105 unsigned int Range = 0;
106 calcL1MET(Ex, Ey, MET, Range, overflow);
107
109 calcL1METSig(MET, Range, SumET, a, b, XEmin, XEmax, sqrtTEmin, sqrtTEmax, XS, OutOfRange);
110
111}
static Double_t a
void calcL1MET(int Ex, int Ey, int &MET, unsigned int &Range, bool &Overflow)
Return MET value as output by MET LUT (7 bit value + 2 bit range)
void calcL1METSig(int Ex, int Ey, int SumET, float a, float b, int XEmin, int XEmax, int sqrtTEmin, int sqrtTEmax, float &XS, int &OutOfRange)
Return MET value at floating point precision used in threshold calculation.

◆ calcL1METSig() [2/2]

void LVL1::L1METvalue::calcL1METSig ( int MET,
unsigned int Range,
int SumET,
float a,
float b,
int XEmin,
int XEmax,
int sqrtTEmin,
int sqrtTEmax,
float & XS,
int & OutOfRange )

Initialise default values

Impose firmware limitations on specified ranges

Convert MET value to single linear scale

Impose hardware limits on MET input to LUT

MET overflow check takes precedence over all other conditions

Protection against invalid input (can never happen in reality, but this is software)

Calculate sqrt(SumET) with integer precision & hardware limits

If in range, calculate XS

Definition at line 113 of file L1METvalue.cxx.

114 {
115
117 XS = -1.;
118 OutOfRange = 0;
119
121 if (XEmax > m_xsXEmax) XEmax = m_xsXEmax;
122 if (sqrtTEmax > m_xsSqrtTEmax) sqrtTEmax = m_xsSqrtTEmax;
123
125 int XE = (MET<<Range);
126
128 if (XE > m_xsXEmax) XE = m_xsXEmax;
129
131 if (XE >= XEmax) {
132 XS = 9999.;
133 OutOfRange = 1;
134 return;
135 }
136
138 if (SumET < 0) {
139 OutOfRange = -1;
140 return;
141 }
142
144 int sqrtSumET = sqrt(SumET);
145 if (sqrtSumET > m_xsSqrtTEmax) sqrtSumET = m_xsSqrtTEmax;
146
147 if (XE < XEmin || sqrtSumET >= sqrtTEmax || sqrtSumET < sqrtTEmin) {
148 //XS = 0.;
149 OutOfRange = -1;
150 }
152 else {
153 OutOfRange = 0;
154 if (sqrtSumET > b) XS = float(XE)/(a*(sqrtSumET-b));
155 }
156
157}
static const int m_xsSqrtTEmax
Definition L1METvalue.h:50
static const int m_xsXEmax
Limits on inputs to XS LUT.
Definition L1METvalue.h:49

Member Data Documentation

◆ m_mask

const unsigned int LVL1::L1METvalue::m_mask = 0x3F
staticprivate

Mask to select Ex/Ey bits.

Definition at line 44 of file L1METvalue.h.

◆ m_nBits

const unsigned int LVL1::L1METvalue::m_nBits = 6
staticprivate

Number of bits in range.

Definition at line 40 of file L1METvalue.h.

◆ m_nRanges

const unsigned int LVL1::L1METvalue::m_nRanges = 4
staticprivate

Number of ET ranges to encode in.

Definition at line 42 of file L1METvalue.h.

◆ m_rangeMask

const unsigned int LVL1::L1METvalue::m_rangeMask = 0x180
staticprivate

Definition at line 47 of file L1METvalue.h.

◆ m_valueMask

const unsigned int LVL1::L1METvalue::m_valueMask = 0x7F
staticprivate

Masks for integer MET word setting.

Definition at line 46 of file L1METvalue.h.

◆ m_xsSqrtTEmax

const int LVL1::L1METvalue::m_xsSqrtTEmax = 63
staticprivate

Definition at line 50 of file L1METvalue.h.

◆ m_xsXEmax

const int LVL1::L1METvalue::m_xsXEmax = 127
staticprivate

Limits on inputs to XS LUT.

Definition at line 49 of file L1METvalue.h.


The documentation for this class was generated from the following files: