CMS 3D CMS Logo

List of all members | Static Public Member Functions | Static Public Attributes
l1t::MuonRawDigiTranslator Class Reference

#include <MuonRawDigiTranslator.h>

Static Public Member Functions

static int calcHwEta (const uint32_t &, const unsigned, const unsigned)
 
static void fillMuon (Muon &, uint32_t, uint32_t, int, unsigned int)
 
static void fillMuon (Muon &, uint64_t, int, unsigned int)
 
static uint64_t generate64bitDataWord (const Muon &)
 
static void generatePackedDataWords (const Muon &, uint32_t &, uint32_t &)
 

Static Public Attributes

static const unsigned absEtaAtVtxShift_ = 23
 
static const unsigned absEtaMask_ = 0xFF
 
static const unsigned absEtaShift_ = 21
 
static const unsigned chargeShift_ = 2
 
static const unsigned chargeValidShift_ = 3
 
static const unsigned etaAtVtxSignShift_ = 31
 
static const unsigned etaSignShift_ = 29
 
static const unsigned isoMask_ = 0x3
 
static const unsigned isoShift_ = 0
 
static const unsigned phiAtVtxShift_ = 0
 
static const unsigned phiMask_ = 0x3FF
 
static const unsigned phiShift_ = 11
 
static const unsigned ptMask_ = 0x1FF
 
static const unsigned ptShift_ = 10
 
static const unsigned qualMask_ = 0xF
 
static const unsigned qualShift_ = 19
 
static const unsigned tfMuonIndexMask_ = 0x7F
 
static const unsigned tfMuonIndexShift_ = 4
 

Detailed Description

Definition at line 7 of file MuonRawDigiTranslator.h.

Member Function Documentation

int l1t::MuonRawDigiTranslator::calcHwEta ( const uint32_t &  raw,
const unsigned  absEtaShift,
const unsigned  etaSignShift 
)
static

Definition at line 111 of file MuonRawDigiTranslator.cc.

References absEtaMask_.

Referenced by fillMuon().

112 {
113  // eta is coded as two's complement
114  int abs_eta = (raw >> absEtaShift) & absEtaMask_;
115  if ((raw >> etaSignShift) & 0x1) {
116  return abs_eta - (1 << (etaSignShift - absEtaShift));
117  } else {
118  return abs_eta;
119  }
120 }
static const unsigned absEtaMask_
void l1t::MuonRawDigiTranslator::fillMuon ( Muon mu,
uint32_t  raw_data_00_31,
uint32_t  raw_data_32_63,
int  fed,
unsigned int  fw 
)
static

Definition at line 5 of file MuonRawDigiTranslator.cc.

References absEtaAtVtxShift_, absEtaShift_, calcHwEta(), chargeShift_, chargeValidShift_, dPhi(), reco::LeafCandidate::eta(), etaAtVtxSignShift_, etaSignShift_, l1t::Muon::hwCharge(), l1t::Muon::hwChargeValid(), l1t::L1Candidate::hwEta(), l1t::Muon::hwEtaAtVtx(), l1t::L1Candidate::hwPhi(), l1t::Muon::hwPhiAtVtx(), l1t::L1Candidate::hwPt(), isoMask_, isoShift_, reco::LeafCandidate::phi(), phiAtVtxShift_, phiMask_, phiShift_, ptMask_, ptShift_, qualMask_, qualShift_, reco::LeafCandidate::setCharge(), l1t::Muon::setEtaAtVtx(), l1t::Muon::setHwCharge(), l1t::Muon::setHwChargeValid(), l1t::Muon::setHwDEtaExtra(), l1t::Muon::setHwDPhiExtra(), l1t::L1Candidate::setHwEta(), l1t::Muon::setHwEtaAtVtx(), l1t::L1Candidate::setHwIso(), l1t::L1Candidate::setHwPhi(), l1t::Muon::setHwPhiAtVtx(), l1t::L1Candidate::setHwPt(), l1t::L1Candidate::setHwQual(), reco::LeafCandidate::setP4(), l1t::Muon::setPhiAtVtx(), l1t::Muon::setTfMuonIndex(), tfMuonIndexMask_, and tfMuonIndexShift_.

Referenced by fillMuon(), l1t::stage2::IntermediateMuonUnpacker::unpack(), and l1t::stage2::MuonUnpacker::unpack().

