ATLAS Offline Software
Loading...
Searching...
No Matches
L1Muon::RPCPatternUtils Namespace Reference

Typedefs

using RdoPairs = std::array<const xAOD::NRPCRDO*, 2>

Functions

uint32_t getSLStripId (bool side, int sector, int doubletPhi, Muon::MuonStationIndex::StIndex RPClayer, int doubletR, int stationEta, int doubletZ, int stripNumber, bool measuresPhi)
int getVirtualBIPhiStripNumber (float loc_pos_along_BIstrip, const MuonGMR4::RpcReadoutElement &readoutElement)
uint32_t getVirtualBIPhiStripCoordinate (const Amg::Vector3D &stripPos, float loc_pos_along_BIstrip)
uint32_t getBMBOPhiStripCoordinate (const Amg::Vector3D &stripPos)
void getStripIdforAlg (const RdoPairs &rdo_pair, std::vector< uint32_t > &stripIDs, std::map< uint32_t, uint32_t > &strip_coordinates, std::map< uint32_t, uint32_t > &strip_etabin, const Muon::RpcCablingData &cabling, const Identifier &offId, const ActsTrk::GeometryContext &geoCtx, const Muon::IMuonIdHelperSvc *idHelperSvc, const MuonGMR4::MuonDetectorManager *detMgr)

Variables

constexpr double s_digitalBiPhiStripWidth = 150.0
constexpr double s_propagationVelocity = 2./3. * Gaudi::Units::c_light

Typedef Documentation

◆ RdoPairs

Definition at line 35 of file RPCPatternUtils.h.

Function Documentation

◆ getBMBOPhiStripCoordinate()

uint32_t L1Muon::RPCPatternUtils::getBMBOPhiStripCoordinate ( const Amg::Vector3D & stripPos)

Definition at line 56 of file RPCPatternUtils.cxx.

56 {
57 // Just trigonometry to get the phi coordinate
58 float phi = stripPos.phi() + M_PI; // convert to [0, 2*pi] range
59 float normPhi = std::clamp(phi / (2.0f * static_cast<float>(M_PI)), 0.0f, 1.0f);
60 uint32_t phi_discrete = static_cast<uint32_t>(std::round(normPhi * 511.0f));
61 return phi_discrete;
62}
#define M_PI
Scalar phi() const
phi method

◆ getSLStripId()

uint32_t L1Muon::RPCPatternUtils::getSLStripId ( bool side,
int sector,
int doubletPhi,
Muon::MuonStationIndex::StIndex RPClayer,
int doubletR,
int stationEta,
int doubletZ,
int stripNumber,
bool measuresPhi )

Definition at line 13 of file RPCPatternUtils.cxx.

13 {
14 return L1Muon::RPCSLStripConverter::pack( side, static_cast<uint8_t>(sector-1), doubletPhi-1,
15 RPClayer, static_cast<uint8_t>(doubletR-1),
16 static_cast<uint8_t>(std::abs(stationEta)),
17 static_cast<uint8_t>(doubletZ-1),
18 static_cast<uint8_t>(stripNumber-1), measuresPhi);
19}
static uint32_t pack(bool side, uint8_t sector, bool doubletPhi, Muon::MuonStationIndex::StIndex station, uint8_t doubletR, uint8_t chamber, uint8_t doubletZ, uint8_t strip, bool measuresPhi)

◆ getStripIdforAlg()

void L1Muon::RPCPatternUtils::getStripIdforAlg ( const RdoPairs & rdo_pair,
std::vector< uint32_t > & stripIDs,
std::map< uint32_t, uint32_t > & strip_coordinates,
std::map< uint32_t, uint32_t > & strip_etabin,
const Muon::RpcCablingData & cabling,
const Identifier & offId,
const ActsTrk::GeometryContext & geoCtx,
const Muon::IMuonIdHelperSvc * idHelperSvc,
const MuonGMR4::MuonDetectorManager * detMgr )

Definition at line 64 of file RPCPatternUtils.cxx.

