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  // 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  }
33  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() > b.getDisc() )
34  return false;
35  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() == b.getDisc() && a.getPatternNumber() > b.getPatternNumber() )
36  return false;
37  else if (a.getQ()==b.getQ() && aRefLayerLogicNum == bRefLayerLogicNum && a.getDisc() == b.getDisc() && 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)) ) it1->fixedEta=it2->getEta();
60  }
61  }
62  }
63  if (killIt != refHitCleanCandsFixedEta.end()) refHitCleanCandsFixedEta.erase(killIt);
64  }
65 
66  // fill outgoing collection
67  std::vector<AlgoMuon> refHitCleanCands;
68  for (const auto & mu : refHitCleanCandsFixedEta) {
69  AlgoMuon fixed = mu;
70  fixed.setEta(mu.fixedEta);
71  refHitCleanCands.push_back(fixed);
72  }
73 
74  refHitCleanCands.resize( 3, AlgoMuon(0,999,9999,0,0,0,0,0) );
75 /*
76  std::stringstream myStr;
77  bool hasCandidates = false;
78  for(unsigned int iRefHit=0;iRefHit<refHitCleanCands.size();++iRefHit){
79  if(refHitCleanCands[iRefHit].getQ()){
80  hasCandidates=true;
81  break;
82  }
83  }
84  for(unsigned int iRefHit=0;iRefHit<refHitCleanCands.size();++iRefHit){
85  if(refHitCleanCands[iRefHit].getQ()) myStr<<"Ref hit: "<<iRefHit<<" "<<refHitCleanCands[iRefHit]<<std::endl;
86  }
87  if(hasCandidates) edm::LogInfo("OMTF Sorter")<<myStr.str();
88 */
89 
90  return refHitCleanCands;
91 }
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