ATLAS Offline Software
Loading...
Searching...
No Matches
FloatingRdoDecoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include "Identifier/Identifier.h"
10#include "MuonRDO/TgcRawData.h"
11#include "MuonRDO/TgcRdo.h"
16
17#include <cmath>
18#include <numbers>
19
20namespace {
21
23 const Identifier& identifier, const Muon::IMuonIdHelperSvc& idHelperSvc) {
26
27 switch (idHelperSvc.phiIndex(identifier)) {
28 case PhiIndex::T1:
29 return FloatingStation::M1;
30 case PhiIndex::T2:
31 return FloatingStation::M2;
32 case PhiIndex::T3:
33 return FloatingStation::M3;
34 case PhiIndex::T4:
35 return FloatingStation::Inner;
36 default:
37 return FloatingStation::Unknown;
38 }
39}
40
41std::uint16_t triggerSector(const float phi) {
42 if (!std::isfinite(phi)) return 0U;
43 constexpr std::uint16_t nSectors = 24U;
44 const float fullTurn = 2.F * std::numbers::pi_v<float>;
45 const float sectorWidth = fullTurn / static_cast<float>(nSectors);
46 float wrapped = static_cast<float>(xAOD::P4Helpers::deltaPhi(phi, 0.));
47 if (wrapped < 0.F) wrapped += fullTurn;
48 std::uint16_t sector = static_cast<std::uint16_t>(
49 std::floor(wrapped / sectorWidth)) + 2U;
50 if (sector > nSectors) sector -= nSectors;
51 return sector;
52}
53
54} // namespace
55
56namespace L1Muon::L1TGC {
57
59 const Muon::TgcCablingMap& cabling,
60 const Muon::IMuonIdHelperSvc& idHelperSvc,
61 const MuonGM::MuonDetectorManager& detectorManager,
62 FloatingHitGroups& hitGroups,
63 FloatingDecodeStatistics& statistics) const {
64 hitGroups.clear();
65 statistics = FloatingDecodeStatistics{};
66
67 // Run-3 RDO conversion is isolated here. Hits are routed immediately to the
68 // Phase-II side/Trigger-Sector/BC processing chain, as in the validated
69 // Floating simulation. Chamber identifiers remain hit provenance only.
70 for (const TgcRdo* rdo : rdos) {
71 for (const TgcRawData* rawData : *rdo) {
72 ++statistics.nRawData;
73 if (rawData->type() != TgcRawData::TYPE_HIT) continue;
74
75 Identifier identifier;
76 const bool mapped = cabling.getOfflineIDfromReadoutID(
77 identifier, rawData->subDetectorId(), rawData->rodId(),
78 rawData->sswId(), rawData->slbId(), rawData->channel());
79 if (!mapped) {
80 ++statistics.nMappingFailures;
81 continue;
82 }
83
84 const FloatingStation hitStation = station(identifier, idHelperSvc);
85 const bool hitIsStrip = idHelperSvc.tgcIdHelper().isStrip(identifier);
86 float eta = 0.F;
87 float phi = 0.F;
88 float r = 0.F;
89 float z = 0.F;
90 const MuonGM::TgcReadoutElement* readoutElement =
91 detectorManager.getTgcReadoutElement(identifier);
92 if (readoutElement != nullptr) {
93 const Amg::Vector3D globalPosition = readoutElement->channelPos(identifier);
94 eta = static_cast<float>(globalPosition.eta());
95 phi = static_cast<float>(globalPosition.phi());
96 r = static_cast<float>(globalPosition.perp());
97 z = static_cast<float>(globalPosition.z());
98 }
99 const std::uint16_t hitTriggerSector = triggerSector(phi);
100 if (hitTriggerSector == 0U) {
101 ++statistics.nMappingFailures;
102 continue;
103 }
104
105 const FloatingHit hit{
106 .subDetectorId = rawData->subDetectorId(),
107 .triggerSector = hitTriggerSector,
108 .detectorSector = rawData->rodId(),
109 .bcTag = rawData->bcTag(),
110 .sswId = rawData->sswId(),
111 .slbId = rawData->slbId(),
112 .readoutChannel = rawData->channel(),
113 .stationEta = static_cast<std::int16_t>(
114 idHelperSvc.tgcIdHelper().stationEta(identifier)),
115 .stationPhi = static_cast<std::uint16_t>(
116 idHelperSvc.tgcIdHelper().stationPhi(identifier)),
117 .gasGap = static_cast<std::uint8_t>(
118 idHelperSvc.tgcIdHelper().gasGap(identifier)),
119 .channel = static_cast<std::uint16_t>(
120 idHelperSvc.tgcIdHelper().channel(identifier)),
121 .station = hitStation,
122 .isStrip = hitIsStrip,
123 .eta = eta,
124 .phi = phi,
125 .r = r,
126 .z = z,
127 };
128 const FloatingHitGroupKey key{.subDetectorId = hit.subDetectorId,
129 .triggerSector = hit.triggerSector,
130 .bcTag = hit.bcTag};
131 hitGroups[key].emplace_back(hit);
132
133 ++statistics.nHits;
134 if (hitIsStrip) ++statistics.nStripHits;
135 else ++statistics.nWireHits;
136 switch (hitStation) {
138 ++statistics.nM1Hits;
139 break;
141 ++statistics.nM2Hits;
142 break;
144 ++statistics.nM3Hits;
145 break;
147 ++statistics.nInnerHits;
148 break;
149 default:
150 ++statistics.nUnknownStation;
151 break;
152 }
153 }
154 }
155 return StatusCode::SUCCESS;
156}
157
158} // namespace L1Muon::L1TGC
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
bool hit(const Container &ids, int pdgId)
#define z
StatusCode decode(const TgcRdoContainer &rdos, const Muon::TgcCablingMap &cabling, const Muon::IMuonIdHelperSvc &idHelperSvc, const MuonGM::MuonDetectorManager &detectorManager, FloatingHitGroups &hitGroups, FloatingDecodeStatistics &statistics) const
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip).
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
virtual MuonStationIndex::PhiIndex phiIndex(const Identifier &id) const =0
calculate phi index from Identifier (not supported for MDT hits)
virtual const TgcIdHelper & tgcIdHelper() const =0
access to TgcIdHelper
int isStrip(const Identifier &id) const
isStrip corresponds to measuresPhi
An unit object of TGC ROD output.
Definition TgcRawData.h:23
int r
Definition globals.cxx:22
std::vector< std::string > mapped
Definition hcg.cxx:56
Eigen::Matrix< double, 3, 1 > Vector3D
std::map< FloatingHitGroupKey, FloatingHitContainer > FloatingHitGroups
PhiIndex
enum to classify the different phi layers in the muon spectrometer
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Event-local hardware processing key.