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(), LogTrace, 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->getPatternNumConstr() >
99  b->getPatternNumConstr()) //should be rather getPatternNum(), but for FW getPatternNumConstr() is easier
100  return false;
101  else if (aRefLayerLogicNum == bRefLayerLogicNum && a->getPdfSum() == b->getPdfSum() &&
102  a->getPatternNumConstr() == b->getPatternNumConstr())
103  return false;
104  else
105  return true;
106  };
107 
108  if (omtfConfig->getGhostBusterType() == "byLLH")
109  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLessByLLH);
110  else if (omtfConfig->getGhostBusterType() == "byFPLLH")
111  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLessByFPLLH);
112  else if (omtfConfig->getGhostBusterType() == "byRefLayer")
113  std::sort(muonsIN.rbegin(), muonsIN.rend(), customByRefLayer);
114  else
115  std::sort(muonsIN.rbegin(), muonsIN.rend(), customLess);
116 
117  // actual GhostBusting. Overwrite eta in case of no DT info.
118  AlgoMuons refHitCleanCandsFixedEta;
119 
120  for (unsigned int iMu1 = 0; iMu1 < muonsIN.size(); iMu1++) {
121  if (muonsIN[iMu1]->getPdfSumConstr() < -1) {
122  LogTrace("OMTFReconstruction") << *(muonsIN[iMu1]) << std::endl
123  << muonsIN[iMu1]->getGpResultConstr() << std::endl
124  << muonsIN[iMu1]->getGpResultUnconstr() << std::endl;
125  }
126  refHitCleanCandsFixedEta.emplace_back(new AlgoMuon(*(muonsIN[iMu1])));
127 
129  refHitCleanCandsFixedEta.back()->setEta(OMTFConfiguration::etaBits2HwEta(muonsIN[iMu1]->getEtaHw()));
130  }
131 
132  for (unsigned int iMu1 = 0; iMu1 < refHitCleanCandsFixedEta.size(); iMu1++) {
133  auto& muIN1 = refHitCleanCandsFixedEta[iMu1];
134  //watch out: the muIN1 is AlgoMuonPtr, so setting the eta here changes the eta in the input muonsIN
135  //this affects algoCandidates in OMTFProcessor<GoldenPatternType>::run
136 
137  if (!muIN1->isValid() || muIN1->isKilled())
138  continue;
139 
140  for (unsigned int iMu2 = refHitCleanCandsFixedEta.size() - 1; iMu2 >= iMu1 + 1; iMu2--) {
141  auto& muIN2 = refHitCleanCandsFixedEta[iMu2];
142  if (muIN2->isValid() &&
143  std::abs(omtfConfig->procPhiToGmtPhi(muIN1->getPhi()) - omtfConfig->procPhiToGmtPhi(muIN2->getPhi())) < 8) {
144  //the candidates are sorted, so only the muIN2 can be killed, as it is "worse" than the muIN1
145  refHitCleanCandsFixedEta[iMu2]->kill();
146  refHitCleanCandsFixedEta[iMu1]->getKilledMuons().emplace_back(muIN2);
147 
148  //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
149  //in this case the eta can be replaced by the eta from the killed algoMuon.
150  //Eta 121 is outside of the OMTF region, therefore all candidates with this eta have quality 0,
151  //so there is no sense to assign this eta to the candidates with eta 75, 79 or 92.
152  //The condition abs(muIN2->getEtaHw()) != 121 was added in the FW in 2024
153  //TODO add 95 meaning no DT segment was found, or don't use 95 in OmtfAngleConverter::getGlobalEta
154  if (omtfConfig->getRefToLogicNumber()[muIN1->getRefLayer()] <= 5 && (omtfConfig->fwVersion() >= 6) &&
155  (abs(muIN1->getEtaHw()) == 75 || abs(muIN1->getEtaHw()) == 79 || abs(muIN1->getEtaHw()) == 92) &&
156  (abs(muIN2->getEtaHw()) != 75 && abs(muIN2->getEtaHw()) != 79 && abs(muIN2->getEtaHw()) != 92 &&
157  abs(muIN2->getEtaHw()) != 121)) {
158  muIN1->setEta(muIN2->getEtaHw());
159  }
160  }
161  }
162  }
163 
164  // fill outgoing collection
165  /* there is nowhere a cut on the pdfSum > 0 for a muon to be valid
166  * muon is valid if getPtConstr() > 0 || getPtUnconstr() > 0,
167  * i.e. when there was a fitting pattern
168  * this mean there can be a muon with pdfSumConstrained = 0 but with not 0 PtConstr
169  * which is OK. See also comment in the GoldenPatternResult::finalise10()
170  */
171  AlgoMuons refHitCleanCands;
172  for (const auto& mu : refHitCleanCandsFixedEta) {
173  if (mu->isValid() && !(mu->isKilled()))
174  refHitCleanCands.emplace_back(mu);
175  if (refHitCleanCands.size() >= 3)
176  break;
177  }
178 
179  while (refHitCleanCands.size() < 3)
180  refHitCleanCands.emplace_back(new AlgoMuon());
181 
182  return refHitCleanCands;
183 }
int procPhiToGmtPhi(int procPhi) const
StubEtaEncoding getStubEtaEncoding() const
#define LogTrace(id)
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:176
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().