Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:34

0001 #ifndef __l1t_regional_muon_candidate_h__
0002 #define __l1t_regional_muon_candidate_h__
0003 
0004 #include "RegionalMuonCandFwd.h"
0005 #include <map>
0006 
0007 namespace l1t {
0008   class RegionalMuonCand {
0009   public:
0010     /// Enum to identify the individual parts of the BMTF track address
0011     /// Update kNumBmtfSubAddr if you add additional enums
0012     enum bmtfAddress {
0013       kWheelSide = 0,
0014       kWheelNum = 1,
0015       kStat1 = 2,
0016       kStat2 = 3,
0017       kStat3 = 4,
0018       kStat4 = 5,
0019       kSegSelStat1 = 6,
0020       kSegSelStat2 = 7,
0021       kSegSelStat3 = 8,
0022       kSegSelStat4 = 9,
0023       kNumBmtfSubAddr = 10
0024     };
0025     /// Enum to identify the individual parts of the OMTF track address
0026     /// Update kNumOmtfSubAddr if you add additional enums
0027     enum omtfAddress { kLayers = 0, kZero = 1, kWeight = 2, kNumOmtfSubAddr = 3 };
0028     /// Enum to identify the individual parts of the EMTF track address
0029     /// Update kNumEmtfSubAddr if you add additional enums
0030     enum emtfAddress {
0031       kME1Seg = 0,
0032       kME1Ch = 1,
0033       kME2Seg = 2,
0034       kME2Ch = 3,
0035       kME3Seg = 4,
0036       kME3Ch = 5,
0037       kME4Seg = 6,
0038       kME4Ch = 7,
0039       kTrkNum = 8,
0040       kBX = 9,
0041       kNumEmtfSubAddr = 10
0042     };
0043 
0044     explicit RegionalMuonCand(uint64_t dataword);
0045 
0046     RegionalMuonCand()
0047         : m_hwPt(0),
0048           m_hwPtUnconstrained(0),
0049           m_hwDXY(0),
0050           m_hwPhi(0),
0051           m_hwEta(0),
0052           m_hwHF(false),
0053           m_hwSign(0),
0054           m_hwSignValid(0),
0055           m_hwQuality(0),
0056           m_dataword(0) {
0057       setTFIdentifiers(0, bmtf);
0058     };
0059 
0060     RegionalMuonCand(int pt, int phi, int eta, int sign, int signvalid, int quality, int processor, tftype trackFinder)
0061         : m_hwPt(pt),
0062           m_hwPtUnconstrained(0),
0063           m_hwDXY(0),
0064           m_hwPhi(phi),
0065           m_hwEta(eta),
0066           m_hwHF(false),
0067           m_hwSign(sign),
0068           m_hwSignValid(signvalid),
0069           m_hwQuality(quality),
0070           m_dataword(0) {
0071       setTFIdentifiers(processor, trackFinder);
0072       // set default track addresses
0073       if (trackFinder == tftype::bmtf) {
0074         m_trackAddress = {{kWheelSide, 0},
0075                           {kWheelNum, 0},
0076                           {kStat1, 0},
0077                           {kStat2, 0},
0078                           {kStat3, 0},
0079                           {kStat4, 0},
0080                           {kSegSelStat1, 0},
0081                           {kSegSelStat2, 0},
0082                           {kSegSelStat3, 0},
0083                           {kSegSelStat4, 0}};
0084       } else if (trackFinder == tftype::omtf_pos || trackFinder == tftype::omtf_neg) {
0085         m_trackAddress = {{kLayers, 0}, {kZero, 0}, {kWeight, 0}};
0086       } else if (trackFinder == tftype::emtf_pos || trackFinder == tftype::emtf_neg) {
0087         m_trackAddress = {{kME1Seg, 0},
0088                           {kME1Ch, 0},
0089                           {kME2Seg, 0},
0090                           {kME2Ch, 0},
0091                           {kME3Seg, 0},
0092                           {kME3Ch, 0},
0093                           {kME4Seg, 0},
0094                           {kME4Ch, 0},
0095                           {kTrkNum, 0},
0096                           {kBX, 0}};
0097       }
0098     };
0099 
0100     RegionalMuonCand(int pt,
0101                      int phi,
0102                      int eta,
0103                      int sign,
0104                      int signvalid,
0105                      int quality,
0106                      int processor,
0107                      tftype trackFinder,
0108                      std::map<int, int> trackAddress)
0109         : m_hwPt(pt),
0110           m_hwPtUnconstrained(0),
0111           m_hwDXY(0),
0112           m_hwPhi(phi),
0113           m_hwEta(eta),
0114           m_hwHF(false),
0115           m_hwSign(sign),
0116           m_hwSignValid(signvalid),
0117           m_hwQuality(quality),
0118           m_trackAddress(trackAddress),
0119           m_dataword(0) {
0120       setTFIdentifiers(processor, trackFinder);
0121     };
0122 
0123     virtual ~RegionalMuonCand(){};
0124 
0125     /// Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
0126     void setHwPt(int bits) { m_hwPt = bits; };
0127     /// Set compressed second displaced  pT as transmitted by hardware LSB = 1.0 (8 bits)
0128     void setHwPtUnconstrained(int bits) { m_hwPtUnconstrained = bits; };
0129     /// Set compressed impact parameter with respect to beamspot (4 bits)
0130     void setHwDXY(int bits) { m_hwDXY = bits; };
0131     /// Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
0132     void setHwPhi(int bits) { m_hwPhi = bits; };
0133     /// Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
0134     void setHwEta(int bits) { m_hwEta = bits; };
0135     /// Set charge sign bit (charge = (-1)^(sign))
0136     void setHwSign(int bits) { m_hwSign = bits; };
0137     /// Set whether charge measurement is valid (0 for high pT muons)
0138     void setHwSignValid(int bits) { m_hwSignValid = bits; };
0139     /// Set compressed quality code as transmitted by hardware (4 bits)
0140     void setHwQual(int bits) { m_hwQuality = bits; };
0141     /// Set HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
0142     void setHwHF(bool bit) { m_hwHF = bit; };
0143     /// Set the processor ID, track-finder type. From these two, the link is set
0144     void setTFIdentifiers(int processor, tftype trackFinder);
0145     // this is left to still be compatible with OMTF
0146     void setLink(int link) { m_link = link; };
0147     // Set the muon index on the link (i.e., 0, 1, or 2)
0148     void setMuIdx(int muIdx) { m_muIdx = muIdx; };
0149     // Set the 64 bit word from two 32 words. bits 0-31->lsbs, bits 32-63->msbs
0150     void setDataword(uint32_t msbs, uint32_t lsbs) { m_dataword = (((uint64_t)msbs) << 32) + lsbs; };
0151     // Set the 64 bit word coming from HW directly
0152     void setDataword(uint64_t bits) { m_dataword = bits; };
0153     /// Set a part of the muon candidates track address; specialised for BMTF
0154     void setTrackSubAddress(bmtfAddress subAddress, int value) { m_trackAddress[subAddress] = value; }
0155     /// Set a part of the muon candidates track address; specialised for OMTF
0156     void setTrackSubAddress(omtfAddress subAddress, int value) { m_trackAddress[subAddress] = value; }
0157     /// Set a part of the muon candidates track address; specialised for EMTF
0158     void setTrackSubAddress(emtfAddress subAddress, int value) { m_trackAddress[subAddress] = value; }
0159     /// Set the whole track address
0160     void setTrackAddress(const std::map<int, int>& address) { m_trackAddress = address; }
0161 
0162     /// Get compressed pT (returned int * 0.5 = pT (GeV))
0163     const int hwPt() const { return m_hwPt; };
0164     /// Get second compressed pT (returned int * 1.0 = pT (GeV))
0165     const int hwPtUnconstrained() const { return m_hwPtUnconstrained; };
0166     /// Get compressed impact parameter (4 bits)
0167     const int hwDXY() const { return m_hwDXY; };
0168     /// Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
0169     const int hwPhi() const { return m_hwPhi; };
0170     /// Get compressed eta (returned int * 0.010875 = eta)
0171     const int hwEta() const { return m_hwEta; };
0172     /// Get charge sign bit (charge = (-1)^(sign))
0173     const int hwSign() const { return m_hwSign; };
0174     /// Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
0175     const int hwSignValid() const { return m_hwSignValid; };
0176     /// Get quality code
0177     const int hwQual() const { return m_hwQuality; };
0178     /// Get link on which the MicroGMT receives the candidate
0179     const int link() const { return m_link; };
0180     /// Get muon index (i.e., 0, 1, or 2)
0181     const int muIdx() const { return m_muIdx; };
0182     /// Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF)
0183     const int processor() const { return m_processor; };
0184     /// Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg)
0185     const tftype trackFinderType() const { return m_trackFinder; };
0186     /// Get HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
0187     const int hwHF() const { return m_hwHF; };
0188     /// Get 64 bit data word
0189     const uint64_t dataword() const { return m_dataword; };
0190     /// Get 32 MSBs of data word
0191     const uint32_t dataword32Msb() const { return (uint32_t)((m_dataword >> 32) & 0xFFFFFFFF); };
0192     /// Get 32 LSBs of data word
0193     const uint32_t dataword32Lsb() const { return (uint32_t)(m_dataword & 0xFFFFFFFF); };
0194     /// Get the track address (identifies track primitives used for reconstruction)
0195     const std::map<int, int>& trackAddress() const { return m_trackAddress; }
0196     /// Get part of track address (identifies track primitives used for reconstruction)
0197     int trackSubAddress(bmtfAddress subAddress) const { return m_trackAddress.at(subAddress); }
0198     /// Get part of track address (identifies track primitives used for reconstruction)
0199     int trackSubAddress(omtfAddress subAddress) const { return m_trackAddress.at(subAddress); }
0200     /// Get part of track address (identifies track primitives used for reconstruction)
0201     int trackSubAddress(emtfAddress subAddress) const { return m_trackAddress.at(subAddress); }
0202 
0203     bool operator==(const RegionalMuonCand& rhs) const;
0204     inline bool operator!=(const RegionalMuonCand& rhs) const { return !(operator==(rhs)); };
0205 
0206   private:
0207     int m_hwPt;
0208     int m_hwPtUnconstrained;
0209     int m_hwDXY;
0210     int m_hwPhi;
0211     int m_hwEta;
0212     bool m_hwHF;
0213     int m_hwSign;
0214     int m_hwSignValid;
0215     int m_hwQuality;
0216     int m_link;
0217     int m_processor;
0218     tftype m_trackFinder;
0219     std::map<int, int> m_trackAddress;
0220 
0221     /// This is the 64 bit word as transmitted in HW
0222     uint64_t m_dataword;
0223     int m_muIdx{-1};
0224   };
0225 
0226 }  // namespace l1t
0227 
0228 #endif /* define __l1t_regional_muon_candidate_h__ */