Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:48

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     // each BMTF processor corresponds to a 30 degree wedge = 48 in int-scale
0015     globPhi = (proc) * 48 + locPhi;
0016     // first processor starts at CMS phi = -15 degrees...
0017     globPhi += 576 - 24;
0018     // handle wrap-around (since we add the 576-24, the value will never be negative!)
0019     globPhi = globPhi % 576;
0020   } else {
0021     // all others correspond to 60 degree sectors = 96 in int-scale
0022     globPhi = (proc) * 96 + locPhi;
0023     // first processor starts at CMS phi = 15 degrees (24 in int)... Handle wrap-around with %. Add 576 to make sure the number is positive
0024     globPhi = (globPhi + 600) % 576;
0025   }
0026   return globPhi;
0027 }
0028 
0029 int l1t::MicroGMTConfiguration::setOutputMuonQuality(int muQual, tftype type, int haloBit, unsigned fwVersion) {
0030   if (fwVersion >= 0x8010000) {
0031     // From 2024 uGMT sends the full quality on to uGT
0032     return muQual;
0033   } else if (haloBit == 1 && (type == tftype::emtf_neg || type == tftype::emtf_pos)) {
0034     // set quality to 0xF if the halo bit is set
0035     return 0xF;
0036   } else {
0037     // use only the two MSBs for the muon to the uGT
0038     return muQual & 0xC;
0039   }
0040 }
0041 
0042 int l1t::MicroGMTConfiguration::calcMuonHwEtaExtra(const l1t::Muon& mu) { return mu.hwEta() + mu.hwDEtaExtra(); }
0043 
0044 int l1t::MicroGMTConfiguration::calcMuonHwPhiExtra(const l1t::Muon& mu) {
0045   auto hwPhiExtra = mu.hwPhi() + mu.hwDPhiExtra();
0046   while (hwPhiExtra < 0) {
0047     hwPhiExtra += 576;
0048   }
0049   while (hwPhiExtra > 575) {
0050     hwPhiExtra -= 576;
0051   }
0052   return hwPhiExtra;
0053 }
0054 
0055 double l1t::MicroGMTConfiguration::calcMuonEtaExtra(const l1t::Muon& mu) { return calcMuonHwEtaExtra(mu) * 0.010875; }
0056 
0057 double l1t::MicroGMTConfiguration::calcMuonPhiExtra(const l1t::Muon& mu) {
0058   //use the LorentzVector to get phi in the range -pi to +pi exactly as in the emulator
0059   math::PtEtaPhiMLorentzVector vec{0., 0., calcMuonHwPhiExtra(mu) * 0.010908, 0.};
0060   return vec.phi();
0061 }