Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/L1TMuonOverlap/interface/GhostBuster.h"
0002 
0003 #include <algorithm>
0004 #include <sstream>
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"
0008 
0009 namespace {
0010   int phiGMT(int phiAlgo) { return phiAlgo * 437 / pow(2, 12); }
0011 }  // namespace

0012 
0013 std::vector<AlgoMuon> GhostBuster::select(std::vector<AlgoMuon> refHitCands, int charge) {
0014   std::vector<AlgoMuon> refHitCleanCands;
0015   // Sort candidates with decreased goodness,

0016   // where goodness definied in < operator of AlgoMuon

0017   std::sort(refHitCands.rbegin(), refHitCands.rend());
0018 
0019   for (std::vector<AlgoMuon>::iterator it1 = refHitCands.begin(); it1 != refHitCands.end(); ++it1) {
0020     bool isGhost = false;
0021     for (std::vector<AlgoMuon>::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(phiGMT(it1->getPhi()) - phiGMT(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.push_back(*it1);
0035   }
0036 
0037   refHitCleanCands.resize(3, AlgoMuon(0, 999, 9999, 0, 0, 0, 0, 0));  //FIXME

0038   //refHitCleanCands.resize( 3, 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 }