Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:07

0001 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBuster.h"
0002 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h"
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 
0006 #include <sstream>
0007 
0008 AlgoMuons GhostBuster::select(AlgoMuons refHitCands, int charge) {
0009   //edm::LogImportant("OMTFReconstruction")<<"calling "<<__PRETTY_FUNCTION__ <<std::endl;

0010 
0011   AlgoMuons refHitCleanCands;
0012   // Sort candidates with decreased goodness,

0013   auto customLess = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
0014     if (!a->isValid()) {
0015       return true;
0016     }
0017     if (!b->isValid()) {
0018       return false;
0019     }
0020 
0021     if (a->getQ() > b->getQ())
0022       return false;
0023     else if (a->getQ() == b->getQ() && a->getDisc() > b->getDisc())
0024       return false;
0025     else if (a->getQ() == b->getQ() && a->getDisc() == b->getDisc() &&
0026              a->getPatternNumConstr() > b->getPatternNumConstr())
0027       return false;
0028     else if (a->getQ() == b->getQ() && a->getDisc() == b->getDisc() &&
0029              a->getPatternNumConstr() == b->getPatternNumConstr() && a->getRefHitNumber() < b->getRefHitNumber())
0030       return false;
0031     else
0032       return true;
0033   };
0034 
0035   std::sort(refHitCands.rbegin(), refHitCands.rend(), customLess);
0036 
0037   for (AlgoMuons::iterator it1 = refHitCands.begin(); it1 != refHitCands.end(); ++it1) {
0038     bool isGhost = false;
0039     for (AlgoMuons::iterator it2 = refHitCleanCands.begin(); it2 != refHitCleanCands.end(); ++it2) {
0040       //do not accept candidates with similar phi (any charge combination)

0041       //veto window 5deg(=half of logic cone)=5/360*5760=80"logic strips"

0042       //veto window 5 degree in GMT scale is 5/360*576=8 units

0043       if (std::abs(omtfConfig->procPhiToGmtPhi((*it1)->getPhi()) - omtfConfig->procPhiToGmtPhi((*it2)->getPhi())) < 8) {
0044         //      if(std::abs(it1->getPhi() - it2->getPhi())<5/360.0*nPhiBins){

0045         isGhost = true;
0046         break;
0047         //which one candidate is killed depends only on the order in the refHitCands (the one with smaller index is taken), and this order is assured by the sort above

0048         //TODO here the candidate that is killed does not kill other candidates - check if the firmware does the same (KB)

0049       }
0050     }
0051     if ((*it1)->getQ() > 0 && !isGhost) {
0052       refHitCleanCands.emplace_back(new AlgoMuon(**it1));
0053       if (omtfConfig->getStubEtaEncoding() == ProcConfigurationBase::StubEtaEncoding::bits)
0054         refHitCleanCands.back()->setEta(OMTFConfiguration::etaBits2HwEta((*it1)->getEtaHw()));
0055     }
0056 
0057     if (refHitCleanCands.size() >= 3)
0058       break;
0059   }
0060 
0061   while (refHitCleanCands.size() < 3)
0062     refHitCleanCands.emplace_back(new AlgoMuon());
0063 
0064   std::stringstream myStr;
0065   bool hasCandidates = false;
0066   for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
0067     if (refHitCands[iRefHit]->getQ()) {
0068       hasCandidates = true;
0069       break;
0070     }
0071   }
0072   for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
0073     if (refHitCands[iRefHit]->getQ())
0074       myStr << "Ref hit: " << iRefHit << " " << refHitCands[iRefHit] << std::endl;
0075   }
0076   myStr << "Selected Candidates with charge: " << charge << std::endl;
0077   for (unsigned int iCand = 0; iCand < refHitCleanCands.size(); ++iCand) {
0078     myStr << "Cand: " << iCand << " " << refHitCleanCands[iCand] << std::endl;
0079   }
0080 
0081   if (hasCandidates)
0082     edm::LogInfo("OMTF Sorter") << myStr.str();
0083 
0084   // update refHitCands with refHitCleanCands

0085   return refHitCleanCands;
0086 }