67 {
68
69 // This function should convert the Identifier to the strip ID used in the algorithm
70 // The exact implementation depends on how the strip ID is defined
71
72 // Get the RPC station information from the cabling map
73 Muon::MuonStationIndex::StIndex RPClayer = idHelperSvc->stationIndex(offId); // RPC[0-3] --> 0:BI, 1:BM, 2:BO, 3:BE
74 int stationEta = cabling.eta; // offline chamber eta index, can be negative or positive
75 int sector = idHelperSvc->sector(offId); // offline sector index [1-16] --> we want [0-15]
76 bool side = stationEta > 0; // side = 1 for positive eta, 0 for negative eta
77 int doubletPhi = cabling.doubletPhi; // it identifies the half-sector within the sector! [1-2] --> we want [0-1]
78 int doubletR = cabling.doubletR; // distinguishes BM1 and BM2 [1-2] --> we want [0-1]
79 int doubletZ = cabling.doubletZ; // group the strips in the Z direction [1-2] --> we want [0-1]
80 bool measuresPhi = cabling.measuresPhi(); // true for phi strips, false for eta strips
81 int stripId = cabling.strip;
82
83 const MuonGMR4::RpcReadoutElement* readOutEle = detMgr->getRpcReadoutElement(offId);
84
85 // Get global position
86 Amg::Vector3D stripPos = readOutEle->stripPosition(geoCtx, offId); // in global coordinates
87
88
89 // get Z coordinate referred to R = center of the chamber (as in agreement with MDTTP)
90 Acts::Transform3 g2l = readOutEle->globalToLocalTransform(geoCtx);
91 Amg::Vector3D localStripPos = g2l * stripPos;
92 localStripPos.z() = 0.0;
93 const Acts::Transform3& l2g = readOutEle->localToGlobalTransform(geoCtx);
94 Amg::Vector3D centerPlaneGlobalPos = l2g * localStripPos;
95 double z_at_center_plane = std::abs(centerPlaneGlobalPos.z());
96 // Pack the Z coordinate into 12 bits [first 2 empty bits, then 10 bits for the range [0, 16368] mm
97 // mapped to [0, 1023] (10 bits)]
98 z_at_center_plane = std::clamp(z_at_center_plane / 16368.0, 0.0, 1.0);
99 uint32_t z_discrete = static_cast<uint32_t>(std::round(z_at_center_plane * 1023.0f));
100
101 if (!measuresPhi) {
102 if (stripId == static_cast<int>(0xFFFFFFFF)) { return; } //
103 uint32_t etaStripID = getSLStripId(side, sector, doubletPhi, RPClayer, doubletR, stationEta, doubletZ, stripId, measuresPhi);
104
105 stripIDs.push_back(etaStripID);
106 float eta = stripPos.eta();
107 uint32_t etaBin_discrete = std::min(static_cast<uint32_t>(std::round( std::abs(eta) / 0.05f)), 22u); // eta bin in the range [-1.05, 1.05] with a step of 0.05
108 strip_etabin[etaStripID] = etaBin_discrete; // pack the eta coordinate in the range [-1.05, 1.05] into 8 bits
109 strip_coordinates[etaStripID] = z_discrete; // pack the z coordinate in the range [0, 16368] mm into 10 bits(+highest 2 bits empty)
110
111 if (RPClayer == Muon::MuonStationIndex::StIndex::BI || (RPClayer == Muon::MuonStationIndex::StIndex::BO && doubletR == 1 && (sector == 11 || sector == 15))) {
112 // if the strip is in the BI-BOR/BOM layer, we do not need to check for the phi strip
113 // We create artificial phi strip for BI layer!
114 int phiStrip = 0; // default value, will be calculated below
115 uint32_t phi_discrete = 0; // default value, will be calculated below
116
117 //TODO: check TOF use when we have just one RDO in the pair
118 //. or set the phi strip to the center of the chamber if we have just one RDO in the pair
119 if (rdo_pair[0] && rdo_pair[1]) {
120 // determine the local position along the BI strip using the time difference between the two RDOs
121 float loc_pos_along_BIstrip = 0.5*s_propagationVelocity*(rdo_pair[0]->time() - rdo_pair[1]->time());
122 phiStrip = getVirtualBIPhiStripNumber(loc_pos_along_BIstrip, *readOutEle);
123 phi_discrete = getVirtualBIPhiStripCoordinate(stripPos, loc_pos_along_BIstrip);
124 } else if (rdo_pair[0]) {
125 // if only the first RDO is present, we can estimate the local position along the BI strip using its time and the known half-length of the strip
126 float loc_pos_along_BIstrip = 0; //(-readOutEle->getParameters().halfWidth + s_propagationVelocity * (rdo_pair[0]->time() - TOF)); // use the time of flight to estimate the local position along the strip);
127 phiStrip = getVirtualBIPhiStripNumber(loc_pos_along_BIstrip, *readOutEle);
128 phi_discrete = getVirtualBIPhiStripCoordinate(stripPos, loc_pos_along_BIstrip);
129 } else if (rdo_pair[1]) {
130 // same as above but using the second RDO in the pair
131 float loc_pos_along_BIstrip = 0; // (readOutEle->getParameters().halfWidth - s_propagationVelocity *(rdo_pair[1]->time() - TOF)); // use the time of flight to estimate the local position along the strip);
132 phiStrip = getVirtualBIPhiStripNumber(loc_pos_along_BIstrip, *readOutEle);
133 phi_discrete = getVirtualBIPhiStripCoordinate(stripPos, loc_pos_along_BIstrip);
134 }
135
136 uint32_t phiStripID = getSLStripId(side, sector, doubletPhi, RPClayer, doubletR, stationEta, doubletZ, phiStrip, true);
137 stripIDs.push_back(phiStripID);
138 strip_coordinates[phiStripID] = phi_discrete;
139
140 // doubling the eta strip so that both instances of the trigger algo can see it.
141 // Since all BI have doubletPhi=1, except for special cases (sector 9 and BOR/BOM in sectors 11 and 15 with doubletR == 1,2),
142 // we can just flip doubletPhi between 1 and 2 for the second instance of the trigger algo.:
143 doubletPhi = (doubletPhi == 2) ? 1 : 2; // flip doubletPhi between 1 and 2
144
145 uint32_t etaStripID_2 = getSLStripId(side, sector, doubletPhi, RPClayer, doubletR, stationEta, doubletZ, stripId, false);
146 stripIDs.push_back(etaStripID_2);
147 strip_etabin[etaStripID_2] = strip_etabin[etaStripID];
148 strip_coordinates[etaStripID_2] = strip_coordinates[etaStripID];
149
150 uint32_t phiStripID_2 = getSLStripId(side, sector, doubletPhi, RPClayer, doubletR, stationEta, doubletZ, phiStrip, true);
151 stripIDs.push_back(phiStripID_2);
152 strip_coordinates[phiStripID_2] = strip_coordinates[phiStripID];
153 }
154 } else {
155 //the following bits of stripId are known to be unset: 8-31
156 uint32_t phiStripID = getSLStripId(side, sector, doubletPhi, RPClayer, doubletR, stationEta, doubletZ, stripId, measuresPhi);
157
158 stripIDs.push_back(phiStripID);
159 strip_coordinates[phiStripID] = getBMBOPhiStripCoordinate(stripPos);
160 }
161
162}
Scalar eta() const
pseudorapidity method
Acts::Transform3 globalToLocalTransform(const ActsTrk::GeometryContext &ctx) const
Returns the transformation from the global ATLAS coordinate system into the local coordinate system o...
const Acts::Transform3 & localToGlobalTransform(const ActsTrk::GeometryContext &ctx) const override final
Returns the transformation from the local coordinate system of the readout element into the global AT...
Amg::Vector3D stripPosition(const ActsTrk::GeometryContext &ctx, const Identifier &measId) const
Returns the position of the strip center.
virtual MuonStationIndex::StIndex stationIndex(const Identifier &id) const =0
calculate station index from Identifier
virtual int sector(const Identifier &id) const =0
return sector number 1-16, odd=large, even=small
Eigen::Matrix< double, 3, 1 > Vector3D
uint32_t getBMBOPhiStripCoordinate(const Amg::Vector3D &stripPos)
constexpr double s_propagationVelocity
uint32_t getSLStripId(bool side, int sector, int doubletPhi, Muon::MuonStationIndex::StIndex RPClayer, int doubletR, int stationEta, int doubletZ, int stripNumber, bool measuresPhi)
uint32_t getVirtualBIPhiStripCoordinate(const Amg::Vector3D &stripPos, float loc_pos_along_BIstrip)
int getVirtualBIPhiStripNumber(float loc_pos_along_BIstrip, const MuonGMR4::RpcReadoutElement &readoutElement)
StIndex
enum to classify the different station layers in the muon spectrometer
setEventNumber uint32_t

