CMS 3D CMS Logo

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