File indexing completed on 2024-04-06 12:21:50
0001 #include "L1Trigger/TrackFindingTMTT/interface/HTcell.h"
0002 #include "L1Trigger/TrackFindingTMTT/interface/TP.h"
0003 #include "L1Trigger/TrackFindingTMTT/interface/Stub.h"
0004
0005 using namespace std;
0006
0007 namespace tmtt {
0008
0009
0010
0011
0012
0013
0014 HTcell::HTcell(const Settings* settings,
0015 unsigned int iPhiSec,
0016 unsigned int iEtaReg,
0017 float etaMinSector,
0018 float etaMaxSector,
0019 float qOverPt,
0020 unsigned int ibin_qOverPt,
0021 bool mergedCell,
0022 bool miniHTcell)
0023 : settings_(settings),
0024
0025 iPhiSec_(iPhiSec),
0026 iEtaReg_(iEtaReg),
0027
0028 etaMinSector_(etaMinSector),
0029 etaMaxSector_(etaMaxSector),
0030
0031 qOverPtCell_(qOverPt),
0032
0033 ibin_qOverPt_(ibin_qOverPt),
0034 mergedCell_(mergedCell),
0035
0036 miniHTcell_(miniHTcell),
0037 invPtToDphi_(settings->invPtToDphi()),
0038
0039 useBendFilter_(settings->useBendFilter()),
0040
0041 numSubSecs_(settings->numSubSecsEta()) {
0042
0043 if (miniHTcell_) {
0044 maxStubsInCell_ = settings->maxStubsInCellMiniHough();
0045 } else {
0046 maxStubsInCell_ = settings->maxStubsInCell();
0047 }
0048 }
0049
0050
0051
0052 void HTcell::end() {
0053
0054
0055
0056
0057
0058
0059 vFilteredStubs_ = vStubs_;
0060 if (useBendFilter_)
0061 vFilteredStubs_ = this->bendFilter(vFilteredStubs_);
0062
0063
0064
0065 constexpr unsigned int disableThreshold = 999;
0066 if (maxStubsInCell_ < disableThreshold)
0067 vFilteredStubs_ = this->maxStubCountFilter(vFilteredStubs_);
0068
0069
0070 numFilteredLayersInCell_ = this->calcNumFilteredLayers();
0071
0072 if (numSubSecs_ > 1) {
0073
0074
0075
0076 numFilteredLayersInCellBestSubSec_ = 0;
0077 for (unsigned int i = 0; i < numSubSecs_; i++) {
0078 unsigned int numLaySubSec = this->calcNumFilteredLayers(i);
0079 numFilteredLayersInCellBestSubSec_ = max(numFilteredLayersInCellBestSubSec_, numLaySubSec);
0080 }
0081 } else {
0082
0083 numFilteredLayersInCellBestSubSec_ = numFilteredLayersInCell_;
0084 }
0085 }
0086
0087
0088
0089
0090 unsigned int HTcell::calcNumFilteredLayers(unsigned int iSubSec) const {
0091 vector<const Stub*> stubsInSubSec;
0092 for (const Stub* s : vFilteredStubs_) {
0093 const vector<bool>& inSubSec = subSectors_.at(s);
0094 if (inSubSec[iSubSec])
0095 stubsInSubSec.push_back(s);
0096 }
0097 return Utility::countLayers(settings_, stubsInSubSec);
0098 }
0099
0100
0101
0102
0103 vector<Stub*> HTcell::bendFilter(const vector<Stub*>& stubs) const {
0104
0105 vector<Stub*> filteredStubs;
0106 for (Stub* s : stubs) {
0107
0108
0109 unsigned int minBin = s->min_qOverPt_bin();
0110 unsigned int maxBin = s->max_qOverPt_bin();
0111 if (mergedCell_) {
0112 if (minBin % 2 == 1)
0113 minBin--;
0114 }
0115 if (minBin <= ibin_qOverPt_ && ibin_qOverPt_ <= maxBin)
0116 filteredStubs.push_back(s);
0117 }
0118
0119 return filteredStubs;
0120 }
0121
0122
0123
0124
0125 vector<Stub*> HTcell::maxStubCountFilter(const vector<Stub*>& stubs) const {
0126 vector<Stub*> filteredStubs;
0127
0128
0129 if (stubs.size() > maxStubsInCell_) {
0130 for (unsigned int i = 0; i < maxStubsInCell_ - 1; i++) {
0131 filteredStubs.push_back(stubs[i]);
0132 }
0133 filteredStubs.push_back(stubs[stubs.size() - 1]);
0134 } else {
0135 filteredStubs = stubs;
0136 }
0137 return filteredStubs;
0138 }
0139
0140 }