CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
OMTFSorter Class Reference

#include <OMTFSorter.h>

Public Member Functions

std::vector
< l1t::RegionalMuonCand
candidates (unsigned int iProcessor, l1t::tftype mtfType, const std::vector< AlgoMuon > &algoCands)
 
void setNphiBins (unsigned int phiBins)
 
void sortRefHitResults (const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
 
AlgoMuon sortRefHitResults (const OMTFProcessor::resultsMap &aResultsMap, int charge=0)
 

Private Member Functions

bool checkHitPatternValidity (unsigned int hits)
 
AlgoMuon sortSingleResult (const OMTFResult &aResult)
 

Private Attributes

unsigned int nPhiBins
 

Detailed Description

Definition at line 15 of file OMTFSorter.h.

Member Function Documentation

std::vector< l1t::RegionalMuonCand > OMTFSorter::candidates ( unsigned int  iProcessor,
l1t::tftype  mtfType,
const std::vector< AlgoMuon > &  algoCands 
)

conversion factor from OMTF to uGMT scale: 5400/576

Definition at line 160 of file OMTFSorter.cc.

References funct::abs(), checkHitPatternValidity(), l1t::RegionalMuonCand::hwPt(), nPhiBins, funct::pow(), HLT_25ns10e33_v2_cff::quality, mps_fire::result, l1t::RegionalMuonCand::setHwEta(), l1t::RegionalMuonCand::setHwPhi(), l1t::RegionalMuonCand::setHwPt(), l1t::RegionalMuonCand::setHwQual(), l1t::RegionalMuonCand::setHwSign(), l1t::RegionalMuonCand::setHwSignValid(), l1t::RegionalMuonCand::setTFIdentifiers(), and l1t::RegionalMuonCand::setTrackAddress().

Referenced by OMTFReconstruction::getProcessorCandidates().

161 {
162 
163  std::vector<l1t::RegionalMuonCand> result;
164 
165  for(auto myCand: algoCands){
166  l1t::RegionalMuonCand candidate;
167  candidate.setHwPt(myCand.getPt());
168  candidate.setHwEta(myCand.getEta());
169 
170  int phiValue = myCand.getPhi();
171  if(phiValue>= int(nPhiBins) ) phiValue-=nPhiBins;
173 // phiValue/=9.375;
174  phiValue *= (437./pow(2,12)); // ie. use as in hw: 9.3729977
175  candidate.setHwPhi(phiValue);
176 
177  candidate.setHwSign(myCand.getCharge()<0 ? 1:0 );
178  candidate.setHwSignValid(1);
179 
180  unsigned int quality = checkHitPatternValidity(myCand.getHits()) ? 0 | (1 << 2) | (1 << 3)
181  : 0 | (1 << 2);
182  if ( abs(myCand.getEta()) == 115
183  && ( static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000001110000000").to_ulong()
184  || static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000001110000000").to_ulong()
185  || static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000000110000000").to_ulong()
186  || static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000001100000000").to_ulong()
187  || static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000001010000000").to_ulong()
188  )
189  ) quality =4;
190 
191 // if (abs(myCand.getEta()) == 121) quality = 4;
192  if (abs(myCand.getEta()) == 121) quality = 0; // changed on request from HI
193 
194  candidate.setHwQual (quality);
195 
196  std::map<int, int> trackAddr;
197  trackAddr[0] = myCand.getHits();
198  trackAddr[1] = myCand.getRefLayer();
199  trackAddr[2] = myCand.getDisc();
200  candidate.setTrackAddress(trackAddr);
201  candidate.setTFIdentifiers(iProcessor,mtfType);
202  if (candidate.hwPt()) result.push_back(candidate);
203  }
204  return result;
205 }
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
unsigned int nPhiBins
Definition: OMTFSorter.h:57
void setTrackAddress(const std::map< int, int > &address)
Set the whole track address.
tuple result
Definition: mps_fire.py:84
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool checkHitPatternValidity(unsigned int hits)
Definition: OMTFSorter.cc:147
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
bool OMTFSorter::checkHitPatternValidity ( unsigned int  hits)
private

Check if the hit pattern of given OMTF candite is not on the list of invalid hit patterns. Invalid hit patterns provode very little to efficiency, but gives high contribution to rate. Candidate with invalid hit patterns is assigned quality=0. Currently the list of invalid patterns is hardcoded. This has to be read from configuration.

FIXME: read the list from configuration so this can be controlled at runtime.

Definition at line 147 of file OMTFSorter.cc.

Referenced by candidates().

147  {
148 
150  std::vector<unsigned int> badPatterns = {99840, 34304, 3075, 36928, 12300, 98816, 98944, 33408, 66688, 66176, 7171, 20528, 33856, 35840, 4156, 34880};
151 
152  for(auto aHitPattern: badPatterns){
153  if(hits==aHitPattern) return false;
154  }
155 
156  return true;
157 }
void OMTFSorter::setNphiBins ( unsigned int  phiBins)
inline

Definition at line 19 of file OMTFSorter.h.

References nPhiBins.

Referenced by OMTFReconstruction::beginRun().

19 { nPhiBins = phiBins;}
unsigned int nPhiBins
Definition: OMTFSorter.h:57
void OMTFSorter::sortRefHitResults ( const std::vector< OMTFProcessor::resultsMap > &  procResults,
std::vector< AlgoMuon > &  refHitCleanCands,
int  charge = 0 
)

Definition at line 134 of file OMTFSorter.cc.

References RPCpg::mu, and AlgoMuon::setRefHitNumber().

Referenced by OMTFReconstruction::getProcessorCandidates(), and OMTFReconstruction::writeResultToXML().

136  {
137 
138 // for(auto itRefHit: procResults) refHitCands.push_back(sortRefHitResults(itRefHit,charge));
139  for (unsigned int iRefHit = 0 ; iRefHit < procResults.size(); iRefHit++) {
140  AlgoMuon mu = sortRefHitResults( procResults[iRefHit],charge);
141  mu.setRefHitNumber(iRefHit);
142  refHitCands.push_back(mu);
143  }
144 }
const int mu
Definition: Constants.h:22
void sortRefHitResults(const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
Definition: OMTFSorter.cc:134
void setRefHitNumber(unsigned int aRefHitNum)
Definition: AlgoMuon.h:42
AlgoMuon OMTFSorter::sortRefHitResults ( const OMTFProcessor::resultsMap aResultsMap,
int  charge = 0 
)

Sort results from a single reference hit. Select candidate with highest number of hit layers Then select a candidate with largest likelihood value and given charge as we allow two candidates with opposite charge from single 10deg region

Accept only candidates with >2 hits

Definition at line 69 of file OMTFSorter.cc.

References AlgoMuon::getDisc(), AlgoMuon::getEta(), AlgoMuon::getHits(), AlgoMuon::getPhi(), AlgoMuon::getPhiRHit(), AlgoMuon::getQ(), AlgoMuon::getRefLayer(), Key::number(), AlgoMuon::setPatternNumber(), AlgoMuon::setPhiRHit(), sortSingleResult(), Key::theCharge, and Key::thePtCode.

70  {
71 
72  unsigned int pdfValMax = 0;
73  unsigned int nHitsMax = 0;
74  unsigned int hitsWord = 0;
75  int refPhi = 9999;
76  int refEta = 999;
77  int refLayer = -1;
78  int refPhiRHit = 9999;
79  Key bestKey;
80 
81 // std::cout <<" ====== sortRefHitResults: " << std::endl;
82  for(auto itKey: aResultsMap){
83  if(charge!=0 && itKey.first.theCharge!=charge) continue; //charge==0 means ignore charge
84  AlgoMuon val = sortSingleResult(itKey.second);
86  if(val.getQ() < 3) continue;
87 
88  if(val.getQ() > (int)nHitsMax){
89  nHitsMax = val.getQ();
90  pdfValMax = val.getDisc();
91  refPhi = val.getPhi();
92  refEta = val.getEta();
93  refLayer = val.getRefLayer();
94  hitsWord = val.getHits();
95  refPhiRHit = val.getPhiRHit();
96  bestKey = itKey.first;
97 // std::cout <<" sorter, byQual, now best is: "<<bestKey << std::endl;
98  }
99  else if(val.getQ() == (int)nHitsMax && val.getDisc() > (int)pdfValMax){
100  pdfValMax = val.getDisc();
101  refPhi = val.getPhi();
102  refEta = val.getEta();
103  refLayer = val.getRefLayer();
104  hitsWord = val.getHits();
105  refPhiRHit = val.getPhiRHit();
106  bestKey = itKey.first;
107 // std::cout <<" sorter, byDisc, now best is: "<<bestKey << std::endl;
108  }
109  else if(val.getQ() == (int)nHitsMax && val.getDisc() == (int)pdfValMax && itKey.first.number() < bestKey.number()) {
110 // itKey.first.thePtCode < bestKey.thePtCode){
111  pdfValMax = val.getDisc();
112  refPhi = val.getPhi();
113  refEta = val.getEta();
114  refLayer = val.getRefLayer();
115  hitsWord = val.getHits();
116  refPhiRHit = val.getPhiRHit();
117  bestKey = itKey.first;
118 // std::cout <<" sorter, byNumb, now best is: "<<bestKey << std::endl;
119  }
120  }
121 
122  AlgoMuon candidate(pdfValMax, refPhi, refEta, refLayer,
123  hitsWord, nHitsMax, 0,
124  bestKey.thePtCode, bestKey.theCharge);
125 
126  candidate.setPhiRHit(refPhiRHit); // for backward compatibility
127  candidate.setPatternNumber(bestKey.number());
128 
129 // std::cout <<" return: " << candidate << std::endl;
130  return candidate;
131 }
int getEta() const
Definition: AlgoMuon.h:20
unsigned int number() const
Definition: GoldenPattern.h:31
int getQ() const
Definition: AlgoMuon.h:23
int theCharge
Definition: GoldenPattern.h:35
unsigned int thePtCode
Definition: GoldenPattern.h:34
int getDisc() const
Definition: AlgoMuon.h:18
int getRefLayer() const
Definition: AlgoMuon.h:21
int getHits() const
Definition: AlgoMuon.h:22
AlgoMuon sortSingleResult(const OMTFResult &aResult)
Definition: OMTFSorter.cc:16
int getPhi() const
Definition: AlgoMuon.h:19
int getPhiRHit() const
Definition: AlgoMuon.h:27
AlgoMuon OMTFSorter::sortSingleResult ( const OMTFResult aResult)
private

Find a candidate with best parameters for given GoldenPattern Sorting is made amongs candidates with different reference layers The output tuple contains (nHitsMax, pdfValMax, refPhi, refLayer, hitsWord, refEta) hitsWord codes number of layers hit: hitsWord= sum 2**iLogicLayer, where sum runs over layers which were hit

Find a result with biggest number of hits

Definition at line 16 of file OMTFSorter.cc.

References assert(), OMTFResult::getHitsWord(), OMTFResult::getRefEtas(), OMTFResult::getRefPhiRHits(), OMTFResult::getRefPhis(), OMTFResult::getSummaryHits(), OMTFResult::getSummaryVals(), AlgoMuon::setDisc(), AlgoMuon::setEta(), AlgoMuon::setHits(), AlgoMuon::setPhi(), AlgoMuon::setPhiRHit(), AlgoMuon::setQ(), and AlgoMuon::setRefLayer().

Referenced by sortRefHitResults().

16  {
17 
18  OMTFResult::vector1D pdfValsVec = aResult.getSummaryVals();
19  OMTFResult::vector1D nHitsVec = aResult.getSummaryHits();
20  OMTFResult::vector1D refPhiVec = aResult.getRefPhis();
21  OMTFResult::vector1D refEtaVec = aResult.getRefEtas();
22  OMTFResult::vector1D hitsVec = aResult.getHitsWord();
23  OMTFResult::vector1D refPhiRHitVec = aResult.getRefPhiRHits();
24 
25  assert(pdfValsVec.size()==nHitsVec.size());
26 
27  unsigned int nHitsMax = 0;
28  unsigned int pdfValMax = 0;
29  unsigned int hitsWord = 0;
30  int refPhi = 1024;
31  int refEta = -10;
32  int refLayer = -1;
33  int refPhiRHit = 1024;
34 
35  AlgoMuon sortedResult(pdfValMax, refPhi, refEta, refLayer, hitsWord, nHitsMax);
36 
38  for(auto itHits: nHitsVec){
39  if(itHits>nHitsMax) nHitsMax = itHits;
40  }
41 
42  if(!nHitsMax) return sortedResult;
43 
44  for(unsigned int ipdfVal=0;ipdfVal<pdfValsVec.size();++ipdfVal){
45  if(nHitsVec[ipdfVal] == nHitsMax){
46  if(pdfValsVec[ipdfVal]>pdfValMax){
47  pdfValMax = pdfValsVec[ipdfVal];
48  refPhi = refPhiVec[ipdfVal];
49  refEta = refEtaVec[ipdfVal];
50  refLayer = ipdfVal;
51  hitsWord = hitsVec[ipdfVal];
52  refPhiRHit = refPhiRHitVec[ipdfVal];
53  }
54  }
55  }
56 
57  sortedResult.setDisc(pdfValMax);
58  sortedResult.setPhi(refPhi);
59  sortedResult.setEta(refEta);
60  sortedResult.setRefLayer(refLayer);
61  sortedResult.setHits(hitsWord);
62  sortedResult.setQ(nHitsMax);
63  sortedResult.setPhiRHit(refPhiRHit);
64 
65  return sortedResult;
66 }
const OMTFResult::vector1D & getRefPhiRHits() const
Definition: OMTFResult.h:32
assert(m_qm.get())
const OMTFResult::vector1D & getRefPhis() const
Definition: OMTFResult.h:26
const OMTFResult::vector1D & getSummaryVals() const
Definition: OMTFResult.h:22
const OMTFResult::vector1D & getHitsWord() const
Definition: OMTFResult.h:30
const OMTFResult::vector1D & getSummaryHits() const
Definition: OMTFResult.h:24
std::vector< unsigned int > vector1D
Definition: OMTFResult.h:13
const OMTFResult::vector1D & getRefEtas() const
Definition: OMTFResult.h:28

Member Data Documentation

unsigned int OMTFSorter::nPhiBins
private

Definition at line 57 of file OMTFSorter.h.

Referenced by candidates(), and setNphiBins().