CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
OMTFSorter< GoldenPatternType > Class Template Reference

#include <OMTFSorter.h>

Inheritance diagram for OMTFSorter< GoldenPatternType >:
SorterBase< GoldenPatternType >

Public Member Functions

std::vector< l1t::RegionalMuonCandcandidates (unsigned int iProcessor, l1t::tftype mtfType, const std::vector< AlgoMuon > &algoCands)
 
void initialize (const OMTFConfiguration *cfg)
 
 OMTFSorter (int sorterTypeFlag)
 
void setNphiBins (unsigned int phiBins)
 
AlgoMuons::value_type sortRefHitResults (unsigned int procIndx, unsigned int iRefHit, const GoldenPatternVec< GoldenPatternType > &gPatterns, int charge=0) override
 
void sortRefHitResults (const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
 
AlgoMuon sortRefHitResults (const OMTFProcessor::resultsMap &aResultsMap, int charge=0)
 
 ~OMTFSorter () override
 
- Public Member Functions inherited from SorterBase< GoldenPatternType >
virtual AlgoMuons sortResults (unsigned int procIndx, const GoldenPatternVec< GoldenPatternType > &gPatterns, int charge=0)
 
virtual ~SorterBase ()
 

Private Member Functions

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

Private Attributes

const OMTFConfigurationmyOmtfConfig
 
int myType
 
unsigned int nPhiBins
 

Detailed Description

template<class GoldenPatternType>
class OMTFSorter< GoldenPatternType >

Definition at line 17 of file OMTFSorter.h.

Constructor & Destructor Documentation

◆ OMTFSorter()

template<class GoldenPatternType >
OMTFSorter< GoldenPatternType >::OMTFSorter ( int  sorterTypeFlag)
inline

Definition at line 10 of file OMTFSorter.h.

10 : myType(sorterTypeFlag) {}
int myType
Definition: OMTFSorter.h:24

◆ ~OMTFSorter()

template<class GoldenPatternType >
OMTFSorter< GoldenPatternType >::~OMTFSorter ( )
inlineoverride

Definition at line 12 of file OMTFSorter.h.

12 {}

Member Function Documentation

◆ candidates()

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

conversion factor from OMTF to uGMT scale is 5400/576 i.e. phiValue/=9.375;

Definition at line 157 of file OMTFSorter.cc.

References funct::abs(), OMTFSorter< GoldenPatternType >::checkHitPatternValidity(), OMTFConfiguration::fwVersion(), l1t::RegionalMuonCand::hwPt(), OMTFSorter< GoldenPatternType >::myOmtfConfig, OMTFSorter< GoldenPatternType >::nPhiBins, funct::pow(), 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().

159  {
160  std::vector<l1t::RegionalMuonCand> result;
161 
162  for (const auto& myCand : algoCands) {
163  l1t::RegionalMuonCand candidate;
164  candidate.setHwPt(myCand.getPt());
165  candidate.setHwEta(myCand.getEta());
166 
167  int phiValue = myCand.getPhi();
168  if (phiValue >= int(nPhiBins))
169  phiValue -= nPhiBins;
171  phiValue = floor(phiValue * 437. / pow(2, 12)); // ie. use as in hw: 9.3729977
172  candidate.setHwPhi(phiValue);
173 
174  candidate.setHwSign(myCand.getCharge() < 0 ? 1 : 0);
175  candidate.setHwSignValid(1);
176 
177  unsigned int quality = checkHitPatternValidity(myCand.getHits()) ? 0 | (1 << 2) | (1 << 3) : 0 | (1 << 2);
178  if (abs(myCand.getEta()) == 115 &&
179  (static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000001110000000").to_ulong() ||
180  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000001110000000").to_ulong() ||
181  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000000110000000").to_ulong() ||
182  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000001100000000").to_ulong() ||
183  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000001010000000").to_ulong()))
184  quality = 4;
185  if (myOmtfConfig->fwVersion() >= 5) {
186  if (static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000010000000011").to_ulong() ||
187  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000100000000011").to_ulong() ||
188  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000001000000000011").to_ulong() ||
189  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000010000000000011").to_ulong() ||
190  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000100000000000011").to_ulong() ||
191  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("001000000000000011").to_ulong() ||
192  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("010000000000000011").to_ulong() ||
193  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000000000000011").to_ulong() ||
194  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000010000001100").to_ulong() ||
195  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000100000001100").to_ulong() ||
196  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000001000000001100").to_ulong() ||
197  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000010000000001100").to_ulong() ||
198  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000100000000001100").to_ulong() ||
199  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("001000000000001100").to_ulong() ||
200  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("010000000000001100").to_ulong() ||
201  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000000000001100").to_ulong() ||
202  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000010000110000").to_ulong() ||
203  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000000100000110000").to_ulong() ||
204  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000001000000110000").to_ulong() ||
205  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000010000000110000").to_ulong() ||
206  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("000100000000110000").to_ulong() ||
207  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("001000000000110000").to_ulong() ||
208  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("010000000000110000").to_ulong() ||
209  static_cast<unsigned int>(myCand.getHits()) == std::bitset<18>("100000000000110000").to_ulong())
210  quality = 1;
211  }
212 
213  // if (abs(myCand.getEta()) == 121) quality = 4;
214  if (abs(myCand.getEta()) == 121)
215  quality = 0; // changed on request from HI
216 
217  candidate.setHwQual(quality);
218 
219  std::map<int, int> trackAddr;
220  trackAddr[0] = myCand.getHits();
221  trackAddr[1] = myCand.getRefLayer();
222  trackAddr[2] = myCand.getDisc();
223  candidate.setTrackAddress(trackAddr);
224  candidate.setTFIdentifiers(iProcessor, mtfType);
225  if (candidate.hwPt())
226  result.push_back(candidate);
227  }
228  return result;
229 }
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
unsigned int nPhiBins
Definition: OMTFSorter.h:54
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
void setTrackAddress(const std::map< int, int > &address)
Set the whole track address.
bool checkHitPatternValidity(unsigned int hits)
Definition: OMTFSorter.cc:143
string quality
unsigned int fwVersion() const
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)
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
const OMTFConfiguration * myOmtfConfig
Definition: OMTFSorter.h:55
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))

