CMS 3D CMS Logo

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
tmtt::HTbase
Definition: HTbase.h:22
tmtt::HTrphi::HTshape::diamond
tmtt::HTrphi::ErrorMonitor::numErrorsTypeB
std::atomic< unsigned int > numErrorsTypeB
Definition: HTrphi.h:35
tmtt::HTrphi::invPtToDphi_
float invPtToDphi_
Definition: HTrphi.h:120
tmtt::HTrphi::nReceivedStubs_
unsigned int nReceivedStubs_
Definition: HTrphi.h:158
mps_fire.i
i
Definition: mps_fire.py:428
tmtt::HTrphi::errMon_
ErrorMonitor * errMon_
Definition: HTrphi.h:161
tmtt::HTrphi::busyInputSectorNumStubs_
unsigned int busyInputSectorNumStubs_
Definition: HTrphi.h:147
tmtt::HTrphi::binSizeQoverPtAxis_
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
tmtt::HTrphi::store
void store(Stub *stub, const std::vector< bool > &inEtaSubSecs)
Definition: HTrphi.cc:179
tmtt::HTrphi::maxAbsQoverPtAxis_
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
tmtt::HTrphi::HTshape::brick
tmtt::HTrphi::nBinsQoverPtAxis_
unsigned int nBinsQoverPtAxis_
Definition: HTrphi.h:128
tmtt::HTrphi::helix2Dconventional
std::pair< float, float > helix2Dconventional(unsigned int i, unsigned int j) const override
Definition: HTrphi.cc:460
tmtt::HTrphi::enableMerge2x2_
bool enableMerge2x2_
Definition: HTrphi.h:137
tmtt::HTrphi::busySectorUseMbinRanges_
bool busySectorUseMbinRanges_
Definition: HTrphi.h:151
tmtt::HTrphi
Definition: HTrphi.h:23
tmtt::HTrphi::busyInputSectorKill_
bool busyInputSectorKill_
Definition: HTrphi.h:145
tmtt::HTrphi::minInvPtToMerge2x2_
float minInvPtToMerge2x2_
Definition: HTrphi.h:138
tmtt::HTrphi::busySectorNumStubs_
unsigned int busySectorNumStubs_
Definition: HTrphi.h:148
DigiToRawDM_cff.TP
TP
Definition: DigiToRawDM_cff.py:51
tmtt::HTrphi::HTshape
HTshape
Definition: HTrphi.h:25
tmtt::TP
Definition: TP.h:23
tmtt::HTrphi::busySectorKill_
bool busySectorKill_
Definition: HTrphi.h:146
tmtt::HTrphi::cell
std::pair< unsigned int, unsigned int > cell(const L1fittedTrack *fitTrk) const override
Definition: HTrphi.cc:507
tmtt::HTrphi::shape_
HTshape shape_
Definition: HTrphi.h:122
tmtt::HTrphi::nBinsPhiTrkAxis_
unsigned int nBinsPhiTrkAxis_
Definition: HTrphi.h:134
tmtt::HTrphi::iPhiRange
std::pair< unsigned int, unsigned int > iPhiRange(const Stub *stub, unsigned int iQoverPtBin, bool debug=false) const
Definition: HTrphi.cc:348
tmtt::HTrphi::ErrorMonitor::numErrorsTypeA
std::atomic< unsigned int > numErrorsTypeA
Definition: HTrphi.h:33
tmtt::HTrphi::HTshape::hexagon
debug
#define debug
Definition: HDRShower.cc:19
tmtt::L1track2D
Definition: L1track2D.h:20
tmtt::HTrphi::killSomeHTCellsRphi_
unsigned int killSomeHTCellsRphi_
Definition: HTrphi.h:143
tmtt::HTrphi::helix2Dhough
std::pair< float, float > helix2Dhough(unsigned int i, unsigned int j) const override
Definition: HTrphi.cc:404
tmtt::HTrphi::trueCell
std::pair< unsigned int, unsigned int > trueCell(const TP *tp) const override
Definition: HTrphi.cc:473
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
tmtt::HTrphi::maxAbsPhiTrkAxis_
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
tmtt::HTrphi::chosenRofPhi_
float chosenRofPhi_
Definition: HTrphi.h:131
tmtt::HTrphi::cellCenters_
std::vector< std::vector< std::pair< float, float > > > cellCenters_
Definition: HTrphi.h:123
tmtt::L1fittedTrack
Definition: L1fittedTrack.h:30
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
tmtt::HTrphi::busySectorMbinOrder_
std::vector< unsigned int > busySectorMbinOrder_
Definition: HTrphi.h:150
tmtt::HTrphi::getMbinRange
unsigned int getMbinRange(const L1track2D &trk) const
Definition: HTrphi.cc:317
tmtt::Settings
Definition: Settings.h:17
tmtt::HTrphi::rowOrder
std::vector< unsigned int > rowOrder(unsigned int numRows) const override
Definition: HTrphi.cc:658
tmtt::HTrphi::busySectorMbinLow_
std::vector< unsigned int > busySectorMbinLow_
Definition: HTrphi.h:153
tmtt::HTrphi::ErrorMonitor
Definition: HTrphi.h:29
tmtt::HTrphi::busySectorUseMbinOrder_
bool busySectorUseMbinOrder_
Definition: HTrphi.h:152
tmtt::HTrphi::nReceivedStubs
unsigned int nReceivedStubs() const
Definition: HTrphi.h:89
tmtt::HTrphi::phiCentreSector_
float phiCentreSector_
Definition: HTrphi.h:132
alignCSCRings.r
r
Definition: alignCSCRings.py:93
tmtt::HTrphi::ErrorMonitor::maxLineGradient
std::atomic< float > maxLineGradient
Definition: HTrphi.h:31
tmtt::HTrphi::mergedCell
bool mergedCell(unsigned int iQoverPtBin, unsigned int jPhiTrkBin) const
Definition: HTrphi.cc:581
tmtt::HTrphi::~HTrphi
~HTrphi() override=default
tmtt::HTrphi::HTshape::square
tmtt::HTrphi::binSizePhiTrkAxis_
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
tmtt::HTrphi::busySectorMbinRanges_
std::vector< unsigned int > busySectorMbinRanges_
Definition: HTrphi.h:149
tmtt::HTrphi::ErrorMonitor::numErrorsNorm
std::atomic< unsigned int > numErrorsNorm
Definition: HTrphi.h:37
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
tmtt::Stub
Definition: Stub.h:43
tmtt::HTrphi::busySectorMbinHigh_
std::vector< unsigned int > busySectorMbinHigh_
Definition: HTrphi.h:154
tmtt::HTrphi::countFirmwareErrors
void countFirmwareErrors(unsigned int iQoverPtBin, unsigned int iPhiTrkBinMin, unsigned int iPhiTrkBinMax, unsigned int jPhiTrkBinMinLast, unsigned int jPhiTrkBinMaxLast)
Definition: HTrphi.cc:379
HTbase.h
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16
tmtt::HTrphi::killTracksBusySec
std::list< L1track2D > killTracksBusySec(const std::list< L1track2D > &tracks) const override
Definition: HTrphi.cc:621
tmtt::HTrphi::HTrphi
HTrphi(const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, float etaMinSector, float etaMaxSector, float phiCentreSector, ErrorMonitor *errMon=nullptr)
Definition: HTrphi.cc:29
tmtt::HTrphi::calcLineGradArray
float calcLineGradArray(float r) const
Definition: HTrphi.cc:605