CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTConfigLUTs.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: DTConfigLUTs
4 //
5 // Description: Configurable parameters and constants
6 // for Level1 Mu DT Trigger - LUTs
7 //
8 //
9 // Author List:
10 // S. Vanini
11 //
12 //-----------------------------------------------------------------------
13 
14 //-----------------------
15 // This Class's Header --
16 //-----------------------
18 
19 //---------------
20 // C++ Headers --
21 //---------------
22 #include <math.h>
23 #include <cstring>
24 
25 //-------------------------------
26 // Collaborating Class Headers --
27 //-------------------------------
28 
30 
31 //----------------
32 // Constructors --
33 //----------------
35  setDefaults(ps);
36 }
37 
38 DTConfigLUTs::DTConfigLUTs(bool debugLUTS, unsigned short int * buffer) {
39 
40  m_debug = debugLUTS;
41 
42  // check if this is a LUT configuration string
43  if (buffer[2]!=0xA8){
44  throw cms::Exception("DTTPG") << "===> ConfigLUTs constructor : not a LUT string!" << std::endl;
45  }
46 
47  // decode
48  short int memory_lut[7];
49  int c=3;
50  for(int i=0;i<7;i++){
51  memory_lut[i] = (buffer[c]<<8) | buffer[c+1];
52  c += 2;
53  //std::cout << hex << memory_bti[i] << " ";
54  }
55 
56  // decode
57  int btic = memory_lut[0];
58  float d;
59  DSPtoIEEE32( memory_lut[1], memory_lut[2], &d );
60  float Xcn;
61  DSPtoIEEE32( memory_lut[3], memory_lut[4], &Xcn );
62  int wheel = memory_lut[5];
63 
64  // set parameters
65  setBTIC(btic);
66  setD(d);
67  setXCN(Xcn);
68  setWHEEL(wheel);
69 
70  return;
71 }
72 
73 //--------------
74 // Destructor --
75 //--------------
77 
78 //--------------
79 // Operations --
80 //--------------
81 
82 void
84 
85  // Debug flag
86  m_debug = m_ps.getUntrackedParameter<bool>("Debug");
87 
88  // BTIC parameter
89  m_btic = m_ps.getUntrackedParameter<int>("BTIC");
90 
91  // d: distance vertex to normal, unit cm.
92  m_d = m_ps.getUntrackedParameter<double>("D");
93 
94  // Xcn: distance vertex to normal, unit cm.
95  m_Xcn = m_ps.getUntrackedParameter<double>("XCN");
96 
97  // wheel sign (-1 or +1)
98  m_wheel = m_ps.getUntrackedParameter<int>("WHEEL");
99 }
100 
101 void
103 
104  std::cout << "******************************************************************************" << std::endl;
105  std::cout << "* DTTrigger configuration : LUT parameters *" << std::endl;
106  std::cout << "******************************************************************************" << std::endl << std::endl;
107  std::cout << "Debug flag : " << debug() << std::endl;
108  std::cout << "BTIC parameter : " << m_btic << std::endl;
109  std::cout << "d: distance vertex to normal, unit cm. " << m_d << std::endl;
110  std::cout << "Xcn: distance vertex to normal, unit cm. " << m_Xcn << std::endl;
111  std::cout << "wheel sign " << m_wheel << std::endl;
112  std::cout << "******************************************************************************" << std::endl;
113 }
114 
115 void
116 DTConfigLUTs::DSPtoIEEE32(short DSPmantissa, short DSPexp, float *f)
117 {
118  DSPexp -= 15;
119  *f = DSPmantissa * (float)pow( 2.0, DSPexp );
120  return;
121 }
122 
123 
124 void
125 DTConfigLUTs::IEEE32toDSP(float f, short int & DSPmantissa, short int & DSPexp)
126 {
127  long int *pl=0, lm;
128  bool sign=false;
129 
130  DSPmantissa = 0;
131  DSPexp = 0;
132 
133  if( f!=0.0 )
134  {
135  //pl = (long *)&f;
136  memcpy(pl,&f,sizeof(float));
137  if((*pl & 0x80000000)!=0)
138  sign=true;
139  lm = ( 0x800000 | (*pl & 0x7FFFFF)); // [1][23bit mantissa]
140  lm >>= 9; //reduce to 15bits
141  lm &= 0x7FFF;
142  DSPexp = ((*pl>>23)&0xFF)-126;
143  DSPmantissa = (short)lm;
144  if(sign)
145  DSPmantissa = - DSPmantissa; // convert negative value in 2.s complement
146 
147  }
148  return;
149 }
150 
151 
152 
153 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setWHEEL(int wheel)
Definition: DTConfigLUTs.h:72
void IEEE32toDSP(float f, short int &DSPmantissa, short int &DSPexp)
IEEE32 to DSP conversion.
double f[11][100]
void print() const
Print the setup.
void setD(float d)
Definition: DTConfigLUTs.h:70
void setBTIC(int btic)
Definition: DTConfigLUTs.h:69
bool debug() const
Debug flag.
Definition: DTConfigLUTs.h:53
void setDefaults(const edm::ParameterSet &m_ps)
Load pset values into class variables.
Definition: DTConfigLUTs.cc:83
void setXCN(float Xcn)
Definition: DTConfigLUTs.h:71
float Xcn() const
Xcn: distance vertex to normal, unit cm.
Definition: DTConfigLUTs.h:62
DTConfigLUTs()
Empty Constructor.
Definition: DTConfigLUTs.h:44
tuple cout
Definition: gather_cfg.py:121
void DSPtoIEEE32(short DSPmantissa, short DSPexp, float *f)
DSP to IEEE32 conversion.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
~DTConfigLUTs()
Destructor.
Definition: DTConfigLUTs.cc:76