◆ checkHitPatternValidity()

template<class GoldenPatternType >
bool OMTFSorter< GoldenPatternType >::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 143 of file OMTFSorter.cc.

References hfClusterShapes_cfi::hits.

Referenced by OMTFSorter< GoldenPatternType >::candidates().

143  {
145  std::vector<unsigned int> badPatterns = {
146  99840, 34304, 3075, 36928, 12300, 98816, 98944, 33408, 66688, 66176, 7171, 20528, 33856, 35840, 4156, 34880};
147 
148  for (auto aHitPattern : badPatterns) {
149  if (hits == aHitPattern)
150  return false;
151  }
152 
153  return true;
154 }

◆ initialize()

template<class GoldenPatternType >
void OMTFSorter< GoldenPatternType >::initialize ( const OMTFConfiguration cfg)
inline

Definition at line 19 of file OMTFSorter.h.

References looper::cfg, and OMTFSorter< GoldenPatternType >::myOmtfConfig.

Referenced by OMTFReconstruction::beginRun().

19 { myOmtfConfig = cfg; }
const OMTFConfiguration * myOmtfConfig
Definition: OMTFSorter.h:55

◆ setNphiBins()

template<class GoldenPatternType >
void OMTFSorter< GoldenPatternType >::setNphiBins ( unsigned int  phiBins)
inline

◆ sortRefHitResults() [1/3]

template<class GoldenPatternType >
AlgoMuons::value_type OMTFSorter< GoldenPatternType >::sortRefHitResults ( unsigned int  procIndx,
unsigned int  iRefHit,
const GoldenPatternVec< GoldenPatternType > &  gPatterns,
int  charge = 0 
)
overridevirtual

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

Implements SorterBase< GoldenPatternType >.

Definition at line 18 of file OMTFSorter.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge.

