CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 407 of file Lut.cc.

References funct::pow().

408 {
409  DSPexp -= 15;
410  *f = DSPmantissa * (float)pow( 2.0, DSPexp );
411 
412  return;
413 }
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 151 of file Lut.cc.

Referenced by lutFmt().

151  {
152  if ( i < 10 ) return ( i + '0' );
153  else return ( ( i - 10 ) + 'A' );
154 }
int i
Definition: DBlmapReader.cc:9
void IEEE32toDSP ( float  f,
short *  DSPmantissa,
short *  DSPexp 
)

Definition at line 416 of file Lut.cc.

References f, i, and jetcorrextractor::sign().

417 {
418  //long *pl, lm;
419  uint32_t pl;
420  uint32_t lm;
421 
422  //101104 SV convert float to int in safe way
423  union { float f; uint32_t i; } u;
424  u.f = f;
425  pl = u.i;
426 
427  bool sign=false;
428  if( f==0.0 )
429  {
430  *DSPexp = 0;
431  *DSPmantissa = 0;
432  }
433  else
434  {
435  //pl = reinterpret_cast<uint32_t*> (&f);
436  //pl = (long*) (&f);
437  if((pl & 0x80000000)!=0)
438  sign=true;
439  lm =( 0x800000 | (pl & 0x7FFFFF)); // [1][23bit mantissa]
440  lm >>= 9; //reduce to 15bits
441  lm &= 0x7FFF;
442  *DSPexp = ((pl>>23)&0xFF)-126;
443  *DSPmantissa = (short)lm;
444  if(sign)
445  *DSPmantissa = - *DSPmantissa; // convert negative value in 2.s
446  // complement
447  }
448  return;
449 }
int i
Definition: DBlmapReader.cc:9
double sign(double x)
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 }
int i
Definition: DBlmapReader.cc:9
char exaDigit(int i)
Definition: Lut.cc:151