File indexing completed on 2024-07-16 02:43:03
0001 #ifndef L1Trigger_Phase2GMT_TPSAlgorithm_h
0002 #define L1Trigger_Phase2GMT_TPSAlgorithm_h
0003
0004 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h"
0005 #include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h"
0006 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0007 #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h"
0008 #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h"
0009 #include "DataFormats/L1TMuonPhase2/interface/SAMuon.h"
0010 #include "DataFormats/L1Trigger/interface/L1TObjComparison.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "L1Trigger/Phase2L1GMT/interface/ConvertedTTTrack.h"
0013 #include "L1Trigger/Phase2L1GMT/interface/PreTrackMatchedMuon.h"
0014 #include "L1Trigger/Phase2L1GMT/interface/TPSLUTs.h"
0015 #include <fstream>
0016 #include <iostream>
0017
0018 namespace Phase2L1GMT {
0019
0020 const unsigned int PHIDIVIDER = 1 << (BITSPHI - BITSSTUBCOORD);
0021 const unsigned int ETADIVIDER = 1 << (BITSETA - BITSSTUBETA);
0022
0023 typedef struct {
0024 ap_int<BITSSTUBCOORD> coord1;
0025 ap_uint<BITSSIGMACOORD> sigma_coord1;
0026 ap_int<BITSSTUBCOORD> coord2;
0027 ap_uint<BITSSIGMACOORD> sigma_coord2;
0028 ap_int<BITSSTUBETA> eta;
0029 ap_uint<BITSSIGMAETA> sigma_eta1;
0030 ap_uint<BITSSIGMAETA> sigma_eta2;
0031 ap_uint<1> valid;
0032 ap_uint<1> is_barrel;
0033 } propagation_t;
0034
0035 typedef struct {
0036 ap_uint<BITSMATCHQUALITY - 2> quality;
0037 ap_uint<BITSSTUBID> id;
0038 ap_uint<2> valid;
0039 bool isGlobal;
0040 l1t::SAMuonRef muRef;
0041 l1t::MuonStubRef stubRef;
0042
0043 } match_t;
0044
0045 class TPSAlgorithm {
0046 public:
0047 TPSAlgorithm(const edm::ParameterSet& iConfig);
0048 ~TPSAlgorithm();
0049
0050 std::vector<PreTrackMatchedMuon> processNonant(const std::vector<ConvertedTTTrack>& convertedTracks,
0051 const l1t::MuonStubRefVector& stubs);
0052
0053 std::vector<PreTrackMatchedMuon> cleanNeighbor(const std::vector<PreTrackMatchedMuon>& muons,
0054 const std::vector<PreTrackMatchedMuon>& muonsPrevious,
0055 const std::vector<PreTrackMatchedMuon>& muonsNext,
0056 bool equality);
0057 std::vector<l1t::TrackerMuon> convert(std::vector<PreTrackMatchedMuon>& muons, uint maximum);
0058 bool outputGT(std::vector<l1t::TrackerMuon>& muons);
0059 void SetQualityBits(std::vector<l1t::TrackerMuon>& muons);
0060 std::vector<l1t::TrackerMuon> sort(std::vector<l1t::TrackerMuon>& muons, uint maximum);
0061
0062 private:
0063 int verbose_;
0064 propagation_t propagate(const ConvertedTTTrack& track, uint layer);
0065 ap_uint<BITSSIGMAETA + 1> deltaEta(const ap_int<BITSSTUBETA>& eta1, const ap_int<BITSSTUBETA>& eta2);
0066 ap_uint<BITSSIGMACOORD + 1> deltaCoord(const ap_int<BITSSTUBCOORD>& phi1, const ap_int<BITSSTUBCOORD>& phi2);
0067 match_t match(const propagation_t prop, const l1t::MuonStubRef& stub, uint trackID);
0068 match_t propagateAndMatch(const ConvertedTTTrack& track, const l1t::MuonStubRef& stub, uint trackID);
0069 match_t getBest(const std::vector<match_t> matches);
0070 PreTrackMatchedMuon processTrack(const ConvertedTTTrack&, const l1t::MuonStubRefVector&);
0071 ap_uint<5> cleanMuon(const PreTrackMatchedMuon& mu, const PreTrackMatchedMuon& other, bool eq);
0072 void matchingInfos(std::vector<match_t> matchInfo, PreTrackMatchedMuon& muon, ap_uint<BITSMATCHQUALITY>& quality);
0073 std::vector<PreTrackMatchedMuon> clean(std::vector<PreTrackMatchedMuon>& muons);
0074 };
0075 }
0076
0077 #endif