19  {
20  GoldenPatternType* bestGP = nullptr; //the GoldenPattern with the best result for this iRefHit
21  //std::cout <<" ====== sortRefHitResults: " << std::endl;
22 
23  for (auto& itGP : gPatterns) {
24  if (!itGP->getResults()[procIndx][iRefHit].isValid())
25  continue;
26 
27  if (charge != 0 && itGP->key().theCharge != charge)
28  continue; //charge==0 means ignore charge
29 
31  if (itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() < 3) //TODO - move 3 to the configuration??
32  continue;
33 
34  if (bestGP == nullptr) {
35  bestGP = itGP.get();
36  } else if (myType == 0 && itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() >
37  bestGP->getResults()[procIndx][iRefHit].getFiredLayerCnt()) {
38  bestGP = itGP.get();
39  /*
40  std::cout <<" sorter, byQual, now best is: "
41  <<bestGP->key() << " "
42  <<itGP->getResults()[procIndx][iRefHit]
43  <<std::endl;
44  */
45  } else if (myType == 1 || (itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() ==
46  bestGP->getResults()[procIndx][iRefHit].getFiredLayerCnt())) {
47  if (itGP->getResults()[procIndx][iRefHit].getPdfSum() > bestGP->getResults()[procIndx][iRefHit].getPdfSum()) {
48  //if the PdfWeigtSum is equal, we take the GP with the lower number, i.e. lower pt = check if this is ok for physics FIXME (KB)
49  bestGP = itGP.get();
50  /*
51  std::cout <<" sorter, byDisc, now best is: "
52  <<bestGP->key() << " "
53  <<itGP->getResults()[procIndx][iRefHit]
54  <<std::endl;
55  */
56  }
57  }
58  }
59  if (bestGP) {
60  AlgoMuons::value_type candidate(new AlgoMuon(bestGP->getResults()[procIndx][iRefHit], bestGP, iRefHit));
61  //std::cout<<__FUNCTION__<<" line "<<__LINE__ <<" return: " << *candidate << std::endl;
62  return candidate;
63  } else {
64  AlgoMuons::value_type candidate(new AlgoMuon());
65  candidate->setRefHitNumber(iRefHit);
66  return candidate;
67  }
68 }
int myType
Definition: OMTFSorter.h:24

◆ sortRefHitResults() [2/3]

template<class GoldenPatternType >
void OMTFSorter< GoldenPatternType >::sortRefHitResults ( const std::vector< OMTFProcessor::resultsMap > &  procResults,
std::vector< AlgoMuon > &  refHitCleanCands,
int  charge = 0 
)

Definition at line 131 of file OMTFSorter.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, and amptDefaultParameters_cff::mu.

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

133  {
134  // for(auto itRefHit: procResults) refHitCands.push_back(sortRefHitResults(itRefHit,charge));
135  for (unsigned int iRefHit = 0; iRefHit < procResults.size(); iRefHit++) {
136  AlgoMuon mu = sortRefHitResults(procResults[iRefHit], charge);
137  mu.setRefHitNumber(iRefHit);
138  refHitCands.push_back(mu);
139  }
140 }
void sortRefHitResults(const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
Definition: OMTFSorter.cc:131

◆ sortRefHitResults() [3/3]

template<class GoldenPatternType >
AlgoMuon OMTFSorter< GoldenPatternType >::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 ALCARECOTkAlJpsiMuMu_cff::charge, createfilelist::int, Key::number(), AlgoMuon::setPatternNumber(), AlgoMuon::setPhiRHit(), OMTFSorter< GoldenPatternType >::sortSingleResult(), Key::theCharge, Key::thePtCode, and heppy_batch::val.

69  {
70  unsigned int pdfValMax = 0;
71  unsigned int nHitsMax = 0;
72  unsigned int hitsWord = 0;
73  int refPhi = 9999;
74  int refEta = 999;
75  int refLayer = -1;
76  int refPhiRHit = 9999;
77  Key bestKey;
78 
79  // std::cout <<" ====== sortRefHitResults: " << std::endl;
80  for (const auto& itKey : aResultsMap) {
81  if (charge != 0 && itKey.first.theCharge != charge)
82  continue; //charge==0 means ignore charge
83  AlgoMuon val = sortSingleResult(itKey.second);
85  if (val.getQ() < 3)
86  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  } else if (val.getQ() == (int)nHitsMax && val.getDisc() > (int)pdfValMax) {
99  pdfValMax = val.getDisc();
100  refPhi = val.getPhi();
101  refEta = val.getEta();
102  refLayer = val.getRefLayer();
103  hitsWord = val.getHits();
104  refPhiRHit = val.getPhiRHit();
105  bestKey = itKey.first;
106  // std::cout <<" sorter, byDisc, now best is: "<<bestKey << std::endl;
107  } else if (val.getQ() == (int)nHitsMax && val.getDisc() == (int)pdfValMax &&
108  itKey.first.number() < bestKey.number()) {
109  // itKey.first.thePtCode < bestKey.thePtCode){
110  pdfValMax = val.getDisc();
111  refPhi = val.getPhi();
112  refEta = val.getEta();
113  refLayer = val.getRefLayer();
114  hitsWord = val.getHits();
115  refPhiRHit = val.getPhiRHit();
116  bestKey = itKey.first;
117  // std::cout <<" sorter, byNumb, now best is: "<<bestKey << std::endl;
118  }
119  }
120 
121  AlgoMuon candidate(pdfValMax, refPhi, refEta, refLayer, hitsWord, nHitsMax, 0, bestKey.thePtCode, bestKey.theCharge);
122 
123  candidate.setPhiRHit(refPhiRHit); // for backward compatibility
124  candidate.setPatternNumber(bestKey.number());
125 
126  // std::cout <<" return: " << candidate << std::endl;
127  return candidate;
128 }
unsigned int number() const
Definition: GoldenPattern.h:32
int theCharge
Definition: GoldenPattern.h:36
AlgoMuon sortSingleResult(const OMTFResult &aResult)
Definition: OMTFSorter.cc:15
unsigned int thePtCode
Definition: GoldenPattern.h:35

