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(unsigned short int * buffer) {
39 
40  // check if this is a LUT configuration string
41  if (buffer[2]!=0xA8){
42  throw cms::Exception("DTTPG") << "===> ConfigLUTs constructor : not a LUT string!" << std::endl;
43  }
44 
45  // decode
46  short int memory_lut[7];
47  int c=3;
48  for(int i=0;i<7;i++){
49  memory_lut[i] = (buffer[c]<<8) | buffer[c+1];
50  c += 2;
51  //std::cout << hex << memory_bti[i] << " ";
52  }
53 
54  // decode
55  int btic = memory_lut[0];
56  float d;
57  DSPtoIEEE32( memory_lut[1], memory_lut[2], &d );
58  float Xcn;
59  DSPtoIEEE32( memory_lut[3], memory_lut[4], &Xcn );
60  int wheel = memory_lut[5];
61 
62  // set parameters
63  setBTIC(btic);
64  setD(d);
65  setXCN(Xcn);
66  setWHEEL(wheel);
67 
68  return;
69 }
70 
71 //--------------
72 // Destructor --
73 //--------------
75 
76 //--------------
77 // Operations --
78 //--------------
79 
80 void
82 
83  // Debug flag
84  m_debug = m_ps.getUntrackedParameter<bool>("Debug");
85 
86  // BTIC parameter
87  m_btic = m_ps.getUntrackedParameter<int>("BTIC");
88 
89  // d: distance vertex to normal, unit cm.
90  m_d = m_ps.getUntrackedParameter<double>("D");
91 
92  // Xcn: distance vertex to normal, unit cm.
93  m_Xcn = m_ps.getUntrackedParameter<double>("XCN");
94 
95  // wheel sign (-1 or +1)
96  m_wheel = m_ps.getUntrackedParameter<int>("WHEEL");
97 }
98 
99 void
101 
102  std::cout << "******************************************************************************" << std::endl;
103  std::cout << "* DTTrigger configuration : LUT parameters *" << std::endl;
104  std::cout << "******************************************************************************" << std::endl << std::endl;
105  std::cout << "Debug flag : " << debug() << std::endl;
106  std::cout << "BTIC parameter : " << m_btic << std::endl;
107  std::cout << "d: distance vertex to normal, unit cm. " << m_d << std::endl;
108  std::cout << "Xcn: distance vertex to normal, unit cm. " << m_Xcn << std::endl;
109  std::cout << "wheel sign " << m_wheel << std::endl;
110  std::cout << "******************************************************************************" << std::endl;
111 }
112 
113 void
114 DTConfigLUTs::DSPtoIEEE32(short DSPmantissa, short DSPexp, float *f)
115 {
116  DSPexp -= 15;
117  *f = DSPmantissa * (float)pow( 2.0, DSPexp );
118  return;
119 }
120 
121 
122 void
123 DTConfigLUTs::IEEE32toDSP(float f, short int & DSPmantissa, short int & DSPexp)
124 {
125  long int *pl=0, lm;
126  bool sign=false;
127 
128  DSPmantissa = 0;
129  DSPexp = 0;
130 
131  if( f!=0.0 )
132  {
133  //pl = (long *)&f;
134  memcpy(pl,&f,sizeof(float));
135  if((*pl & 0x80000000)!=0)
136  sign=true;
137  lm = ( 0x800000 | (*pl & 0x7FFFFF)); // [1][23bit mantissa]
138  lm >>= 9; //reduce to 15bits
139  lm &= 0x7FFF;
140  DSPexp = ((*pl>>23)&0xFF)-126;
141  DSPmantissa = (short)lm;
142  if(sign)
143  DSPmantissa = - DSPmantissa; // convert negative value in 2.s complement
144 
145  }
146  return;
147 }
148 
149 
150 
151 
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:81
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:41
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:74