CMS 3D CMS Logo

HTbase.h
Go to the documentation of this file.
1 
2 #ifndef L1Trigger_TrackFindingTMTT_HTbase_h
3 #define L1Trigger_TrackFindingTMTT_HTbase_h
4 
7 
8 #include <vector>
9 #include <list>
10 #include <utility>
11 #include <memory>
12 
13 namespace tmtt {
14  template <typename T>
15  class matrix {
16  public:
17  //for a mxn matrix - row major
18  matrix(unsigned int m, unsigned int n) : _n{n}, _m{m} { _matrix.resize(m * n); }
19  const T& operator()(unsigned int i, unsigned int j) const { return _matrix.at(i * _n + j); }
20  T& operator()(unsigned int i, unsigned int j) {
21  if (i >= _m || j >= _n)
22  throw std::out_of_range("matrix access out of bounds");
23 
24  return _matrix[i * _n + j];
25  }
26 
27  private:
28  std::vector<T> _matrix;
29  unsigned int _n, _m;
30  };
31 } // namespace tmtt
32 
33 //=== Base class for Hough Transform array for a single (eta,phi) sector.
34 namespace tmtt {
35 
36  class Settings;
37  class Stub;
38  class TP;
39  class L1fittedTrack;
40 
41  class HTbase {
42  public:
43  // Initialization.
44  HTbase(
45  const Settings* settings, unsigned int iPhiSec, unsigned int iEtaReg, unsigned int nBinsX, unsigned int nBinsY);
46 
47  virtual ~HTbase() = default;
48 
49  // Termination. Causes HT array to search for tracks etc.
50  virtual void end();
51 
52  //=== Get info about filtered stubs in HT array.
53  //=== (N.B. The `filtered stubs' are stubs passing any requested stub filters, e.g. bend and/or rapidity.
54  //=== If no filters were requested, they are identical to the unfiltered stubs.)
55 
56  // Get sum of number of filtered stubs stored in each cell of HT array (so a stub appearing in multiple cells is counted multiple times).
57  virtual unsigned int numStubsInc() const;
58 
59  // Get sum the number of filtered stubs in the HT array, where each individual stub is counted only once, even if it appears in multiple cells.
60  virtual unsigned int numStubsExc() const;
61 
62  // Get all the cells that make up the array, which in turn give access to the stubs inside them.
63  // N.B. You can use allCells().size1() and allCells().size2() to get the dimensions ofthe array.
64  virtual const matrix<std::unique_ptr<HTcell>>& allCells() const { return htArray_; }
65 
66  //=== Info about track candidates found.
67 
68  // N.B. If a duplicate track filter was run inside the HT, this will contain the reduced list of tracks passing this filter.
69  // N.B. If some tracks could not be read out during the TM period, then such tracks are deleted from this list.
70 
71  // Get list of all track candidates found in this HT array, giving access to stubs on each track
72  // and helix parameters.
73  virtual const std::list<L1track2D>& trackCands2D() const { return trackCands2D_; }
74 
75  // Number of track candidates found in this HT array.
76  // If a duplicate track filter was run, this will contain the reduced list of tracks passing this filter.
77  virtual unsigned int numTrackCands2D() const { return trackCands2D_.size(); }
78 
79  // Get number of filtered stubs assigned to track candidates found in this HT array.
80  virtual unsigned int numStubsOnTrackCands2D() const;
81 
82  // Get all reconstructed tracks that were associated to the given tracking particle.
83  // (If the std::vector is empty, then the tracking particle was not reconstructed in this sector).
84  virtual std::vector<const L1track2D*> assocTrackCands2D(const TP& tp) const;
85 
86  //=== Function to replace the collection of 2D tracks found by this HT.
87 
88  // (This is used by classes MuxHToutputs & MiniHTstage).
89  virtual void replaceTrackCands2D(const std::list<L1track2D>& newTracks) { trackCands2D_ = newTracks; }
90 
91  //=== Utilities
92 
93  // Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
94  // The helix parameters returned will be those corresponding to the two axes of the HT array.
95  // So they might be (q/pt, phi65), (eta, z0) or (z110, z0) etc. depending on the configuration.
96  virtual std::pair<float, float> helix2Dhough(unsigned int i, unsigned int j) const = 0;
97 
98  // Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
99  // The helix parameters returned will be always be (q/Pt, phi0) or (tan_lambda, z0), irrespective of
100  // how the axes of the HT array are defined.
101  virtual std::pair<float, float> helix2Dconventional(unsigned int i, unsigned int j) const = 0;
102 
103  // Which cell in HT array should this TP be in, based on its true trajectory?
104  // Returns 999999 in at least one index if TP not expected to be in any cell in this array.
105  virtual std::pair<unsigned int, unsigned int> trueCell(const TP* tp) const = 0;
106 
107  // Which cell in HT array should this fitted track be in, based on its fitted trajectory?
108  // Returns 999999 in at least one index if fitted track not expected to be in any cell in this array.
109  virtual std::pair<unsigned int, unsigned int> cell(const L1fittedTrack* fitTrk) const = 0;
110 
111  // Disable filters (used for debugging).
112  virtual void disableBendFilter();
113 
114  protected:
115  // Given a range in one of the coordinates specified by coordRange, calculate the corresponding range of bins. The other arguments specify the axis. And also if some cells nominally associated to stub are to be killed.
116  virtual std::pair<unsigned int, unsigned int> convertCoordRangeToBinRange(std::pair<float, float> coordRange,
117  unsigned int nBinsAxis,
118  float coordAxisMin,
119  float coordAxisBinSize,
120  unsigned int killSomeHTcells) const;
121 
122  private:
123  // Return a list of all track candidates found in this array, giving access to all the stubs on each one
124  // and the track helix parameters, plus the associated truth particle (if any).
125  virtual std::list<L1track2D> calcTrackCands2D() const;
126 
127  // If requested, kill those tracks in this sector that can't be read out during the time-multiplexed period, because
128  // the HT has associated too many stubs to tracks.
129  virtual std::list<L1track2D> killTracksBusySec(const std::list<L1track2D>& tracks) const = 0;
130 
131  // Define the order in which the hardware processes rows of the HT array when it outputs track candidates.
132  virtual std::vector<unsigned int> rowOrder(unsigned int numRows) const = 0;
133 
134  // Calculate output opto-link ID from HT, assuming there is no MUX stage.
135  virtual unsigned int calcOptoLinkID() const {
136  unsigned int numPhiSecPerNon = settings_->numPhiSectors() / settings_->numPhiNonants();
137  return (iEtaReg_ * numPhiSecPerNon + iPhiSec_);
138  }
139 
140  protected:
141  const Settings* settings_; // configuration parameters.
142 
143  unsigned int iPhiSec_; // Sector number.
144  unsigned int iEtaReg_;
145 
146  unsigned int nBinsX_; // Bins in HT array.
147  unsigned int nBinsY_;
148 
149  // Hough transform array.
150  // This has two dimensions, representing the two track helix parameters being varied.
152 
153  unsigned int optoLinkID_; // ID of opto-link from HT to Track Fitter.
154 
155  // List of all track candidates found by HT & their associated properties.
156  // If a duplicate track filter was run inside the HT, this will contain the reduced list of tracks passing this filter.
157  // If some tracks could not be read out during the TM period, then such tracks are deleted from this list.
158  std::list<L1track2D> trackCands2D_;
159  };
160 
161 } // namespace tmtt
162 
163 #endif
tmtt::HTbase::calcTrackCands2D
virtual std::list< L1track2D > calcTrackCands2D() const
Definition: HTbase.cc:186
tmtt::HTbase
Definition: HTbase.h:41
tmtt::matrix::_m
unsigned int _m
Definition: HTbase.h:29
tmtt::HTbase::htArray_
matrix< std::unique_ptr< HTcell > > htArray_
Definition: HTbase.h:151
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:428
tmtt::Settings::numPhiNonants
unsigned int numPhiNonants() const
Definition: Settings.h:109
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
tmtt::HTbase::numTrackCands2D
virtual unsigned int numTrackCands2D() const
Definition: HTbase.h:77
tmtt::HTbase::convertCoordRangeToBinRange
virtual std::pair< unsigned int, unsigned int > convertCoordRangeToBinRange(std::pair< float, float > coordRange, unsigned int nBinsAxis, float coordAxisMin, float coordAxisBinSize, unsigned int killSomeHTcells) const
Definition: HTbase.cc:122
tmtt::matrix::operator()
T & operator()(unsigned int i, unsigned int j)
Definition: HTbase.h:20
tmtt::HTbase::disableBendFilter
virtual void disableBendFilter()
Definition: HTbase.cc:111
tmtt::HTbase::cell
virtual std::pair< unsigned int, unsigned int > cell(const L1fittedTrack *fitTrk) const =0
tmtt::HTbase::trackCands2D
virtual const std::list< L1track2D > & trackCands2D() const
Definition: HTbase.h:73
DigiToRawDM_cff.TP
TP
Definition: DigiToRawDM_cff.py:51
tmtt::HTbase::~HTbase
virtual ~HTbase()=default
tmtt::HTbase::settings_
const Settings * settings_
Definition: HTbase.h:141
tmtt::TP
Definition: TP.h:23
tmtt::HTbase::allCells
virtual const matrix< std::unique_ptr< HTcell > > & allCells() const
Definition: HTbase.h:64
tmtt::HTbase::rowOrder
virtual std::vector< unsigned int > rowOrder(unsigned int numRows) const =0
tmtt::HTbase::helix2Dconventional
virtual std::pair< float, float > helix2Dconventional(unsigned int i, unsigned int j) const =0
tmtt::HTbase::replaceTrackCands2D
virtual void replaceTrackCands2D(const std::list< L1track2D > &newTracks)
Definition: HTbase.h:89
tmtt::matrix::matrix
matrix(unsigned int m, unsigned int n)
Definition: HTbase.h:18
tmtt::HTbase::numStubsInc
virtual unsigned int numStubsInc() const
Definition: HTbase.cc:47
tmtt::HTbase::optoLinkID_
unsigned int optoLinkID_
Definition: HTbase.h:153
tmtt::matrix
Definition: HTbase.h:15
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
tmtt::HTbase::nBinsX_
unsigned int nBinsX_
Definition: HTbase.h:146
tmtt::HTbase::killTracksBusySec
virtual std::list< L1track2D > killTracksBusySec(const std::list< L1track2D > &tracks) const =0
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
tmtt::L1fittedTrack
Definition: L1fittedTrack.h:30
tmtt::HTbase::trueCell
virtual std::pair< unsigned int, unsigned int > trueCell(const TP *tp) const =0
tmtt::HTbase::assocTrackCands2D
virtual std::vector< const L1track2D * > assocTrackCands2D(const TP &tp) const
Definition: HTbase.cc:95
HTcell.h
tmtt::HTbase::calcOptoLinkID
virtual unsigned int calcOptoLinkID() const
Definition: HTbase.h:135
tmtt::HTbase::helix2Dhough
virtual std::pair< float, float > helix2Dhough(unsigned int i, unsigned int j) const =0
tmtt::Settings
Definition: Settings.h:17
tmtt::Settings::numPhiSectors
unsigned int numPhiSectors() const
Definition: Settings.h:110
L1track2D.h
tmtt::HTbase::trackCands2D_
std::list< L1track2D > trackCands2D_
Definition: HTbase.h:158
tmtt::HTbase::numStubsExc
virtual unsigned int numStubsExc() const
Definition: HTbase.cc:62
tmtt::HTbase::iPhiSec_
unsigned int iPhiSec_
Definition: HTbase.h:143
tmtt::HTbase::HTbase
HTbase(const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, unsigned int nBinsX, unsigned int nBinsY)
Definition: HTbase.cc:14
tmtt::HTbase::nBinsY_
unsigned int nBinsY_
Definition: HTbase.h:147
T
long double T
Definition: Basic3DVectorLD.h:48
tmtt::matrix::_n
unsigned int _n
Definition: HTbase.h:29
tmtt::HTbase::numStubsOnTrackCands2D
virtual unsigned int numStubsOnTrackCands2D() const
Definition: HTbase.cc:81
tmtt::matrix::_matrix
std::vector< T > _matrix
Definition: HTbase.h:28
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: ChiSquaredFit4.h:6
tmtt::HTbase::iEtaReg_
unsigned int iEtaReg_
Definition: HTbase.h:144
tmtt::matrix::operator()
const T & operator()(unsigned int i, unsigned int j) const
Definition: HTbase.h:19
tmtt::HTbase::end
virtual void end()
Definition: HTbase.cc:26