CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RegionalMuonRawDigiTranslator.cc
Go to the documentation of this file.
2 
3 void
4 l1t::RegionalMuonRawDigiTranslator::fillRegionalMuonCand(RegionalMuonCand& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int proc, tftype tf)
5 {
6  // translations as defined in DN-15-017
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  // phi is coded as two's complement
19  int abs_phi = (raw_data_00_31 >> absPhiShift_) & absPhiMask_;
20  if ((raw_data_00_31 >> phiSignShift_) & 0x1) {
21  mu.setHwPhi(abs_phi - (1 << (phiSignShift_ - absPhiShift_)));
22  } else {
23  mu.setHwPhi(abs_phi);
24  }
25 
26  // sign is coded as -1^signBit
27  mu.setHwSign((raw_data_32_63 >> signShift_) & 0x1);
28  mu.setHwSignValid((raw_data_32_63 >> signValidShift_) & 0x1);
29  mu.setHwHF((raw_data_00_31 >> hfShift_) & hfMask_);
30 
31  // set track address with subaddresses
32  int rawTrackAddress = (raw_data_32_63 >> trackAddressShift_) & trackAddressMask_;
33  if (tf == bmtf) {
34  int segSel = (rawTrackAddress >> bmtfTrAddrSegSelShift_) & bmtfTrAddrSegSelMask_;
35  int detSide = (rawTrackAddress >> bmtfTrAddrDetSideShift_) & 0x1;
36  int wheelNum = (rawTrackAddress >> bmtfTrAddrWheelShift_) & bmtfTrAddrWheelMask_;
37  int statAddr1 = ((rawTrackAddress >> bmtfTrAddrStat1Shift_) & bmtfTrAddrStat1Mask_)
38  | ((segSel & 0x1) << 2);
39  int statAddr2 = ((rawTrackAddress >> bmtfTrAddrStat2Shift_) & bmtfTrAddrStat2Mask_)
40  | ((segSel & 0x2) << 3);
41  int statAddr3 = ((rawTrackAddress >> bmtfTrAddrStat3Shift_) & bmtfTrAddrStat3Mask_)
42  | ((segSel & 0x4) << 2);
43  int statAddr4 = ((rawTrackAddress >> bmtfTrAddrStat4Shift_) & bmtfTrAddrStat4Mask_)
44  | ((segSel & 0x8) << 1);
55  } else if (tf == emtf_neg || tf == emtf_pos) {
69  } else {
70  std::map<int, int> trackAddr;
71  trackAddr[0] = rawTrackAddress;
72  mu.setTrackAddress(trackAddr);
73  }
74 
75  mu.setTFIdentifiers(proc, tf);
76  mu.setDataword(raw_data_32_63, raw_data_00_31);
77 }
78 
79 void
81 {
82  fillRegionalMuonCand(mu, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF), proc, tf);
83 }
84 
85 void
86 l1t::RegionalMuonRawDigiTranslator::generatePackedDataWords(const RegionalMuonCand& mu, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63)
87 {
88  int abs_eta = mu.hwEta();
89  if (abs_eta < 0) {
90  abs_eta += (1 << (etaSignShift_ - absEtaShift_));
91  }
92  int abs_phi = mu.hwPhi();
93  if (abs_phi < 0) {
94  abs_phi += (1 << (phiSignShift_ - absPhiShift_));
95  }
96  raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_
97  | (mu.hwQual() & qualMask_) << qualShift_
98  | (abs_eta & absEtaMask_) << absEtaShift_
99  | (mu.hwEta() < 0) << etaSignShift_
100  | (mu.hwHF() & hfMask_) << hfShift_
101  | (abs_phi & absPhiMask_) << absPhiShift_
102  | (mu.hwPhi() < 0) << phiSignShift_;
103 
104  int tf = mu.trackFinderType();
105  int rawTrkAddr = 0;
106  if (tf == bmtf) {
108  int wheelNum = mu.trackSubAddress(RegionalMuonCand::kWheelNum);
113 
118 
119  rawTrkAddr = (segSel & bmtfTrAddrSegSelMask_) << bmtfTrAddrSegSelShift_
120  | (detSide & 0x1) << bmtfTrAddrDetSideShift_
121  | (wheelNum & bmtfTrAddrWheelMask_) << bmtfTrAddrWheelShift_
122  | (stat1 & bmtfTrAddrStat1Mask_) << bmtfTrAddrStat1Shift_
123  | (stat2 & bmtfTrAddrStat2Mask_) << bmtfTrAddrStat2Shift_
124  | (stat3 & bmtfTrAddrStat3Mask_) << bmtfTrAddrStat3Shift_
125  | (stat4 & bmtfTrAddrStat4Mask_) << bmtfTrAddrStat4Shift_;
126  } else if (tf == emtf_neg || tf == emtf_pos) {
127  rawTrkAddr = (mu.trackSubAddress(RegionalMuonCand::kSectorId) & emtfTrAddrSectIdMask_) << emtfTrAddrSectIdShift_
128  | (mu.trackSubAddress(RegionalMuonCand::kME1) & emtfTrAddrMe1Mask_) << emtfTrAddrMe1Shift_
129  | (mu.trackSubAddress(RegionalMuonCand::kME1SubSecId) & 0x1) << emtfTrAddrMe1SubSecIdShift_
130  | (mu.trackSubAddress(RegionalMuonCand::kME1Order) & 0x1) << emtfTrAddrMe1OrderShift_
131  | (mu.trackSubAddress(RegionalMuonCand::kME2) & emtfTrAddrMe2Mask_) << emtfTrAddrMe2Shift_
132  | (mu.trackSubAddress(RegionalMuonCand::kME2SubSecId) & 0x1) << emtfTrAddrMe2SubSecIdShift_
133  | (mu.trackSubAddress(RegionalMuonCand::kME2Order) & 0x1) << emtfTrAddrMe2OrderShift_
134  | (mu.trackSubAddress(RegionalMuonCand::kME3) & emtfTrAddrMe3Mask_) << emtfTrAddrMe3Shift_
135  | (mu.trackSubAddress(RegionalMuonCand::kME3SubSecId) & 0x1) << emtfTrAddrMe3SubSecIdShift_
136  | (mu.trackSubAddress(RegionalMuonCand::kME3Order) & 0x1) << emtfTrAddrMe3OrderShift_
137  | (mu.trackSubAddress(RegionalMuonCand::kME4) & emtfTrAddrMe4Mask_) << emtfTrAddrMe4Shift_
138  | (mu.trackSubAddress(RegionalMuonCand::kME4SubSecId) & 0x1) << emtfTrAddrMe4SubSecIdShift_
139  | (mu.trackSubAddress(RegionalMuonCand::kME4Order) & 0x1) << emtfTrAddrMe4OrderShift_;
140  } else {
141  rawTrkAddr = mu.trackAddress().at(0);
142  }
143 
144  raw_data_32_63 = mu.hwSign() << signShift_
145  | mu.hwSignValid() << signValidShift_
146  | (rawTrkAddr & trackAddressMask_) << trackAddressShift_;
147 }
148 
149 uint64_t
151 {
152  uint32_t lsw;
153  uint32_t msw;
154 
155  generatePackedDataWords(mu, lsw, msw);
156  return (((uint64_t)msw) << 32) + lsw;
157 }
158 
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
const int hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
static void generatePackedDataWords(const RegionalMuonCand &, uint32_t &, uint32_t &)
TrainProcessor *const proc
Definition: MVATrainer.cc:101
void setTrackAddress(const std::map< int, int > &address)
Set the whole track address.
const int hwQual() const
Get quality code.
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
void setTrackSubAddress(bmtfAddress subAddress, int value)
Set a part of the muon candidates track address; specialised for BMTF.
const int hwHF() const
Get HF (halo / fine eta) bit (EMTF: halo -&gt; 1; BMTF: fine eta -&gt; 1)
void setDataword(uint32_t msbs, uint32_t lsbs)
void setHwHF(bool bit)
Set HF (halo / fine eta) bit (EMTF: halo -&gt; 1; BMTF: fine eta -&gt; 1)
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const int mu
Definition: Constants.h:22
const std::map< int, int > & trackAddress() const
Get the track address (identifies track primitives used for reconstruction)
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
unsigned long long uint64_t
Definition: Time.h:15
static void fillRegionalMuonCand(RegionalMuonCand &, uint32_t, uint32_t, int, tftype)
static uint64_t generate64bitDataWord(const RegionalMuonCand &)
int trackSubAddress(bmtfAddress subAddress) const
Get part of track address (identifies track primitives used for reconstruction)
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))