CMS 3D CMS Logo

RegionalMuonRawDigiTranslator.cc
Go to the documentation of this file.
3 
4 void
5 l1t::RegionalMuonRawDigiTranslator::fillRegionalMuonCand(RegionalMuonCand& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int proc, tftype tf)
6 {
7  // translations as defined in DN-15-017
8  mu.setHwPt((raw_data_00_31 >> ptShift_) & ptMask_);
9  mu.setHwQual((raw_data_00_31 >> qualShift_) & qualMask_);
10 
11  // eta is coded as two's complement
12  int abs_eta = (raw_data_00_31 >> absEtaShift_) & absEtaMask_;
13  if ((raw_data_00_31 >> etaSignShift_) & 0x1) {
14  mu.setHwEta(abs_eta - (1 << (etaSignShift_ - absEtaShift_)));
15  } else {
16  mu.setHwEta(abs_eta);
17  }
18 
19  // phi is coded as two's complement
20  int abs_phi = (raw_data_00_31 >> absPhiShift_) & absPhiMask_;
21  if ((raw_data_00_31 >> phiSignShift_) & 0x1) {
22  mu.setHwPhi(abs_phi - (1 << (phiSignShift_ - absPhiShift_)));
23  } else {
24  mu.setHwPhi(abs_phi);
25  }
26 
27  // sign is coded as -1^signBit
28  mu.setHwSign((raw_data_32_63 >> signShift_) & 0x1);
29  mu.setHwSignValid((raw_data_32_63 >> signValidShift_) & 0x1);
30  mu.setHwHF((raw_data_00_31 >> hfShift_) & hfMask_);
31 
32  // set track address with subaddresses
33  int rawTrackAddress = (raw_data_32_63 >> trackAddressShift_) & trackAddressMask_;
34  if (tf == bmtf) {
35  int segSel = (rawTrackAddress >> bmtfTrAddrSegSelShift_) & bmtfTrAddrSegSelMask_;
36  int detSide = (rawTrackAddress >> bmtfTrAddrDetSideShift_) & 0x1;
37  int wheelNum = (rawTrackAddress >> bmtfTrAddrWheelShift_) & bmtfTrAddrWheelMask_;
38  int statAddr1 = ((rawTrackAddress >> bmtfTrAddrStat1Shift_) & bmtfTrAddrStat1Mask_)
39  | ((segSel & 0x1) << 2);
40  int statAddr2 = ((rawTrackAddress >> bmtfTrAddrStat2Shift_) & bmtfTrAddrStat2Mask_)
41  | ((segSel & 0x2) << 3);
42  int statAddr3 = ((rawTrackAddress >> bmtfTrAddrStat3Shift_) & bmtfTrAddrStat3Mask_)
43  | ((segSel & 0x4) << 2);
44  int statAddr4 = ((rawTrackAddress >> bmtfTrAddrStat4Shift_) & bmtfTrAddrStat4Mask_)
45  | ((segSel & 0x8) << 1);
56  } else if (tf == emtf_neg || tf == emtf_pos) {
67  } else if (tf == omtf_neg || tf == omtf_pos) {
71  } else {
72  std::map<int, int> trackAddr;
73  trackAddr[0] = rawTrackAddress;
74  mu.setTrackAddress(trackAddr);
75  }
76 
77  mu.setTFIdentifiers(proc, tf);
78  mu.setDataword(raw_data_32_63, raw_data_00_31);
79 }
80 
81 void
83 {
84  fillRegionalMuonCand(mu, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF), proc, tf);
85 }
86 
87 void
88 l1t::RegionalMuonRawDigiTranslator::generatePackedDataWords(const RegionalMuonCand& mu, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63)
89 {
90  int abs_eta = mu.hwEta();
91  if (abs_eta < 0) {
92  abs_eta += (1 << (etaSignShift_ - absEtaShift_));
93  }
94  int abs_phi = mu.hwPhi();
95  if (abs_phi < 0) {
96  abs_phi += (1 << (phiSignShift_ - absPhiShift_));
97  }
98  raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_
99  | (mu.hwQual() & qualMask_) << qualShift_
100  | (abs_eta & absEtaMask_) << absEtaShift_
101  | (mu.hwEta() < 0) << etaSignShift_
102  | (mu.hwHF() & hfMask_) << hfShift_
103  | (abs_phi & absPhiMask_) << absPhiShift_
104  | (mu.hwPhi() < 0) << phiSignShift_;
105 
106  // generate the raw track address from the subaddresses
107  int tf = mu.trackFinderType();
108  int rawTrkAddr = 0;
109  if (tf == bmtf) {
110  // protection against a track address map with the wrong size
111  if (mu.trackAddress().size() == RegionalMuonCand::kNumBmtfSubAddr) {
113  int wheelNum = mu.trackSubAddress(RegionalMuonCand::kWheelNum);
118 
123 
124  rawTrkAddr = (segSel & bmtfTrAddrSegSelMask_) << bmtfTrAddrSegSelShift_
125  | (detSide & 0x1) << bmtfTrAddrDetSideShift_
131  } else {
132  edm::LogWarning("L1T") << "BMTF muon track address map contains " << mu.trackAddress().size() << " instead of the expected " << RegionalMuonCand::kNumBmtfSubAddr << " subaddresses. Check the data format. Setting track address to 0.";
133  rawTrkAddr = 0;
134  }
135  } else if (tf == emtf_neg || tf == emtf_pos) {
136  // protection against a track address map with the wrong size
137  if (mu.trackAddress().size() == RegionalMuonCand::kNumEmtfSubAddr) {
138 
139  rawTrkAddr =
150 
151  } else {
152  edm::LogWarning("L1T") << "EMTF muon track address map contains " << mu.trackAddress().size() << " instead of the expected " << RegionalMuonCand::kNumEmtfSubAddr << " subaddresses. Check the data format. Setting track address to 0.";
153  rawTrkAddr = 0;
154  }
155  } else if (tf == omtf_neg || tf == omtf_pos) {
156  // protection against a track address map with the wrong size
157  if (mu.trackAddress().size() == RegionalMuonCand::kNumOmtfSubAddr) {
158 
159  rawTrkAddr =
162 
163  } else {
164  edm::LogWarning("L1T") << "OMTF muon track address map contains " << mu.trackAddress().size() << " instead of the expected " << RegionalMuonCand::kNumOmtfSubAddr << " subaddresses. Check the data format. Setting track address to 0.";
165  rawTrkAddr = 0;
166  }
167  } else {
168  rawTrkAddr = mu.trackAddress().at(0);
169  }
170 
171  raw_data_32_63 = mu.hwSign() << signShift_
172  | mu.hwSignValid() << signValidShift_
173  | (rawTrkAddr & trackAddressMask_) << trackAddressShift_;
174 }
175 
176 uint64_t
178 {
179  uint32_t lsw;
180  uint32_t msw;
181 
182  generatePackedDataWords(mu, lsw, msw);
183  return (((uint64_t)msw) << 32) + lsw;
184 }
185 
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 -> 1; BMTF: fine eta -> 1)
void setDataword(uint32_t msbs, uint32_t lsbs)
void setHwHF(bool bit)
Set HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 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))