CMS 3D CMS Logo

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

#include <GhostBusterPreferRefDt.h>

Inheritance diagram for GhostBusterPreferRefDt:
IGhostBuster

Public Member Functions

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

Private Attributes

const OMTFConfigurationomtfConfig
 

Detailed Description

Definition at line 16 of file GhostBusterPreferRefDt.h.

Constructor & Destructor Documentation

GhostBusterPreferRefDt::GhostBusterPreferRefDt ( OMTFConfiguration omtfConfig)
inline

Definition at line 20 of file GhostBusterPreferRefDt.h.

20 :omtfConfig(omtfConfig) {};
const OMTFConfiguration * omtfConfig
GhostBusterPreferRefDt::~GhostBusterPreferRefDt ( )
inlineoverride

Definition at line 22 of file GhostBusterPreferRefDt.h.

References ALCARECOTkAlJpsiMuMu_cff::charge, and select().

22 {};

Member Function Documentation

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

Implements IGhostBuster.

Definition at line 12 of file GhostBusterPreferRefDt.cc.

References a, funct::abs(), b, AlgoMuon::getDisc(), AlgoMuon::getPatternNumber(), AlgoMuon::getQ(), AlgoMuon::getRefHitNumber(), AlgoMuon::getRefLayer(), OMTFConfiguration::getRefToLogicNumber(), and omtfConfig.

Referenced by ~GhostBusterPreferRefDt().

12  {
13  auto customLess = [&](const AlgoMuon& a, const AlgoMuon& b)->bool {
14  int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a.getRefLayer()];
15  int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b.getRefLayer()];
16  if(a.getQ() > b.getQ())
17  return false;
18  else if(a.getQ()==b.getQ() && aRefLayerLogicNum < bRefLayerLogicNum) {
19  return false;
20  }
21  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() > b.getDisc() )
22  return false;
23  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() == b.getDisc() && a.getPatternNumber() > b.getPatternNumber() )
24  return false;
25  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() == b.getDisc() && a.getPatternNumber() == b.getPatternNumber() && a.getRefHitNumber() < b.getRefHitNumber())
26  return false;
27  else
28  return true;
29  //TODO check if the firmware really includes the pattern number and refHit number here
30  };
31 
32 /* auto customLess = [&](const AlgoMuon& a, const AlgoMuon& b)->bool {
33  int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a.getRefLayer()];
34  int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b.getRefLayer()];
35  if(a.getQ() > b.getQ())
36  return false;
37  else if(a.getQ()==b.getQ() && aRefLayerLogicNum < bRefLayerLogicNum) {
38  return false;
39  }
40  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getPatternNumber() > b.getPatternNumber() )
41  return false;
42  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getPatternNumber() == b.getPatternNumber() && a.getRefHitNumber() < b.getRefHitNumber())
43  return false;
44  else
45  return true;
46  //TODO check if the firmware really includes the pattern number and refHit number here
47  };*/
48 
49  std::vector<AlgoMuon> refHitCleanCands;
50  // Sort candidates with decreased goodness,
51  // where goodness definied in < operator of AlgoMuon
52  std::sort( refHitCands.rbegin(), refHitCands.rend(), customLess );
53 
54  for(std::vector<AlgoMuon>::iterator it1 = refHitCands.begin();
55  it1 != refHitCands.end(); ++it1){
56  bool isGhost=false;
57  for(std::vector<AlgoMuon>::iterator it2 = refHitCleanCands.begin();
58  it2 != refHitCleanCands.end(); ++it2){
59  //do not accept candidates with similar phi (any charge combination)
60  //veto window 5deg(=half of logic cone)=5/360*5760=80"logic strips"
61  //veto window 5 degree in GMT scale is 5/360*576=8 units
62  if (std::abs( phiGMT(it1->getPhi()) - phiGMT(it2->getPhi()) ) < 8 ) {
63 // if(std::abs(it1->getPhi() - it2->getPhi())<5/360.0*nPhiBins){
64  isGhost=true;
65  break;
66  //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
67  //TODO here the candidate that is killed does not kill other candidates - check if the firmware does the same (KB)
68  }
69  }
70  if(it1->getQ()>0 && !isGhost) refHitCleanCands.push_back(*it1);
71  }
72 
73  refHitCleanCands.resize( 3, AlgoMuon(0,999,9999,0,0,0,0,0) ); //FIXME
74  //refHitCleanCands.resize( 3, AlgoMuon() );
75 
76 
77  std::stringstream myStr;
78  bool hasCandidates = false;
79  for(unsigned int iRefHit=0;iRefHit<refHitCands.size();++iRefHit){
80  if(refHitCands[iRefHit].getQ()){
81  hasCandidates=true;
82  break;
83  }
84  }
85  for(unsigned int iRefHit=0;iRefHit<refHitCands.size();++iRefHit){
86  if(refHitCands[iRefHit].getQ()) myStr<<"Ref hit: "<<iRefHit<<" "<<refHitCands[iRefHit]<<std::endl;
87  }
88  myStr<<"Selected Candidates with charge: "<<charge<<std::endl;
89  for(unsigned int iCand=0; iCand<refHitCleanCands.size(); ++iCand){
90  myStr<<"Cand: "<<iCand<<" "<<refHitCleanCands[iCand]<<std::endl;
91  }
92 
93  if(hasCandidates) edm::LogInfo("OMTF Sorter")<<myStr.str();
94 
95  // update refHitCands with refHitCleanCands
96  return refHitCleanCands;
97 }
int getQ() const
Definition: AlgoMuon.h:23
unsigned int getRefHitNumber() const
Definition: AlgoMuon.h:29
int getDisc() const
Definition: AlgoMuon.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int getRefLayer() const
Definition: AlgoMuon.h:21
const OMTFConfiguration * omtfConfig
double b
Definition: hdecay.h:120
const std::vector< int > & getRefToLogicNumber() const
double a
Definition: hdecay.h:121
unsigned int getPatternNumber() const
Definition: AlgoMuon.h:28

Member Data Documentation

const OMTFConfiguration* GhostBusterPreferRefDt::omtfConfig
private

Definition at line 18 of file GhostBusterPreferRefDt.h.

Referenced by select().