Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-06 02:54:08

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     return (*a) < (*b);  //< operator of AlgoMuon

0015   };
0016 
0017   std::sort(refHitCands.rbegin(), refHitCands.rend(), customLess);
0018 
0019   for (AlgoMuons::iterator it1 = refHitCands.begin(); it1 != refHitCands.end(); ++it1) {
0020     bool isGhost = false;
0021     for (AlgoMuons::iterator it2 = refHitCleanCands.begin(); it2 != refHitCleanCands.end(); ++it2) {
0022       //do not accept candidates with similar phi (any charge combination)

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

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

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

0027         isGhost = true;
0028         break;
0029         //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

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

0031       }
0032     }
0033     if ((*it1)->getQ() > 0 && !isGhost)
0034       refHitCleanCands.emplace_back(new AlgoMuon(**it1));
0035   }
0036 
0037   while (refHitCleanCands.size() < 3)
0038     refHitCleanCands.emplace_back(new AlgoMuon());
0039 
0040   std::stringstream myStr;
0041   bool hasCandidates = false;
0042   for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
0043     if (refHitCands[iRefHit]->getQ()) {
0044       hasCandidates = true;
0045       break;
0046     }
0047   }
0048   for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
0049     if (refHitCands[iRefHit]->getQ())
0050       myStr << "Ref hit: " << iRefHit << " " << refHitCands[iRefHit] << std::endl;
0051   }
0052   myStr << "Selected Candidates with charge: " << charge << std::endl;
0053   for (unsigned int iCand = 0; iCand < refHitCleanCands.size(); ++iCand) {
0054     myStr << "Cand: " << iCand << " " << refHitCleanCands[iCand] << std::endl;
0055   }
0056 
0057   if (hasCandidates)
0058     edm::LogInfo("OMTF Sorter") << myStr.str();
0059 
0060   // update refHitCands with refHitCleanCands

0061   return refHitCleanCands;
0062 }