CMS 3D CMS Logo

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

#include <GhostBusterPreferRefDt.h>

Inheritance diagram for GhostBusterPreferRefDt:
IGhostBuster IGhostBuster

Public Member Functions

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

Private Attributes

const OMTFConfigurationomtfConfig
 

Detailed Description

Definition at line 16 of file GhostBusterPreferRefDt.h.

Constructor & Destructor Documentation

◆ GhostBusterPreferRefDt() [1/2]

GhostBusterPreferRefDt::GhostBusterPreferRefDt ( OMTFConfiguration omtfConfig)
inline

Definition at line 21 of file GhostBusterPreferRefDt.h.

const OMTFConfiguration * omtfConfig

◆ ~GhostBusterPreferRefDt() [1/2]

GhostBusterPreferRefDt::~GhostBusterPreferRefDt ( )
inlineoverride

Definition at line 23 of file GhostBusterPreferRefDt.h.

23 {};

◆ GhostBusterPreferRefDt() [2/2]

GhostBusterPreferRefDt::GhostBusterPreferRefDt ( const OMTFConfiguration omtfConfig)
inline

Definition at line 20 of file GhostBusterPreferRefDt.h.

const OMTFConfiguration * omtfConfig

◆ ~GhostBusterPreferRefDt() [2/2]

GhostBusterPreferRefDt::~GhostBusterPreferRefDt ( )
inlineoverride

Definition at line 22 of file GhostBusterPreferRefDt.h.

22 {};

Member Function Documentation

◆ select() [1/2]

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

Implements IGhostBuster.

Definition at line 17 of file GhostBusterPreferRefDt.cc.

References a, funct::abs(), b, alignBH_cfg::fixed, OMTFConfiguration::fwVersion(), OMTFConfiguration::getGhostBusterType(), OMTFConfiguration::getRefToLogicNumber(), amptDefaultParameters_cff::mu, GetRecoTauVFromDQM_MC_cff::next, omtfConfig, OMTFConfiguration::procPhiToGmtPhi(), and jetsAK4_CHS_cff::sort.

