CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
Lut.cc File Reference
#include "L1Trigger/DTTraco/interface/Lut.h"

Go to the source code of this file.

Functions

void DSPtoIEEE32 (short DSPmantissa, short DSPexp, float *f)
 
char exaDigit (int i)
 
void IEEE32toDSP (float f, short *DSPmantissa, short *DSPexp)
 
std::string lutFmt (int i)
 

Function Documentation

void DSPtoIEEE32 ( short  DSPmantissa,
short  DSPexp,
float *  f 
)

Definition at line 401 of file Lut.cc.

References funct::pow().

401  {
402  DSPexp -= 15;
403  *f = DSPmantissa * (float)pow(2.0, DSPexp);
404 
405  return;
406 }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
char exaDigit ( int  i)

Definition at line 147 of file Lut.cc.

Referenced by lutFmt().

147  {
148  if (i < 10)
149  return (i + '0');
150  else
151  return ((i - 10) + 'A');
152 }
void IEEE32toDSP ( float  f,
short *  DSPmantissa,
short *  DSPexp 
)

Definition at line 408 of file Lut.cc.

References validate-o2o-wbm::f, mps_fire::i, and jetcorrextractor::sign().

408  {
409  // long *pl, lm;
410  uint32_t pl;
411  uint32_t lm;
412 
413  // 101104 SV convert float to int in safe way
414  union {
415  float f;
416  uint32_t i;
417  } u;
418  u.f = f;
419  pl = u.i;
420 
421  bool sign = false;
422  if (f == 0.0) {
423  *DSPexp = 0;
424  *DSPmantissa = 0;
425  } else {
426  // pl = reinterpret_cast<uint32_t*> (&f);
427  // pl = (long*) (&f);
428  if ((pl & 0x80000000) != 0)
429  sign = true;
430  lm = (0x800000 | (pl & 0x7FFFFF)); // [1][23bit mantissa]
431  lm >>= 9; // reduce to 15bits
432  lm &= 0x7FFF;
433  *DSPexp = ((pl >> 23) & 0xFF) - 126;
434  *DSPmantissa = (short)lm;
435  if (sign)
436  *DSPmantissa = -*DSPmantissa; // convert negative value in 2.s
437  // complement
438  }
439  return;
440 }
double sign(double x)
std::string lutFmt ( int  i)

Definition at line 154 of file Lut.cc.

References visDQMUpload::buf, exaDigit(), alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

154  {
155  char *buf = new char[6];
156  buf[2] = ' ';
157  buf[5] = '\0';
158  int j4 = i % 16;
159  i /= 16;
160  int j3 = i % 16;
161  i /= 16;
162  int j2 = i % 16;
163  i /= 16;
164  int j1 = i % 16;
165  buf[0] = exaDigit(j1);
166  buf[1] = exaDigit(j2);
167  buf[3] = exaDigit(j3);
168  buf[4] = exaDigit(j4);
169  std::string s(buf);
170  return s;
171 }
char exaDigit(int i)
Definition: Lut.cc:147