Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:56:14

0001 #ifndef L1Trigger_TrackFindingTMTT_HTbase_h
0002 #define L1Trigger_TrackFindingTMTT_HTbase_h
0003 
0004 #include "L1Trigger/TrackFindingTMTT/interface/HTcell.h"
0005 #include "L1Trigger/TrackFindingTMTT/interface/L1track2D.h"
0006 #include "L1Trigger/TrackFindingTMTT/interface/Array2D.h"
0007 
0008 #include <vector>
0009 #include <list>
0010 #include <utility>
0011 #include <memory>
0012 
0013 //=== Base class for Hough Transform array for a single (eta,phi) sector.
0014 
0015 namespace tmtt {
0016 
0017   class Settings;
0018   class Stub;
0019   class TP;
0020   class L1fittedTrack;
0021 
0022   class HTbase {
0023   public:
0024     // Initialization.
0025     HTbase(
0026         const Settings* settings, unsigned int iPhiSec, unsigned int iEtaReg, unsigned int nBinsX, unsigned int nBinsY);
0027 
0028     virtual ~HTbase() = default;
0029 
0030     // Termination. Causes HT array to search for tracks etc.
0031     virtual void end();
0032 
0033     //=== Get info about filtered stubs in HT array.
0034     //=== (N.B. The `filtered stubs' are stubs passing any requested stub filters, e.g. bend and/or rapidity.
0035     //=== If no filters were requested, they are identical to the unfiltered stubs.)
0036 
0037     // 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).
0038     virtual unsigned int numStubsInc() const;
0039 
0040     // 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.
0041     virtual unsigned int numStubsExc() const;
0042 
0043     // Get all the cells that make up the array, which in turn give access to the stubs inside them.
0044     // N.B. You can use allCells().size1() and allCells().size2() to get the dimensions ofthe array.
0045     virtual const Array2D<std::unique_ptr<HTcell>>& allCells() const { return htArray_; }
0046 
0047     //=== Info about track candidates found.
0048 
0049     // N.B. If a duplicate track filter was run inside the HT, this will contain the reduced list of tracks passing this filter.
0050     // N.B. If some tracks could not be read out during the TM period, then such tracks are deleted from this list.
0051 
0052     // Get list of all track candidates found in this HT array, giving access to stubs on each track
0053     // and helix parameters.
0054     virtual const std::list<L1track2D>& trackCands2D() const { return trackCands2D_; }
0055 
0056     // Number of track candidates found in this HT array.
0057     // If a duplicate track filter was run, this will contain the reduced list of tracks passing this filter.
0058     virtual unsigned int numTrackCands2D() const { return trackCands2D_.size(); }
0059 
0060     // Get number of filtered stubs assigned to track candidates found in this HT array.
0061     virtual unsigned int numStubsOnTrackCands2D() const;
0062 
0063     // Get all reconstructed tracks that were associated to the given tracking particle.
0064     // (If the std::vector is empty, then the tracking particle was not reconstructed in this sector).
0065     virtual std::vector<const L1track2D*> assocTrackCands2D(const TP& tp) const;
0066 
0067     //=== Function to replace the collection of 2D tracks found by this HT.
0068 
0069     // (This is used by classes MuxHToutputs & MiniHTstage).
0070     virtual void replaceTrackCands2D(const std::list<L1track2D>& newTracks) { trackCands2D_ = newTracks; }
0071 
0072     //=== Utilities
0073 
0074     // Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
0075     // The helix parameters returned will be those corresponding to the two axes of the HT array.
0076     // So they might be (q/pt, phi65), (eta, z0) or (z110, z0) etc. depending on the configuration.
0077     virtual std::pair<float, float> helix2Dhough(unsigned int i, unsigned int j) const = 0;
0078 
0079     // Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
0080     // The helix parameters returned will be always be (q/Pt, phi0) or (tan_lambda, z0), irrespective of
0081     // how the axes of the HT array are defined.
0082     virtual std::pair<float, float> helix2Dconventional(unsigned int i, unsigned int j) const = 0;
0083 
0084     // Which cell in HT array should this TP be in, based on its true trajectory?
0085     // Returns 999999 in at least one index if TP not expected to be in any cell in this array.
0086     virtual std::pair<unsigned int, unsigned int> trueCell(const TP* tp) const = 0;
0087 
0088     // Which cell in HT array should this fitted track be in, based on its fitted trajectory?
0089     // Returns 999999 in at least one index if fitted track not expected to be in any cell in this array.
0090     virtual std::pair<unsigned int, unsigned int> cell(const L1fittedTrack* fitTrk) const = 0;
0091 
0092     // Disable filters (used for debugging).
0093     virtual void disableBendFilter();
0094 
0095   protected:
0096     // 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.
0097     virtual std::pair<unsigned int, unsigned int> convertCoordRangeToBinRange(std::pair<float, float> coordRange,
0098                                                                               unsigned int nBinsAxis,
0099                                                                               float coordAxisMin,
0100                                                                               float coordAxisBinSize,
0101                                                                               unsigned int killSomeHTcells) const;
0102 
0103   private:
0104     // Return a list of all track candidates found in this array, giving access to all the stubs on each one
0105     // and the track helix parameters, plus the associated truth particle (if any).
0106     virtual std::list<L1track2D> calcTrackCands2D() const;
0107 
0108     // If requested, kill those tracks in this sector that can't be read out during the time-multiplexed period, because
0109     // the HT has associated too many stubs to tracks.
0110     virtual std::list<L1track2D> killTracksBusySec(const std::list<L1track2D>& tracks) const = 0;
0111 
0112     // Define the order in which the hardware processes rows of the HT array when it outputs track candidates.
0113     virtual std::vector<unsigned int> rowOrder(unsigned int numRows) const = 0;
0114 
0115     // Calculate output opto-link ID from HT, assuming there is no MUX stage.
0116     virtual unsigned int calcOptoLinkID() const {
0117       unsigned int numPhiSecPerNon = settings_->numPhiSectors() / settings_->numPhiNonants();
0118       return (iEtaReg_ * numPhiSecPerNon + iPhiSec_);
0119     }
0120 
0121   protected:
0122     const Settings* settings_;  // configuration parameters.
0123 
0124     unsigned int iPhiSec_;  // Sector number.
0125     unsigned int iEtaReg_;
0126 
0127     unsigned int nBinsX_;  // Bins in HT array.
0128     unsigned int nBinsY_;
0129 
0130     // Hough transform array.
0131     // This has two dimensions, representing the two track helix parameters being varied.
0132     Array2D<std::unique_ptr<HTcell>> htArray_;
0133 
0134     unsigned int optoLinkID_;  // ID of opto-link from HT to Track Fitter.
0135 
0136     // List of all track candidates found by HT & their associated properties.
0137     // If a duplicate track filter was run inside the HT, this will contain the reduced list of tracks passing this filter.
0138     // If some tracks could not be read out during the TM period, then such tracks are deleted from this list.
0139     std::list<L1track2D> trackCands2D_;
0140   };
0141 
0142 }  // namespace tmtt
0143 
0144 #endif