Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:38

0001 
0002 #ifndef L1Trigger_DemonstratorTools_codecs_tracks_h
0003 #define L1Trigger_DemonstratorTools_codecs_tracks_h
0004 
0005 #include <array>
0006 #include <sstream>
0007 #include <vector>
0008 
0009 #include "ap_int.h"
0010 
0011 #include "DataFormats/Common/interface/Handle.h"
0012 #include "DataFormats/Common/interface/Ref.h"
0013 #include "DataFormats/Common/interface/View.h"
0014 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h"
0015 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0016 
0017 namespace l1t::demo::codecs {
0018   //function to get the gttLinkID from the TrackFindingProcessors
0019   template <typename T>
0020   unsigned int gttLinkID(T track) {
0021     // use the sign bit of the tanL word to remove dependence on TTTrack eta member.
0022     unsigned int etaSector = (track.getTrackWord()(TTTrack_TrackWord::TrackBitLocations::kTanlMSB,
0023                                                    TTTrack_TrackWord::TrackBitLocations::kTanlMSB)
0024                                   ? 0
0025                                   : 1);
0026     return etaSector + (2 * track.phiSector());
0027   }
0028 
0029   static inline std::pair<unsigned int, unsigned int> sectorsEtaPhiFromGTTLinkID(unsigned int id) {
0030     unsigned int etaSector = (id % 2);
0031     unsigned int phiSector = (static_cast<unsigned int>(id) - etaSector) / 2;
0032     return std::pair<unsigned int, unsigned int>(etaSector, phiSector);
0033   }
0034 
0035   // Return true if a track is contained within a collection
0036   bool trackInCollection(const edm::Ref<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>&,
0037                          const edm::Handle<edm::RefVector<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>>&);
0038 
0039   // Encodes a single track into a 96-bit track word
0040   ap_uint<96> encodeTrack(const TTTrack_TrackWord& t);
0041 
0042   // Return the 96-bit track words from a given track collection and place them on the appropriate 18 'logical' links
0043   std::array<std::vector<ap_uint<96>>, 18> getTrackWords(const edm::View<TTTrack<Ref_Phase2TrackerDigi_>>&);
0044   std::array<std::vector<ap_uint<96>>, 18> getTrackWords(
0045       const edm::Handle<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>&,
0046       const edm::Handle<edm::RefVector<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>>&);
0047 
0048   // Encodes track collection onto 18 'logical' output links (2x9 eta-phi sectors; -/+ eta pairs)
0049   std::array<std::vector<ap_uint<64>>, 18> encodeTracks(const edm::View<TTTrack<Ref_Phase2TrackerDigi_>>&,
0050                                                         int debug = 0);
0051 
0052   // Encodes a track collection based off the ordering of another track collection
0053   // Requirement: The second collection must be a subset of the first
0054   std::array<std::vector<ap_uint<64>>, 18> encodeTracks(
0055       const edm::Handle<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>&,
0056       const edm::Handle<edm::RefVector<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>>&,
0057       int debug = 0);
0058 
0059   // Decodes the tracks for a single link
0060   std::vector<TTTrack_TrackWord> decodeTracks(const std::vector<ap_uint<64>>&);
0061 
0062   // Decodes the tracks from 18 'logical' output links (2x9 eta-phi sectors; , -/+ eta pairs)
0063   std::array<std::vector<TTTrack_TrackWord>, 18> decodeTracks(const std::array<std::vector<ap_uint<64>>, 18>&);
0064 
0065 }  // namespace l1t::demo::codecs
0066 
0067 #endif