Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-17 03:58:16

0001 #ifndef PHASE2GMT_PRETRACKMATCHEDMUON
0002 #define PHASE2GMT_PRETRACKMATCHEDMUON
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "DataFormats/L1TMuonPhase2/interface/Constants.h"
0006 #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
0007 #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h"
0008 #include "DataFormats/Common/interface/Ptr.h"
0009 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h"
0010 #include "DataFormats/L1TrackTrigger/interface/TTStub.h"
0011 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0012 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0013 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0014 #include "DataFormats/L1Trigger/interface/Vertex.h"
0015 
0016 #include <vector>
0017 
0018 namespace Phase2L1GMT {
0019 
0020   class PreTrackMatchedMuon {
0021   public:
0022     PreTrackMatchedMuon(const uint& charge,
0023                         const uint& pt,
0024                         const int& eta,
0025                         const int& phi,
0026                         const int& z0,
0027                         const int& d0,
0028                         const uint& beta = 15)
0029         : charge_(charge),
0030           pt_(pt),
0031           eta_(eta),
0032           phi_(phi),
0033           z0_(z0),
0034           d0_(d0),
0035           beta_(beta),
0036           isGlobal_(false),
0037           quality_(0),
0038           stubID0_(511),
0039           stubID1_(511),
0040           stubID2_(511),
0041           stubID3_(511),
0042           stubID4_(511),
0043           valid_(false) {}
0044 
0045     const uint charge() const { return charge_; }
0046     const uint pt() const { return pt_; }
0047     const int eta() const { return eta_; }
0048     const int phi() const { return phi_; }
0049     const int z0() const { return z0_; }
0050     const int d0() const { return d0_; }
0051     const uint beta() const { return beta_; }
0052 
0053     bool isGlobalMuon() const { return isGlobal_; }
0054     const int quality() const { return quality_; }
0055     const int offline_pt() const { return offline_pt_; }
0056     const float offline_eta() const { return offline_eta_; }
0057     const float offline_phi() const { return offline_phi_; }
0058 
0059     const uint stubID0() const { return stubID0_; }
0060     const uint stubID1() const { return stubID1_; }
0061     const uint stubID2() const { return stubID2_; }
0062     const uint stubID3() const { return stubID3_; }
0063     const uint stubID4() const { return stubID4_; }
0064     bool valid() const { return valid_; }
0065 
0066     void setQuality(uint quality) { quality_ = quality; }
0067     void setValid(bool v) { valid_ = v; }
0068 
0069     void setOfflineQuantities(float pt, float eta, float phi) {
0070       offline_pt_ = pt;
0071       offline_eta_ = eta;
0072       offline_phi_ = phi;
0073     }
0074 
0075     void addMuonRef(const l1t::RegionalMuonCandRef& ref) {
0076       muRef_.push_back(ref);
0077       isGlobal_ = true;
0078     }
0079 
0080     void resetGlobal() { isGlobal_ = false; }
0081 
0082     const std::vector<l1t::RegionalMuonCandRef>& muonRef() const { return muRef_; }
0083     void addStub(const l1t::MuonStubRef& stub) {
0084       stubs_.push_back(stub);
0085       if (stub->tfLayer() == 0)
0086         stubID0_ = stub->id();
0087       else if (stub->tfLayer() == 1)
0088         stubID1_ = stub->id();
0089       else if (stub->tfLayer() == 2)
0090         stubID2_ = stub->id();
0091       else if (stub->tfLayer() == 3)
0092         stubID3_ = stub->id();
0093       else if (stub->tfLayer() == 4)
0094         stubID4_ = stub->id();
0095     }
0096 
0097     const l1t::MuonStubRefVector& stubs() const { return stubs_; }
0098 
0099     void setTrkPtr(const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> >& trkPtr) { trkPtr_ = trkPtr; }
0100 
0101     const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > trkPtr() const { return trkPtr_; }
0102 
0103     void print() const {
0104       LogDebug("PreTrackMatchedMuon") << "preconstructed muon : charge=" << charge_ << " pt=" << offline_pt_ << ","
0105                                       << pt_ << " eta=" << offline_eta_ << "," << eta_ << " phi=" << offline_phi_ << ","
0106                                       << phi_ << " z0=" << z0_ << " d0=" << d0_ << " quality=" << quality_
0107                                       << " isGlobal=" << isGlobal_ << " valid=" << valid_ << " stubs: " << stubID0_
0108                                       << " " << stubID1_ << " " << stubID2_ << " " << stubID3_ << " " << stubID4_;
0109     }
0110 
0111     uint64_t lsb() const {
0112       uint64_t w = charge_ & 0x1;
0113       w = w | (twos_complement(pt_, BITSPT) << 1);
0114       w = w | (twos_complement(phi_, BITSPHI) << (BITSPT + 1));
0115       w = w | (twos_complement(eta_, BITSETA) << (BITSPHI + BITSPT + 1));
0116       w = w | (twos_complement(z0_, BITSZ0) << (BITSETA + BITSPHI + BITSPT + 1));
0117       w = w | (twos_complement(d0_, BITSD0) << (BITSZ0 + BITSETA + BITSPHI + BITSPT + 1));
0118       return w;
0119     }
0120 
0121     uint64_t msb() const {
0122       uint64_t w2 = 0;
0123       w2 = twos_complement(stubID0_, BITSSTUBID);
0124       w2 = w2 | (twos_complement(stubID1_, BITSSTUBID) << BITSSTUBID);
0125       w2 = w2 | (twos_complement(stubID2_, BITSSTUBID) << (2 * BITSSTUBID));
0126       w2 = w2 | (twos_complement(stubID3_, BITSSTUBID) << (3 * BITSSTUBID));
0127       w2 = w2 | (twos_complement(stubID4_, BITSSTUBID) << (4 * BITSSTUBID));
0128       w2 = w2 | (twos_complement(isGlobal_, 1) << (5 * BITSSTUBID));
0129       w2 = w2 | (twos_complement(beta_, BITSMUONBETA) << (5 * BITSSTUBID + 1));
0130       w2 = w2 | (twos_complement(quality_, BITSMATCHQUALITY) << (BITSMUONBETA + 5 * BITSSTUBID + 1));
0131       w2 = w2 | (twos_complement(valid_, 1) << (BITSMATCHQUALITY + BITSMUONBETA + 5 * BITSSTUBID + 1));
0132       return w2;
0133     }
0134 
0135     void printWord() const {
0136       LogDebug("PreTrackMatchedMuon") << "PreTrackMatchedMuon : word=" << std::setfill('0') << std::setw(16) << std::hex
0137                                       << (long long unsigned int)(msb() >> 2) << std::setfill('0') << std::setw(16)
0138                                       << std::hex
0139                                       << (long long unsigned int)((lsb() | (msb() << 62)) & 0xffffffffffffffff);
0140     }
0141 
0142   private:
0143     uint charge_;
0144     uint pt_;
0145     int eta_;
0146     int phi_;
0147     int z0_;
0148     int d0_;
0149     uint beta_;
0150     bool isGlobal_;
0151     uint quality_;
0152     float offline_pt_;
0153     float offline_eta_;
0154     float offline_phi_;
0155     uint stubID0_;
0156     uint stubID1_;
0157     uint stubID2_;
0158     uint stubID3_;
0159     uint stubID4_;
0160     bool valid_;
0161     l1t::MuonStubRefVector stubs_;
0162     std::vector<l1t::RegionalMuonCandRef> muRef_;
0163     edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_> > trkPtr_;
0164   };
0165 }  // namespace Phase2L1GMT
0166 
0167 #endif