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

◆ DSPtoIEEE32()

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

Definition at line 401 of file Lut.cc.

401  {
402  DSPexp -= 15;
403  *f = DSPmantissa * (float)pow(2.0, DSPexp);
404 
405  return;
406 }

References f, dqmMemoryStats::float, and funct::pow().

◆ exaDigit()

char exaDigit ( int  i)

Definition at line 147 of file Lut.cc.

147  {
148  if (i < 10)
149  return (i + '0');
150  else
151  return ((i - 10) + 'A');
152 }

References mps_fire::i.

Referenced by lutFmt().

◆ IEEE32toDSP()

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

Definition at line 408 of file Lut.cc.

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 }

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

◆ lutFmt()

std::string lutFmt ( int  i)

Definition at line 154 of file Lut.cc.

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 }

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

mps_fire.i
i
Definition: mps_fire.py:355
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
exaDigit
char exaDigit(int i)
Definition: Lut.cc:147
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
alignCSCRings.s
s
Definition: alignCSCRings.py:92
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30