CMS 3D CMS Logo

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 <cmath>
23 #include <cstring>
24 
25 //-------------------------------
26 // Collaborating Class Headers --
27 //-------------------------------
28 
30 
31 //----------------
32 // Constructors --
33 //----------------
35 
36 DTConfigLUTs::DTConfigLUTs(bool debugLUTS, unsigned short int* buffer) {
37  m_debug = debugLUTS;
38 
39  // check if this is a LUT configuration string
40  if (buffer[2] != 0xA8) {
41  throw cms::Exception("DTTPG") << "===> ConfigLUTs constructor : not a LUT string!" << std::endl;
42  }
43 
44  // decode
45  short int memory_lut[7];
46  int c = 3;
47  for (int i = 0; i < 7; i++) {
48  memory_lut[i] = (buffer[c] << 8) | buffer[c + 1];
49  c += 2;
50  //std::cout << hex << memory_bti[i] << " ";
51  }
52 
53  // decode
54  int btic = memory_lut[0];
55  float d;
56  DSPtoIEEE32(memory_lut[1], memory_lut[2], &d);
57  float Xcn;
58  DSPtoIEEE32(memory_lut[3], memory_lut[4], &Xcn);
59  int wheel = memory_lut[5];
60 
61  // set parameters
62  setBTIC(btic);
63  setD(d);
64  setXCN(Xcn);
65  setWHEEL(wheel);
66 
67  return;
68 }
69 
70 //--------------
71 // Destructor --
72 //--------------
74 
75 //--------------
76 // Operations --
77 //--------------
78 
80  // Debug flag
81  m_debug = m_ps.getUntrackedParameter<bool>("Debug");
82 
83  // BTIC parameter
84  m_btic = m_ps.getUntrackedParameter<int>("BTIC");
85 
86  // d: distance vertex to normal, unit cm.
87  m_d = m_ps.getUntrackedParameter<double>("D");
88 
89  // Xcn: distance vertex to normal, unit cm.
90  m_Xcn = m_ps.getUntrackedParameter<double>("XCN");
91 
92  // wheel sign (-1 or +1)
93  m_wheel = m_ps.getUntrackedParameter<int>("WHEEL");
94 }
95 
96 void DTConfigLUTs::print() const {
97  std::cout << "******************************************************************************" << std::endl;
98  std::cout << "* DTTrigger configuration : LUT parameters *" << std::endl;
99  std::cout << "******************************************************************************" << std::endl
100  << std::endl;
101  std::cout << "Debug flag : " << debug() << std::endl;
102  std::cout << "BTIC parameter : " << m_btic << std::endl;
103  std::cout << "d: distance vertex to normal, unit cm. " << m_d << std::endl;
104  std::cout << "Xcn: distance vertex to normal, unit cm. " << m_Xcn << std::endl;
105  std::cout << "wheel sign " << m_wheel << std::endl;
106  std::cout << "******************************************************************************" << std::endl;
107 }
108 
109 void DTConfigLUTs::DSPtoIEEE32(short DSPmantissa, short DSPexp, float* f) const {
110  DSPexp -= 15;
111  *f = DSPmantissa * (float)pow(2.0, DSPexp);
112  return;
113 }
114 
115 void DTConfigLUTs::IEEE32toDSP(float f, short int& DSPmantissa, short int& DSPexp) const {
116  long int pl = 0;
117  static_assert(sizeof(decltype(pl)) >= sizeof(float));
118 
119  DSPmantissa = 0;
120  DSPexp = 0;
121 
122  if (f != 0.0) {
123  //pl = (long *)&f;
124  memcpy(&pl, &f, sizeof(float));
125  bool sign = false;
126  if ((pl & 0x80000000) != 0)
127  sign = true;
128  long int lm = (0x800000 | (pl & 0x7FFFFF)); // [1][23bit mantissa]
129  lm >>= 9; //reduce to 15bits
130  lm &= 0x7FFF;
131  DSPexp = ((pl >> 23) & 0xFF) - 126;
132  DSPmantissa = (short)lm;
133  if (sign)
134  DSPmantissa = -DSPmantissa; // convert negative value in 2.s complement
135  }
136  return;
137 }
DTConfigLUTs::setDefaults
void setDefaults(const edm::ParameterSet &m_ps)
Load pset values into class variables.
Definition: DTConfigLUTs.cc:79
DTConfigLUTs::setXCN
void setXCN(float Xcn)
Definition: DTConfigLUTs.h:69
DTConfigLUTs::m_btic
int m_btic
Definition: DTConfigLUTs.h:89
DTConfigLUTs::m_wheel
int m_wheel
Definition: DTConfigLUTs.h:92
DTConfigLUTs::setWHEEL
void setWHEEL(int wheel)
Definition: DTConfigLUTs.h:70
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
gather_cfg.cout
cout
Definition: gather_cfg.py:144
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
DTConfigLUTs::m_Xcn
float m_Xcn
Definition: DTConfigLUTs.h:91
DTConfigLUTs::print
void print() const
Print the setup.
Definition: DTConfigLUTs.cc:96
DTConfigLUTs::setBTIC
void setBTIC(int btic)
Definition: DTConfigLUTs.h:67
edm::ParameterSet
Definition: ParameterSet.h:36
DTConfigLUTs::DSPtoIEEE32
void DSPtoIEEE32(short DSPmantissa, short DSPexp, float *f) const
DSP to IEEE32 conversion.
Definition: DTConfigLUTs.cc:109
DTConfigLUTs::m_debug
bool m_debug
Definition: DTConfigLUTs.h:88
DTConfigLUTs.h
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
DTConfigLUTs::~DTConfigLUTs
~DTConfigLUTs() override
Destructor.
Definition: DTConfigLUTs.cc:73
DTConfigLUTs::Xcn
float Xcn() const
Xcn: distance vertex to normal, unit cm.
Definition: DTConfigLUTs.h:60
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
DTConfigLUTs::IEEE32toDSP
void IEEE32toDSP(float f, short int &DSPmantissa, short int &DSPexp) const
IEEE32 to DSP conversion.
Definition: DTConfigLUTs.cc:115
DTConfigLUTs::setD
void setD(float d)
Definition: DTConfigLUTs.h:68
Exception
Definition: hltDiff.cc:246
Exception.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
ztail.d
d
Definition: ztail.py:151
DTConfigLUTs::debug
bool debug() const
Debug flag.
Definition: DTConfigLUTs.h:51
DTConfigLUTs::m_d
float m_d
Definition: DTConfigLUTs.h:90
DTConfigLUTs::DTConfigLUTs
DTConfigLUTs()
Empty Constructor.
Definition: DTConfigLUTs.h:42