CMS 3D CMS Logo

GhostBuster.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
4 #include <sstream>
5 
8 
9 namespace {
10  int phiGMT(int phiAlgo) { return phiAlgo * 437 / pow(2, 12); }
11 } // namespace
12 
13 std::vector<AlgoMuon> GhostBuster::select(std::vector<AlgoMuon> refHitCands, int charge) {
14  std::vector<AlgoMuon> refHitCleanCands;
15  // Sort candidates with decreased goodness,
16  // where goodness definied in < operator of AlgoMuon
17  std::sort(refHitCands.rbegin(), refHitCands.rend());
18 
19  for (std::vector<AlgoMuon>::iterator it1 = refHitCands.begin(); it1 != refHitCands.end(); ++it1) {
20  bool isGhost = false;
21  for (std::vector<AlgoMuon>::iterator it2 = refHitCleanCands.begin(); it2 != refHitCleanCands.end(); ++it2) {
22  //do not accept candidates with similar phi (any charge combination)
23  //veto window 5deg(=half of logic cone)=5/360*5760=80"logic strips"
24  //veto window 5 degree in GMT scale is 5/360*576=8 units
25  if (std::abs(phiGMT(it1->getPhi()) - phiGMT(it2->getPhi())) < 8) {
26  // if(std::abs(it1->getPhi() - it2->getPhi())<5/360.0*nPhiBins){
27  isGhost = true;
28  break;
29  //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
30  //TODO here the candidate that is killed does not kill other candidates - check if the firmware does the same (KB)
31  }
32  }
33  if (it1->getQ() > 0 && !isGhost)
34  refHitCleanCands.push_back(*it1);
35  }
36 
37  refHitCleanCands.resize(3, AlgoMuon(0, 999, 9999, 0, 0, 0, 0, 0)); //FIXME
38  //refHitCleanCands.resize( 3, AlgoMuon() );
39 
40  std::stringstream myStr;
41  bool hasCandidates = false;
42  for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
43  if (refHitCands[iRefHit].getQ()) {
44  hasCandidates = true;
45  break;
46  }
47  }
48  for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
49  if (refHitCands[iRefHit].getQ())
50  myStr << "Ref hit: " << iRefHit << " " << refHitCands[iRefHit] << std::endl;
51  }
52  myStr << "Selected Candidates with charge: " << charge << std::endl;
53  for (unsigned int iCand = 0; iCand < refHitCleanCands.size(); ++iCand) {
54  myStr << "Cand: " << iCand << " " << refHitCleanCands[iCand] << std::endl;
55  }
56 
57  if (hasCandidates)
58  edm::LogInfo("OMTF Sorter") << myStr.str();
59 
60  // update refHitCands with refHitCleanCands
61  return refHitCleanCands;
62 }
std::vector< AlgoMuon > select(std::vector< AlgoMuon > refHitCands, int charge=0) override
Definition: GhostBuster.cc:13
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Info, false > LogInfo
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29