CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HTcell.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 
7 namespace tmtt {
8 
9  //=== Initialization with cfg params,
10  //=== rapidity range of current sector, and estimated q/Pt of cell,
11  //=== and the bin number of the cell along the q/Pt axis of the r-phi HT array,
12  //=== and a flag indicating if this cell is the merge of smaller HT cells.
13 
14  HTcell::HTcell(const Settings* settings,
15  unsigned int iPhiSec,
16  unsigned int iEtaReg,
17  float etaMinSector,
18  float etaMaxSector,
19  float qOverPt,
20  unsigned int ibin_qOverPt,
21  bool mergedCell,
22  bool miniHTcell)
23  : settings_(settings),
24  // Sector number
25  iPhiSec_(iPhiSec),
26  iEtaReg_(iEtaReg),
27  // Rapidity range of sector.
28  etaMinSector_(etaMinSector),
29  etaMaxSector_(etaMaxSector),
30  // Track q/Pt.
31  qOverPtCell_(qOverPt),
32  // Note bin number of cell along q/Pt axis of r-phi HT array. (Not used if r-z HT).
33  ibin_qOverPt_(ibin_qOverPt),
34  mergedCell_(mergedCell),
35  // Is cell in Mini-HT?
36  miniHTcell_(miniHTcell),
37  invPtToDphi_(settings->invPtToDphi()), // B*c/2E11
38  // Use filter in each HT cell using only stubs which have consistent bend?
39  useBendFilter_(settings->useBendFilter()),
40  // Check if subsectors are being used within each sector. These are only ever used for r-phi HT.
41  numSubSecs_(settings->numSubSecsEta()) {
42  // A filter is used each HT cell, which prevents more than the specified number of stubs being stored in the cell. (Reflecting memory limit of hardware).
43  if (miniHTcell_) {
45  } else {
46  maxStubsInCell_ = settings->maxStubsInCell();
47  }
48  }
49 
50  //=== Termination. Search for track in this HT cell etc.
51 
52  void HTcell::end() {
53  // Produce list of filtered stubs by applying all requested filters (e.g. on stub bend).
54  // (If no filters are requested, then filtered & unfiltered stub collections will be identical).
55 
56  // N.B. Other filters, such as the r-z filters, which the firmware runs after the HT because they are too slow within it,
57  // are not defined here, but instead inside class TrkFilterAfterRphiHT.
58 
60  if (useBendFilter_)
62 
63  // Prevent too many stubs being stored in a single HT cell if requested (to reflect hardware memory limits).
64  // N.B. This MUST be the last filter applied.
65  constexpr unsigned int disableThreshold = 999;
66  if (maxStubsInCell_ < disableThreshold)
68 
69  // Calculate the number of layers the filtered stubs in this cell are in.
71 
72  if (numSubSecs_ > 1) {
73  // If using subsectors within each sector, calculate the number of layers the filters stubs in this cell are in,
74  // when one considers only the subset of the stubs within each subsector.
75  // Look for the "best" subsector.
77  for (unsigned int i = 0; i < numSubSecs_; i++) {
78  unsigned int numLaySubSec = this->calcNumFilteredLayers(i);
80  }
81  } else {
82  // If only 1 sub-sector, then subsector and sector are identical.
84  }
85  }
86 
87  // Calculate how many tracker layers the filter stubs in this cell are in, when only the subset of those stubs
88  // that are in the specified subsector are counted.
89 
90  unsigned int HTcell::calcNumFilteredLayers(unsigned int iSubSec) const {
91  vector<const Stub*> stubsInSubSec;
92  for (const Stub* s : vFilteredStubs_) {
93  const vector<bool>& inSubSec = subSectors_.at(s); // Find out which subsectors this stub is in.
94  if (inSubSec[iSubSec])
95  stubsInSubSec.push_back(s);
96  }
97  return Utility::countLayers(settings_, stubsInSubSec);
98  }
99 
100  //=== Produce a filtered collection of stubs in this cell that all have consistent bend.
101  //=== Only called for r-phi Hough transform.
102 
103  vector<Stub*> HTcell::bendFilter(const vector<Stub*>& stubs) const {
104  // Create bend-filtered stub collection.
105  vector<Stub*> filteredStubs;
106  for (Stub* s : stubs) {
107  // Require stub bend to be consistent with q/Pt of this cell.
108 
109  unsigned int minBin = s->min_qOverPt_bin();
110  unsigned int maxBin = s->max_qOverPt_bin();
111  if (mergedCell_) {
112  if (minBin % 2 == 1)
113  minBin--;
114  }
115  if (minBin <= ibin_qOverPt_ && ibin_qOverPt_ <= maxBin)
116  filteredStubs.push_back(s);
117  }
118 
119  return filteredStubs;
120  }
121 
122  //=== Filter stubs so as to prevent more than specified number of stubs being stored in one cell.
123  //=== This reflects finite memory of hardware.
124 
125  vector<Stub*> HTcell::maxStubCountFilter(const vector<Stub*>& stubs) const {
126  vector<Stub*> filteredStubs;
127  // If there are too many stubs in a cell, the hardware keeps (maxStubsInCell - 1) of the first stubs in the list
128  // plus the last stub.
129  if (stubs.size() > maxStubsInCell_) {
130  for (unsigned int i = 0; i < maxStubsInCell_ - 1; i++) { // first stubs
131  filteredStubs.push_back(stubs[i]);
132  }
133  filteredStubs.push_back(stubs[stubs.size() - 1]); // plus last stub
134  } else {
135  filteredStubs = stubs;
136  }
137  return filteredStubs;
138  }
139 
140 } // namespace tmtt
unsigned int calcNumFilteredLayers() const
Definition: HTcell.h:97
constexpr unsigned int maxBin
unsigned int numSubSecs_
Definition: HTcell.h:142
bool mergedCell_
Definition: HTcell.h:129
unsigned int numFilteredLayersInCellBestSubSec_
Definition: HTcell.h:150
unsigned int ibin_qOverPt_
Definition: HTcell.h:127
std::vector< Stub * > maxStubCountFilter(const std::vector< Stub * > &stubs) const
Definition: HTcell.cc:125
std::vector< Stub * > vFilteredStubs_
Definition: HTcell.h:147
std::vector< Stub * > vStubs_
Definition: HTcell.h:146
unsigned int maxStubsInCell_
Definition: HTcell.h:139
std::map< const Stub *, std::vector< bool > > subSectors_
Definition: HTcell.h:151
const std::vector< Stub * > & stubs() const
Definition: HTcell.h:60
const Settings * settings_
Definition: HTcell.h:116
bool miniHTcell_
Definition: HTcell.h:132
void end()
Definition: HTcell.cc:52
unsigned int numFilteredLayersInCell_
Definition: HTcell.h:149
std::vector< Stub * > bendFilter(const std::vector< Stub * > &stubs) const
Definition: HTcell.cc:103
unsigned int countLayers(const Settings *settings, const std::vector< const Stub * > &stubs, bool disableReducedLayerID=false, bool onlyPS=false)
Definition: Utility.cc:25
unsigned int maxStubsInCellMiniHough() const
Definition: Settings.h:172
unsigned int maxStubsInCell() const
Definition: Settings.h:170
bool useBendFilter_
Definition: HTcell.h:137
constexpr unsigned int minBin