◆ getVirtualBIPhiStripCoordinate()

uint32_t L1Muon::RPCPatternUtils::getVirtualBIPhiStripCoordinate ( const Amg::Vector3D & stripPos,
float loc_pos_along_BIstrip )

Definition at line 33 of file RPCPatternUtils.cxx.

33 {
34 // Just trigonometry to get the phi coordinate
35 // The center of the chamber is the BI eta strip at (stripPos.x(), stripPos.y()) --> forms an angle phi_center = atan2(y, x)
36 // The local position along the strip gives a shift in phi: dphi = atan(loc_pos_along_BIstrip / R)
37 // The final phi coordinate is then: phi = phi_center - dphi
38 // We subtract dphi because the local position is defined positive towards decreasing phi (check with geometry)
39 // Since we want phi in [0, 2*pi], we add 2*pi if the result is negative.
40 float phi_center = stripPos.phi() + M_PI; // convert to [0, 2*pi] range
41 float R =stripPos.perp();
42 float dPhi = std::atan(loc_pos_along_BIstrip / R);
43 float phi = phi_center - dPhi;
44 if (phi < 0) {
45 phi += 2.0f * static_cast<float>(M_PI);
46 }
47 if (phi > 2.0f * static_cast<float>(M_PI)) {
48 phi -= 2.0f * static_cast<float>(M_PI);
49 }
50
51 float normPhi = std::clamp(phi / (2.0f * static_cast<float>(M_PI)), 0.0f, 1.0f);
52 uint32_t phi_discrete = static_cast<uint32_t>(std::round(normPhi * 511.0f));
53 return phi_discrete;
54}

