CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HTrphi.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTMTT_HTrphi_h
2 #define L1Trigger_TrackFindingTMTT_HTrphi_h
3 
5 
6 #include <vector>
7 #include <list>
8 #include <utility>
9 #include <atomic>
10 
11 //=== The r-phi Hough Transform array for a single (eta,phi) sector.
12 //===
13 //=== Its axes are (q/Pt, phiTrk), where phiTrk is the phi at which the track crosses a
14 //=== user-configurable radius from the beam-line.
15 
16 namespace tmtt {
17 
18  class Settings;
19  class Stub;
20  class TP;
21  class L1fittedTrack;
22 
23  class HTrphi : public HTbase {
24  public:
25  enum class HTshape { square, diamond, hexagon, brick };
26 
27  //--- Error monitoring
28 
29  struct ErrorMonitor {
30  // Maximum |gradient| of line corresponding to any stub. FW assumes it's < 1.0.
31  std::atomic<float> maxLineGradient;
32  // Error count when stub added to cell not NE, E or SE of cell stub added to in previous HT column.
33  std::atomic<unsigned int> numErrorsTypeA;
34  // Error count when stub added to more than 2 cells in one HT column
35  std::atomic<unsigned int> numErrorsTypeB;
36  // Error count normalisation
37  std::atomic<unsigned int> numErrorsNorm;
38  };
39 
40  // Initialization with sector number, eta range covered by sector and phi coordinate of its centre.
41  HTrphi(const Settings* settings,
42  unsigned int iPhiSec,
43  unsigned int iEtaReg,
44  float etaMinSector,
45  float etaMaxSector,
46  float phiCentreSector,
47  ErrorMonitor* errMon = nullptr);
48 
49  ~HTrphi() override = default;
50 
51  // Add stub to HT array.
52  // If eta subsectors are being used within each sector, specify which ones the stub is compatible with.
53  void store(Stub* stub, const std::vector<bool>& inEtaSubSecs);
54 
55  // Termination. Causes HT array to search for tracks etc.
56  // ... function end() is in base class ...
57 
58  //=== Info about track candidates found.
59 
60  // ... is available via base class ...
61 
62  //=== Utilities
63 
64  // Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
65  // The helix parameters returned will be those corresponding to the two axes of the HT array.
66  // So they might be (q/pt, phi0) or (q/pt, phi65) etc. depending on the configuration.
67  std::pair<float, float> helix2Dhough(unsigned int i, unsigned int j) const override;
68 
69  // Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
70  // The helix parameters returned will be always be (q/pt, phi0), irrespective of how the axes
71  // of the HT array are defined.
72  std::pair<float, float> helix2Dconventional(unsigned int i, unsigned int j) const override;
73 
74  // Which cell in HT array should this TP be in, based on its true trajectory?
75  // (If TP is outside HT array, it it put in the closest bin inside it).
76  std::pair<unsigned int, unsigned int> trueCell(const TP* tp) const override;
77 
78  // Which cell in HT array should this fitted track be in, based on its fitted trajectory?
79  // Always uses beam-spot constrained trajectory if available.
80  // (If fitted track is outside HT array, it it put in the closest bin inside it).
81  std::pair<unsigned int, unsigned int> cell(const L1fittedTrack* fitTrk) const override;
82 
83  // Check if specified cell has been merged with its 2x2 neighbours into a single cell,
84  // as it is in low Pt region.
85  bool mergedCell(unsigned int iQoverPtBin, unsigned int jPhiTrkBin) const;
86 
87  // Number of stubs received from GP, irrespective of whether the stub was actually stored in
88  // a cell in the HT array.
89  unsigned int nReceivedStubs() const { return nReceivedStubs_; }
90 
91  // Determine which m-bin (q/pt) range the specified track is in. (Used if outputting each m bin range on a different opto-link).
92  unsigned int getMbinRange(const L1track2D& trk) const;
93 
94  private:
95  // For a given Q/Pt bin, find the range of phi bins that a given stub is consistent with.
96  std::pair<unsigned int, unsigned int> iPhiRange(const Stub* stub,
97  unsigned int iQoverPtBin,
98  bool debug = false) const;
99 
100  // Check that limitations of firmware would not prevent stub being stored correctly in this HT column.
101  void countFirmwareErrors(unsigned int iQoverPtBin,
102  unsigned int iPhiTrkBinMin,
103  unsigned int iPhiTrkBinMax,
104  unsigned int jPhiTrkBinMinLast,
105  unsigned int jPhiTrkBinMaxLast);
106 
107  // Calculate line |gradient| of stubs in HT array, so can check it doesn't exceed 1.
108  float calcLineGradArray(float r) const;
109 
110  // If requested, kill those tracks in this sector that can't be read out during the time-multiplexed period, because
111  // the HT has associated too many stubs to tracks.
112  std::list<L1track2D> killTracksBusySec(const std::list<L1track2D>& tracks) const override;
113 
114  // Define the order in which the hardware processes rows of the HT array when it outputs track candidates.
115  // Currently corresponds to highest Pt tracks first.
116  // If two tracks have the same Pt, the -ve charge one is output before the +ve charge one.
117  std::vector<unsigned int> rowOrder(unsigned int numRows) const override;
118 
119  private:
120  float invPtToDphi_; // conversion constant.
121 
123  std::vector<std::vector<std::pair<float, float> > > cellCenters_;
124 
125  //--- Specifications of HT array.
126 
127  float maxAbsQoverPtAxis_; // Max. |q/Pt| covered by HT array.
128  unsigned int nBinsQoverPtAxis_; // Number of bins in HT array in q/Pt.
129  float binSizeQoverPtAxis_; // HT array bin size in q/Pt.
130 
131  float chosenRofPhi_; // Use phi of track at radius="chosenRofPhi" to define one of the r-phi HT axes.
132  float phiCentreSector_; // phiTrk angle of centre of this (eta,phi) sector.
133  float maxAbsPhiTrkAxis_; // Half-width of phiTrk axis in HT array.
134  unsigned int nBinsPhiTrkAxis_; // Number of bins in HT array in phiTrk axis.
135  float binSizePhiTrkAxis_; // HT array bin size in phiTrk
136  // Optionally merge 2x2 neighbouring cells into a single cell at low Pt, to reduce efficiency loss due to scattering. (Used also by mini-HT).
139 
140  //--- Options when filling HT array.
141 
142  // Take all cells in HT array crossed by line corresponding to each stub (= 0) or take only some to reduce rate at cost of efficiency ( > 0)
143  unsigned int killSomeHTCellsRphi_;
144  // Options for killing stubs/tracks that cant be sent within time-multiplexed period.
148  unsigned int busySectorNumStubs_;
149  std::vector<unsigned int> busySectorMbinRanges_;
150  std::vector<unsigned int> busySectorMbinOrder_;
153  std::vector<unsigned int> busySectorMbinLow_;
154  std::vector<unsigned int> busySectorMbinHigh_;
155 
156  // Number of stubs received from GP, irrespective of whether the stub was actually stored in
157  // a cell in the HT array.
158  unsigned int nReceivedStubs_;
159 
160  // Error monitoring.
162 
163  // ... The Hough transform array data is in the base class ...
164 
165  // ... The list of found track candidates is in the base class ...
166  };
167 
168 } // namespace tmtt
169 
170 #endif
std::vector< unsigned int > busySectorMbinRanges_
Definition: HTrphi.h:149
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
bool enableMerge2x2_
Definition: HTrphi.h:137
~HTrphi() override=default
float chosenRofPhi_
Definition: HTrphi.h:131
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
void store(Stub *stub, const std::vector< bool > &inEtaSubSecs)
Definition: HTrphi.cc:179
std::vector< unsigned int > busySectorMbinLow_
Definition: HTrphi.h:153
std::vector< unsigned int > busySectorMbinOrder_
Definition: HTrphi.h:150
auto const & tracks
cannot be loose
unsigned int killSomeHTCellsRphi_
Definition: HTrphi.h:143
unsigned int nBinsPhiTrkAxis_
Definition: HTrphi.h:134
unsigned int busyInputSectorNumStubs_
Definition: HTrphi.h:147
std::atomic< float > maxLineGradient
Definition: HTrphi.h:31
float invPtToDphi_
Definition: HTrphi.h:120
std::atomic< unsigned int > numErrorsNorm
Definition: HTrphi.h:37
ErrorMonitor * errMon_
Definition: HTrphi.h:161
bool busySectorUseMbinOrder_
Definition: HTrphi.h:152
std::atomic< unsigned int > numErrorsTypeA
Definition: HTrphi.h:33
Definition: TP.h:23
std::vector< unsigned int > rowOrder(unsigned int numRows) const override
Definition: HTrphi.cc:658
std::pair< unsigned int, unsigned int > trueCell(const TP *tp) const override
Definition: HTrphi.cc:473
std::pair< unsigned int, unsigned int > cell(const L1fittedTrack *fitTrk) const override
Definition: HTrphi.cc:507
std::pair< float, float > helix2Dhough(unsigned int i, unsigned int j) const override
Definition: HTrphi.cc:404
float calcLineGradArray(float r) const
Definition: HTrphi.cc:605
std::pair< float, float > helix2Dconventional(unsigned int i, unsigned int j) const override
Definition: HTrphi.cc:460
bool busySectorUseMbinRanges_
Definition: HTrphi.h:151
void countFirmwareErrors(unsigned int iQoverPtBin, unsigned int iPhiTrkBinMin, unsigned int iPhiTrkBinMax, unsigned int jPhiTrkBinMinLast, unsigned int jPhiTrkBinMaxLast)
Definition: HTrphi.cc:379
float minInvPtToMerge2x2_
Definition: HTrphi.h:138
bool busySectorKill_
Definition: HTrphi.h:146
unsigned int busySectorNumStubs_
Definition: HTrphi.h:148
#define debug
Definition: HDRShower.cc:19
unsigned int nReceivedStubs_
Definition: HTrphi.h:158
bool mergedCell(unsigned int iQoverPtBin, unsigned int jPhiTrkBin) const
Definition: HTrphi.cc:581
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
unsigned int getMbinRange(const L1track2D &trk) const
Definition: HTrphi.cc:317
std::atomic< unsigned int > numErrorsTypeB
Definition: HTrphi.h:35
bool busyInputSectorKill_
Definition: HTrphi.h:145
std::vector< std::vector< std::pair< float, float > > > cellCenters_
Definition: HTrphi.h:123
unsigned int nReceivedStubs() const
Definition: HTrphi.h:89
HTrphi(const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, float etaMinSector, float etaMaxSector, float phiCentreSector, ErrorMonitor *errMon=nullptr)
Definition: HTrphi.cc:29
float phiCentreSector_
Definition: HTrphi.h:132
std::list< L1track2D > killTracksBusySec(const std::list< L1track2D > &tracks) const override
Definition: HTrphi.cc:621
std::pair< unsigned int, unsigned int > iPhiRange(const Stub *stub, unsigned int iQoverPtBin, bool debug=false) const
Definition: HTrphi.cc:348
HTshape shape_
Definition: HTrphi.h:122
unsigned int nBinsQoverPtAxis_
Definition: HTrphi.h:128
std::vector< unsigned int > busySectorMbinHigh_
Definition: HTrphi.h:154