Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-21 02:53:15

0001 #include "L1Trigger/CSCTrackFinder/interface/CSCTFMuonSorter.h"
0002 #include "DataFormats/CSCDigi/interface/CSCConstants.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 CSCTFMuonSorter::CSCTFMuonSorter(const edm::ParameterSet& pset) {
0006   m_minBX = pset.getParameter<int>("MinBX");
0007   m_maxBX = pset.getParameter<int>("MaxBX");
0008 }
0009 
0010 std::vector<L1MuRegionalCand> CSCTFMuonSorter::run(const CSCTriggerContainer<csc::L1Track>& tracks) const {
0011   std::vector<L1MuRegionalCand> result;
0012 
0013   // First we sort and crop the incoming tracks based on their rank.
0014   for (int bx = m_minBX - CSCConstants::LCT_CENTRAL_BX; bx <= m_maxBX - CSCConstants::LCT_CENTRAL_BX;
0015        ++bx)  // switch back into signed BX
0016   {
0017     std::vector<csc::L1Track> tks = tracks.get(bx);
0018     std::sort(tks.begin(), tks.end(), std::greater<csc::L1Track>());
0019     if (tks.size() > 4)
0020       tks.resize(4);  // resize to max number of muons the MS can output
0021 
0022     std::vector<csc::L1Track>::iterator itr = tks.begin();
0023     std::vector<csc::L1Track>::const_iterator end = tks.end();
0024     for (; itr != end; itr++) {
0025       unsigned gbl_phi =
0026           itr->localPhi() + ((itr->sector() - 1) * 24) + 6;  // for now, convert using this.. LUT in the future
0027       if (gbl_phi > 143)
0028         gbl_phi -= 143;
0029       itr->setPhiPacked(gbl_phi & 0xff);
0030       unsigned eta_sign = (itr->endcap() == 1 ? 0 : 1);
0031 
0032       int gbl_eta = itr->eta_packed() | eta_sign << (L1MuRegionalCand::ETA_LENGTH - 1);
0033 
0034       itr->setEtaPacked(gbl_eta & 0x3f);
0035       unsigned pt = 0, quality = 0;
0036       decodeRank(itr->rank(), quality, pt);
0037 
0038       itr->setQualityPacked(quality & 0x3);
0039       itr->setPtPacked(pt & 0x1f);
0040 
0041       if (!itr->empty())
0042         result.push_back(*itr);
0043     }
0044   }
0045 
0046   std::vector<L1MuRegionalCand>::const_iterator ittr = result.begin();
0047   unsigned ii = 1;
0048   for (; ittr != result.end(); ittr++) {
0049     LogDebug("CSCTFMuonSorter:run()") << "TRACK " << ii++ << ": Eta: " << ittr->etaValue()
0050                                       << " Phi: " << ittr->phiValue() << " Pt: " << ittr->ptValue()
0051                                       << " Quality: " << ittr->quality() << " BX: " << ittr->bx();
0052   }
0053 
0054   return result;
0055 }
0056 
0057 // This will change to use a look up table
0058 void CSCTFMuonSorter::decodeRank(const unsigned& rank, unsigned& quality, unsigned& pt) const {
0059   if (rank == 0) {
0060     quality = 0;
0061     pt = 0;
0062   } else {
0063     quality = rank >> L1MuRegionalCand::PT_LENGTH;
0064     pt = rank & ((1 << L1MuRegionalCand::PT_LENGTH) - 1);
0065   }
0066 }