CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GhostBuster Class Reference

#include <GhostBuster.h>

Inheritance diagram for GhostBuster:
IGhostBuster IGhostBuster

Public Member Functions

 GhostBuster (const OMTFConfiguration *omtfConfig)
 
AlgoMuons select (AlgoMuons refHitCands, int charge=0) override
 
std::vector< AlgoMuonselect (std::vector< AlgoMuon > refHitCands, int charge=0) override
 
 ~GhostBuster () override
 
 ~GhostBuster () override
 
- Public Member Functions inherited from IGhostBuster
virtual ~IGhostBuster ()
 
virtual ~IGhostBuster ()
 

Private Attributes

const OMTFConfigurationomtfConfig
 

Detailed Description

Definition at line 15 of file GhostBuster.h.

Constructor & Destructor Documentation

◆ ~GhostBuster() [1/2]

GhostBuster::~GhostBuster ( )
inlineoverride

Definition at line 17 of file GhostBuster.h.

17 {};

◆ GhostBuster()

GhostBuster::GhostBuster ( const OMTFConfiguration omtfConfig)
inline

Definition at line 12 of file GhostBuster.h.

const OMTFConfiguration * omtfConfig
Definition: GhostBuster.h:9

◆ ~GhostBuster() [2/2]

GhostBuster::~GhostBuster ( )
inlineoverride

Definition at line 14 of file GhostBuster.h.

14 {};

Member Function Documentation

◆ select() [1/2]

AlgoMuons GhostBuster::select ( AlgoMuons  refHitCands,
int  charge = 0 
)
overridevirtual

Implements IGhostBuster.

Definition at line 8 of file GhostBuster.cc.

References a, funct::abs(), b, ProcConfigurationBase::bits, ALCARECOTkAlJpsiMuMu_cff::charge, OMTFConfiguration::etaBits2HwEta(), ProcConfigurationBase::getStubEtaEncoding(), omtfConfig, OMTFConfiguration::procPhiToGmtPhi(), and jetUpdater_cfi::sort.

8  {
9  //edm::LogImportant("OMTFReconstruction")<<"calling "<<__PRETTY_FUNCTION__ <<std::endl;
10 
11  AlgoMuons refHitCleanCands;
12  // Sort candidates with decreased goodness,
13  auto customLess = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
14  if (!a->isValid()) {
15  return true;
16  }
17  if (!b->isValid()) {
18  return false;
19  }
20 
21  if (a->getQ() > b->getQ())
22  return false;
23  else if (a->getQ() == b->getQ() && a->getDisc() > b->getDisc())
24  return false;
25  else if (a->getQ() == b->getQ() && a->getDisc() == b->getDisc() &&
26  a->getPatternNumConstr() > b->getPatternNumConstr())
27  return false;
28  else if (a->getQ() == b->getQ() && a->getDisc() == b->getDisc() &&
29  a->getPatternNumConstr() == b->getPatternNumConstr() && a->getRefHitNumber() < b->getRefHitNumber())
30  return false;
31  else
32  return true;
33  };
34 
35  std::sort(refHitCands.rbegin(), refHitCands.rend(), customLess);
36 
37  for (AlgoMuons::iterator it1 = refHitCands.begin(); it1 != refHitCands.end(); ++it1) {
38  bool isGhost = false;
39  for (AlgoMuons::iterator it2 = refHitCleanCands.begin(); it2 != refHitCleanCands.end(); ++it2) {
40  //do not accept candidates with similar phi (any charge combination)
41  //veto window 5deg(=half of logic cone)=5/360*5760=80"logic strips"
42  //veto window 5 degree in GMT scale is 5/360*576=8 units
43  if (std::abs(omtfConfig->procPhiToGmtPhi((*it1)->getPhi()) - omtfConfig->procPhiToGmtPhi((*it2)->getPhi())) < 8) {
44  // if(std::abs(it1->getPhi() - it2->getPhi())<5/360.0*nPhiBins){
45  isGhost = true;
46  break;
47  //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
48  //TODO here the candidate that is killed does not kill other candidates - check if the firmware does the same (KB)
49  }
50  }
51  if ((*it1)->getQ() > 0 && !isGhost) {
52  refHitCleanCands.emplace_back(new AlgoMuon(**it1));
54  refHitCleanCands.back()->setEta(OMTFConfiguration::etaBits2HwEta((*it1)->getEtaHw()));
55  }
56 
57  if (refHitCleanCands.size() >= 3)
58  break;
59  }
60 
61  while (refHitCleanCands.size() < 3)
62  refHitCleanCands.emplace_back(new AlgoMuon());
63 
64  std::stringstream myStr;
65  bool hasCandidates = false;
66  for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
67  if (refHitCands[iRefHit]->getQ()) {
68  hasCandidates = true;
69  break;
70  }
71  }
72  for (unsigned int iRefHit = 0; iRefHit < refHitCands.size(); ++iRefHit) {
73  if (refHitCands[iRefHit]->getQ())
74  myStr << "Ref hit: " << iRefHit << " " << refHitCands[iRefHit] << std::endl;
75  }
76  myStr << "Selected Candidates with charge: " << charge << std::endl;
77  for (unsigned int iCand = 0; iCand < refHitCleanCands.size(); ++iCand) {
78  myStr << "Cand: " << iCand << " " << refHitCleanCands[iCand] << std::endl;
79  }
80 
81  if (hasCandidates)
82  edm::LogInfo("OMTF Sorter") << myStr.str();
83 
84  // update refHitCands with refHitCleanCands
85  return refHitCleanCands;
86 }
int procPhiToGmtPhi(int procPhi) const
StubEtaEncoding getStubEtaEncoding() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Info, false > LogInfo
double b
Definition: hdecay.h:120
std::vector< AlgoMuonPtr > AlgoMuons
Definition: AlgoMuon.h:183
const OMTFConfiguration * omtfConfig
Definition: GhostBuster.h:9
double a
Definition: hdecay.h:121
static unsigned int etaBits2HwEta(unsigned int eta)

◆ select() [2/2]

std::vector< AlgoMuon > GhostBuster::select ( std::vector< AlgoMuon refHitCands,
int  charge = 0 
)
overridevirtual

Implements IGhostBuster.

Definition at line 13 of file GhostBuster.cc.

References funct::abs(), ALCARECOTkAlJpsiMuMu_cff::charge, and jetUpdater_cfi::sort.

13  {
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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Info, false > LogInfo

Member Data Documentation

◆ omtfConfig

const OMTFConfiguration* GhostBuster::omtfConfig
private

Definition at line 9 of file GhostBuster.h.

Referenced by select().