CMS 3D CMS Logo

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 403 of file Lut.cc.

References objects.autophobj::float, and funct::pow().

403  {
404  DSPexp -= 15;
405  *f = DSPmantissa * (float)pow(2.0, DSPexp);
406 
407  return;
408 }
double f[11][100]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
char exaDigit ( int  i)

Definition at line 149 of file Lut.cc.

Referenced by lutFmt().

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

Definition at line 410 of file Lut.cc.

References f, mps_fire::i, and Validation_hcalonly_cfi::sign.

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

Definition at line 156 of file Lut.cc.

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

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