◆ sortSingleResult()

template<class GoldenPatternType >
AlgoMuon OMTFSorter< GoldenPatternType >::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 15 of file OMTFSorter.cc.

References cms::cuda::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 OMTFSorter< GoldenPatternType >::sortRefHitResults().

15  {
16  OMTFResult::vector1D pdfValsVec = aResult.getSummaryVals();
17  OMTFResult::vector1D nHitsVec = aResult.getSummaryHits();
18  OMTFResult::vector1D refPhiVec = aResult.getRefPhis();
19  OMTFResult::vector1D refEtaVec = aResult.getRefEtas();
20  OMTFResult::vector1D hitsVec = aResult.getHitsWord();
21  OMTFResult::vector1D refPhiRHitVec = aResult.getRefPhiRHits();
22 
23  assert(pdfValsVec.size() == nHitsVec.size());
24 
25  unsigned int nHitsMax = 0;
26  unsigned int pdfValMax = 0;
27  unsigned int hitsWord = 0;
28  int refPhi = 1024;
29  int refEta = -10;
30  int refLayer = -1;
31  int refPhiRHit = 1024;
32 
33  AlgoMuon sortedResult(pdfValMax, refPhi, refEta, refLayer, hitsWord, nHitsMax);
34 
36  for (auto itHits : nHitsVec) {
37  if (itHits > nHitsMax)
38  nHitsMax = itHits;
39  }
40 
41  if (!nHitsMax)
42  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 & getSummaryHits() const
Definition: OMTFResult.h:22
assert(be >=bs)
const OMTFResult::vector1D & getSummaryVals() const
Definition: OMTFResult.h:20
const OMTFResult::vector1D & getRefPhis() const
Definition: OMTFResult.h:24
std::vector< unsigned int > vector1D
Definition: OMTFResult.h:11
const OMTFResult::vector1D & getHitsWord() const
Definition: OMTFResult.h:28
const OMTFResult::vector1D & getRefEtas() const
Definition: OMTFResult.h:26
const OMTFResult::vector1D & getRefPhiRHits() const
Definition: OMTFResult.h:30

Member Data Documentation

◆ myOmtfConfig

template<class GoldenPatternType >
const OMTFConfiguration* OMTFSorter< GoldenPatternType >::myOmtfConfig
private

◆ myType

template<class GoldenPatternType >
int OMTFSorter< GoldenPatternType >::myType
private

Definition at line 24 of file OMTFSorter.h.

◆ nPhiBins

template<class GoldenPatternType >
unsigned int OMTFSorter< GoldenPatternType >::nPhiBins
private