File indexing completed on 2024-04-06 12:10:51
0001
0002
0003 #ifndef EventFilter_L1TRawToDigi_EMTFUnpackerTools_h
0004 #define EventFilter_L1TRawToDigi_EMTFUnpackerTools_h
0005
0006
0007 #include <iostream>
0008 #include <iomanip> // For things like std::setw
0009 #include <array>
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "DataFormats/L1TMuon/interface/EMTFDaqOut.h"
0012 #include "DataFormats/L1TMuon/interface/EMTFHit.h"
0013 #include "DataFormats/L1TMuon/interface/EMTFTrack.h"
0014 #include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h"
0015
0016 namespace l1t {
0017 namespace stage2 {
0018 namespace emtf {
0019 namespace L1TMuonEndCap =
0020 ::emtf;
0021
0022 void ImportME(EMTFHit& _hit, const l1t::emtf::ME _ME, const int _endcap, const int _evt_sector);
0023 void ImportRPC(EMTFHit& _hit, const l1t::emtf::RPC _RPC, const int _endcap, const int _evt_sector);
0024 void ImportGEM(EMTFHit& _hit, const l1t::emtf::GEM& _GEM, const int _endcap, const int _evt_sector);
0025 void ImportSP(EMTFTrack& _track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector);
0026
0027
0028 inline int PowInt(int base, int exp) {
0029 if (exp == 0)
0030 return 1;
0031 if (exp == 1)
0032 return base;
0033 return base * PowInt(base, exp - 1);
0034 }
0035
0036
0037 inline int TwosCompl(int nBits, int bits) {
0038 if (bits >> (nBits - 1) == 0)
0039 return bits;
0040 else
0041 return bits - PowInt(2, nBits);
0042 };
0043
0044
0045 inline uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit) {
0046 return ((word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1));
0047 }
0048
0049
0050 inline uint32_t GetHexBits(uint32_t word, uint32_t lowBit, uint32_t highBit) {
0051 return ((word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1));
0052 }
0053
0054
0055 inline uint32_t GetHexBits(
0056 uint16_t word1, uint16_t lowBit1, uint16_t highBit1, uint16_t word2, uint16_t lowBit2, uint16_t highBit2) {
0057 uint16_t word1_sel = (word1 >> lowBit1) & (PowInt(2, (1 + highBit1 - lowBit1)) - 1);
0058 uint16_t word2_sel = (word2 >> lowBit2) & (PowInt(2, (1 + highBit2 - lowBit2)) - 1);
0059 return ((word2_sel << (1 + highBit1 - lowBit1)) | word1_sel);
0060 }
0061
0062 }
0063 }
0064 }
0065
0066 #endif