CMS 3D CMS Logo

GhostBusterPreferRefDt.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
4 #include <sstream>
5 
8 
9 namespace {
10 
11  int phiGMT(int phiAlgo) { return phiAlgo * 437 / pow(2, 12); }
12 
13  struct AlgoMuonEtaFix : public AlgoMuon {
14  AlgoMuonEtaFix(const AlgoMuon& mu) : AlgoMuon(mu), fixedEta(mu.getEta()) {}
15  unsigned int fixedEta;
16  };
17 
18 } // namespace
19 
20 std::vector<AlgoMuon> GhostBusterPreferRefDt::select(std::vector<AlgoMuon> muonsIN, int charge) {
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 }
constexpr int pow(int x)
Definition: conifer.h:24
float getEta(float r, float z)
Definition: Hit.h:38
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
std::vector< AlgoMuon > select(std::vector< AlgoMuon > refHitCands, int charge=0) override