CMS 3D CMS Logo

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