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 13 of file GhostBusterPreferRefDt.h.

const OMTFConfiguration * omtfConfig

◆ ~GhostBusterPreferRefDt() [2/2]

GhostBusterPreferRefDt::~GhostBusterPreferRefDt ( )
inlineoverride

Definition at line 15 of file GhostBusterPreferRefDt.h.

15 {};

Member Function Documentation

◆ select() [1/2]

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

Implements IGhostBuster.

Definition at line 8 of file GhostBusterPreferRefDt.cc.

References a, funct::abs(), b, ProcConfigurationBase::bits, OMTFConfiguration::etaBits2HwEta(), OMTFConfiguration::fwVersion(), OMTFConfiguration::getGhostBusterType(), OMTFConfiguration::getRefToLogicNumber(), ProcConfigurationBase::getStubEtaEncoding(), amptDefaultParameters_cff::mu, omtfConfig, OMTFConfiguration::procPhiToGmtPhi(), and jetUpdater_cfi::sort.

8  {
9  // sorting within GB.
10  //this function is only for the OMTF version without unconstrained pt
11  auto customLess = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
12  if (!a->isValid()) {
13  return true;
14  }
15  if (!b->isValid()) {
16  return false;
17  }
18 
19  int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a->getRefLayer()];
20  int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b->getRefLayer()];
21  if (a->getFiredLayerCntConstr() > b->getFiredLayerCntConstr())
22  return false;
23  else if (a->getFiredLayerCntConstr() == b->getFiredLayerCntConstr() && aRefLayerLogicNum < bRefLayerLogicNum) {
24  return false;
25  } else if (a->getFiredLayerCntConstr() == b->getFiredLayerCntConstr() && aRefLayerLogicNum == bRefLayerLogicNum &&
26  a->getPdfSumConstr() > b->getPdfSumConstr())
27  return false;
28  else if (a->getFiredLayerCntConstr() == b->getFiredLayerCntConstr() && aRefLayerLogicNum == bRefLayerLogicNum &&
29  a->getPdfSumConstr() == b->getPdfSumConstr() && a->getPatternNumConstr() > b->getPatternNumConstr())
30  return false;
31  else if (a->getFiredLayerCntConstr() == b->getFiredLayerCntConstr() && aRefLayerLogicNum == bRefLayerLogicNum &&
32  a->getPdfSumConstr() == b->getPdfSumConstr() && a->getPatternNumConstr() == b->getPatternNumConstr() &&
33  a->getRefHitNumber() < b->getRefHitNumber())
34  return false;
35  else
36  return true;
37  };
38 
39  auto customLessByFPLLH = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
40  if (!a->isValid()) {
41  return true;
42  }
43  if (!b->isValid()) {
44  return false;
45  }
46 
47  if (a->getFiredLayerCntConstr() > b->getFiredLayerCntConstr())
48  return false;
49  else if (a->getFiredLayerCntConstr() == b->getFiredLayerCntConstr() && a->getPdfSumConstr() > b->getPdfSumConstr())
50  return false;
51  else if (a->getFiredLayerCntConstr() == b->getFiredLayerCntConstr() &&
52  a->getPdfSumConstr() == b->getPdfSumConstr() && a->getPatternNumConstr() > b->getPatternNumConstr())
53  return false;
54  else if (a->getFiredLayerCntConstr() == b->getFiredLayerCntConstr() &&
55  a->getPdfSumConstr() == b->getPdfSumConstr() && a->getPatternNumConstr() == b->getPatternNumConstr() &&
56  a->getRefHitNumber() < b->getRefHitNumber())
57  return false;
58  else
59  return true;
60  };
61 
62  auto customLessByLLH = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
63  if (!a->isValid()) {
64  return true;
65  }
66  if (!b->isValid()) {
67  return false;
68  }
69 
70  if (a->getPdfSumConstr() > b->getPdfSumConstr())
71  return false;
72  else if (a->getPdfSumConstr() == b->getPdfSumConstr() && a->getPatternNumConstr() > b->getPatternNumConstr())
73  return false;
74  else if (a->getPdfSumConstr() == b->getPdfSumConstr() && a->getPatternNumConstr() == b->getPatternNumConstr() &&
75  a->getRefHitNumber() < b->getRefHitNumber())
76  return false;
77  else
78  return true;
79  };
80 
81  //this function is for the OMTF version with unconstrained pt
82  auto customByRefLayer = [&](const AlgoMuons::value_type& a, const AlgoMuons::value_type& b) -> bool {
83  if (!a->isValid()) {
84  return true;
85  }
86  if (!b->isValid()) {
87  return false;
88  }
89 
90  int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a->getRefLayer()];
91  int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b->getRefLayer()];
92 
93  if (aRefLayerLogicNum < bRefLayerLogicNum) {
94  return false;
95  } else if (aRefLayerLogicNum == bRefLayerLogicNum && a->getPdfSum() > b->getPdfSum())
96  return false;
97  else if (aRefLayerLogicNum == bRefLayerLogicNum && a->getPdfSum() == b->getPdfSum() &&
98  a->getPatternNum() > b->getPatternNum())
99  return false;
100  else if (aRefLayerLogicNum == bRefLayerLogicNum && a->getPdfSum() == b->getPdfSum() &&
101  a->getPatternNum() == b->getPatternNum() && a->getRefHitNumber() < b->getRefHitNumber())
102  return false;
103  else
104  return true;
105  };
106 
107  if (omtfConfig->getGhostBusterType() == "byLLH")
108  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLessByLLH);
109  else if (omtfConfig->getGhostBusterType() == "byFPLLH")
110  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLessByFPLLH);
111  else if (omtfConfig->getGhostBusterType() == "byRefLayer")
112  std::sort(muonsIN.rbegin(), muonsIN.rend(), customByRefLayer);
113  else
114  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLess);
115 
116  // actual GhostBusting. Overwrite eta in case of no DT info.
117  AlgoMuons refHitCleanCandsFixedEta;
118 
119  for (unsigned int iMu1 = 0; iMu1 < muonsIN.size(); iMu1++) {
120  refHitCleanCandsFixedEta.emplace_back(new AlgoMuon(*(muonsIN[iMu1])));
121 
123  refHitCleanCandsFixedEta.back()->setEta(OMTFConfiguration::etaBits2HwEta(muonsIN[iMu1]->getEtaHw()));
124  }
125 
126  for (unsigned int iMu1 = 0; iMu1 < refHitCleanCandsFixedEta.size(); iMu1++) {
127  auto& muIN1 = refHitCleanCandsFixedEta[iMu1];
128  //watch out: the muIN1 is AlgoMuonPtr, so setting the eta here changes the eta in the input muonsIN
129  //this affects algoCandidates in OMTFProcessor<GoldenPatternType>::run
130 
131  if (!muIN1->isValid() || muIN1->isKilled())
132  continue;
133 
134  for (unsigned int iMu2 = refHitCleanCandsFixedEta.size() - 1; iMu2 >= iMu1 + 1; iMu2--) {
135  auto& muIN2 = refHitCleanCandsFixedEta[iMu2];
136  if (muIN2->isValid() &&
137  std::abs(omtfConfig->procPhiToGmtPhi(muIN1->getPhi()) - omtfConfig->procPhiToGmtPhi(muIN2->getPhi())) < 8) {
138  //the candidates are sorted, so only the muIN2 can be killed, as it is "worse" than the muIN1
139  refHitCleanCandsFixedEta[iMu2]->kill();
140  refHitCleanCandsFixedEta[iMu1]->getKilledMuons().emplace_back(muIN2);
141 
142  //for the DT stubs, if there is no eta, the middle of the chamber is set as the stub eta, i.e. 75, 79 or 92 respectively
143  //in this case the eta can be replaced by the eta from the killed algoMuon
144  if (omtfConfig->getRefToLogicNumber()[muIN1->getRefLayer()] <= 5 && (omtfConfig->fwVersion() >= 6) &&
145  ((abs(muIN1->getEtaHw()) == 75 || abs(muIN1->getEtaHw()) == 79 || abs(muIN1->getEtaHw()) == 92)) &&
146  ((abs(muIN2->getEtaHw()) != 75 && abs(muIN2->getEtaHw()) != 79 &&
147  abs(muIN2->getEtaHw()) != 92))) { //FIXME condition in this do not affects the final result
148 
149  muIN1->setEta(muIN2->getEtaHw());
150  }
151  }
152  }
153  }
154 
155  // fill outgoing collection
156  /* there is nowhere a cut on the pdfSum > 0 for a muon to be valid
157  * muon is valid if getPtConstr() > 0 || getPtUnconstr() > 0,
158  * i.e. when there was a fitting pattern
159  * this mean there can be a muon with pdfSumConstrained = 0 but with not 0 PtConstr
160  * which is OK. See also comment in the GoldenPatternResult::finalise10()
161  */
162  AlgoMuons refHitCleanCands;
163  for (const auto& mu : refHitCleanCandsFixedEta) {
164  if (mu->isValid() && !(mu->isKilled()))
165  refHitCleanCands.emplace_back(mu);
166  if (refHitCleanCands.size() >= 3)
167  break;
168  }
169 
170  while (refHitCleanCands.size() < 3)
171  refHitCleanCands.emplace_back(new AlgoMuon());
172 
173  return refHitCleanCands;
174 }
int procPhiToGmtPhi(int procPhi) const
StubEtaEncoding getStubEtaEncoding() 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:120
const std::string & getGhostBusterType() const
std::vector< AlgoMuonPtr > AlgoMuons
Definition: AlgoMuon.h:183
double a
Definition: hdecay.h:121
static unsigned int etaBits2HwEta(unsigned int eta)
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 jetUpdater_cfi::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:120
double a
Definition: hdecay.h:121
const OMTFConfiguration * omtfConfig

Member Data Documentation

◆ omtfConfig

const OMTFConfiguration * GhostBusterPreferRefDt::omtfConfig
private

Definition at line 18 of file GhostBusterPreferRefDt.h.

Referenced by select().