ATLAS Offline Software
L1METvalue.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 /***************************************************************************
5  L1METvalue.cxx - description
6  -------------------
7  begin : 19-10-2007
8  email : Alan.Watson@cern.ch
9 
10  A simple set of functions to calculate ETmiss at the precision available
11  in the L1 thresholding logic (depending on values of Ex & Ey).
12 
13  Because of the way the thresholding logic works, Ex or Ey values outside
14  the defined range will simply cause all thresholds to be set (irrespective
15  of values). In this case there is no "correct" ETmiss value to return, and
16  so we (a) return a boolean flag to indicate that overflow has occurred,
17  and (b) set the returned ETmiss value to 1 TeV (outside the threshold
18  range). The flag should however always be checked before using the ETmiss
19  value.
20  ***************************************************************************/
21 
23 #include <cmath>
24 
25 namespace LVL1 {
26 
27 
28 void LVL1::L1METvalue::calcL1METQ(int Ex, int Ey, int& METQ, bool& Overflow) {
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 }
56 
57 void LVL1::L1METvalue::calcL1MET(int Ex, int Ey, float& MET, bool& Overflow) {
58  int METQ;
59  calcL1METQ(Ex, Ey, METQ, Overflow);
60  MET = sqrt(static_cast<float>(METQ));
61 }
62 
63 void LVL1::L1METvalue::calcL1MET(int Ex, int Ey, int& MET, unsigned int& Range, bool& Overflow) {
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 }
98 
99 void LVL1::L1METvalue::calcL1METSig(int Ex, int Ey, int SumET, float a, float b, int XEmin, int XEmax, int sqrtTEmin, int sqrtTEmax,
100  float& XS, int& OutOfRange) {
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 }
112 
113 void LVL1::L1METvalue::calcL1METSig(int MET, unsigned int Range, int SumET, float a, float b, int XEmin, int XEmax, int sqrtTEmin, int sqrtTEmax,
114  float& XS, int& OutOfRange) {
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 }
158 
159 } // end of namespace bracket
LVL1::L1METvalue::calcL1METQ
void calcL1METQ(int Ex, int Ey, int &METQ, bool &Overflow)
Return MET**2 value at precision used in threshold calculation.
Definition: L1METvalue.cxx:44
LVL1::Range
Range class declaration.
Definition: Trigger/TrigT1/TrigT1Interfaces/TrigT1Interfaces/Range.h:22
max
#define max(a, b)
Definition: cfImp.cxx:41
L1METvalue.h
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::L1METvalue::calcL1METSig
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.
Definition: L1METvalue.cxx:115
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
TCS::MET
@ MET
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Types.h:16
LVL1::L1METvalue::calcL1MET
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)
Definition: L1METvalue.cxx:79
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:27
a
TList * a
Definition: liststreamerinfos.cxx:10
readCCLHist.float
float
Definition: readCCLHist.py:83