Back to home page

Project CMSSW displayed by LXR

 
 

    


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     // 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) {
0030   // use only the two MSBs for the muon to the uGT
0031   int outQual = muQual & 0xC;
0032   if (haloBit == 1 && (type == tftype::emtf_neg || type == tftype::emtf_pos)) {
0033     // set quality to 0xF if the halo bit is set
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   //use the LorentzVector to get phi in the range -pi to +pi exactly as in the emulator
0056   math::PtEtaPhiMLorentzVector vec{0., 0., calcMuonHwPhiExtra(mu) * 0.010908, 0.};
0057   return vec.phi();
0058 }