ATLAS Offline Software
Loading...
Searching...
No Matches
RPCMuonPattern.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Class to store and manipulate the information of patterns for RPCPatternMatching algorithm.
6// Pattern structure:
7// m_header: 16 bits, number of trigger sector (0-63)
8// m_BIBM1: 32 bits, unique identifiers for BI and BM1 strips (16 bits each, BI in the higher 16 bits, BM1 in the lower 16 bits)
9// m_BM2BO: 32 bits, unique identifiers for BM2 and BO strips (16 bits each, BM2 in the higher 16 bits, BO in the lower 16 bits)
10// m_coordBIBM1: 32 bits, coordinates for BI and BM1 strips (12 bits each, BI in the higher 12 bits, BM1 in the middle 12 bits)
11// + 8 bits for pt (lower 8 bits)
12// m_coordBM2BO: 32 bits, coordinates for BM2 and BO strips (12 bits each, BM2 in the higher 12 bits, BO in the middle 12 bits)
13// + 8 bits for pt (lower 8 bits)
14// m_infos: 32 bits, additional information (eta bin: higher 5 bits, charge: next 1 bit, eta: next 14 bits, phi: next 9 bits, 3 bits reserved)
15// The decision for such structure, reflect a fragment of the final candidate format the L1Muon Barrel SL will provide.
16
17#ifndef RPCMuonPattern_H
18#define RPCMuonPattern_H
19
20#include "GaudiKernel/MsgStream.h"
21#include <iomanip>
22#include <cstdint>
23#include <map>
24#include <cmath>
25
26namespace L1Muon {
28 public:
29 RPCMuonPattern() = default;
30
31 RPCMuonPattern(const uint16_t header, const uint32_t BIBM1, const uint32_t BM2BO,
32 const uint32_t coordBIBM1, const uint32_t coordBM2BO,
33 const uint32_t infos) :
34 m_header(header), m_BIBM1(BIBM1), m_BM2BO(BM2BO),
35 m_coordBIBM1(coordBIBM1), m_coordBM2BO(coordBM2BO),
36 m_infos(infos) {} ;
37
38 RPCMuonPattern(const uint16_t header,
39 const uint32_t packedBI, const uint32_t packedBM1,
40 const uint32_t packedBM2, const uint32_t packedBO,
41 const uint32_t coordBI, const uint32_t coordBM1,
42 const uint32_t coordBM2, const uint32_t coordBO,
43 const uint32_t pt, const uint32_t packedInfos) :
45 m_BIBM1( (packedBI & m_lower16BitsMask) << m_highestStripShift | (packedBM1 & m_lower16BitsMask) ), // combine BI and BM1 into a single 32-bit value, take the lower 16 bits for both BI and BM1
46 m_BM2BO( (packedBM2 & m_lower16BitsMask) << m_highestStripShift | (packedBO & m_lower16BitsMask) ), // combine BM2 and BO into a single 32-bit value, take the lower 16 bits for both BM2 and BO
47 m_coordBIBM1( (coordBI & m_lower12BitsMask) << m_highestCoordShift | (coordBM1 & m_lower12BitsMask) << m_lowestCoordShift | (pt & m_lower8BitsMask)), // combine coordinates into a single 32-bit value, take the lower 8 bits for each coordinate
48 m_coordBM2BO( (coordBM2 & m_lower12BitsMask) << m_highestCoordShift | (coordBO & m_lower12BitsMask) << m_lowestCoordShift ), // combine coordinates into a single 32-bit value, take the lower 8 bits for each coordinate
49 m_infos(packedInfos) {} ;
50
51 RPCMuonPattern(const RPCMuonPattern& other, const uint32_t newInfos) :
52 m_header(other.m_header), m_BIBM1(other.m_BIBM1), m_BM2BO(other.m_BM2BO),
54 m_infos(newInfos) {} ;
55
56 uint16_t getHeader() const { return m_header; };
57 uint16_t getTriggerSector() const { return m_header; }; // same as getHeader()
58 uint32_t getBIBM1() const { return m_BIBM1; };
59 uint32_t getBM2BO() const { return m_BM2BO; };
60 uint32_t getCoordBIBM1() const { return m_coordBIBM1; };
61 uint32_t getCoordBM2BO() const { return m_coordBM2BO; };
62 uint32_t getInfos() const { return m_infos; };
63 uint32_t getStripBI() const { return m_BIBM1 >> m_highestStripShift; }; // get the BI strip from the packed BI-BM1 information
64 uint32_t getStripBM1() const { return m_BIBM1 & m_lower16BitsMask; }; // get the BM1 strip from the packed BI-BM1 information
65 uint32_t getStripBM2() const { return m_BM2BO >> m_highestStripShift; }; // get the BM2 strip from the packed BM2-BO information
66 uint32_t getStripBO() const { return m_BM2BO & m_lower16BitsMask; }; // get the BO strip from the packed BM2-BO information
67 uint32_t getCoordBI() const { return m_coordBIBM1 >> m_highestCoordShift; }; // get the BI coordinate from the packed coordinates
68 uint32_t getCoordBM1() const { return (m_coordBIBM1 >> m_lowestCoordShift) & m_lower12BitsMask; }; // get the BM1 coordinate from the packed coordinates
69 uint32_t getCoordBM2() const { return m_coordBM2BO >> m_highestCoordShift; }; // get the BM2 coordinate from the packed coordinates
70 uint32_t getCoordBO() const { return (m_coordBM2BO >> m_lowestCoordShift) & m_lower12BitsMask; }; // get the BO coordinate from the packed coordinates
71 uint32_t getPt() const { return m_coordBIBM1 & m_lower8BitsMask; }; // get the pt from the packed coordinates
72 uint32_t getEtaBin() const { return m_infos >> m_etaBinShift; }; // get the eta bin region from the packed infos
73 uint32_t getCharge() const { return (m_infos >> m_chargeShift) & m_lower1BitMask; }; // get the charge from the packed infos
74 uint32_t getEta() const { return (m_infos >> m_etaShift) & m_lower14BitsMask; }; // get the eta from the packed infos
75 uint32_t getPhi() const { return (m_infos >> m_phiShift) & m_lower9BitsMask; }; // get the phi from the packed infos
76
77 float getEtaFloat() const { return static_cast<float>(getEta()) * 5.4f / 16383.0f - 2.7f; }; // convert the eta from 14 bits to float in the range [-2.7, 2.7]
78 float getPhiFloat() const { return static_cast<float>(getPhi()) * (2.0f * static_cast<float>(M_PI)) / 511.0f; }; // convert the phi from 9 bits to float in the range [0, 2pi]
79 float getPtFloat() const { return static_cast<float>(getPt()) * 127.0f / 255.0f; }; // convert the pt from 8 bits to float in the range [0, 127]
80 float getCoordSign() const { return (getEtaFloat() >= 0.0f) ? 1.0f : -1.0f; }; // get the sign of the coordinate based on the eta value
81 float getCoordBIFloat() const { return getCoordSign() * static_cast<float>(getCoordBI()) * 16368.0f / 1023.0f; }; // convert the BI coordinate from 10 bits to float in the range [0, 16368]
82 float getCoordBM1Float() const { return getCoordSign() * static_cast<float>(getCoordBM1()) * 16368.0f / 1023.0f; }; // convert the BM1 coordinate from 10 bits to float in the range [0, 16368]
83 float getCoordBM2Float() const { return getCoordSign() * static_cast<float>(getCoordBM2()) * 16368.0f / 1023.0f; }; // convert the BM2 coordinate from 10 bits to float in the range [0, 16368]
84 float getCoordBOFloat() const { return getCoordSign() * static_cast<float>(getCoordBO()) * 16368.0f / 1023.0f; }; // convert the BO coordinate from 10 bits to float in the range [0, 16368]
85 uint32_t getMaxThreshold() const {
86 static const std::map<int, int> th_map = {{4, 0}, {5, 1}, {6, 2}, {7, 3}, {8, 4}, {9, 5}, {10, 6},
87 {12, 7}, {15, 8}, {18, 9}, {20, 10}, {25, 11}, {30, 12},
88 {40, 13}, {80, 14}, {100, 15}};
89 // upper_bound gives first element > x
90 auto it = th_map.upper_bound(std::round(getPtFloat()));
91 if (it == th_map.begin()) { return -1; }
92 --it;
93 return uint32_t(it->first); // returns threshold value
94 // return it->second; // or ID, if that's what you want
95 };
96
97 int getPriority() const {
98 // BI-BO
101 // BI-BM1-BM2
102 else if (((m_BM2BO & m_lower16BitsMask) == m_nullBOEtaStrip) ||
103 ((m_BM2BO & m_lower16BitsMask) == m_nullBOPhiStrip)) { return 2; }
104 // BM1-BM2-BO
105 else if (((m_BIBM1 >> m_highestStripShift) == m_nullBIEtaStrip) ||
106 ((m_BIBM1 >> m_highestStripShift) == m_nullBIPhiStrip)) { return 3; }
107 // BI-BM1-BO
108 else if (((m_BM2BO >> m_highestStripShift) == m_nullBM2EtaStrip) ||
109 ((m_BM2BO >> m_highestStripShift) == m_nullBM2PhiStrip)) { return 4; }
110 // BI-BM2-BO
111 else if (((m_BIBM1 & m_lower16BitsMask) == m_nullBM1EtaStrip) ||
112 ((m_BIBM1 & m_lower16BitsMask) == m_nullBM1PhiStrip)) { return 5; }
113 else { return 0; } // no valid pattern
114 };
115
116 void print(MsgStream& msg) const {
117 msg << "RPCMuonPattern: header: " << std::hex << m_header
118 << ", BIBM1: " << m_BIBM1
119 << ", BM2BO: " << m_BM2BO
120 << ", coordBIBM1: " << m_coordBIBM1
121 << ", coordBM2BO: " << m_coordBM2BO
122 << ", infos: " << m_infos << std::dec << endmsg;
123 msg << " BI strip: " << getStripBI()
124 << ", BM1 strip: " << getStripBM1()
125 << ", BM2 strip: " << getStripBM2()
126 << ", BO strip: " << getStripBO() << endmsg;
127 };
128
129 private:
130
131 uint16_t m_header{0};
132 uint32_t m_BIBM1{0};
133 uint32_t m_BM2BO{0};
134 uint32_t m_coordBIBM1{0};
135 uint32_t m_coordBM2BO{0};
136 uint32_t m_infos{0};
137
138 // Constants for bit manipulation
140 static constexpr uint32_t m_lower16BitsMask = 0x0000FFFF;
141 static constexpr uint32_t m_lower12BitsMask = 0x00000FFF;
142 static constexpr uint32_t m_lower8BitsMask = 0x000000FF;
143 static constexpr uint32_t m_lower1BitMask = 0x00000001;
144 static constexpr uint32_t m_lower14BitsMask = 0x00003FFF;
145 static constexpr uint32_t m_lower9BitsMask = 0x000001FF;
146
148 static constexpr int m_highestStripShift = 16;
149 static constexpr int m_highestCoordShift = 20;
150 static constexpr int m_lowestCoordShift = 8;
151 static constexpr int m_etaBinShift = 27;
152 static constexpr int m_chargeShift = 26;
153 static constexpr int m_etaShift = 12;
154 static constexpr int m_phiShift = 3;
155
156 // Null values for each station and strip type
157 // These values are used to indicate that a particular station or strip type is not present
158 static constexpr uint16_t m_nullBIEtaStrip = 0x0000;
159 static constexpr uint16_t m_nullBM1EtaStrip = 0x4000;
160 static constexpr uint16_t m_nullBM2EtaStrip = 0x8000;
161 static constexpr uint16_t m_nullBOEtaStrip = 0xc000;
162 static constexpr uint16_t m_nullBIPhiStrip = 0x0001;
163 static constexpr uint16_t m_nullBM1PhiStrip = 0x4001;
164 static constexpr uint16_t m_nullBM2PhiStrip = 0x8001;
165 static constexpr uint16_t m_nullBOPhiStrip = 0xc001;
166
167 };
168} // end of namespace L1Muon
169#endif // RPCMuonPattern_H
#define M_PI
#define endmsg
static constexpr uint16_t m_nullBM2PhiStrip
static constexpr uint32_t m_lower12BitsMask
uint32_t getPhi() const
static constexpr uint16_t m_nullBOPhiStrip
static constexpr int m_chargeShift
static constexpr int m_lowestCoordShift
RPCMuonPattern(const uint16_t header, const uint32_t BIBM1, const uint32_t BM2BO, const uint32_t coordBIBM1, const uint32_t coordBM2BO, const uint32_t infos)
static constexpr int m_highestStripShift
static constexpr int m_etaShift
RPCMuonPattern(const uint16_t header, const uint32_t packedBI, const uint32_t packedBM1, const uint32_t packedBM2, const uint32_t packedBO, const uint32_t coordBI, const uint32_t coordBM1, const uint32_t coordBM2, const uint32_t coordBO, const uint32_t pt, const uint32_t packedInfos)
uint32_t getCoordBM2() const
uint16_t getHeader() const
static constexpr uint16_t m_nullBM2EtaStrip
void print(MsgStream &msg) const
uint16_t getTriggerSector() const
static constexpr uint16_t m_nullBIPhiStrip
float getCoordBM2Float() const
static constexpr uint16_t m_nullBIEtaStrip
RPCMuonPattern(const RPCMuonPattern &other, const uint32_t newInfos)
static constexpr uint32_t m_lower14BitsMask
float getPhiFloat() const
float getCoordSign() const
static constexpr int m_etaBinShift
static constexpr uint16_t m_nullBOEtaStrip
static constexpr uint32_t m_lower1BitMask
uint32_t getCoordBO() const
uint32_t getStripBI() const
float getCoordBOFloat() const
uint32_t getEtaBin() const
static constexpr uint32_t m_lower8BitsMask
uint32_t getBM2BO() const
uint32_t getPt() const
static constexpr uint32_t m_lower9BitsMask
uint32_t getStripBM2() const
uint32_t getCoordBM2BO() const
static constexpr uint16_t m_nullBM1EtaStrip
uint32_t getStripBM1() const
float getCoordBIFloat() const
uint32_t getCoordBI() const
static constexpr uint32_t m_lower16BitsMask
uint32_t getStripBO() const
static constexpr int m_highestCoordShift
float getCoordBM1Float() const
float getEtaFloat() const
uint32_t getCoordBIBM1() const
uint32_t getInfos() const
uint32_t getCharge() const
uint32_t getMaxThreshold() const
uint32_t getEta() const
static constexpr int m_phiShift
uint32_t getCoordBM1() const
static constexpr uint16_t m_nullBM1PhiStrip
uint32_t getBIBM1() const
MsgStream & msg
Definition testRead.cxx:32