File indexing completed on 2024-04-06 12:21:07
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 std::vector<int>& extrapolatedPhi,
0049 const MuonStubPtr& refStub) {
0050
0051
0052 int phiMean = this->meanDistPhiValue(iLayer, iRefLayer, refStub->phiBHw);
0053 int phiDistMin = myOmtfConfig->nPhiBins();
0054
0055
0056
0057 MuonStubPtr selectedStub;
0058
0059 int phiRefHit = 0;
0060 if (refStub)
0061 phiRefHit = refStub->phiHw;
0062
0063 if (this->myOmtfConfig->isBendingLayer(iLayer)) {
0064 phiRefHit = 0;
0065 }
0066
0067 for (size_t iStub = 0; iStub < layerStubs.size(); iStub++) {
0068 const auto& stub = layerStubs[iStub];
0069 if (!stub)
0070 continue;
0071
0072 int hitPhi = stub->phiHw;
0073 if (this->myOmtfConfig->isBendingLayer(iLayer)) {
0074
0075 hitPhi = stub->phiBHw;
0076 }
0077
0078 if (hitPhi >= (int)myOmtfConfig->nPhiBins())
0079 continue;
0080
0081 int phiDist = this->myOmtfConfig->foldPhi(hitPhi - extrapolatedPhi[iStub] - phiMean - phiRefHit);
0082
0083
0084
0085
0086
0087
0088 int sign = phiDist < 0 ? -1 : 1;
0089 phiDist = std::abs(phiDist) >> this->getDistPhiBitShift(iLayer, iRefLayer);
0090 phiDist *= sign;
0091
0092
0093 if (std::abs(phiDist) < std::abs(phiDistMin)) {
0094 phiDistMin = phiDist;
0095 selectedStub = stub;
0096 }
0097 }
0098
0099 if (!selectedStub) {
0100 PdfValueType pdfVal = 0;
0101 if (this->myOmtfConfig->isNoHitValueInPdf())
0102 pdfVal = this->pdfValue(iLayer, iRefLayer, 0);
0103 return StubResult(pdfVal, false, myOmtfConfig->nPhiBins(), iLayer, selectedStub);
0104 }
0105
0106 int pdfMiddle = 1 << (myOmtfConfig->nPdfAddrBits() - 1);
0107
0108
0109
0110
0111
0112
0113
0114
0115 if (std::abs(phiDistMin) > ((1 << (myOmtfConfig->nPdfAddrBits() - 1)) - 1)) {
0116 return StubResult(0, false, phiDistMin + pdfMiddle, iLayer, selectedStub);
0117
0118
0119
0120 }
0121
0122
0123 phiDistMin += pdfMiddle;
0124
0125 PdfValueType pdfVal = this->pdfValue(iLayer, iRefLayer, phiDistMin);
0126 if (pdfVal <= 0) {
0127 return StubResult(0, false, phiDistMin, iLayer, selectedStub);
0128 }
0129 return StubResult(pdfVal, true, phiDistMin, iLayer, selectedStub);
0130 }
0131
0132
0133
0134 void GoldenPatternBase::finalise(unsigned int procIndx) {
0135 for (auto& result : getResults()[procIndx]) {
0136 result.finalise();
0137 }
0138 }