Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-03 00:12:20

0001 #ifndef L1Trigger_TrackFindingTracklet_DuplicateRemoval_h
0002 #define L1Trigger_TrackFindingTracklet_DuplicateRemoval_h
0003 
0004 #include "L1Trigger/TrackTrigger/interface/Setup.h"
0005 #include "L1Trigger/TrackerTFP/interface/LayerEncoding.h"
0006 #include "L1Trigger/TrackFindingTracklet/interface/DataFormats.h"
0007 #include "L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h"
0008 
0009 #include <vector>
0010 
0011 namespace trklet {
0012 
0013   /*! \class  trklet::DuplicateRemoval
0014    *  \brief  Class to bit- and clock-accurate emulate duplicate removal
0015    *          DR identifies duplicates based on pairs of tracks that share stubs in at least 3 layers.
0016    *          It keeps the first such track in each pair. The Track order is determined by TrackMultiplexer,
0017    *          provided by ProducerTM.
0018    *  \author Thomas Schuh
0019    *  \date   2023, Feb
0020    */
0021   class DuplicateRemoval {
0022   public:
0023     DuplicateRemoval(const tt::Setup* setup_,
0024                      const trackerTFP::LayerEncoding* layerEncoding,
0025                      const DataFormats* dataFormats,
0026                      const ChannelAssignment* channelAssignment,
0027                      int region);
0028     ~DuplicateRemoval() = default;
0029     // read in and organize input tracks and stubs
0030     void consume(const tt::StreamsTrack& streamsTrack, const tt::StreamsStub& streamsStub);
0031     // fill output products
0032     void produce(tt::StreamsTrack& acceptedTracks, tt::StreamsStub& accpetedStubs);
0033 
0034   private:
0035     struct Stub {
0036       Stub(const tt::FrameStub& frame, int stubId, int layer) : frame_(frame), stubId_(stubId), layer_(layer) {}
0037       // output frame
0038       tt::FrameStub frame_;
0039       // all stubs id
0040       int stubId_;
0041       // kf layer id
0042       int layer_;
0043     };
0044     struct Track {
0045       // max number of stubs a track may formed of (we allow only one stub per layer)
0046       static constexpr int max_ = 11;
0047       Track() { stubs_.reserve(max_); }
0048       Track(const tt::FrameTrack& frame, const std::vector<Stub*>& stubs) : frame_(frame), stubs_(stubs) {}
0049       tt::FrameTrack frame_;
0050       std::vector<Stub*> stubs_;
0051     };
0052     // compares two tracks, returns true if those are considered duplicates
0053     bool equalEnough(Track* t0, Track* t1) const;
0054     // true if truncation is enbaled
0055     bool enableTruncation_;
0056     // provides run-time constants
0057     const tt::Setup* setup_;
0058     // helper class to encode layer
0059     const trackerTFP::LayerEncoding* layerEncoding_;
0060     // provides dataformats
0061     const DataFormats* dataFormats_;
0062     // helper class to assign tracks to channel
0063     const ChannelAssignment* channelAssignment_;
0064     // processing region (0 - 8) aka processing phi nonant
0065     const int region_;
0066     // storage of input tracks
0067     std::vector<Track> tracks_;
0068     // storage of input stubs
0069     std::vector<Stub> stubs_;
0070     // h/w liked organized pointer to input tracks
0071     std::vector<Track*> input_;
0072     // dataformat used to calculate pitch over stubs radius
0073     DataFormat r_;
0074     // number of TM layers
0075     int tmNumLayers_;
0076     // phi data format
0077     DataFormat phi_;
0078   };
0079 
0080 }  // namespace trklet
0081 
0082 #endif