ATLAS Offline Software
Loading...
Searching...
No Matches
RPCDQUtils.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6
7// Local
8
9#include "RPCDQUtils.h"
10
11// Athena
16
17// C/C++
18#include <cmath>
19#include <sstream>
20
21//========================================================================================================
22// struct RpcPanel
23//========================================================================================================
24RpcPanel::RpcPanel(Identifier id, const RpcIdHelper &rpcIdHelper) {
25 FillRpcId(id, rpcIdHelper);
26}
27
28//========================================================================================================
29void RpcPanel::FillRpcId(Identifier id, const RpcIdHelper &rpcIdHelper) {
30 //
31 // Read RPC data
32 //
33 stationName = rpcIdHelper.stationName(id);
34 stationEta = rpcIdHelper.stationEta(id);
35 stationPhi = rpcIdHelper.stationPhi(id);
36 doubletR = rpcIdHelper.doubletR(id);
37 doubletZ = rpcIdHelper.doubletZ(id);
38 doubletPhi = rpcIdHelper.doubletPhi(id);
39 gasGap = rpcIdHelper.gasGap(id);
40 measPhi = rpcIdHelper.measuresPhi(id);
41
42 panelId =
45
46 // panel_index = stationName*6144 + stationPhi*768 + (stationEta+9)*48 +
47 // doubletR*24 + doubletPhi*12 + doubletZ*4 + gasGap*2 + measPhi;
48}
49
50//========================================================================================================
52 const MuonGM::RpcReadoutElement *readoutEl_,
53 const int doubletZ_, const int doubletPhi_,
54 const int gasgap_, const int measPhi_)
55 : readoutEl(readoutEl_),
56 doubletR(readoutEl_->getDoubletR()),
57 doubletZ(doubletZ_),
58 doubletPhi(doubletPhi_),
59 gasGap(gasgap_),
60 measPhi(measPhi_) {
61 const RpcIdHelper &rpcIdHelper = idHelperSvc.rpcIdHelper();
62 const Identifier readEl_id = readoutEl->identify();
63
64 stationName = rpcIdHelper.stationName(readEl_id);
66
67 stationEta = rpcIdHelper.stationEta(readEl_id);
68 stationPhi = rpcIdHelper.stationPhi(readEl_id);
69
70 //
71 // Get Identifier for this panel
72 //
73 panelId =
76 if (panel_valid) {
77 panel_str = idHelperSvc.toString(panelId);
79 } else {
80 panel_str = idHelperSvc.toString(panelId) + " - INVALID ID";
81 }
82}
83
84//========================================================================================================
88
89//========================================================================================================
90std::string RpcPanel::getElementStr() const {
91 std::ostringstream ele_key;
92
93 ele_key << stationName << "_" << stationEta << "_" << stationPhi << "_"
94 << doubletR << "_" << doubletZ;
95 return ele_key.str();
96}
97
98//========================================================================================================
99bool RpcPanel::operator==(const RpcPanel &rhs) const {
100 if (this->stationName == rhs.stationName &&
101 this->stationPhi == rhs.stationPhi &&
102 this->stationEta == rhs.stationEta && this->doubletR == rhs.doubletR &&
103 this->doubletPhi == rhs.doubletPhi && this->doubletZ == rhs.doubletZ &&
104 this->gasGap == rhs.gasGap && this->measPhi == rhs.measPhi) {
105 return true;
106 } else {
107 return false;
108 }
109}
110
111//========================================================================================================
112bool RpcPanel::operator<(const RpcPanel &rhs) const {
113 return this->panel_index < rhs.panel_index;
114}
115
116//========================================================================================================
117bool RpcPanel::operator>(const RpcPanel &rhs) const {
118 return this->panel_index > rhs.panel_index;
119}
120
121//========================================================================================================
122std::string RpcPanel::getOnlineConvention() const {
123 const std::string mystring_name = stationNameStr;
124 const std::string mystring_eta = std::to_string(std::abs(stationEta));
125 const std::string mystring_dPhi = "DP" + std::to_string(doubletPhi) + ".";
126 const std::string mystring_gap = "Ly" + std::to_string(gasGap - 1) + ".";
127 const std::string mystring_dZ = "DZ" + std::to_string(doubletZ);
128
129 std::string mystring_phi;
130 std::string mystring_side;
131 std::string mystring_PICO; // pivot or confirm
132 std::string mystring_ETAPHI;
133
134 int myphi_part = (2 * stationPhi) - 1;
135
136 if (stationEta > 0) {
137 mystring_side = "A";
138 } else if (stationEta < 0) {
139 mystring_side = "C";
140 } else {
141 mystring_side = "N";
142 } // N: NULL, "ETA NOT DEFINED"
143
144 if (stationName == 3 || stationName == 5 || stationName == 8 ||
145 stationName == 9 || stationName == 10) {
146 myphi_part += 1;
147 }
148
149 if (myphi_part < 10) {
150 mystring_phi = "0" + std::to_string(myphi_part);
151 } else {
152 mystring_phi = std::to_string(myphi_part);
153 }
154
155 if ((stationNameStr == "BMS" && doubletR == 1) ||
156 (stationNameStr == "BML" && doubletR == 1) ||
157 (stationNameStr == "BMF" && doubletR == 1)) {
158 mystring_PICO = ".CO.";
159 } else if ((stationNameStr == "BMS" && doubletR == 2) ||
160 (stationNameStr == "BML" && doubletR == 2) ||
161 (stationNameStr == "BMF" && doubletR == 2)) {
162 mystring_PICO = ".PI.";
163 } else if ((stationNameStr == "BOS" && doubletR == 1) ||
164 (stationNameStr == "BOL" && doubletR == 1) ||
165 (stationNameStr == "BOF" && doubletR == 1) ||
166 (stationNameStr == "BOG" && doubletR == 1)) {
167 mystring_PICO = ".CO.";
168 } else {
169 // mystring_PICO = ".PIVOT_CONFIRMED_NOT_DEFINED.";
170 mystring_PICO =
171 ".NU" + std::to_string(doubletR) + "."; // NU: NULL, Not defined
172 }
173
174 if (measPhi == 0) {
175 mystring_ETAPHI = "ETA.";
176 } else {
177 mystring_ETAPHI = "PHI.";
178 }
179
180 return mystring_name + mystring_eta + mystring_side + mystring_phi +
181 mystring_PICO + mystring_dPhi + mystring_gap + mystring_dZ +
182 mystring_ETAPHI;
183}
184
185//========================================================================================================
186std::pair<int, int> RpcPanel::getSectorLayer() const {
187 // {'2':'BML', '3':'BMS', '4':'BOL', '5':'BOS', '8':'BMF' , '9':'BOF',
188 // '10':'BOG', '53':'BME'}
189 int sector = 0;
190 int layer = 0;
191
192 if (stationName == 2 || stationName == 53) {
193 sector = stationPhi * 2 - 1;
194 layer = (doubletR - 1) * 2 + gasGap;
195 } else if (stationName == 4) {
196 sector = stationPhi * 2 - 1;
197 layer = 4 + (doubletR - 1) * 2 + gasGap;
198 } else if (stationName == 3 || stationName == 8) {
199 sector = stationPhi * 2;
200 layer = (doubletR - 1) * 2 + gasGap;
201 } else if (stationName == 5 || stationName == 9 || stationName == 10) {
202 sector = stationPhi * 2;
203 layer = 4 + (doubletR - 1) * 2 + gasGap;
204 }
205 if (stationEta < 0)
206 sector = -1 * sector;
207
208 std::pair<int, int> sec_layer(sector, layer);
209
210 return sec_layer;
211}
212
213//========================================================================================================
214// strcuct ExResult
215//========================================================================================================
217 const Trk::PropDirection direction_)
218 : gasgap_id(gasgap_id_), direction(direction_) {}
219
220//========================================================================================================
221// GasGapData
222//========================================================================================================
224 const MuonGM::RpcReadoutElement *readoutEl_,
225 const int doubletZ_, const int doubletPhi_,
226 const unsigned gasgap_)
227 : readoutEl(readoutEl_),
228 doubletR(readoutEl_->getDoubletR()),
229 doubletZ(doubletZ_),
230 doubletPhi(doubletPhi_),
231 gasgap(gasgap_) {
232 const RpcIdHelper &rpcIdHelper = idHelperSvc.rpcIdHelper();
233 const Identifier readEl_id = readoutEl->identify();
234
235 stationName = rpcIdHelper.stationName(readEl_id);
236 stationEta = rpcIdHelper.stationEta(readEl_id);
237 stationPhi = rpcIdHelper.stationPhi(readEl_id);
238
239 //
240 // Get Identifier for this gas gap
241 //
244
245 if (gapid_valid) {
246 gapid_str = idHelperSvc.toString(gapid);
247 } else {
248 gapid_str = idHelperSvc.toString(gapid) + " - INVALID ID";
249 }
250
251 NetaStrips = readoutEl->NetaStrips();
252 NphiStrips = readoutEl->NphiStrips();
253
254 // Determine gas gap span in eta
255 const Identifier etaIdFirst{rpcIdHelper.channelID(gapid, doubletZ, doubletPhi, gasgap, false, 1)};
256 const Amg::Vector3D glbPos_etaStrip_1st = readoutEl->stripPos(etaIdFirst);
257 double eta_etaStrip_1st = glbPos_etaStrip_1st.eta();
258
259 const Identifier etaIdLast{rpcIdHelper.channelID(gapid, doubletZ, doubletPhi, gasgap, false, NetaStrips)};
260 const Amg::Vector3D glbPos_etaStrip_last = readoutEl->stripPos(etaIdLast);
261 double eta_etaStrip_last = glbPos_etaStrip_last.eta();
262
263 if (eta_etaStrip_1st < eta_etaStrip_last) {
264 minStripEta = eta_etaStrip_1st;
265 maxStripEta = eta_etaStrip_last;
266 } else {
267 minStripEta = eta_etaStrip_last;
268 maxStripEta = eta_etaStrip_1st;
269 }
270
271 //
272 // Determine gas gap span in phi
273 //
274 const Identifier phiIdFirst{rpcIdHelper.channelID(gapid, doubletZ, doubletPhi, gasgap, true, 1)};
275 const Amg::Vector3D glbPos_phiStrip_1st = readoutEl->stripPos(phiIdFirst);
276 double phi_phiStrip_1st = glbPos_phiStrip_1st.phi();
277
278 const Identifier phiIdLast{rpcIdHelper.channelID(gapid, doubletZ, doubletPhi, gasgap, true, NphiStrips)};
279 const Amg::Vector3D glbPos_phiStrip_last = readoutEl->stripPos(phiIdLast);
280 double phi_phiStrip_last = glbPos_phiStrip_last.phi();
281
282 if (phi_phiStrip_1st < phi_phiStrip_last) {
283 minStripPhi = phi_phiStrip_1st;
284 maxStripPhi = phi_phiStrip_last;
285 } else {
286 minStripPhi = phi_phiStrip_last;
287 maxStripPhi = phi_phiStrip_1st;
288 }
289}
290
291//========================================================================================================
293 ExResult &result, const xAOD::TrackParticle &track) const {
294 /*
295 This function:
296 - computes minum DR distance between track and RpcReadoutElement
297 - do this before expensive call to extrapolator
298 */
299
300 const double deta1 = std::abs(minStripEta - track.eta());
301 const double deta2 = std::abs(maxStripEta - track.eta());
302
303 const double dphi1 =
304 std::abs(xAOD::P4Helpers::deltaPhi(minStripPhi, track.phi()));
305 const double dphi2 =
306 std::abs(xAOD::P4Helpers::deltaPhi(maxStripPhi, track.phi()));
307
308 result.minTrackGasGapDEta = std::min<double>(deta1, deta2);
309 result.minTrackGasGapDPhi = std::min<double>(dphi1, dphi2);
310
311 //
312 // Now check if track position is between min and max - if true, set
313 // distance to zero
314 //
315 if (minStripEta <= track.eta() && track.eta() <= maxStripEta) {
316 result.minTrackGasGapDEta = 0.0;
317 }
318 if (minStripPhi <= track.phi() && track.phi() <= maxStripPhi) {
319 result.minTrackGasGapDPhi = 0.0;
320 }
321
322 //
323 // Compute min DR to this gas gap
324 //
325 result.minTrackGasGapDR =
326 std::sqrt(result.minTrackGasGapDEta * result.minTrackGasGapDEta +
327 result.minTrackGasGapDPhi * result.minTrackGasGapDPhi);
328}
329
330//========================================================================================================
332 ExResult &result, const Trk::TrackParameters *trackParam) const {
333 /*
334 This function:
335 - computes minum DR distance between track and RpcReadoutElement
336 - do this before expensive call to extrapolator
337 */
338
339 const double deta1 = std::abs(minStripEta - trackParam->position().eta());
340 const double deta2 = std::abs(maxStripEta - trackParam->position().eta());
341
342 const double dphi1 = std::abs(
343 xAOD::P4Helpers::deltaPhi(minStripPhi, trackParam->position().phi()));
344 const double dphi2 = std::abs(
345 xAOD::P4Helpers::deltaPhi(maxStripPhi, trackParam->position().phi()));
346
347 result.minTrackGasGapDEta = std::min<double>(deta1, deta2);
348 result.minTrackGasGapDPhi = std::min<double>(dphi1, dphi2);
349
350 //
351 // Now check if trackParam->position() position is between min and max - if
352 // true, set distance to zero
353 //
354 if (minStripEta <= trackParam->position().eta() &&
355 trackParam->position().eta() <= maxStripEta) {
356 result.minTrackGasGapDEta = 0.0;
357 }
358 if (minStripPhi <= trackParam->position().phi() &&
359 trackParam->position().phi() <= maxStripPhi) {
360 result.minTrackGasGapDPhi = 0.0;
361 }
362
363 //
364 // Compute min DR to this gas gap
365 //
366 result.minTrackGasGapDR =
367 std::sqrt(result.minTrackGasGapDEta * result.minTrackGasGapDEta +
368 result.minTrackGasGapDPhi * result.minTrackGasGapDPhi);
369}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
int stationEta(const Identifier &id) const
const std::string & stationNameString(const Identifier &id) const
int stationPhi(const Identifier &id) const
int stationName(const Identifier &id) const
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
virtual const RpcIdHelper & rpcIdHelper() const =0
access to RpcIdHelper
virtual std::string toString(const Identifier &id) const =0
print all fields to string
Identifier channelID(int stationName, int stationEta, int stationPhi, int doubletR, int doubletZ, int doubletPhi, int gasGap, int measuresPhi, int strip) const
int gasGap(const Identifier &id) const override
get the hashes
Identifier panelID(const Identifier &padID, int gasGap, int measuresPhi) const
Identifier gapID(const Identifier &padID, int gasGap) const
int doubletPhi(const Identifier &id) const
int doubletR(const Identifier &id) const
bool measuresPhi(const Identifier &id) const override
int doubletZ(const Identifier &id) const
const Amg::Vector3D & position() const
Access method for the position.
Eigen::Matrix< double, 3, 1 > Vector3D
PropDirection
PropDirection, enum for direction of the propagation.
ParametersBase< TrackParametersDim, Charged > TrackParameters
Definition index.py:1
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
TrackParticle_v1 TrackParticle
Reference the current persistent version:
ExResult(const Identifier gasgap_id_, const Trk::PropDirection direction_)
const Trk::PropDirection direction
Definition RPCDQUtils.h:95
const Identifier gasgap_id
Definition RPCDQUtils.h:94
double minStripEta
Definition RPCDQUtils.h:133
Identifier gapid
Definition RPCDQUtils.h:119
void computeTrackDistanceToGasGap(ExResult &result, const xAOD::TrackParticle &track) const
unsigned NetaStrips
Definition RPCDQUtils.h:131
bool gapid_valid
Definition RPCDQUtils.h:120
const MuonGM::RpcReadoutElement * readoutEl
Definition RPCDQUtils.h:117
int stationName
Definition RPCDQUtils.h:123
double maxStripEta
Definition RPCDQUtils.h:134
unsigned NphiStrips
Definition RPCDQUtils.h:132
std::string gapid_str
Definition RPCDQUtils.h:121
double maxStripPhi
Definition RPCDQUtils.h:136
GasGapData(const Muon::IMuonIdHelperSvc &idHelperSvc, const MuonGM::RpcReadoutElement *readoutEl_, const int doubletZ_, const int doubletPhi_, const unsigned gasgap_)
double minStripPhi
Definition RPCDQUtils.h:135
unsigned gasgap
Definition RPCDQUtils.h:129
RpcPanel()=default
bool panel_valid
Definition RPCDQUtils.h:39
void SetPanelIndex(int index)
int stationEta
Definition RPCDQUtils.h:48
int doubletZ
Definition RPCDQUtils.h:51
bool operator==(const RpcPanel &rhs) const
std::string panel_name
Definition RPCDQUtils.h:41
const MuonGM::RpcReadoutElement * readoutEl
Definition RPCDQUtils.h:36
Identifier panelId
Definition RPCDQUtils.h:38
int gasGap
Definition RPCDQUtils.h:53
bool operator>(const RpcPanel &rhs) const
int doubletR
Definition RPCDQUtils.h:50
int panel_index
Definition RPCDQUtils.h:55
int measPhi
Definition RPCDQUtils.h:54
std::string stationNameStr
Definition RPCDQUtils.h:42
int stationPhi
Definition RPCDQUtils.h:49
bool operator<(const RpcPanel &rhs) const
int doubletPhi
Definition RPCDQUtils.h:52
void FillRpcId(Identifier id, const RpcIdHelper &rpcIdHelper)
int stationName
Definition RPCDQUtils.h:47
std::string panel_str
Definition RPCDQUtils.h:40
std::string getOnlineConvention() const
std::string getElementStr() const
std::pair< int, int > getSectorLayer() const