File indexing completed on 2021-02-14 14:23:12
0001 #include "L1Trigger/L1TMuon/interface/MicroGMTConfiguration.h"
0002
0003 unsigned l1t::MicroGMTConfiguration::getTwosComp(const int signed_int, const int width) {
0004 if (signed_int >= 0) {
0005 return (unsigned)signed_int;
0006 }
0007 int all_one = (1 << width) - 1;
0008 return ((-signed_int) ^ all_one) + 1;
0009 }
0010
0011 int l1t::MicroGMTConfiguration::calcGlobalPhi(int locPhi, tftype t, int proc) {
0012 int globPhi = 0;
0013 if (t == bmtf) {
0014
0015 globPhi = (proc)*48 + locPhi;
0016
0017 globPhi += 576 - 24;
0018
0019 globPhi = globPhi % 576;
0020 } else {
0021
0022 globPhi = (proc)*96 + locPhi;
0023
0024 globPhi = (globPhi + 600) % 576;
0025 }
0026 return globPhi;
0027 }
0028
0029 int l1t::MicroGMTConfiguration::setOutputMuonQuality(int muQual, tftype type, int haloBit) {
0030
0031 int outQual = muQual & 0xC;
0032 if (haloBit == 1 && (type == tftype::emtf_neg || type == tftype::emtf_pos)) {
0033
0034 outQual = 0xF;
0035 }
0036 return outQual;
0037 }
0038
0039 int l1t::MicroGMTConfiguration::calcMuonHwEtaExtra(const l1t::Muon& mu) { return mu.hwEta() + mu.hwDEtaExtra(); }
0040
0041 int l1t::MicroGMTConfiguration::calcMuonHwPhiExtra(const l1t::Muon& mu) {
0042 auto hwPhiExtra = mu.hwPhi() + mu.hwDPhiExtra();
0043 while (hwPhiExtra < 0) {
0044 hwPhiExtra += 576;
0045 }
0046 while (hwPhiExtra > 575) {
0047 hwPhiExtra -= 576;
0048 }
0049 return hwPhiExtra;
0050 }
0051
0052 double l1t::MicroGMTConfiguration::calcMuonEtaExtra(const l1t::Muon& mu) { return calcMuonHwEtaExtra(mu) * 0.010875; }
0053
0054 double l1t::MicroGMTConfiguration::calcMuonPhiExtra(const l1t::Muon& mu) {
0055
0056 math::PtEtaPhiMLorentzVector vec{0., 0., calcMuonHwPhiExtra(mu) * 0.010908, 0.};
0057 return vec.phi();
0058 }