CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonRawDigiTranslator.cc
Go to the documentation of this file.
1 #include "TMath.h"
3 
4 void
5 l1t::MuonRawDigiTranslator::fillMuon(Muon& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63)
6 {
7  mu.setHwPt((raw_data_00_31 >> ptShift_) & ptMask_);
8  mu.setHwQual((raw_data_00_31 >> qualShift_) & qualMask_);
9 
10  // eta is coded as two's complement
11  int abs_eta = (raw_data_00_31 >> absEtaShift_) & absEtaMask_;
12  if ((raw_data_00_31 >> etaSignShift_) & 0x1) {
13  mu.setHwEta(abs_eta - (1 << (etaSignShift_ - absEtaShift_)));
14  } else {
15  mu.setHwEta(abs_eta);
16  }
17 
18  mu.setHwPhi((raw_data_00_31 >> phiShift_) & phiMask_);
19  mu.setHwIso((raw_data_32_63 >> isoShift_) & isoMask_);
20  // charge is coded as -1^chargeBit
21  mu.setHwCharge((raw_data_32_63 >> chargeShift_) & 0x1);
22  mu.setHwChargeValid((raw_data_32_63 >> chargeValidShift_) & 0x1);
23  mu.setTfMuonIndex((raw_data_32_63 >> tfMuonIndexShift_) & tfMuonIndexMask_);
24 
25  if (mu.hwPt() > 0) {
26  math::PtEtaPhiMLorentzVector vec{(mu.hwPt()-1)*0.5, mu.hwEta()*0.010875, mu.hwPhi()*0.010908, 0.0};
27  mu.setP4(vec);
28  if (mu.hwChargeValid()) {
29  mu.setCharge(1 - 2 * mu.hwCharge());
30  } else {
31  mu.setCharge(0);
32  }
33  }
34 }
35 
36 void
38 {
39  fillMuon(mu, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF));
40 }
41 
42 void
43 l1t::MuonRawDigiTranslator::generatePackedDataWords(const Muon& mu, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63)
44 {
45  int abs_eta = mu.hwEta();
46  if (abs_eta < 0) {
47  abs_eta += (1 << (etaSignShift_ - absEtaShift_));
48  }
49  raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_
50  | (mu.hwQual() & qualMask_) << qualShift_
51  | (abs_eta & absEtaMask_) << absEtaShift_
52  | (mu.hwEta() < 0) << etaSignShift_
53  | (mu.hwPhi() & phiMask_) << phiShift_;
54 
55  raw_data_32_63 = mu.hwCharge() << chargeShift_
56  | mu.hwChargeValid() << chargeValidShift_
57  | (mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_
58  | (mu.hwIso() & isoMask_) << isoShift_;
59 }
60 
61 uint64_t
63 {
64  uint32_t lsw;
65  uint32_t msw;
66 
67  generatePackedDataWords(mu, lsw, msw);
68  return (((uint64_t)msw) << 32) + lsw;
69 }
70 
static const unsigned tfMuonIndexShift_
static const unsigned phiMask_
static const unsigned isoShift_
static void fillMuon(Muon &, uint32_t, uint32_t)
static const unsigned etaSignShift_
void setHwQual(int qual)
Definition: L1Candidate.h:44
int hwPhi() const
Definition: L1Candidate.h:50
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
int hwIso() const
Definition: L1Candidate.h:52
static const unsigned qualShift_
static const unsigned tfMuonIndexMask_
void setTfMuonIndex(int index)
Definition: Muon.cc:100
static const unsigned absEtaShift_
void setHwCharge(int charge)
Definition: Muon.cc:82
static const unsigned phiShift_
void setHwChargeValid(int valid)
Definition: Muon.cc:88
virtual void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
const int mu
Definition: Constants.h:22
int hwEta() const
Definition: L1Candidate.h:49
static const unsigned chargeValidShift_
int hwQual() const
Definition: L1Candidate.h:51
Definition: Muon.h:16
static const unsigned absEtaMask_
void setHwPhi(int phi)
Definition: L1Candidate.h:43
void setHwIso(int iso)
Definition: L1Candidate.h:45
int tfMuonIndex() const
Definition: Muon.cc:154
int hwPt() const
Definition: L1Candidate.h:48
static uint64_t generate64bitDataWord(const Muon &)
unsigned long long uint64_t
Definition: Time.h:15
static const unsigned ptShift_
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
static void generatePackedDataWords(const Muon &, uint32_t &, uint32_t &)
static const unsigned isoMask_
void setHwPt(int pt)
Definition: L1Candidate.h:41
static const unsigned chargeShift_
void setHwEta(int eta)
Definition: L1Candidate.h:42
static const unsigned qualMask_
int hwChargeValid() const
Definition: Muon.cc:142
int hwCharge() const
Definition: Muon.cc:136
static const unsigned ptMask_