17  {
18  // sorting within GB.
19  auto customLess = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
20  if (!a->isValid()) {
21  return true;
22  }
23  if (!b->isValid()) {
24  return false;
25  }
26 
27  int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a->getRefLayer()];
28  int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b->getRefLayer()];
29  if (a->getQ() > b->getQ())
30  return false;
31  else if (a->getQ() == b->getQ() && aRefLayerLogicNum < bRefLayerLogicNum) {
32  return false;
33  } else if (a->getQ() == b->getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a->getDisc() > b->getDisc())
34  return false;
35  else if (a->getQ() == b->getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a->getDisc() == b->getDisc() &&
36  a->getPatternNumber() > b->getPatternNumber())
37  return false;
38  else if (a->getQ() == b->getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a->getDisc() == b->getDisc() &&
39  a->getPatternNumber() == b->getPatternNumber() && a->getRefHitNumber() < b->getRefHitNumber())
40  return false;
41  else
42  return true;
43  };
44 
45  auto customLessByFPLLH = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
46  if (!a->isValid()) {
47  return true;
48  }
49  if (!b->isValid()) {
50  return false;
51  }
52 
53  if (a->getQ() > b->getQ())
54  return false;
55  else if (a->getQ() == b->getQ()) {
56  return false;
57  } else if (a->getQ() == b->getQ() && a->getDisc() > b->getDisc())
58  return false;
59  else if (a->getQ() == b->getQ() && a->getDisc() == b->getDisc() && a->getPatternNumber() > b->getPatternNumber())
60  return false;
61  else if (a->getQ() == b->getQ() && a->getDisc() == b->getDisc() && a->getPatternNumber() == b->getPatternNumber() &&
62  a->getRefHitNumber() < b->getRefHitNumber())
63  return false;
64  else
65  return true;
66  };
67 
68  auto customLessByLLH = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
69  if (!a->isValid()) {
70  return true;
71  }
72  if (!b->isValid()) {
73  return false;
74  }
75 
76  if (a->getDisc() > b->getDisc())
77  return false;
78  else if (a->getDisc() == b->getDisc() && a->getPatternNumber() > b->getPatternNumber())
79  return false;
80  else if (a->getDisc() == b->getDisc() && a->getPatternNumber() == b->getPatternNumber() &&
81  a->getRefHitNumber() < b->getRefHitNumber())
82  return false;
83  else
84  return true;
85  };
86 
87  auto customLessByReLayer = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
88  if (!a->isValid()) {
89  return true;
90  }
91  if (!b->isValid()) {
92  return false;
93  }
94 
95  int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a->getRefLayer()];
96  int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b->getRefLayer()];
97 
98  if (aRefLayerLogicNum < bRefLayerLogicNum) {
99  return false;
100  }
101  //TODO maybe use getQ here?
102  // if(a->getQ() > b->getQ())
103  // return false;
104  else if (aRefLayerLogicNum == bRefLayerLogicNum && a->getDisc() > b->getDisc())
105  return false;
106  else if (aRefLayerLogicNum == bRefLayerLogicNum && a->getDisc() == b->getDisc() &&
107  a->getPatternNumber() > b->getPatternNumber())
108  return false;
109  else if (aRefLayerLogicNum == bRefLayerLogicNum && a->getDisc() == b->getDisc() &&
110  a->getPatternNumber() == b->getPatternNumber() && a->getRefHitNumber() < b->getRefHitNumber())
111  return false;
112  else
113  return true;
114  };
115 
116  if (omtfConfig->getGhostBusterType() == "byLLH")
117  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLessByLLH);
118  else if (omtfConfig->getGhostBusterType() == "byFPLLH")
119  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLessByFPLLH);
120  else if (omtfConfig->getGhostBusterType() == "byReLayer")
121  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLessByReLayer);
122  else
123  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLess);
124 
125  // actual GhostBusting. Overwrite eta in case of no DT info.
126  std::vector<AlgoMuonEtaFix> refHitCleanCandsFixedEta;
127  for (const auto& muIN : muonsIN) {
128  if (!muIN->isValid())
129  continue;
130 
131  //LogTrace("l1tOmtfEventPrint")<< "GhostBusting "<<*muIN<<" phiGMT "<<omtfConfig->procPhiToGmtPhi(muIN->getPhi())<< std::endl;
132 
133  refHitCleanCandsFixedEta.push_back(*muIN); //FIXME to much copying here...
134  auto killIt = refHitCleanCandsFixedEta.end();
135 
136  //do not accept candidates with similar phi (any charge combination)
137  //veto window 5 degree in GMT scale is 5/360*576=8 units
138  for (auto it1 = refHitCleanCandsFixedEta.begin(); it1 != refHitCleanCandsFixedEta.end(); ++it1) {
139  for (auto it2 = std::next(it1); it2 != refHitCleanCandsFixedEta.end(); ++it2) {
140  if (it2->isValid() &&
141  std::abs(omtfConfig->procPhiToGmtPhi(it1->getPhi()) - omtfConfig->procPhiToGmtPhi(it2->getPhi())) < 8) {
142  killIt = it2;
143  if ((omtfConfig->fwVersion() >= 6) &&
144  ((abs(it1->getEtaHw()) == 75 || abs(it1->getEtaHw()) == 79 || abs(it1->getEtaHw()) == 92)) &&
145  ((abs(it2->getEtaHw()) != 75 && abs(it2->getEtaHw()) != 79 && abs(it2->getEtaHw()) != 92)))
146  it1->fixedEta = it2->getEtaHw();
147  }
148  }
149  }
150  if (killIt != refHitCleanCandsFixedEta.end())
151  refHitCleanCandsFixedEta.erase(killIt);
152  }
153 
154  // fill outgoing collection
155  AlgoMuons refHitCleanCands;
156  for (const auto& mu : refHitCleanCandsFixedEta) {
157  AlgoMuon fixed = mu;
158  fixed.setEta(mu.fixedEta);
159  refHitCleanCands.emplace_back(new AlgoMuon(fixed));
160  if (refHitCleanCands.size() >= 3)
161  break;
162  }
163 
164  while (refHitCleanCands.size() < 3)
165  refHitCleanCands.emplace_back(new AlgoMuon());
166 
167  return refHitCleanCands;
168 }
int procPhiToGmtPhi(int procPhi) const
unsigned int fwVersion() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< int > & getRefToLogicNumber() const
double b
Definition: hdecay.h:118
const std::string & getGhostBusterType() const
std::vector< AlgoMuonPtr > AlgoMuons
Definition: AlgoMuon.h:102
double a
Definition: hdecay.h:119
const OMTFConfiguration * omtfConfig

◆ select() [2/2]

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

Implements IGhostBuster.

