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