6 {
7  int hwPt = (raw_data_00_31 >> ptShift_) & ptMask_;
8  if (hwPt > 0) {
9  mu.setHwPt(hwPt);
10  mu.setHwQual((raw_data_00_31 >> qualShift_) & qualMask_);
11  mu.setHwIso((raw_data_32_63 >> isoShift_) & isoMask_);
12  // charge is coded as -1^chargeBit
13  mu.setHwCharge((raw_data_32_63 >> chargeShift_) & 0x1);
14  mu.setHwChargeValid((raw_data_32_63 >> chargeValidShift_) & 0x1);
15  mu.setTfMuonIndex((raw_data_32_63 >> tfMuonIndexShift_) & tfMuonIndexMask_);
16 
17  // The position of the eta and phi coordinates in the RAW data changed between the 2016 run and the 2017 run.
18  // Eta and phi at the muon system are replaced by eta and phi at the vertex
19  // Eta and phi at the muon system are moved to spare bits
20  // The uGMT (FED 1402) or uGT (FED 1404) FW versions are used to determine the era.
21  // FIXME: set correct FW versions for uGT and uGMT once they are known
22  if ((fed == 1402 && fw < 0x5000000) || (fed == 1404 && fw < 0x10A5)) {
23  // coordinates at the muon system are in 2016 where in 2017 eta and phi at the vertex are
24  mu.setHwEta(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
25  mu.setHwPhi((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
26 
27  // set the coordiantes at vertex to be the same as the coordinates at the muon system
28  mu.setHwEtaAtVtx(mu.hwEta());
29  mu.setHwPhiAtVtx(mu.hwPhi());
30  // deltas are 0
31  mu.setHwDEtaExtra(0);
32  mu.setHwDPhiExtra(0);
33  } else {
34  // coordinates at the muon system
35  mu.setHwEta(calcHwEta(raw_data_32_63, absEtaShift_, etaSignShift_));
36  mu.setHwPhi((raw_data_32_63 >> phiShift_) & phiMask_);
37 
38  // coordinates at the vertex
39  mu.setHwEtaAtVtx(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
40  mu.setHwPhiAtVtx((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
41  // deltas
42  mu.setHwDEtaExtra(mu.hwEtaAtVtx() - mu.hwEta());
43  int dPhi = mu.hwPhiAtVtx() - mu.hwPhi();
44  if (mu.hwCharge() == 1 && dPhi > 0) {
45  dPhi -= 576;
46  } else if (mu.hwCharge() == 0 && dPhi < 0) {
47  dPhi += 576;
48  }
49  mu.setHwDPhiExtra(dPhi);
50  }
51 
52  math::PtEtaPhiMLorentzVector vec{(mu.hwPt()-1)*0.5, mu.hwEta()*0.010875, mu.hwPhi()*0.010908, 0.0};
53  mu.setP4(vec);
54  // generate a muon at the vertex to extract the physical eta and phi coordinates
55  math::PtEtaPhiMLorentzVector vecAtVtx{(mu.hwPt()-1)*0.5, mu.hwEtaAtVtx()*0.010875, mu.hwPhiAtVtx()*0.010908, 0.0};
56  Muon muAtVtx;
57  muAtVtx.setP4(vecAtVtx);
58  mu.setEtaAtVtx(muAtVtx.eta());
59  mu.setPhiAtVtx(muAtVtx.phi());
60  if (mu.hwChargeValid()) {
61  mu.setCharge(1 - 2 * mu.hwCharge());
62  } else {
63  mu.setCharge(0);
64  }
65  }
66 }
static const unsigned etaAtVtxSignShift_
static const unsigned tfMuonIndexShift_
static const unsigned phiMask_
static const unsigned isoShift_
static const unsigned etaSignShift_
static const unsigned absEtaAtVtxShift_
static int calcHwEta(const uint32_t &, const unsigned, const unsigned)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
static const unsigned qualShift_
static const unsigned tfMuonIndexMask_
static const unsigned absEtaShift_
Definition: Muon.py:1
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
static const unsigned phiShift_
const int mu
Definition: Constants.h:22
static const unsigned chargeValidShift_
static const unsigned ptShift_
static const unsigned isoMask_
static const unsigned chargeShift_
static const unsigned qualMask_
static const unsigned phiAtVtxShift_
static const unsigned ptMask_
void l1t::MuonRawDigiTranslator::fillMuon ( Muon mu,
uint64_t  dataword,
int  fed,
unsigned int  fw 
)
static

Definition at line 69 of file MuonRawDigiTranslator.cc.

References fillMuon().

70 {
71  fillMuon(mu, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF), fed, fw);
72 }
const int mu
Definition: Constants.h:22
static void fillMuon(Muon &, uint32_t, uint32_t, int, unsigned int)
uint64_t l1t::MuonRawDigiTranslator::generate64bitDataWord ( const Muon mu)
static

Definition at line 101 of file MuonRawDigiTranslator.cc.

References generatePackedDataWords().

102 {
103  uint32_t lsw;
104  uint32_t msw;
105 
106  generatePackedDataWords(mu, lsw, msw);
107  return (((uint64_t)msw) << 32) + lsw;
108 }
const int mu
Definition: Constants.h:22
unsigned long long uint64_t
Definition: Time.h:15
static void generatePackedDataWords(const Muon &, uint32_t &, uint32_t &)
void l1t::MuonRawDigiTranslator::generatePackedDataWords ( const Muon mu,
uint32_t &  raw_data_00_31,
uint32_t &  raw_data_32_63 
)
static

Definition at line 75 of file MuonRawDigiTranslator.cc.

References absEtaAtVtxShift_, absEtaMask_, absEtaShift_, chargeShift_, chargeValidShift_, etaAtVtxSignShift_, etaSignShift_, l1t::Muon::hwCharge(), l1t::Muon::hwChargeValid(), l1t::L1Candidate::hwEta(), l1t::Muon::hwEtaAtVtx(), l1t::L1Candidate::hwIso(), l1t::L1Candidate::hwPhi(), l1t::Muon::hwPhiAtVtx(), l1t::L1Candidate::hwPt(), l1t::L1Candidate::hwQual(), isoMask_, isoShift_, phiAtVtxShift_, phiMask_, phiShift_, ptMask_, ptShift_, qualMask_, qualShift_, l1t::Muon::tfMuonIndex(), tfMuonIndexMask_, and tfMuonIndexShift_.

Referenced by generate64bitDataWord(), and l1t::stage2::MuonPacker::pack().

76 {
77  int abs_eta = mu.hwEta();
78  if (abs_eta < 0) {
79  abs_eta += (1 << (etaSignShift_ - absEtaShift_));
80  }
81  int abs_eta_at_vtx = mu.hwEtaAtVtx();
82  if (abs_eta_at_vtx < 0) {
83  abs_eta_at_vtx += (1 << (etaAtVtxSignShift_ - absEtaAtVtxShift_));
84  }
85  raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_
86  | (mu.hwQual() & qualMask_) << qualShift_
87  | (abs_eta_at_vtx & absEtaMask_) << absEtaAtVtxShift_
88  | (mu.hwEtaAtVtx() < 0) << etaAtVtxSignShift_
89  | (mu.hwPhiAtVtx() & phiMask_) << phiAtVtxShift_;
90 
91  raw_data_32_63 = mu.hwCharge() << chargeShift_
92  | mu.hwChargeValid() << chargeValidShift_
93  | (mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_
94  | (mu.hwIso() & isoMask_) << isoShift_
95  | (abs_eta & absEtaMask_) << absEtaShift_
96  | (mu.hwEta() < 0) << etaSignShift_
97  | (mu.hwPhi() & phiMask_) << phiShift_;
98 }
static const unsigned etaAtVtxSignShift_
static const unsigned tfMuonIndexShift_
static const unsigned phiMask_
static const unsigned isoShift_
static const unsigned etaSignShift_
static const unsigned absEtaAtVtxShift_
static const unsigned qualShift_
static const unsigned tfMuonIndexMask_
static const unsigned absEtaShift_
static const unsigned phiShift_
const int mu
Definition: Constants.h:22
static const unsigned chargeValidShift_
static const unsigned absEtaMask_
static const unsigned ptShift_
static const unsigned isoMask_
static const unsigned chargeShift_
static const unsigned qualMask_
static const unsigned phiAtVtxShift_
static const unsigned ptMask_

Member Data Documentation

const unsigned l1t::MuonRawDigiTranslator::absEtaAtVtxShift_ = 23
static

Definition at line 21 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::absEtaMask_ = 0xFF
static

Definition at line 19 of file MuonRawDigiTranslator.h.

Referenced by calcHwEta(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::absEtaShift_ = 21
static

Definition at line 20 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::chargeShift_ = 2
static

Definition at line 27 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::chargeValidShift_ = 3
static

Definition at line 28 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::etaAtVtxSignShift_ = 31
static

Definition at line 23 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::etaSignShift_ = 29
static

Definition at line 22 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::isoMask_ = 0x3
static

Definition at line 31 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::isoShift_ = 0
static

Definition at line 32 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::phiAtVtxShift_ = 0
static

Definition at line 26 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::phiMask_ = 0x3FF
static

Definition at line 24 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::phiShift_ = 11
static

Definition at line 25 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::ptMask_ = 0x1FF
static
const unsigned l1t::MuonRawDigiTranslator::ptShift_ = 10
static
const unsigned l1t::MuonRawDigiTranslator::qualMask_ = 0xF
static

Definition at line 17 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::qualShift_ = 19
static

Definition at line 18 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::tfMuonIndexMask_ = 0x7F
static

Definition at line 29 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().

const unsigned l1t::MuonRawDigiTranslator::tfMuonIndexShift_ = 4
static

Definition at line 30 of file MuonRawDigiTranslator.h.

Referenced by fillMuon(), and generatePackedDataWords().