◆ getVirtualBIPhiStripNumber()

int L1Muon::RPCPatternUtils::getVirtualBIPhiStripNumber ( float loc_pos_along_BIstrip,
const MuonGMR4::RpcReadoutElement & readoutElement )

Definition at line 21 of file RPCPatternUtils.cxx.

21 {
22 float halfSectorWidth = readoutElement.getParameters().halfWidth; // half of the sector width in local coordinates
23 int nMax_strip = static_cast<int>(2 * halfSectorWidth / s_digitalBiPhiStripWidth); // number of phi strips in the half-sector
24
25 // Since loc_pos_along_BIstrip ranges from 0 to ± halfSectorWidth, we map it to strip numbers accordingly:
26 // phiStrip == 1 at loc_pos_along_BIstrip == -halfSectorWidth
27 // phiStrip == nMax_strip at loc_pos_along_BIstrip == halfSectorWidth
28 // The formula below maps the local position to the corresponding strip number
29 int phiStrip = static_cast<int>(1 + std::round(((loc_pos_along_BIstrip + halfSectorWidth) / (2 * halfSectorWidth)) * (nMax_strip - 1)));
30 return std::clamp(phiStrip, 1, nMax_strip);
31}
constexpr double s_digitalBiPhiStripWidth

Variable Documentation

◆ s_digitalBiPhiStripWidth

double L1Muon::RPCPatternUtils::s_digitalBiPhiStripWidth = 150.0
inlineconstexpr

Definition at line 49 of file RPCPatternUtils.h.

◆ s_propagationVelocity

double L1Muon::RPCPatternUtils::s_propagationVelocity = 2./3. * Gaudi::Units::c_light
inlineconstexpr

Definition at line 50 of file RPCPatternUtils.h.