File indexing completed on 2023-03-17 11:12:52
0001
0002
0003
0004
0005
0006
0007
0008 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include <iomanip>
0012
0013 std::ostream& operator<<(std::ostream& out, const Key& o) {
0014 out << "Key_" << std::setw(2) << o.theNumber << " hwNum " << std::setw(2) << o.getHwPatternNumber() << " group "
0015 << std::setw(2) << o.theGroup << ":" << o.theIndexInGroup << " : (eta=" << o.theEtaCode << ", pt=" << std::setw(3)
0016 << o.thePt << ", charge=" << setw(2) << o.theCharge << ")";
0017 return out;
0018 }
0019
0020 GoldenPatternBase::GoldenPatternBase(const Key& aKey) : theKey(aKey), myOmtfConfig(nullptr) {}
0021
0022 GoldenPatternBase::GoldenPatternBase(const Key& aKey, const OMTFConfiguration* omtfConfig)
0023 : theKey(aKey),
0024 myOmtfConfig(omtfConfig),
0025 results(boost::extents[myOmtfConfig->processorCnt()][myOmtfConfig->nTestRefHits()]) {
0026 for (unsigned int iProc = 0; iProc < results.size(); iProc++) {
0027 for (unsigned int iTestRefHit = 0; iTestRefHit < results[iProc].size(); iTestRefHit++) {
0028 results[iProc][iTestRefHit].init(omtfConfig);
0029 }
0030 }
0031 }
0032
0033 void GoldenPatternBase::setConfig(const OMTFConfiguration* omtfConfig) {
0034 myOmtfConfig = omtfConfig;
0035 results.resize(boost::extents[myOmtfConfig->processorCnt()][myOmtfConfig->nTestRefHits()]);
0036 for (unsigned int iProc = 0; iProc < results.size(); iProc++) {
0037 for (unsigned int iTestRefHit = 0; iTestRefHit < results[iProc].size(); iTestRefHit++) {
0038 results[iProc][iTestRefHit].init(omtfConfig);
0039 }
0040 }
0041 }
0042
0043
0044
0045 StubResult GoldenPatternBase::process1Layer1RefLayer(unsigned int iRefLayer,
0046 unsigned int iLayer,
0047 MuonStubPtrs1D layerStubs,
0048 const MuonStubPtr refStub) {
0049
0050
0051 int phiMean = this->meanDistPhiValue(iLayer, iRefLayer, refStub->phiBHw);
0052 int phiDistMin = myOmtfConfig->nPhiBins();
0053
0054
0055
0056 MuonStubPtr selectedStub;
0057
0058 int phiRefHit = 0;
0059 if (refStub)
0060 phiRefHit = refStub->phiHw;
0061
0062 if (this->myOmtfConfig->isBendingLayer(iLayer)) {
0063 phiRefHit = 0;
0064 }
0065
0066 for (auto& stub : layerStubs) {
0067 if (!stub)
0068 continue;
0069
0070 int hitPhi = stub->phiHw;
0071 if (this->myOmtfConfig->isBendingLayer(iLayer)) {
0072
0073 hitPhi = stub->phiBHw;
0074 }
0075
0076 if (hitPhi >= (int)myOmtfConfig->nPhiBins())
0077 continue;
0078
0079 int phiDist = this->myOmtfConfig->foldPhi(hitPhi - phiMean - phiRefHit);
0080
0081
0082
0083
0084
0085
0086
0087
0088 int sign = phiDist < 0 ? -1 : 1;
0089 phiDist = abs(phiDist) >> this->getDistPhiBitShift(iLayer, iRefLayer);
0090 phiDist *= sign;
0091
0092
0093 if (abs(phiDist) < abs(phiDistMin)) {
0094 phiDistMin = phiDist;
0095 selectedStub = stub;
0096 }
0097 }
0098
0099 if (!selectedStub) {
0100 if (this->myOmtfConfig->isNoHitValueInPdf()) {
0101 PdfValueType pdfVal = this->pdfValue(iLayer, iRefLayer, 0);
0102 return StubResult(pdfVal, false, myOmtfConfig->nPhiBins(), iLayer, selectedStub);
0103 } else {
0104 return StubResult(0, false, myOmtfConfig->nPhiBins(), iLayer, selectedStub);
0105 }
0106 }
0107
0108 int pdfMiddle = 1 << (myOmtfConfig->nPdfAddrBits() - 1);
0109
0110
0111
0112
0113
0114
0115
0116
0117 if (abs(phiDistMin) > ((1 << (myOmtfConfig->nPdfAddrBits() - 1)) - 1)) {
0118 return StubResult(0, false, phiDistMin + pdfMiddle, iLayer, selectedStub);
0119
0120
0121
0122
0123 }
0124
0125
0126 phiDistMin += pdfMiddle;
0127
0128 PdfValueType pdfVal = this->pdfValue(iLayer, iRefLayer, phiDistMin);
0129 if (pdfVal <= 0) {
0130 return StubResult(0, false, phiDistMin, iLayer, selectedStub);
0131 }
0132 return StubResult(pdfVal, true, phiDistMin, iLayer, selectedStub);
0133 }
0134
0135
0136
0137 void GoldenPatternBase::finalise(unsigned int procIndx) {
0138 for (auto& result : getResults()[procIndx]) {
0139 result.finalise();
0140 }
0141 }