CMS 3D CMS Logo

RegionalMuonRawDigiTranslator.cc
Go to the documentation of this file.
3 
5  RegionalMuonCand& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int proc, tftype tf) {
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  int statAddr2 = ((rawTrackAddress >> bmtfTrAddrStat2Shift_) & bmtfTrAddrStat2Mask_);
39  int statAddr3 = ((rawTrackAddress >> bmtfTrAddrStat3Shift_) & bmtfTrAddrStat3Mask_);
40  int statAddr4 = ((rawTrackAddress >> bmtfTrAddrStat4Shift_) & bmtfTrAddrStat4Mask_);
41 
52  //mu.setTrackSubAddress(RegionalMuonCand::kNumBmtfSubAddr, 0);
53  } else if (tf == emtf_neg || tf == emtf_pos) {
63  (rawTrackAddress >> emtfTrAddrTrkNumShift_) & emtfTrAddrTrkNumMask_);
65  } else if (tf == omtf_neg || tf == omtf_pos) {
67  (rawTrackAddress >> omtfTrAddrLayersShift_) & omtfTrAddrLayersMask_);
70  (rawTrackAddress >> omtfTrAddrWeightShift_) & omtfTrAddrWeightMask_);
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 
82  uint64_t dataword,
83  int proc,
84  tftype tf) {
85  fillRegionalMuonCand(mu, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF), proc, tf);
86 }
87 
89  uint32_t& raw_data_00_31,
90  uint32_t& raw_data_32_63) {
91  int abs_eta = mu.hwEta();
92  if (abs_eta < 0) {
93  abs_eta += (1 << (etaSignShift_ - absEtaShift_));
94  }
95  int abs_phi = mu.hwPhi();
96  if (abs_phi < 0) {
97  abs_phi += (1 << (phiSignShift_ - absPhiShift_));
98  }
99  raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_ | (mu.hwQual() & qualMask_) << qualShift_ |
100  (abs_eta & absEtaMask_) << absEtaShift_ | (mu.hwEta() < 0) << etaSignShift_ |
101  (mu.hwHF() & hfMask_) << hfShift_ | (abs_phi & absPhiMask_) << absPhiShift_ |
102  (mu.hwPhi() < 0) << phiSignShift_;
103 
104  // generate the raw track address from the subaddresses
105  int tf = mu.trackFinderType();
106  int rawTrkAddr = 0;
107  if (tf == bmtf) {
108  // protection against a track address map with the wrong size
109  if (mu.trackAddress().size() == RegionalMuonCand::kNumBmtfSubAddr) {
111  int wheelNum = mu.trackSubAddress(RegionalMuonCand::kWheelNum);
116 
121 
122  rawTrkAddr = (segSel & bmtfTrAddrSegSelMask_) << bmtfTrAddrSegSelShift_ |
123  (detSide & 0x1) << bmtfTrAddrDetSideShift_ |
129  } else {
130  edm::LogWarning("L1T") << "BMTF muon track address map contains " << mu.trackAddress().size()
131  << " instead of the expected " << RegionalMuonCand::kNumBmtfSubAddr
132  << " 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) {
148 
149  } else {
150  edm::LogWarning("L1T") << "EMTF muon track address map contains " << mu.trackAddress().size()
151  << " instead of the expected " << RegionalMuonCand::kNumEmtfSubAddr
152  << " 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) {
160 
161  } else {
162  edm::LogWarning("L1T") << "OMTF muon track address map contains " << mu.trackAddress().size()
163  << " instead of the expected " << RegionalMuonCand::kNumOmtfSubAddr
164  << " 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_ | mu.hwSignValid() << signValidShift_ |
172  (rawTrkAddr & trackAddressMask_) << trackAddressShift_;
173 }
174 
176  uint32_t lsw;
177  uint32_t msw;
178 
179  generatePackedDataWords(mu, lsw, msw);
180  return (((uint64_t)msw) << 32) + lsw;
181 }
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 &)
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 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:13
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))