Definition at line 20 of file GhostBusterPreferRefDt.cc.

References a, funct::abs(), b, alignBH_cfg::fixed, OMTFConfiguration::fwVersion(), OMTFConfiguration::getRefToLogicNumber(), amptDefaultParameters_cff::mu, GetRecoTauVFromDQM_MC_cff::next, omtfConfig, and jetsAK4_CHS_cff::sort.

20  {
21  // sorting within GB.
22  auto customLess = [&](const AlgoMuon& a, const AlgoMuon& b) -> bool {
23  // protect against access violation
24  if (a.getRefLayer() == -1 || b.getRefLayer() == -1)
25  return false;
26  int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a.getRefLayer()];
27  int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b.getRefLayer()];
28  if (a.getQ() > b.getQ())
29  return false;
30  else if (a.getQ() == b.getQ() && aRefLayerLogicNum < bRefLayerLogicNum) {
31  return false;
32  } else if (a.getQ() == b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() > b.getDisc())
33  return false;
34  else if (a.getQ() == b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() == b.getDisc() &&
35  a.getPatternNumber() > b.getPatternNumber())
36  return false;
37  else if (a.getQ() == b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() == b.getDisc() &&
38  a.getPatternNumber() == b.getPatternNumber() && a.getRefHitNumber() < b.getRefHitNumber())
39  return false;
40  else
41  return true;
42  };
43 
44  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLess);
45 
46  // actual GhostBusting. Overwrite eta in case of no DT info.
47  std::vector<AlgoMuonEtaFix> refHitCleanCandsFixedEta;
48  for (const auto& muIN : muonsIN) {
49  refHitCleanCandsFixedEta.push_back(muIN);
50  auto killIt = refHitCleanCandsFixedEta.end();
51 
52  //do not accept candidates with similar phi (any charge combination)
53  //veto window 5 degree in GMT scale is 5/360*576=8 units
54  for (auto it1 = refHitCleanCandsFixedEta.begin(); it1 != refHitCleanCandsFixedEta.end(); ++it1) {
55  for (auto it2 = std::next(it1); it2 != refHitCleanCandsFixedEta.end(); ++it2) {
56  if (std::abs(phiGMT(it1->getPhi()) - phiGMT(it2->getPhi())) < 8) {
57  killIt = it2;
58  if ((omtfConfig->fwVersion() >= 6) &&
59  ((abs(it1->getEta()) == 75 || abs(it1->getEta()) == 79 || abs(it1->getEta()) == 92)) &&
60  ((abs(it2->getEta()) != 75 && abs(it2->getEta()) != 79 && abs(it2->getEta()) != 92)))
61  it1->fixedEta = it2->getEta();
62  }
63  }
64  }
65  if (killIt != refHitCleanCandsFixedEta.end())
66  refHitCleanCandsFixedEta.erase(killIt);
67  }
68 
69  // fill outgoing collection
70  std::vector<AlgoMuon> refHitCleanCands;
71  for (const auto& mu : refHitCleanCandsFixedEta) {
72  AlgoMuon fixed = mu;
73  fixed.setEta(mu.fixedEta);
74  refHitCleanCands.push_back(fixed);
75  }
76 
77  refHitCleanCands.resize(3, AlgoMuon(0, 999, 9999, 0, 0, 0, 0, 0));
78  /*
79  std::stringstream myStr;
80  bool hasCandidates = false;
81  for(unsigned int iRefHit=0;iRefHit<refHitCleanCands.size();++iRefHit){
82  if(refHitCleanCands[iRefHit].getQ()){
83  hasCandidates=true;
84  break;
85  }
86  }
87  for(unsigned int iRefHit=0;iRefHit<refHitCleanCands.size();++iRefHit){
88  if(refHitCleanCands[iRefHit].getQ()) myStr<<"Ref hit: "<<iRefHit<<" "<<refHitCleanCands[iRefHit]<<std::endl;
89  }
90  if(hasCandidates) edm::LogInfo("OMTF Sorter")<<myStr.str();
91 */
92 
93  return refHitCleanCands;
94 }
unsigned int fwVersion() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< int > & getRefToLogicNumber() const
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
const OMTFConfiguration * omtfConfig

Member Data Documentation

◆ omtfConfig

const OMTFConfiguration * GhostBusterPreferRefDt::omtfConfig
private

Definition at line 18 of file GhostBusterPreferRefDt.h.

Referenced by select().