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 =
20  ::emtf; // use alias 'L1TMuonEndCap' for the namespace 'emtf' used in L1Trigger/L1TMuonEndCap
21 
22  void ImportME(EMTFHit& _hit, const l1t::emtf::ME _ME, const int _endcap, const int _evt_sector);
23  void ImportRPC(EMTFHit& _hit, const l1t::emtf::RPC _RPC, const int _endcap, const int _evt_sector);
24  void ImportGEM(EMTFHit& _hit, const l1t::emtf::GEM& _GEM, const int _endcap, const int _evt_sector);
25  void ImportSP(EMTFTrack& _track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector);
26 
27  // Integer version of pow() - returns base^exp
28  inline int PowInt(int base, int exp) {
29  if (exp == 0)
30  return 1;
31  if (exp == 1)
32  return base;
33  return base * PowInt(base, exp - 1);
34  }
35 
36  // Compute the two's complement of an integer
37  inline int TwosCompl(int nBits, int bits) {
38  if (bits >> (nBits - 1) == 0)
39  return bits;
40  else
41  return bits - PowInt(2, nBits);
42  };
43 
44  // Get the integer value of specified bits from a 16-bit word (0xffff)
45  inline uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit) {
46  return ((word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1));
47  }
48 
49  // Get the integer value of specified bits from a 32-bit word (0xffffffff)
50  inline uint32_t GetHexBits(uint32_t word, uint32_t lowBit, uint32_t highBit) {
51  return ((word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1));
52  }
53 
54  // Get the integer value of specified bits from two 16-bit words (0xffff, 0xffff)
55  inline uint32_t GetHexBits(
56  uint16_t word1, uint16_t lowBit1, uint16_t highBit1, uint16_t word2, uint16_t lowBit2, uint16_t highBit2) {
57  uint16_t word1_sel = (word1 >> lowBit1) & (PowInt(2, (1 + highBit1 - lowBit1)) - 1);
58  uint16_t word2_sel = (word2 >> lowBit2) & (PowInt(2, (1 + highBit2 - lowBit2)) - 1);
59  return ((word2_sel << (1 + highBit1 - lowBit1)) | word1_sel);
60  }
61 
62  } // End namespace emtf
63  } // End namespace stage2
64 } // End namespace l1t
65 
66 #endif /* define EventFilter_L1TRawToDigi_EMTFUnpackerTools_h */
MessageLogger.h
l1t::stage2::emtf::ImportRPC
void ImportRPC(EMTFHit &_hit, const l1t::emtf::RPC _RPC, const int _endcap, const int _evt_sector)
Definition: EMTFUnpackerTools.cc:37
l1t::emtf::RPC
Definition: RPC.h:11
l1t::emtf::ME
Definition: ME.h:11
EMTFTrack.h
l1t::stage2::emtf::ImportGEM
void ImportGEM(EMTFHit &_hit, const l1t::emtf::GEM &_GEM, const int _endcap, const int _evt_sector)
Definition: EMTFUnpackerTools.cc:63
l1t::stage2::emtf::TwosCompl
int TwosCompl(int nBits, int bits)
Definition: EMTFUnpackerTools.h:37
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
TrackTools.h
l1t::emtf::SP
Definition: SP.h:11
emtf
Definition: Event.h:15
EMTFDaqOut.h
l1t::EMTFTrack
Definition: EMTFTrack.h:42
l1t::emtf::GEM
Definition: GEM.h:11
l1t::EMTFHit
Definition: EMTFHit.h:25
l1t
delete x;
Definition: CaloConfig.h:22
EMTFHit.h
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::stage2::emtf::ImportSP
void ImportSP(EMTFTrack &_track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector)
Definition: EMTFUnpackerTools.cc:93
l1t::stage2::emtf::ImportME
void ImportME(EMTFHit &_hit, const l1t::emtf::ME _ME, const int _endcap, const int _evt_sector)
Definition: EMTFUnpackerTools.cc:8
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
l1t::stage2::emtf::GetHexBits
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)
Definition: EMTFUnpackerTools.h:45
l1t::stage2::emtf::PowInt
int PowInt(int base, int exp)
Definition: EMTFUnpackerTools.h:28