CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
OMTFSorter Class Reference

#include <OMTFSorter.h>

Public Member Functions

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

Private Member Functions

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

Private Attributes

const OMTFConfigurationmyOmtfConfig
 
unsigned int nPhiBins
 

Detailed Description

Definition at line 17 of file OMTFSorter.h.

Member Function Documentation

◆ candidates()

std::vector< l1t::RegionalMuonCand > OMTFSorter::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.

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 }

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

◆ checkHitPatternValidity()

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 143 of file OMTFSorter.cc.

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 }

References hfClusterShapes_cfi::hits.

Referenced by candidates().

◆ initialize()

void OMTFSorter::initialize ( const OMTFConfiguration cfg)
inline

Definition at line 19 of file OMTFSorter.h.

19 { myOmtfConfig = cfg; }

References looper::cfg, and myOmtfConfig.

Referenced by OMTFReconstruction::beginRun().

◆ setNphiBins()

void OMTFSorter::setNphiBins ( unsigned int  phiBins)
inline

Definition at line 20 of file OMTFSorter.h.

20 { nPhiBins = phiBins; }

References nPhiBins.

Referenced by OMTFReconstruction::beginRun().

◆ sortRefHitResults() [1/2]

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.

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 }

References ALCARECOTkAlJpsiMuMu_cff::charge, createfilelist::int, Key::number(), AlgoMuon::setPatternNumber(), AlgoMuon::setPhiRHit(), sortSingleResult(), Key::theCharge, Key::thePtCode, and heppy_batch::val.

◆ sortRefHitResults() [2/2]

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

Definition at line 131 of file OMTFSorter.cc.

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 }

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

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

◆ sortSingleResult()

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 15 of file OMTFSorter.cc.

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 }

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 sortRefHitResults().

Member Data Documentation

◆ myOmtfConfig

const OMTFConfiguration* OMTFSorter::myOmtfConfig
private

Definition at line 55 of file OMTFSorter.h.

Referenced by candidates(), and initialize().

◆ nPhiBins

unsigned int OMTFSorter::nPhiBins
private

Definition at line 54 of file OMTFSorter.h.

Referenced by candidates(), and setNphiBins().

hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
OMTFResult::getSummaryVals
const OMTFResult::vector1D & getSummaryVals() const
Definition: OMTFResult.h:20
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
OMTFResult::vector1D
std::vector< unsigned int > vector1D
Definition: OMTFResult.h:11
l1t::RegionalMuonCand::setHwSign
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
Definition: RegionalMuonCand.h:136
Key::thePtCode
unsigned int thePtCode
Definition: GoldenPattern.h:35
l1t::RegionalMuonCand::setTrackAddress
void setTrackAddress(const std::map< int, int > &address)
Set the whole track address.
Definition: RegionalMuonCand.h:158
OMTFResult::getRefPhis
const OMTFResult::vector1D & getRefPhis() const
Definition: OMTFResult.h:24
OMTFResult::getHitsWord
const OMTFResult::vector1D & getHitsWord() const
Definition: OMTFResult.h:28
cms::cuda::assert
assert(be >=bs)
OMTFResult::getRefEtas
const OMTFResult::vector1D & getRefEtas() const
Definition: OMTFResult.h:26
OMTFConfiguration::fwVersion
unsigned int fwVersion() const
Definition: OMTFConfiguration.h:81
OMTFSorter::sortRefHitResults
void sortRefHitResults(const std::vector< OMTFProcessor::resultsMap > &procResults, std::vector< AlgoMuon > &refHitCleanCands, int charge=0)
Definition: OMTFSorter.cc:131
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
l1t::RegionalMuonCand::hwPt
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
Definition: RegionalMuonCand.h:161
Key
Definition: GoldenPattern.h:15
Key::theCharge
int theCharge
Definition: GoldenPattern.h:36
OMTFSorter::sortSingleResult
AlgoMuon sortSingleResult(const OMTFResult &aResult)
Definition: OMTFSorter.cc:15
OMTFResult::getRefPhiRHits
const OMTFResult::vector1D & getRefPhiRHits() const
Definition: OMTFResult.h:30
l1t::RegionalMuonCand::setTFIdentifiers
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
Definition: RegionalMuonCand.cc:5
OMTFSorter::checkHitPatternValidity
bool checkHitPatternValidity(unsigned int hits)
Definition: OMTFSorter.cc:143
l1t::RegionalMuonCand::setHwPt
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
Definition: RegionalMuonCand.h:126
AlgoMuon
Definition: AlgoMuon.h:6
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
OMTFSorter::nPhiBins
unsigned int nPhiBins
Definition: OMTFSorter.h:54
l1t::RegionalMuonCand::setHwEta
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
Definition: RegionalMuonCand.h:134
createfilelist.int
int
Definition: createfilelist.py:10
l1t::RegionalMuonCand::setHwQual
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
Definition: RegionalMuonCand.h:140
l1t::RegionalMuonCand::setHwSignValid
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
Definition: RegionalMuonCand.h:138
looper.cfg
cfg
Definition: looper.py:297
OMTFResult::getSummaryHits
const OMTFResult::vector1D & getSummaryHits() const
Definition: OMTFResult.h:22
heppy_batch.val
val
Definition: heppy_batch.py:351
OMTFSorter::myOmtfConfig
const OMTFConfiguration * myOmtfConfig
Definition: OMTFSorter.h:55
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
l1t::RegionalMuonCand::setHwPhi
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
Definition: RegionalMuonCand.h:132
Key::number
unsigned int number() const
Definition: GoldenPattern.h:32
l1t::RegionalMuonCand
Definition: RegionalMuonCand.h:8