107 static const int of_val = 0x1FFF;
109 static const int n_iterations = 6;
112 const int cordic_angles[n_iterations] = { 0x120, 0x0AA, 0x05A, 0x02E, 0x017, 0x00B };
113 const int cordic_starting_angle_090 = 0x240;
114 const int cordic_starting_angle_270 = 0x6C0;
115 const int cordic_angle_360 = 0x900;
117 const int cordic_scale_factor = 0x26E;
126 z = cordic_starting_angle_090;
131 z = cordic_starting_angle_090;
135 z = cordic_starting_angle_270;
139 for (
int i=0;
i<n_iterations;
i++) {
145 z = z + cordic_angles[
i];
149 z = z - cordic_angles[
i];
153 int scaled_magnitude = x * cordic_scale_factor;
154 int adjusted_angle = ( (z < 0) ? (z + cordic_angle_360) :
z ) % cordic_angle_360;
155 result.
mag = scaled_magnitude >> 10;
156 result.
phi = adjusted_angle >> 5;
157 if (result.
mag > (
unsigned) of_val) result.
mag = (
unsigned) of_val;
167 r = (((e>>(nBits-1)) + 1)>>1);
179 static const int componentMask = maxComponent-1;
180 static const int maxPosComponent = componentMask >> 1;
200 if (of || (
abs(ex) >= maxInput) || (
abs(ey) >= maxInput)) {
201 hxCompBits = maxPosComponent;
202 hyCompBits = maxPosComponent;
211 result.
phi =
static_cast<unsigned>(lutData) & resultPhiMask;
237 unsigned eneCoarse, phiCoarse;
238 unsigned eneCorect, phiCorect;
240 const unsigned root2fact = 181;
241 const unsigned corrFact[11] = {24, 39, 51, 60, 69, 77, 83, 89, 95, 101, 106};
242 const unsigned corrDphi[11] = { 0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4};
244 std::vector<bool>
s(3);
255 My =
static_cast<unsigned>(
abs(ey));
256 Mx =
static_cast<unsigned>(
abs(ex));
257 Mw = (((Mx+My)*root2fact)+0x80)>>8;
264 for (
int i=0;
i<3;
i++) {
265 if (s.at(
i)) { b=1-
b;} phibin = 2*phibin +
b;
269 phiCoarse = phibin*9;
275 for (eFact=0; eFact<10; eFact++) {
276 Dx = (Mx*corrFact[eFact])>>8;
277 Dy = (My*corrFact[eFact])>>8;
278 if ((Dx>=My) || (Dy>=Mx)) {midphi=
false;
break;}
279 if ((Mx+Dx)>=(My-Dy) && (My+Dy)>=(Mx-Dx)) {midphi=
true;
break;}
281 eneCorect = (eneCoarse*(128+eFact))>>7;
282 if (midphi ^ (b==1)) {
283 phiCorect = phiCoarse + 8 - corrDphi[eFact];
285 phiCorect = phiCoarse + corrDphi[eFact];
290 result.
mag = eneCorect;
291 result.
phi = phiCorect;
302 double fx =
static_cast<double>(ex);
303 double fy =
static_cast<double>(ey);
304 double fmag =
sqrt(fx*fx + fy*fy);
305 double fphi = 36.*atan2(fy, fx)/
M_PI;
307 result.
mag =
static_cast<unsigned>(fmag);
309 result.
phi =
static_cast<unsigned>(fphi);
311 result.
phi =
static_cast<unsigned>(fphi+72.);
bool overFlow() const
access overflow
etComponentType m_exComponent
void setEtScale(const L1CaloEtScale *const fn)
Set the functions.
void setOverFlow(bool oflow)
set the overflow bit
L1GctMet(const unsigned ex=0, const unsigned ey=0, const metAlgoType algo=cordicTranslate)
const bool inputOverFlow() const
const double componentLsb() const
etmiss_internal useHtMissLutAlgo(const int ex, const int ey, const bool of) const
LUT for conversion of Ht components x and y to magnitude and angle.
void setEyComponent(const unsigned ey)
void setExComponent(const unsigned ex)
etmiss_internal oldGctAlgo(const int ex, const int ey) const
void setEtScale(const L1CaloEtScale *const fn)
const T & max(const T &a, const T &b)
int cordicShiftAndRoundBits(const int e, const unsigned nBits) const
Abs< T >::type abs(const T &t)
void setExEyLsb(const double lsb)
const double componentLsb() const
L1GctHtMissLut * m_htMissLut
etmiss_internal cordicTranslateAlgo(const int ex, const int ey, const bool of) const
etComponentType m_eyComponent
int value() const
access value as signed int
const L1CaloEtScale * etScale() const
etmiss_vec metVector() const
etmiss_internal floatingPointAlgo(const int ex, const int ey) const
const L1CaloEtScale * etScale() const
Return the Lut functions and parameters.
void setValue(unsigned value)
Set value from unsigned.
uint16_t lutValue(const uint16_t lutAddress) const
Access the look-up table contents for a given Address.
bool overFlow() const
access overflow
unsigned short m_bitShift
void setEtComponentLsb(const double lsb)