CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RegionalMuonRawDigiTranslator.cc
Go to the documentation of this file.
3 
5  const uint32_t raw_data_00_31,
6  const uint32_t raw_data_32_63,
7  const int proc,
8  const tftype tf,
9  const bool isKbmtf,
10  const bool useEmtfDisplacementInfo) {
11  // translations as defined in DN-15-017
12  mu.setHwPt((raw_data_00_31 >> ptShift_) & ptMask_);
13  mu.setHwQual((raw_data_00_31 >> qualShift_) & qualMask_);
14 
15  // eta is coded as two's complement
16  int abs_eta = (raw_data_00_31 >> absEtaShift_) & absEtaMask_;
17  if ((raw_data_00_31 >> etaSignShift_) & 0x1) {
18  mu.setHwEta(abs_eta - (1 << (etaSignShift_ - absEtaShift_)));
19  } else {
20  mu.setHwEta(abs_eta);
21  }
22 
23  // phi is coded as two's complement
24  int abs_phi = (raw_data_00_31 >> absPhiShift_) & absPhiMask_;
25  if ((raw_data_00_31 >> phiSignShift_) & 0x1) {
26  mu.setHwPhi(abs_phi - (1 << (phiSignShift_ - absPhiShift_)));
27  } else {
28  mu.setHwPhi(abs_phi);
29  }
30 
31  // sign is coded as -1^signBit
32  mu.setHwSign((raw_data_32_63 >> signShift_) & 0x1);
33  mu.setHwSignValid((raw_data_32_63 >> signValidShift_) & 0x1);
34  mu.setHwHF((raw_data_00_31 >> hfShift_) & hfMask_);
35 
36  // set track address with subaddresses
37  int rawTrackAddress = (raw_data_32_63 >> trackAddressShift_) & trackAddressMask_;
38  if (tf == bmtf) {
39  int detSide = (rawTrackAddress >> bmtfTrAddrDetSideShift_) & 0x1;
40  int wheelNum = (rawTrackAddress >> bmtfTrAddrWheelShift_) & bmtfTrAddrWheelMask_;
41  int statAddr1 = ((rawTrackAddress >> bmtfTrAddrStat1Shift_) & bmtfTrAddrStat1Mask_);
42  int statAddr2 = ((rawTrackAddress >> bmtfTrAddrStat2Shift_) & bmtfTrAddrStat2Mask_);
43  int statAddr3 = ((rawTrackAddress >> bmtfTrAddrStat3Shift_) & bmtfTrAddrStat3Mask_);
44  int statAddr4 = ((rawTrackAddress >> bmtfTrAddrStat4Shift_) & bmtfTrAddrStat4Mask_);
45 
48  if (!isKbmtf) { // The Run-2 standard configuration for BMTF
53  } else {
54  // For Run-3 track address encoding has changed as the Kalman Filter tracks from outside in.
55  // As a result station assignment is inverted
56  // (i.e. the field that contained the station 1 information for Run-2 now contains station 4 information and so on.)
61  // Additionally we now have displacement information from the BMTF
63  mu.setHwDXY((raw_data_32_63 >> bmtfDxyShift_) & dxyMask_);
64  }
69  //mu.setTrackSubAddress(RegionalMuonCand::kNumBmtfSubAddr, 0);
70  } else if (tf == emtf_neg || tf == emtf_pos) {
79  if (useEmtfDisplacementInfo) { // In Run-3 we receive displaced muon information from EMTF
81  mu.setHwDXY((raw_data_32_63 >> emtfDxyShift_) & dxyMask_);
84  } else {
86  (rawTrackAddress >> emtfTrAddrTrkNumShift_) & emtfTrAddrTrkNumMask_);
88  }
89  } else if (tf == omtf_neg || tf == omtf_pos) {
91  (rawTrackAddress >> omtfTrAddrLayersShift_) & omtfTrAddrLayersMask_);
94  (rawTrackAddress >> omtfTrAddrWeightShift_) & omtfTrAddrWeightMask_);
95  } else {
96  std::map<int, int> trackAddr;
97  trackAddr[0] = rawTrackAddress;
98  mu.setTrackAddress(trackAddr);
99  }
100 
101  mu.setTFIdentifiers(proc, tf);
102  mu.setDataword(raw_data_32_63, raw_data_00_31);
103 }
104 
106  const uint64_t dataword,
107  const int proc,
108  const tftype tf,
109  const bool isKbmtf,
110  const bool useEmtfDisplacementInfo) {
111  fillRegionalMuonCand(mu,
112  (uint32_t)(dataword & 0xFFFFFFFF),
113  (uint32_t)((dataword >> 32) & 0xFFFFFFFF),
114  proc,
115  tf,
116  isKbmtf,
117  useEmtfDisplacementInfo);
118 }
119 
121  RegionalMuonShower& muShower, std::vector<uint32_t> bxPayload, int proc, tftype tf, bool useEmtfShowers) {
122  if (useEmtfShowers && (tf == emtf_pos || tf == emtf_neg)) {
123  muShower.setTFIdentifiers(proc, tf);
124 
125  muShower.setOneNominalInTime(((bxPayload[emtfShowerInTimeFrame_] >> emtfShowerOneNominalShift_) & 1) == 1);
126  muShower.setOneNominalOutOfTime(((bxPayload[emtfShowerOOTFrame_] >> emtfShowerOneNominalShift_) & 1) == 1);
127  muShower.setOneTightInTime(((bxPayload[emtfShowerInTimeFrame_] >> emtfShowerOneTightShift_) & 1) == 1);
128  muShower.setOneTightOutOfTime(((bxPayload[emtfShowerOOTFrame_] >> emtfShowerOneTightShift_) & 1) == 1);
129 
130  return muShower.isValid();
131  } else {
132  return false;
133  }
134 }
135 
137  std::array<uint32_t, 6>& payload,
138  const bool useEmtfShowers) {
139  if (!useEmtfShowers || !shower.isValid()) {
140  return;
141  }
142  // First we check whether we're going to overwrite something in the payload.
143  if ((((payload.at(emtfShowerInTimeFrame_) >> emtfShowerOneNominalShift_) & emtfShowerMask_) != 0) ||
144  (((payload.at(emtfShowerInTimeFrame_) >> emtfShowerOneTightShift_) & emtfShowerMask_) != 0) ||
145  (((payload.at(emtfShowerOOTFrame_) >> emtfShowerOneNominalShift_) & emtfShowerMask_) != 0) ||
146  (((payload.at(emtfShowerOOTFrame_) >> emtfShowerOneTightShift_) & emtfShowerMask_) != 0)) {
147  edm::LogError("L1T") << "Check constants for RegionalMuonShower fields! It looks like we're in danger of "
148  "overwriting muon data in the packer! InTimeFrame is "
149  << payload.at(emtfShowerInTimeFrame_) << ", OOTFrame is " << payload.at(emtfShowerOOTFrame_);
150  return;
151  }
152  payload.at(emtfShowerInTimeFrame_) |= (shower.isOneNominalInTime() & 1) << emtfShowerOneNominalShift_ |
153  (shower.isOneTightInTime() & 1) << emtfShowerOneTightShift_;
154  payload.at(emtfShowerOOTFrame_) |= (shower.isOneNominalOutOfTime() & 1) << emtfShowerOneNominalShift_ |
155  (shower.isOneTightOutOfTime() & 1) << emtfShowerOneTightShift_;
156 }
157 
159  uint32_t& raw_data_00_31,
160  uint32_t& raw_data_32_63,
161  const bool isKbmtf,
162  const bool useEmtfDisplacementInfo) {
163  int abs_eta = mu.hwEta();
164  if (abs_eta < 0) {
165  abs_eta += (1 << (etaSignShift_ - absEtaShift_));
166  }
167  int abs_phi = mu.hwPhi();
168  if (abs_phi < 0) {
169  abs_phi += (1 << (phiSignShift_ - absPhiShift_));
170  }
171  raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_ | (mu.hwQual() & qualMask_) << qualShift_ |
172  (abs_eta & absEtaMask_) << absEtaShift_ | (mu.hwEta() < 0) << etaSignShift_ |
173  (mu.hwHF() & hfMask_) << hfShift_ | (abs_phi & absPhiMask_) << absPhiShift_ |
174  (mu.hwPhi() < 0) << phiSignShift_;
175 
176  // generate the raw track address from the subaddresses
177  int rawTrkAddr = generateRawTrkAddress(mu, isKbmtf);
178 
179  raw_data_32_63 = mu.hwSign() << signShift_ | mu.hwSignValid() << signValidShift_ |
180  (rawTrkAddr & trackAddressMask_) << trackAddressShift_;
181  if (isKbmtf && mu.trackFinderType() == bmtf) {
182  raw_data_32_63 |= (mu.hwPtUnconstrained() & ptUnconstrainedMask_) << bmtfPtUnconstrainedShift_ |
183  (mu.hwDXY() & dxyMask_) << bmtfDxyShift_;
184  } else if (useEmtfDisplacementInfo && (mu.trackFinderType() == emtf_pos || mu.trackFinderType() == emtf_neg)) {
185  raw_data_32_63 |= (mu.hwPtUnconstrained() & ptUnconstrainedMask_) << emtfPtUnconstrainedShift_ |
186  (mu.hwDXY() & dxyMask_) << emtfDxyShift_;
187  }
188 }
189 
191  const bool isKbmtf,
192  const bool useEmtfDisplacementInfo) {
193  uint32_t lsw;
194  uint32_t msw;
195 
196  generatePackedDataWords(mu, lsw, msw, isKbmtf, useEmtfDisplacementInfo);
197  return (((uint64_t)msw) << 32) + lsw;
198 }
199 
201  int tf = mu.trackFinderType();
202  int rawTrkAddr = 0;
203  if (tf == bmtf) {
204  // protection against a track address map with the wrong size
205  if (mu.trackAddress().size() == RegionalMuonCand::kNumBmtfSubAddr) {
207  int wheelNum = mu.trackSubAddress(RegionalMuonCand::kWheelNum);
212  if (isKalman) {
217  }
218 
219  rawTrkAddr = (detSide & 0x1) << bmtfTrAddrDetSideShift_ |
220  (wheelNum & bmtfTrAddrWheelMask_) << bmtfTrAddrWheelShift_ |
221  (stat1 & bmtfTrAddrStat1Mask_) << bmtfTrAddrStat1Shift_ |
222  (stat2 & bmtfTrAddrStat2Mask_) << bmtfTrAddrStat2Shift_ |
223  (stat3 & bmtfTrAddrStat3Mask_) << bmtfTrAddrStat3Shift_ |
224  (stat4 & bmtfTrAddrStat4Mask_) << bmtfTrAddrStat4Shift_;
225  } else {
226  edm::LogWarning("L1T") << "BMTF muon track address map contains " << mu.trackAddress().size()
227  << " instead of the expected " << RegionalMuonCand::kNumBmtfSubAddr
228  << " subaddresses. Check the data format. Setting track address to 0.";
229  rawTrkAddr = 0;
230  }
231  } else if (tf == emtf_neg || tf == emtf_pos) {
232  // protection against a track address map with the wrong size
233  if (mu.trackAddress().size() == RegionalMuonCand::kNumEmtfSubAddr) {
234  rawTrkAddr = (mu.trackSubAddress(RegionalMuonCand::kME1Seg) & 0x1) << emtfTrAddrMe1SegShift_ |
235  (mu.trackSubAddress(RegionalMuonCand::kME1Ch) & emtfTrAddrMe1ChMask_) << emtfTrAddrMe1ChShift_ |
236  (mu.trackSubAddress(RegionalMuonCand::kME2Seg) & 0x1) << emtfTrAddrMe2SegShift_ |
237  (mu.trackSubAddress(RegionalMuonCand::kME2Ch) & emtfTrAddrMe2ChMask_) << emtfTrAddrMe2ChShift_ |
238  (mu.trackSubAddress(RegionalMuonCand::kME3Seg) & 0x1) << emtfTrAddrMe3SegShift_ |
239  (mu.trackSubAddress(RegionalMuonCand::kME3Ch) & emtfTrAddrMe3ChMask_) << emtfTrAddrMe3ChShift_ |
240  (mu.trackSubAddress(RegionalMuonCand::kME4Seg) & 0x1) << emtfTrAddrMe4SegShift_ |
241  (mu.trackSubAddress(RegionalMuonCand::kME4Ch) & emtfTrAddrMe4ChMask_) << emtfTrAddrMe4ChShift_;
242 
243  } else {
244  edm::LogWarning("L1T") << "EMTF muon track address map contains " << mu.trackAddress().size()
245  << " instead of the expected " << RegionalMuonCand::kNumEmtfSubAddr
246  << " subaddresses. Check the data format. Setting track address to 0.";
247  rawTrkAddr = 0;
248  }
249  } else if (tf == omtf_neg || tf == omtf_pos) {
250  // protection against a track address map with the wrong size
251  if (mu.trackAddress().size() == RegionalMuonCand::kNumOmtfSubAddr) {
252  rawTrkAddr = (mu.trackSubAddress(RegionalMuonCand::kLayers) & omtfTrAddrLayersMask_) << omtfTrAddrLayersShift_ |
253  (mu.trackSubAddress(RegionalMuonCand::kWeight) & omtfTrAddrWeightMask_) << omtfTrAddrWeightShift_;
254 
255  } else {
256  edm::LogWarning("L1T") << "OMTF muon track address map contains " << mu.trackAddress().size()
257  << " instead of the expected " << RegionalMuonCand::kNumOmtfSubAddr
258  << " subaddresses. Check the data format. Setting track address to 0.";
259  rawTrkAddr = 0;
260  }
261  } else {
262  rawTrkAddr = mu.trackAddress().at(0);
263  }
264 
265  return rawTrkAddr;
266 }
void setOneTightInTime(const bool bit)
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)
const int hwDXY() const
Get compressed impact parameter (4 bits)
void setOneTightOutOfTime(const bool bit)
static void generatePackedShowerPayload(const RegionalMuonShower &shower, std::array< uint32_t, 6 > &payload, bool useEmtfShowers)
bool isOneTightOutOfTime() const
Log< level::Error, false > LogError
bool isOneNominalInTime() const
void setTrackAddress(const std::map< int, int > &address)
Set the whole track address.
const int hwQual() const
Get quality code.
static void generatePackedDataWords(const RegionalMuonCand &mu, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63, bool isKbmtf, bool useEmtfDisplacementInfo)
bool isOneNominalOutOfTime() const
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)
void setHwDXY(int bits)
Set compressed impact parameter with respect to beamspot (4 bits)
void setOneNominalInTime(const bool bit)
unsigned long long uint64_t
Definition: Time.h:13
static int generateRawTrkAddress(const RegionalMuonCand &, bool isKalman)
static bool fillRegionalMuonShower(RegionalMuonShower &muShower, std::vector< uint32_t > bxPayload, int proc, tftype tf, bool useEmtfShowers)
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
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)
static uint64_t generate64bitDataWord(const RegionalMuonCand &mu, bool isKbmtf, bool useEmtfDisplacementInfo)
Log< level::Warning, false > LogWarning
static void fillRegionalMuonCand(RegionalMuonCand &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int proc, tftype tf, bool isKbmtf, bool useEmtfDisplacementInfo)
void setOneNominalOutOfTime(const bool bit)
void setHwPtUnconstrained(int bits)
Set compressed second displaced pT as transmitted by hardware LSB = 1.0 (8 bits)
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
const int hwPtUnconstrained() const
Get second compressed pT (returned int * 1.0 = pT (GeV))