ATLAS Offline Software
Loading...
Searching...
No Matches
StgcPrdVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN
3 for the benefit of the ATLAS collaboration
4*/
8
9namespace MuonValR4 {
10
14
16 m_applyFilter = true;
17 m_filteredChamb.insert( idHelperSvc()->chamberId(chamberId));
18}
19
21 m_applyFilter = true;
22 const auto [it, inserted] = m_stripIdx.emplace( prd.identify(), m_stripIdx.size());
23
24 if (inserted) {
25 m_seedStrips.push_back(&prd);
26 }
27
28 return it->second;
29}
30
32 m_applyFilter = true;
33 const auto [it, inserted] = m_wireIdx.emplace( prd.identify(), m_wireIdx.size());
34
35 if (inserted) {
36 m_seedWires.push_back(&prd);
37 }
38
39 return it->second;
40}
41
43 m_applyFilter = true;
44 const auto [it, inserted] = m_padIdx.emplace( prd.identify(), m_padIdx.size());
45
46 if (inserted) {
47 m_seedPads.push_back(&prd);
48 }
49
50 return it->second;
51}
52
54 m_filteredChamb.clear();
55 m_stripIdx.clear();
56 m_wireIdx.clear();
57 m_padIdx.clear();
58 m_seedStrips.clear();
59 m_seedWires.clear();
60 m_seedPads.clear();
61 // Intentionally do NOT reset m_applyFilter (same as MM).
62}
63
65 const std::string& stripKey,
66 const std::string& wireKey,
67 const std::string& padKey,
68 bool writeStripNumbers,
69 bool writeStripCharges,
70 bool writeStripTimes,
71 MSG::Level msgLvl)
72 : TesterModuleBase{tree, "StgcPrds", msgLvl},
73 m_stripKey{stripKey},
74 m_wireKey{wireKey},
75 m_padKey{padKey}{
76 // Book optional branches only if requested, so no empty jagged
77 // vectors or baskets are written when a detail switch is false.
78 if (writeStripNumbers) {
79 m_stripNumbers = &parent().newMatrix<uint16_t>("StgcStrip_stripNumbers");
80 }
81 if (writeStripCharges) {
82 m_stripCharges = &parent().newMatrix<int>("StgcStrip_stripCharges");
83 }
84 if (writeStripTimes) {
85 m_stripTimes = &parent().newMatrix<short>("StgcStrip_stripTimes");
86 }
87}
88
89
95
96bool StgcPrdVariables::fill(const EventContext& ctx) {
97 const ActsTrk::GeometryContext& gctx{getGeoCtx(ctx)};
98
102
103 if (!strips.isValid() || !wires.isValid() || !pads.isValid()) {
104 ATH_MSG_ERROR("Missing sTGC PRD container(s): "
105 << m_stripKey.fullKey() << " (valid=" << strips.isValid() << "), "
106 << m_wireKey.fullKey() << " (valid=" << wires.isValid() << "), "
107 << m_padKey.fullKey() << " (valid=" << pads.isValid() << ")");
109 return false;
110 }
111
112 // The explicit seeds are written first. push_back() indices therefore
113 // correspond to their positions in the resulting per-type output vectors.
114 for (const auto* prd : m_seedStrips) dumpStrip(gctx, *prd);
115 for (const auto* prd : m_seedWires) dumpWire(gctx, *prd);
116 for (const auto* prd : m_seedPads) dumpPad(gctx, *prd);
117
118 // Then append the other hits, subject to the optional chamber filter.
119 // The maps already contain seeded IDs; insert new IDs as they are dumped.
120 for (const auto* prd : *strips) {
121 const Identifier id{prd->identify()};
122 if (m_applyFilter && !m_filteredChamb.count(idHelperSvc()->chamberId(id))) continue;
123 if (!m_stripIdx.emplace(id, m_stripIdx.size()).second) continue;
124 dumpStrip(gctx, *prd);
125 }
126 for (const auto* prd : *wires) {
127 const Identifier id{prd->identify()};
128 if (m_applyFilter && !m_filteredChamb.count(idHelperSvc()->chamberId(id))) continue;
129 if (!m_wireIdx.emplace(id, m_wireIdx.size()).second) continue;
130 dumpWire(gctx, *prd);
131 }
132 for (const auto* prd : *pads) {
133 const Identifier id{prd->identify()};
134 if (m_applyFilter && !m_filteredChamb.count(idHelperSvc()->chamberId(id))) continue;
135 if (!m_padIdx.emplace(id, m_padIdx.size()).second) continue;
136 dumpPad(gctx, *prd);
137 }
138
140 return true;
141}
142
144 const auto* strip = &prd;
145 const Identifier id{strip->identify()};
146 const auto* re = strip->readoutElement();
147 const Amg::Vector3D global{ re->localToGlobalTransform(gctx, strip->layerHash()) * strip->localMeasurementPos()};
148
149 m_stripId.push_back(id);
150 m_stripGlobal.push_back(global);
151 m_stripLocal.push_back(strip->localPosition<1>()[0]);
152 m_stripCov.push_back(strip->localCovariance<1>()(0, 0));
153 m_stripTime.push_back(strip->time());
154 m_stripCharge.push_back(strip->charge());
155 m_stripAuthor.push_back(static_cast<uint8_t>(strip->author()));
156 //m_stripQuality.push_back(static_cast<uint8_t>(strip->quality()));
157
158 if (m_stripNumbers) m_stripNumbers->push_back(strip->stripNumbers());
159 if (m_stripCharges) m_stripCharges->push_back(strip->stripCharges());
160 if (m_stripTimes) m_stripTimes->push_back(strip->stripTimes());
161}
162
164 const auto* wire = &prd;
165 const Identifier id{wire->identify()};
166 const auto* re = wire->readoutElement();
167 const Amg::Vector3D global{ re->localToGlobalTransform(gctx, wire->layerHash()) * wire->localMeasurementPos()};
168
169 m_wireId.push_back(id);
170 m_wireGlobal.push_back(global);
171 // The scalar localPosition<1>() is along local Y for wires.
172 m_wireLocal.push_back(wire->localPosition<1>()[0]);
173 m_wireCov.push_back(wire->localCovariance<1>()(0, 0));
174 m_wireTime.push_back(wire->time());
175 m_wireCharge.push_back(wire->charge());
176 m_wireAuthor.push_back(static_cast<uint8_t>(wire->author()));
177}
178
180 const auto* pad = &prd;
181 const Identifier id{pad->identify()};
182 const auto* re = pad->readoutElement();
183 const Amg::Vector3D global{ re->localToGlobalTransform(gctx, pad->layerHash()) * pad->localMeasurementPos()};
184
185 const auto pos = pad->localPosition<2>();
186 const auto cov = pad->localCovariance<2>();
187
188 m_padId.push_back(id);
189 m_padGlobal.push_back(global);
190 m_padLocalX.push_back(pos[0]);
191 m_padLocalY.push_back(pos[1]);
192 m_padCovXX.push_back(cov(0, 0));
193 m_padCovXY.push_back(cov(0, 1));
194 m_padCovYY.push_back(cov(1, 1));
195 m_padTime.push_back(pad->time());
196 m_padCharge.push_back(pad->charge());
197 m_padAuthor.push_back(static_cast<uint8_t>(pad->author()));
198}
199
200
201} // namespace MuonValR4
const std::regex re(r_e)
#define ATH_MSG_ERROR(x,...)
Handle class for reading from StoreGate.
bool msgLvl(const MSG::Level lvl) const
Test the output level.
MuonVal::VectorBranch< float > & m_stripLocal
Measured local position of each sTGC strip cluster.
MuonVal::VectorBranch< short > & m_stripTime
Time recorded for each sTGC strip cluster.
MuonVal::MatrixBranch< short > * m_stripTimes
Optional per-cluster lists of constituent strip times; null when not booked.
std::vector< const xAOD::sTgcStripCluster * > m_seedStrips
Strip clusters explicitly selected for output in the current event.
void dumpWire(const ActsTrk::GeometryContext &gctx, const xAOD::sTgcWireHit &prd)
Append a wire hit's identifier and measurement data to the tree.
bool fill(const EventContext &ctx) override final
Read the sTGC containers and append selected measurements to the tree.
unsigned int push_back(const xAOD::sTgcStripCluster &prd)
Select a strip cluster for output.
std::unordered_map< Identifier, unsigned int > m_padIdx
Map from pad-hit identifier to its output index.
MuonVal::VectorBranch< int > & m_padCharge
Charge recorded for each sTGC pad hit.
SG::ReadHandleKey< xAOD::sTgcStripContainer > m_stripKey
StoreGate key for the sTGC strip-cluster container.
MuonVal::VectorBranch< float > & m_padCovYY
Local YY covariance component of each sTGC pad hit.
void dumpAllHitsInChamber(const Identifier &chamberId)
Include all sTGC measurements from the specified chamber in the output.
MuonVal::VectorBranch< float > & m_padCovXY
Local XY covariance component of each sTGC pad hit.
SG::ReadHandleKey< xAOD::sTgcPadContainer > m_padKey
StoreGate key for the sTGC pad-hit container.
MuonVal::ThreeVectorBranch m_stripGlobal
Global-frame position of each sTGC strip cluster.
MuonVal::VectorBranch< short > & m_wireTime
Time recorded for each sTGC wire hit.
std::vector< const xAOD::sTgcWireHit * > m_seedWires
Wire hits explicitly selected for output in the current event.
MuonVal::MatrixBranch< uint16_t > * m_stripNumbers
Optional per-cluster lists of constituent strip numbers; null when not booked.
MuonVal::VectorBranch< float > & m_padLocalY
Local Y coordinate of each sTGC pad hit.
StgcPrdVariables(MuonVal::MuonTesterTree &tree, const std::string &stripKey, const std::string &wireKey, const std::string &padKey, bool writeStripNumbers=true, bool writeStripCharges=true, bool writeStripTimes=true, MSG::Level msgLvl=MSG::INFO)
MuonVal::VectorBranch< int > & m_stripCharge
Charge recorded for each sTGC strip cluster.
MuonVal::VectorBranch< short > & m_padTime
Time recorded for each sTGC pad hit.
void dumpPad(const ActsTrk::GeometryContext &gctx, const xAOD::sTgcPadHit &prd)
Append a pad hit's identifier and measurement data to the tree.
std::unordered_map< Identifier, unsigned int > m_stripIdx
Map from strip-cluster identifier to its output index.
void enableSeededDump()
Enable selection-based output.
MuonVal::VectorBranch< int > & m_wireCharge
Charge recorded for each sTGC wire hit.
std::unordered_map< Identifier, unsigned int > m_wireIdx
Map from wire-hit identifier to its output index.
MuonVal::sTgcIdentifierBranch m_stripId
Identifier branch for sTGC strip clusters.
void clearEventSelection()
Clear the per-event measurement and chamber selections.
std::vector< const xAOD::sTgcPadHit * > m_seedPads
Pad hits explicitly selected for output in the current event.
MuonVal::ThreeVectorBranch m_wireGlobal
Global-frame position of each sTGC wire hit.
MuonVal::VectorBranch< float > & m_wireCov
Local measurement variance of each sTGC wire hit.
SG::ReadHandleKey< xAOD::sTgcWireContainer > m_wireKey
StoreGate key for the sTGC wire-hit container.
std::unordered_set< Identifier > m_filteredChamb
Chamber identifiers whose measurements are included by the chamber filter.
MuonVal::VectorBranch< uint8_t > & m_wireAuthor
Reconstruction author code for each sTGC wire hit.
MuonVal::MatrixBranch< int > * m_stripCharges
Optional per-cluster lists of constituent strip charges; null when not booked.
MuonVal::ThreeVectorBranch m_padGlobal
Global-frame position of each sTGC pad hit.
MuonVal::VectorBranch< uint8_t > & m_padAuthor
Reconstruction author code for each sTGC pad hit.
MuonVal::VectorBranch< float > & m_padCovXX
Local XX covariance component of each sTGC pad hit.
MuonVal::VectorBranch< float > & m_stripCov
Local measurement variance of each sTGC strip cluster.
MuonVal::VectorBranch< uint8_t > & m_stripAuthor
Reconstruction author code for each sTGC strip cluster.
MuonVal::sTgcIdentifierBranch m_wireId
Identifier branch for sTGC wire hits.
MuonVal::sTgcIdentifierBranch m_padId
Identifier branch for sTGC pad hits.
bool m_applyFilter
Whether output is restricted to selected measurements and chambers.
bool declare_keys() override final
Declare dependencies on the configured strip, wire, and pad containers.
MuonVal::VectorBranch< float > & m_wireLocal
Measured local position of each wire hit, along local Y.
void dumpStrip(const ActsTrk::GeometryContext &gctx, const xAOD::sTgcStripCluster &prd)
Append a strip cluster's identifier and measurement data to the tree.
MuonVal::VectorBranch< float > & m_padLocalX
Local X coordinate of each sTGC pad hit.
const Muon::IMuonIdHelperSvc * idHelperSvc() const
TesterModuleBase(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl=MSG::Level::INFO)
const ActsTrk::GeometryContext & getGeoCtx(const EventContext &ctx) const
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
TTree * tree() override final
Returns the underlying TTree object.
MatrixBranch< T > & newMatrix(const std::string &name)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const Identifier & identify() const
Returns the Athena identifier of the measurement.
Eigen::Matrix< double, 3, 1 > Vector3D
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
sTgcStripCluster_v1 sTgcStripCluster
sTgcWireHit_v1 sTgcWireHit
sTgcPadHit_v1 sTgcPadHit