test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GhostBuster.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <map>
3 #include <set>
4 #include <vector>
5 #include <ostream>
6 #include <memory>
7 #include <algorithm>
8 #include <iostream>
9 #include <strstream>
10 #include <bitset>
11 #include <cassert>
12 
14 
17 
18 void OMTFGhostBuster::select(std::vector<AlgoMuon> & refHitCands, int charge){
19 
20  std::vector<AlgoMuon> refHitCleanCands;
21  // Sort candidates with decreased goodness,
22  // where goodness definied in < operator of AlgoMuon
23  std::sort( refHitCands.rbegin(), refHitCands.rend() );
24 
25  for(std::vector<AlgoMuon>::iterator it1 = refHitCands.begin();
26  it1 != refHitCands.end(); ++it1){
27  bool isGhost=false;
28  for(std::vector<AlgoMuon>::iterator it2 = refHitCleanCands.begin();
29  it2 != refHitCleanCands.end(); ++it2){
30  //do not accept candidates with similar phi (any charge combination)
31  //veto window 5deg(=half of logic cone)=5/360*5760=80"logic strips"
32  if(std::abs(it1->getPhi() - it2->getPhi())<5/360.0*nPhiBins){
33  isGhost=true;
34  break;
35  }
36  }
37  if(it1->getQ()>0 && !isGhost) refHitCleanCands.push_back(*it1);
38  }
39 
40  refHitCleanCands.resize( 3, AlgoMuon(0,999,9999,0,0,0,0,0) );
41 
42  std::ostringstream myStr;
43  bool hasCandidates = false;
44  for(unsigned int iRefHit=0;iRefHit<refHitCands.size();++iRefHit){
45  if(refHitCands[iRefHit].getQ()){
46  hasCandidates=true;
47  break;
48  }
49  }
50  for(unsigned int iRefHit=0;iRefHit<refHitCands.size();++iRefHit){
51  if(refHitCands[iRefHit].getQ()) myStr<<"Ref hit: "<<iRefHit<<" "<<refHitCands[iRefHit]<<std::endl;
52  }
53  myStr<<"Selected Candidates with charge: "<<charge<<std::endl;
54  for(unsigned int iCand=0; iCand<refHitCleanCands.size(); ++iCand){
55  myStr<<"Cand: "<<iCand<<" "<<refHitCleanCands[iCand]<<std::endl;
56  }
57 
58  if(hasCandidates) edm::LogInfo("OMTF Sorter")<<myStr.str();
59 
60  // update refHitCands with refHitCleanCands
61  refHitCands = refHitCleanCands;
62 }
unsigned int nPhiBins
Definition: GhostBuster.h:20
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void select(std::vector< AlgoMuon > &refHitCands, int charge=0)
Definition: GhostBuster.cc:18