6 uint32_t raw_data_spare,
7 uint32_t raw_data_00_31,
8 uint32_t raw_data_32_63,
21 if ((fed == 1402 &&
fw < 0x4010000) || (fed == 1404 &&
fw < 0x10A6)) {
23 }
else if ((fed == 1402 &&
fw < 0x6000000) || (fed == 1404 &&
fw < 0x1120)) {
25 }
else if ((fed == 1402 &&
fw == 0x6000001) || (fed == 1404 &&
fw < 0x1130)) {
37 uint32_t raw_data_00_31,
38 uint32_t raw_data_32_63,
41 mu.setHwCharge((raw_data_32_63 >> chargeShift_) & 0
x1);
44 fillMuonCoordinates2016(
mu, raw_data_00_31, raw_data_32_63);
45 }
else if (
fw < 0x6000000) {
46 fillMuonCoordinatesFrom2017(
mu, raw_data_00_31, raw_data_32_63);
48 fillIntermediateMuonQuantitiesRun3(
mu, raw_data_00_31, raw_data_32_63);
52 fillMuonStableQuantities(
mu, raw_data_00_31, raw_data_32_63);
56 mu.setHwPt((raw_data_00_31 >> ptShift_) & ptMask_);
57 mu.setHwQual((raw_data_00_31 >> qualShift_) & qualMask_);
58 mu.setHwIso((raw_data_32_63 >> isoShift_) & isoMask_);
60 mu.setHwChargeValid((raw_data_32_63 >> chargeValidShift_) & 0
x1);
61 mu.setTfMuonIndex((raw_data_32_63 >> tfMuonIndexShift_) & tfMuonIndexMask_);
62 if (
mu.hwChargeValid()) {
63 mu.setCharge(1 - 2 *
mu.hwCharge());
72 (
mu.hwPt() - 1) * 0.5,
mu.hwEtaAtVtx() * 0.010875,
mu.hwPhiAtVtx() * 0.010908, 0.0};
74 muAtVtx.
setP4(vecAtVtx);
75 mu.setEtaAtVtx(muAtVtx.
eta());
76 mu.setPhiAtVtx(muAtVtx.
phi());
78 int hwPtUnconstrained{
mu.hwPtUnconstrained()};
79 mu.setPtUnconstrained(
80 hwPtUnconstrained == 0 ? 0 : (hwPtUnconstrained - 1));
84 Muon&
mu, uint32_t raw_data_spare,
uint64_t dataword,
int fed,
unsigned int fw,
int muInBx) {
86 mu, raw_data_spare, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF), fed,
fw, muInBx);
91 mu.setHwEta(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
92 mu.setHwPhi((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
95 mu.setHwEtaAtVtx(
mu.hwEta());
96 mu.setHwPhiAtVtx(
mu.hwPhi());
103 uint32_t raw_data_00_31,
104 uint32_t raw_data_32_63) {
106 mu.setHwEta(calcHwEta(raw_data_32_63, absEtaShift_, etaSignShift_));
107 mu.setHwPhi((raw_data_32_63 >> phiShift_) & phiMask_);
110 mu.setHwEtaAtVtx(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
111 mu.setHwPhiAtVtx((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
113 mu.setHwDEtaExtra(
mu.hwEtaAtVtx() -
mu.hwEta());
114 int dPhi =
mu.hwPhiAtVtx() -
mu.hwPhi();
115 if (
mu.hwCharge() == 1 &&
dPhi > 0) {
117 }
else if (
mu.hwCharge() == 0 &&
dPhi < 0) {
124 uint32_t raw_data_spare,
125 uint32_t raw_data_00_31,
126 uint32_t raw_data_32_63,
128 bool wasSpecialMWGR ) {
129 unsigned absEtaMu1Shift{absEtaMu1Shift_};
130 unsigned etaMu1SignShift{etaMu1SignShift_};
131 unsigned absEtaMu2Shift{absEtaMu2Shift_};
132 unsigned etaMu2SignShift{etaMu2SignShift_};
135 if (wasSpecialMWGR) {
144 mu.setHwEta(calcHwEta(raw_data_spare, absEtaMu1Shift, etaMu1SignShift));
145 }
else if (muInBx == 2) {
146 mu.setHwEta(calcHwEta(raw_data_spare, absEtaMu2Shift, etaMu2SignShift));
148 edm::LogWarning(
"L1T") <<
"Received invalid muon id " << muInBx <<
". Cannot fill eta value in the muon system.";
150 mu.setHwPhi((raw_data_32_63 >> phiShift_) & phiMask_);
153 mu.setHwEtaAtVtx(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
154 mu.setHwPhiAtVtx((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
156 mu.setHwDEtaExtra(
mu.hwEtaAtVtx() -
mu.hwEta());
157 int dPhi =
mu.hwPhiAtVtx() -
mu.hwPhi();
158 if (
mu.hwCharge() == 1 &&
dPhi > 0) {
160 }
else if (
mu.hwCharge() == 0 &&
dPhi < 0) {
166 mu.setHwDXY((raw_data_32_63 >> dxyShift_) & dxyMask_);
167 mu.setHwPtUnconstrained((raw_data_32_63 >> ptUnconstrainedShift_) & ptUnconstrainedMask_);
171 uint32_t raw_data_00_31,
172 uint32_t raw_data_32_63) {
173 fillMuonCoordinatesFrom2017(
mu, raw_data_00_31, raw_data_32_63);
176 mu.setHwDXY((raw_data_32_63 >> dxyShift_) & dxyMask_);
177 mu.setHwPtUnconstrained((raw_data_00_31 >> ptUnconstrainedIntermedidateShift_) & ptUnconstrainedMask_);
181 uint32_t& raw_data_spare,
182 uint32_t& raw_data_00_31,
183 uint32_t& raw_data_32_63,
187 int abs_eta =
mu.hwEta();
189 abs_eta += (1 << (etaSignShift_ - absEtaShift_));
191 int abs_eta_at_vtx =
mu.hwEtaAtVtx();
192 if (abs_eta_at_vtx < 0) {
193 abs_eta_at_vtx += (1 << (etaAtVtxSignShift_ - absEtaAtVtxShift_));
195 if ((fedID == 1402 && fwID < 0x4010000) || (fedID == 1404 && fwID < 0x10A6)) {
198 raw_data_00_31 = (
mu.hwPt() & ptMask_) << ptShift_ | (
mu.hwQual() & qualMask_) << qualShift_ |
199 (abs_eta & absEtaMask_) << absEtaAtVtxShift_ | (
mu.hwEta() < 0) << etaAtVtxSignShift_ |
200 (
mu.hwPhi() & phiMask_) << phiAtVtxShift_;
201 raw_data_32_63 =
mu.hwCharge() << chargeShift_ |
mu.hwChargeValid() << chargeValidShift_ |
202 (
mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (
mu.hwIso() & isoMask_) << isoShift_;
203 }
else if ((fedID == 1402 && fwID < 0x6000000) || (fedID == 1404 && fwID < 0x1120)) {
205 raw_data_00_31 = (
mu.hwPt() & ptMask_) << ptShift_ | (
mu.hwQual() & qualMask_) << qualShift_ |
206 (abs_eta_at_vtx & absEtaMask_) << absEtaAtVtxShift_ | (
mu.hwEtaAtVtx() < 0) << etaAtVtxSignShift_ |
207 (
mu.hwPhiAtVtx() & phiMask_) << phiAtVtxShift_;
209 raw_data_32_63 =
mu.hwCharge() << chargeShift_ |
mu.hwChargeValid() << chargeValidShift_ |
210 (
mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (
mu.hwIso() & isoMask_) << isoShift_ |
211 (abs_eta & absEtaMask_) << absEtaShift_ | (
mu.hwEta() < 0) << etaSignShift_ |
212 (
mu.hwPhi() & phiMask_) << phiShift_;
213 }
else if ((fedID == 1402 && fwID == 0x6000001) ||
214 (fedID == 1404 && fwID < 0x1130)) {
215 generatePackedMuonDataWordsRun3(
216 mu, abs_eta, abs_eta_at_vtx, raw_data_spare, raw_data_00_31, raw_data_32_63, muInBx,
true);
218 generatePackedMuonDataWordsRun3(
219 mu, abs_eta, abs_eta_at_vtx, raw_data_spare, raw_data_00_31, raw_data_32_63, muInBx,
false);
225 const int abs_eta_at_vtx,
226 uint32_t& raw_data_spare,
227 uint32_t& raw_data_00_31,
228 uint32_t& raw_data_32_63,
230 const bool wasSpecialMWGR ) {
231 int absEtaShiftRun3{0}, etaSignShiftRun3{0};
233 absEtaShiftRun3 = absEtaMu1Shift_;
234 etaSignShiftRun3 = etaMu1SignShift_;
235 }
else if (muInBx == 2) {
236 absEtaShiftRun3 = absEtaMu2Shift_;
237 etaSignShiftRun3 = etaMu2SignShift_;
241 if (wasSpecialMWGR && (muInBx == 1 || muInBx == 2)) {
246 raw_data_spare = (abs_eta & absEtaMask_) << absEtaShiftRun3 | (
mu.hwEta() < 0) << etaSignShiftRun3;
247 raw_data_00_31 = (
mu.hwPt() & ptMask_) << ptShift_ | (
mu.hwQual() & qualMask_) << qualShift_ |
248 (abs_eta_at_vtx & absEtaMask_) << absEtaAtVtxShift_ | (
mu.hwEtaAtVtx() < 0) << etaAtVtxSignShift_ |
249 (
mu.hwPhiAtVtx() & phiMask_) << phiAtVtxShift_;
250 raw_data_32_63 =
mu.hwCharge() << chargeShift_ |
mu.hwChargeValid() << chargeValidShift_ |
251 (
mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (
mu.hwIso() & isoMask_) << isoShift_ |
252 (
mu.hwPhi() & phiMask_) << phiShift_ |
253 (
mu.hwPtUnconstrained() & ptUnconstrainedMask_) << ptUnconstrainedShift_ |
254 (
mu.hwDXY() & dxyMask_) << dxyShift_;
258 const Muon&
mu, uint32_t& raw_data_spare,
uint64_t& dataword,
int fedId,
int fwId,
int muInBx) {
262 generatePackedMuonDataWords(
mu, raw_data_spare, lsw, msw,
fedId, fwId, muInBx);
263 dataword = (((
uint64_t)msw) << 32) + lsw;
267 if ((
fedId == 1402 && fwId >= 0x7000000) || (
fedId == 1404 && fwId >= 0x00010f01)) {
268 return ((shower_word >> showerShift_) & 1) == 1;
275 const unsigned int fwId) {
276 std::array<uint32_t, 4>
res{};
277 if ((
fedId == 1402 && fwId >= 0x7000000) || (
fedId == 1404 && fwId >= 0x00010f01)) {
285 const unsigned absEtaShift,
286 const unsigned etaSignShift) {
288 int abs_eta = (raw >> absEtaShift) & absEtaMask_;
289 if ((raw >> etaSignShift) & 0x1) {
290 return abs_eta - (1 << (etaSignShift - absEtaShift));
bool isOneTightInTime() const
static std::array< uint32_t, 4 > getPackedShowerDataWords(const MuonShower &shower, int fedId, unsigned int fwId)
static void fillMuonQuantitiesRun3(Muon &mu, uint32_t raw_data_spare, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int muInBx, bool wasSpecialMWGR=false)
static int calcHwEta(const uint32_t &raw, unsigned absEtaShift, unsigned etaSignShift)
static void fillIntermediateMuon(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, unsigned int fw)
static void fillIntermediateMuonQuantitiesRun3(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
bool isOneNominalInTime() const
static constexpr unsigned chargeShift_
static void fillMuonStableQuantities(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63)
static void generatePackedMuonDataWords(const Muon &mu, uint32_t &raw_data_spare, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63, int fedId, int fwId, int muInBx)
unsigned long long uint64_t
static void generate64bitDataWord(const Muon &mu, uint32_t &raw_data_spare, uint64_t &dataword, int fedId, int fwId, int muInBx)
static void fillMuonCoordinatesFrom2017(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63)
static void fillMuon(Muon &mu, uint32_t raw_data_spare, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int fed, unsigned int fw, int muInBx)
static void fillMuonCoordinates2016(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63)
Log< level::Warning, false > LogWarning
static bool showerFired(uint32_t shower_word, int fedId, unsigned int fwId)
static void generatePackedMuonDataWordsRun3(const Muon &mu, int abs_eta, int abs_eta_at_vtx, uint32_t &raw_data_spare, uint32_t &raw_data_00_31, uint32_t &raw_data_32_63, int muInBx, bool wasSpecialMWGR=false)
double phi() const final
momentum azimuthal angle
void setP4(const LorentzVector &p4) final
set 4-momentum
double eta() const final
momentum pseudorapidity