CMS 3D CMS Logo

EMTFUnpackerTools.h
Go to the documentation of this file.
1 // Tools for unpacking and packing EMTF data
2 
3 #ifndef EventFilter_L1TRawToDigi_EMTFUnpackerTools_h
4 #define EventFilter_L1TRawToDigi_EMTFUnpackerTools_h
5 
6 // Generally useful includes
7 #include <iostream>
8 #include <iomanip> // For things like std::setw
9 #include <array>
15 
16 namespace l1t {
17  namespace stage2 {
18  namespace emtf {
19  namespace L1TMuonEndCap = ::emtf; // use alias 'L1TMuonEndCap' for the namespace 'emtf' used in L1Trigger/L1TMuonEndCap
20 
21  void ImportME ( EMTFHit& _hit, const l1t::emtf::ME _ME, const int _endcap, const int _evt_sector );
22  void ImportRPC ( EMTFHit& _hit, const l1t::emtf::RPC _RPC, const int _endcap, const int _evt_sector );
23  void ImportSP ( EMTFTrack& _track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector );
24 
25  // Integer version of pow() - returns base^exp
26  inline int PowInt(int base, int exp) {
27  if (exp == 0) return 1;
28  if (exp == 1) return base;
29  return base * PowInt(base, exp-1);
30  }
31 
32  // Compute the two's complement of an integer
33  inline int TwosCompl(int nBits, int bits) {
34  if (bits >> (nBits - 1) == 0) return bits;
35  else return bits - PowInt(2, nBits);
36  };
37 
38  // Get the integer value of specified bits from a 16-bit word (0xffff)
39  inline uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit) {
40  return ( (word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1) );
41  }
42 
43  // Get the integer value of specified bits from a 32-bit word (0xffffffff)
44  inline uint32_t GetHexBits(uint32_t word, uint32_t lowBit, uint32_t highBit) {
45  return ( (word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1) );
46  }
47 
48  // Get the integer value of specified bits from two 16-bit words (0xffff, 0xffff)
49  inline uint32_t GetHexBits(uint16_t word1, uint16_t lowBit1, uint16_t highBit1,
50  uint16_t word2, uint16_t lowBit2, uint16_t highBit2) {
51  uint16_t word1_sel = (word1 >> lowBit1) & (PowInt(2, (1 + highBit1 - lowBit1)) - 1);
52  uint16_t word2_sel = (word2 >> lowBit2) & (PowInt(2, (1 + highBit2 - lowBit2)) - 1);
53  return ( (word2_sel << (1 + highBit1 - lowBit1)) | word1_sel );
54  }
55 
56  } // End namespace emtf
57  } // End namespace stage2
58 } // End namespace l1t
59 
60 #endif /* define EventFilter_L1TRawToDigi_EMTFUnpackerTools_h */
int PowInt(int base, int exp)
void ImportME(EMTFHit &_hit, const l1t::emtf::ME _ME, const int _endcap, const int _evt_sector)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
Definition: Event.h:15
delete x;
Definition: CaloConfig.h:22
void ImportRPC(EMTFHit &_hit, const l1t::emtf::RPC _RPC, const int _endcap, const int _evt_sector)
int TwosCompl(int nBits, int bits)
base
Make Sure CMSSW is Setup ##.
void ImportSP(EMTFTrack &_track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector)
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)