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 }
0012
0013 std::vector<AlgoMuon> GhostBuster::select(std::vector<AlgoMuon> refHitCands, int charge) {
0014 std::vector<AlgoMuon> refHitCleanCands;
0015
0016
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
0023
0024
0025 if (std::abs(phiGMT(it1->getPhi()) - phiGMT(it2->getPhi())) < 8) {
0026
0027 isGhost = true;
0028 break;
0029
0030
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));
0038
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
0061 return refHitCleanCands;
0062 }