6 Muon&
mu, uint32_t raw_data_spare, uint32_t raw_data_00_31, uint32_t raw_data_32_63,
int fed,
int fw,
int muInBx) {
33 uint32_t raw_data_00_31,
34 uint32_t raw_data_32_63,
37 mu.setHwCharge((raw_data_32_63 >> chargeShift_) & 0x1);
39 if (
fw < kUgmtFwVersionUntil2016) {
40 fillMuonCoordinates2016(
mu, raw_data_00_31, raw_data_32_63);
41 }
else if (
fw < kUgmtFwVersionUntil2017) {
42 fillMuonCoordinatesFrom2017(
mu, raw_data_00_31, raw_data_32_63);
44 fillIntermediateMuonQuantitiesRun3(
mu, raw_data_00_31, raw_data_32_63);
48 fillMuonStableQuantities(
mu, raw_data_00_31, raw_data_32_63);
52 mu.setHwPt((raw_data_00_31 >> ptShift_) & ptMask_);
53 mu.setHwQual((raw_data_00_31 >> qualShift_) & qualMask_);
54 mu.setHwIso((raw_data_32_63 >> isoShift_) & isoMask_);
56 mu.setHwChargeValid((raw_data_32_63 >> chargeValidShift_) & 0x1);
57 mu.setTfMuonIndex((raw_data_32_63 >> tfMuonIndexShift_) & tfMuonIndexMask_);
58 if (
mu.hwChargeValid()) {
59 mu.setCharge(1 - 2 *
mu.hwCharge());
68 (
mu.hwPt() - 1) * 0.5,
mu.hwEtaAtVtx() * 0.010875,
mu.hwPhiAtVtx() * 0.010908, 0.0};
70 muAtVtx.
setP4(vecAtVtx);
71 mu.setEtaAtVtx(muAtVtx.
eta());
72 mu.setPhiAtVtx(muAtVtx.
phi());
75 mu.setPtUnconstrained(
80 Muon&
mu, uint32_t raw_data_spare,
uint64_t dataword,
int fed,
int fw,
int muInBx) {
82 mu, raw_data_spare, (uint32_t)(dataword & 0xFFFFFFFF), (uint32_t)((dataword >> 32) & 0xFFFFFFFF), fed,
fw, muInBx);
87 mu.setHwEta(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
88 mu.setHwPhi((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
91 mu.setHwEtaAtVtx(
mu.hwEta());
92 mu.setHwPhiAtVtx(
mu.hwPhi());
99 uint32_t raw_data_00_31,
100 uint32_t raw_data_32_63) {
102 mu.setHwEta(calcHwEta(raw_data_32_63, absEtaShift_, etaSignShift_));
103 mu.setHwPhi((raw_data_32_63 >> phiShift_) & phiMask_);
106 mu.setHwEtaAtVtx(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
107 mu.setHwPhiAtVtx((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
109 mu.setHwDEtaExtra(
mu.hwEtaAtVtx() -
mu.hwEta());
110 int dPhi =
mu.hwPhiAtVtx() -
mu.hwPhi();
111 if (
mu.hwCharge() == 1 && dPhi > 0) {
113 }
else if (
mu.hwCharge() == 0 && dPhi < 0) {
116 mu.setHwDPhiExtra(dPhi);
120 uint32_t raw_data_spare,
121 uint32_t raw_data_00_31,
122 uint32_t raw_data_32_63,
124 bool wasSpecialMWGR ) {
125 unsigned absEtaMu1Shift{absEtaMu1Shift_};
126 unsigned etaMu1SignShift{etaMu1SignShift_};
127 unsigned absEtaMu2Shift{absEtaMu2Shift_};
128 unsigned etaMu2SignShift{etaMu2SignShift_};
131 if (wasSpecialMWGR) {
140 mu.setHwEta(calcHwEta(raw_data_spare, absEtaMu1Shift, etaMu1SignShift));
141 }
else if (muInBx == 2) {
142 mu.setHwEta(calcHwEta(raw_data_spare, absEtaMu2Shift, etaMu2SignShift));
144 edm::LogWarning(
"L1T") <<
"Received invalid muon id " << muInBx <<
". Cannot fill eta value in the muon system.";
146 mu.setHwPhi((raw_data_32_63 >> phiShift_) & phiMask_);
149 mu.setHwEtaAtVtx(calcHwEta(raw_data_00_31, absEtaAtVtxShift_, etaAtVtxSignShift_));
150 mu.setHwPhiAtVtx((raw_data_00_31 >> phiAtVtxShift_) & phiMask_);
152 mu.setHwDEtaExtra(
mu.hwEtaAtVtx() -
mu.hwEta());
153 int dPhi =
mu.hwPhiAtVtx() -
mu.hwPhi();
154 if (
mu.hwCharge() == 1 && dPhi > 0) {
156 }
else if (
mu.hwCharge() == 0 && dPhi < 0) {
159 mu.setHwDPhiExtra(dPhi);
162 mu.setHwDXY((raw_data_32_63 >> dxyShift_) & dxyMask_);
163 mu.setHwPtUnconstrained((raw_data_32_63 >> ptUnconstrainedShift_) & ptUnconstrainedMask_);
167 uint32_t raw_data_00_31,
168 uint32_t raw_data_32_63) {
169 fillMuonCoordinatesFrom2017(
mu, raw_data_00_31, raw_data_32_63);
172 mu.setHwDXY((raw_data_32_63 >> dxyShift_) & dxyMask_);
173 mu.setHwPtUnconstrained((raw_data_00_31 >> ptUnconstrainedIntermedidateShift_) & ptUnconstrainedMask_);
177 uint32_t& raw_data_spare,
178 uint32_t& raw_data_00_31,
179 uint32_t& raw_data_32_63,
183 int abs_eta =
mu.hwEta();
185 abs_eta += (1 << (etaSignShift_ - absEtaShift_));
187 int abs_eta_at_vtx =
mu.hwEtaAtVtx();
188 if (abs_eta_at_vtx < 0) {
189 abs_eta_at_vtx += (1 << (etaAtVtxSignShift_ - absEtaAtVtxShift_));
191 if ((fedID == kUgmtFedId && fwID < kUgmtFwVersionUntil2016) ||
192 (fedID == kUgtFedId && fwID < kUgtFwVersionUntil2016)) {
195 raw_data_00_31 = (
mu.hwPt() & ptMask_) << ptShift_ | (
mu.hwQual() & qualMask_) << qualShift_ |
196 (abs_eta & absEtaMask_) << absEtaAtVtxShift_ | (
mu.hwEta() < 0) << etaAtVtxSignShift_ |
197 (
mu.hwPhi() & phiMask_) << phiAtVtxShift_;
198 raw_data_32_63 =
mu.hwCharge() << chargeShift_ |
mu.hwChargeValid() << chargeValidShift_ |
199 (
mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (
mu.hwIso() & isoMask_) << isoShift_;
200 }
else if ((fedID == kUgmtFedId && fwID < kUgmtFwVersionUntil2017) ||
201 (fedID == kUgtFedId && fwID < kUgtFwVersionUntil2017)) {
203 raw_data_00_31 = (
mu.hwPt() & ptMask_) << ptShift_ | (
mu.hwQual() & qualMask_) << qualShift_ |
204 (abs_eta_at_vtx & absEtaMask_) << absEtaAtVtxShift_ | (
mu.hwEtaAtVtx() < 0) << etaAtVtxSignShift_ |
205 (
mu.hwPhiAtVtx() & phiMask_) << phiAtVtxShift_;
207 raw_data_32_63 =
mu.hwCharge() << chargeShift_ |
mu.hwChargeValid() << chargeValidShift_ |
208 (
mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (
mu.hwIso() & isoMask_) << isoShift_ |
209 (abs_eta & absEtaMask_) << absEtaShift_ | (
mu.hwEta() < 0) << etaSignShift_ |
210 (
mu.hwPhi() & phiMask_) << phiShift_;
211 }
else if ((fedID == kUgmtFedId && fwID == kUgmtFwVersionRun3Start) ||
212 (fedID == kUgtFedId &&
213 fwID < kUgtFwVersionUntilRun3Start)) {
214 generatePackedMuonDataWordsRun3(
215 mu, abs_eta, abs_eta_at_vtx, raw_data_spare, raw_data_00_31, raw_data_32_63, muInBx,
true);
217 generatePackedMuonDataWordsRun3(
218 mu, abs_eta, abs_eta_at_vtx, raw_data_spare, raw_data_00_31, raw_data_32_63, muInBx,
false);
224 const int abs_eta_at_vtx,
225 uint32_t& raw_data_spare,
226 uint32_t& raw_data_00_31,
227 uint32_t& raw_data_32_63,
229 const bool wasSpecialMWGR ) {
230 int absEtaShiftRun3{0}, etaSignShiftRun3{0};
232 absEtaShiftRun3 = absEtaMu1Shift_;
233 etaSignShiftRun3 = etaMu1SignShift_;
234 }
else if (muInBx == 2) {
235 absEtaShiftRun3 = absEtaMu2Shift_;
236 etaSignShiftRun3 = etaMu2SignShift_;
240 if (wasSpecialMWGR && (muInBx == 1 || muInBx == 2)) {
245 raw_data_spare = (abs_eta & absEtaMask_) << absEtaShiftRun3 | (
mu.hwEta() < 0) << etaSignShiftRun3;
246 raw_data_00_31 = (
mu.hwPt() & ptMask_) << ptShift_ | (
mu.hwQual() & qualMask_) << qualShift_ |
247 (abs_eta_at_vtx & absEtaMask_) << absEtaAtVtxShift_ | (
mu.hwEtaAtVtx() < 0) << etaAtVtxSignShift_ |
248 (
mu.hwPhiAtVtx() & phiMask_) << phiAtVtxShift_;
249 raw_data_32_63 =
mu.hwCharge() << chargeShift_ |
mu.hwChargeValid() << chargeValidShift_ |
250 (
mu.tfMuonIndex() & tfMuonIndexMask_) << tfMuonIndexShift_ | (
mu.hwIso() & isoMask_) << isoShift_ |
251 (
mu.hwPhi() & phiMask_) << phiShift_ |
252 (
mu.hwPtUnconstrained() & ptUnconstrainedMask_) << ptUnconstrainedShift_ |
253 (
mu.hwDXY() & dxyMask_) << dxyShift_;
257 const Muon&
mu, uint32_t& raw_data_spare,
uint64_t& dataword,
int fedId,
int fwId,
int muInBx) {
261 generatePackedMuonDataWords(
mu, raw_data_spare, lsw, msw,
fedId, fwId, muInBx);
262 dataword = (((
uint64_t)msw) << 32) + lsw;
266 return ((
fedId == kUgmtFedId && fwId >= kUgmtFwVersionFirstWithShowers) ||
267 (
fedId == kUgtFedId && fwId >= kUgtFwVersionFirstWithShowers));
271 if (isFwVersionWithShowers(
fedId, fwId)) {
272 return ((shower_word >> showerShift_) & 1) == 1;
280 std::array<std::array<uint32_t, 4>, 2>
res{};
281 if (isFwVersionWithShowers(
fedId, fwId)) {
285 if ((
fedId == kUgmtFedId && fwId >= kUgmtFwVersionShowersFrom2023_patched) ||
286 (
fedId == kUgtFedId && fwId >= kUgtFwVersionShowersFrom2023)) {
288 ? (1 << showerShift_)
290 }
else if (
fedId == kUgmtFedId && fwId >= kUgmtFwVersionShowersFrom2023) {
292 ? (1 << showerShift_)
299 const unsigned absEtaShift,
300 const unsigned etaSignShift) {
302 int abs_eta = (raw >> absEtaShift) & absEtaMask_;
303 if ((raw >> etaSignShift) & 0x1) {
304 return abs_eta - (1 << (etaSignShift - absEtaShift));
bool isOneTightInTime() const
static constexpr int kUgtFwVersionUntil2016
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 constexpr int kUgtFwVersionUntil2017
static void fillMuon(Muon &mu, uint32_t raw_data_spare, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int fed, int fw, int muInBx)
static std::array< std::array< uint32_t, 4 >, 2 > getPackedShowerDataWords(const MuonShower &shower, int fedId, int fwId)
static int calcHwEta(const uint32_t &raw, unsigned absEtaShift, unsigned etaSignShift)
static constexpr int kUgmtFedId
static void fillIntermediateMuon(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int fw)
static constexpr int kUgmtFwVersionRun3Start
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.
static constexpr int kUgmtFwVersionUntil2016
static constexpr int kUgtFedId
static bool isFwVersionWithShowers(int fedId, int fwId)
bool isOneNominalInTime() const
static bool showerFired(uint32_t shower_word, int fedId, int fwId)
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)
bool isTwoLooseDiffSectorsInTime() const
static void fillMuonCoordinatesFrom2017(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63)
static void fillMuonCoordinates2016(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63)
Log< level::Warning, false > LogWarning
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
static constexpr int kUgtFwVersionUntilRun3Start
static constexpr int kUgmtFwVersionUntil2017
double eta() const final
momentum pseudorapidity