CMS 3D CMS Logo

MuonROI.h
Go to the documentation of this file.
1 #ifndef PHASE2GMT_MUONROI
2 #define PHASE2GMT_MUONROI
3 #include <iosfwd>
11 
12 namespace Phase2L1GMT {
13 
14  class MuonROI {
15  public:
17 
18  const int bx() const { return bx_; }
19 
20  const uint charge() const { return charge_; }
21 
22  const uint pt() const { return pt_; }
23  const int quality() const { return quality_; }
24 
25  const float offline_pt() const { return offline_pt_; }
26 
27  void setOfflinePt(float pt) { offline_pt_ = pt; }
28 
29  void addStub(const l1t::MuonStubRef& stub) { stubs_.push_back(stub); }
30 
32  muRef_ = ref;
33  isGlobal_ = true;
34  }
35  bool isGlobalMuon() const { return isGlobal_; }
36 
37  const l1t::RegionalMuonCandRef& muonRef() const { return muRef_; }
38 
39  friend std::ostream& operator<<(std::ostream& s, const MuonROI& id) {
40  s.setf(ios::right, ios::adjustfield);
41  s << "ROI:"
42  << " "
43  << "BX: " << setw(5) << id.bx_ << " "
44  << "charge:" << setw(5) << id.charge_ << " "
45  << "pt:" << setw(5) << id.pt_ << " "
46  << "quality:" << setw(5) << id.quality_ << " "
47  << "offline pt:" << setw(5) << id.offline_pt_;
48  return s;
49  }
50 
51  const l1t::MuonStubRefVector& stubs() const { return stubs_; }
52 
53  ap_uint<64> stubWord(const l1t::MuonStubRef& stub) const {
54  ap_uint<64> word = 0;
55  word = word | twos_complement(stub->coord1(), BITSSTUBCOORD);
56  word = word | (twos_complement(stub->coord2(), BITSSTUBCOORD) << BITSSTUBCOORD);
57  word = word | (twos_complement(stub->eta1(), BITSSTUBETA) << (2 * BITSSTUBCOORD));
58  word = word | (twos_complement(stub->eta2(), BITSSTUBETA) << (2 * BITSSTUBCOORD + BITSSTUBETA));
59  word = word | (twos_complement(stub->quality(), BITSSTUBPHIQUALITY) << (2 * BITSSTUBCOORD + 2 * BITSSTUBETA));
60  word = word | (twos_complement(stub->etaQuality(), BITSSTUBETAQUALITY)
62  word = word | (twos_complement(stub->bxNum(), BITSSTUBTIME)
64  word = word | (twos_complement(stub->id(), BITSSTUBID)
66  return word;
67  }
68 
69  ap_uint<32> roiWord() const {
70  ap_uint<32> word = 0;
73  word = word | (twos_complement(charge_, 1) << (BITSMUONBX + 1));
74  word = word | (twos_complement(pt_, BITSPT) << (BITSMUONBX + 2));
76  return word;
77  }
78 
79  void printROILine() const {
80  ap_uint<64> s0 = 0x1ff000000000000;
81  ap_uint<64> s1 = 0x1ff000000000000;
82  ap_uint<64> s2 = 0x1ff000000000000;
83  ap_uint<64> s3 = 0x1ff000000000000;
84  ap_uint<64> s4 = 0x1ff000000000000;
85  for (const auto& s : stubs_) {
86  if (s->tfLayer() == 0)
87  s0 = stubWord(s);
88  if (s->tfLayer() == 1)
89  s1 = stubWord(s);
90  if (s->tfLayer() == 2)
91  s2 = stubWord(s);
92  if (s->tfLayer() == 3)
93  s3 = stubWord(s);
94  if (s->tfLayer() == 4)
95  s4 = stubWord(s);
96  }
97  LogDebug("MuonROI") << "MuonROI " << std::setfill('0') << std::setw(8) << std::hex
98  << (long long unsigned int)(roiWord().to_uint64()) << std::setfill('0') << std::setw(16)
99  << std::hex << (long long unsigned int)(s4.to_uint64()) << std::setfill('0') << std::setw(16)
100  << std::hex << (long long unsigned int)(s3.to_uint64()) << std::setfill('0') << std::setw(16)
101  << std::hex << (long long unsigned int)(s2.to_uint64()) << std::setfill('0') << std::setw(16)
102  << std::hex << (long long unsigned int)(s1.to_uint64()) << std::setfill('0') << std::setw(16)
103  << std::hex << (long long unsigned int)(s0.to_uint64());
104  }
105 
106  private:
107  int bx_;
111  bool isGlobal_;
112  float offline_pt_;
113 
116  };
117 } // namespace Phase2L1GMT
118 
119 #endif
l1t::MuonStubRefVector stubs_
Definition: MuonROI.h:114
const int BITSSTUBCOORD
Definition: Constants.h:31
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
bool isGlobalMuon() const
Definition: MuonROI.h:35
const uint pt() const
Definition: MuonROI.h:22
l1t::RegionalMuonCandRef muRef_
Definition: MuonROI.h:115
MuonROI(int bx, uint charge, uint pt, uint quality)
Definition: MuonROI.h:16
const int BITSSTUBETA
Definition: Constants.h:32
const int BITSSTUBETAQUALITY
Definition: Constants.h:35
const float offline_pt() const
Definition: MuonROI.h:25
void printROILine() const
Definition: MuonROI.h:79
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
const int BITSSTUBTIME
Definition: Constants.h:36
uint64_t word
const int BITSPT
Definition: Constants.h:24
const l1t::RegionalMuonCandRef & muonRef() const
Definition: MuonROI.h:37
ap_uint< 64 > stubWord(const l1t::MuonStubRef &stub) const
Definition: MuonROI.h:53
const uint charge() const
Definition: MuonROI.h:20
const int BITSSTUBID
Definition: Constants.h:33
const int BITSSTUBPHIQUALITY
Definition: Constants.h:34
const int BITSSTAMUONQUALITY
Definition: Constants.h:37
const int BITSMUONBX
Definition: Constants.h:38
friend std::ostream & operator<<(std::ostream &s, const MuonROI &id)
Definition: MuonROI.h:39
const l1t::MuonStubRefVector & stubs() const
Definition: MuonROI.h:51
void addStub(const l1t::MuonStubRef &stub)
Definition: MuonROI.h:29
const int bx() const
Definition: MuonROI.h:18
const int quality() const
Definition: MuonROI.h:23
void setOfflinePt(float pt)
Definition: MuonROI.h:27
ap_uint< 32 > roiWord() const
Definition: MuonROI.h:69
void setMuonRef(const l1t::RegionalMuonCandRef &ref)
Definition: MuonROI.h:31
uint64_t twos_complement(long long int v, uint bits)
Definition: Constants.h:91
#define LogDebug(id)