CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EMTFUnpackerTools.h
Go to the documentation of this file.
1 // Tools for unpacking and packing EMTF data
2 
3 #ifndef EMTFUnpackerTools_h
4 #define EMTFUnpackerTools_h
5 
6 // Generally useful includes
7 #include <iostream>
8 #include <iomanip> // For things like std::setw
9 
10 namespace l1t {
11  namespace stage2 {
12  namespace emtf {
13 
14  inline int PowInt(int base, int exp) {
15  if (exp == 0) return 1;
16  if (exp == 1) return base;
17  return base * PowInt(base, exp-1);
18  }
19 
20  inline uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit) {
21  return ( (word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1) );
22  }
23 
24  inline uint32_t GetHexBits(uint32_t word, uint32_t lowBit, uint32_t highBit) {
25  return ( (word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1) );
26  }
27 
28  inline uint32_t GetHexBits(uint16_t word1, uint16_t lowBit1, uint16_t highBit1,
29  uint16_t word2, uint16_t lowBit2, uint16_t highBit2) {
30  uint16_t word1_sel = (word1 >> lowBit1) & (PowInt(2, (1 + highBit1 - lowBit1)) - 1);
31  uint16_t word2_sel = (word2 >> lowBit2) & (PowInt(2, (1 + highBit2 - lowBit2)) - 1);
32  return ( (word2_sel << (1 + highBit1 - lowBit1)) | word1_sel );
33  }
34 
35  } // End namespace emtf
36  } // End namespace stage2
37 } // End namespace l1t
38 
39 #endif /* define EMTFUnpackerTools_h */
tuple base
Main Program
Definition: newFWLiteAna.py:91
int PowInt(int base, int exp)
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)