ATLAS Offline Software
Loading...
Searching...
No Matches
MeasurementMarkerAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
10
11namespace MuonR4{
12
15 using SegLinkVec_t = std::vector<SegLink_t>;
16
18 using PrdLinkVec_t = std::vector<PrdLink_t>;
19
22
24
26 ATH_CHECK(m_segKey.initialize());
27 ATH_CHECK(m_readMarkKey.initialize());
28 ATH_CHECK(m_prdLinkKey.initialize());
29 ATH_CHECK(m_measKeys.initialize());
30 if (m_measKeys.empty()) {
31 ATH_MSG_FATAL("Please configure the measurement containers to decorate.");
32 return StatusCode::FAILURE;
33 }
34 const std::string decor = SG::decorKeyFromKey(m_readMarkKey.key());
35 for (const auto& key : m_measKeys) {
36 m_writeMarkKeys.emplace_back(key, decor);
37 if (m_segLink.value().size()) {
38 m_writeSegLinkKeys.emplace_back(key, m_segLink);
39 }
40 }
41 ATH_CHECK(m_writeMarkKeys.initialize());
42 ATH_CHECK(m_writeSegLinkKeys.initialize());
43 return StatusCode::SUCCESS;
44 }
45 StatusCode MeasurementMarkerAlg::execute(const EventContext& ctx) const{
46 const xAOD::MuonSegmentContainer* segments{nullptr};
47 ATH_CHECK(SG::get(segments, m_segKey, ctx));
51
52 std::unordered_map<const SG::AuxVectorData*, MarkerHandle_t> writeDecorMap{};
53 std::unordered_map<const SG::AuxVectorData*, LinkHandle_t> linkDecorMap{};
54 for (const WriteDecorKey_t& decorKey : m_writeMarkKeys) {
55 const xAOD::UncalibratedMeasurementContainer* measCont{nullptr};
56 ATH_CHECK(SG::get(measCont, decorKey.contHandleKey(), ctx));
57 writeDecorMap.emplace(std::make_pair(measCont, MarkerHandle_t{decorKey, ctx}));
58 }
59
60 for (const WriteDecorKey_t& key : m_writeSegLinkKeys) {
61 const xAOD::UncalibratedMeasurementContainer* measCont{nullptr};
62 ATH_CHECK(SG::get(measCont, key.contHandleKey(), ctx));
63 linkDecorMap.emplace(std::make_pair(measCont, LinkHandle_t{key, ctx}));
64 }
65
66 for (const xAOD::MuonSegment* seg : *segments) {
67 if (!readDecor(*seg)){
68 continue;
69 }
70 SegLink_t segLink{segments, seg->index()};
71 for (const PrdLink_t& link : prdLinks(*seg)) {
72 const auto* prd = (*link);
73 writeDecorMap.at(prd->container())(*prd) = readDecor(*seg);
74 if (m_segLink.value().empty()) {
75 continue;
76 }
77 linkDecorMap.at(prd->container())(*prd).push_back(segLink);
78 }
79 }
80 return StatusCode::SUCCESS;
81 }
82}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
SG::ReadHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_measKeys
Key to the segment container to fetch the marked segments.
SG::WriteDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_writeMarkKeys
Key to the decoration.
Gaudi::Property< std::string > m_segLink
virtual StatusCode execute(const EventContext &ctx) const override final
virtual StatusCode initialize() override final
SG::WriteDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_writeSegLinkKeys
Key to the decoration.
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_readMarkKey
Key to the decoration to fetch the marked muons.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segKey
Key to the primary muon container to select the muon from.
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_prdLinkKey
Key to the prd association decoration.
Handle class for reading a decoration on an object.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Auxiliary class to instantiate WriteDecorHandles.The handles can be created in an empty state.
This header ties the generic definitions in this package.
ElementLink< PrdCont_t > PrdLink_t
xAOD::ContainerDecorator< PrdCont_t, SegLinkVec_t > LinkHandle_t
std::vector< SegLink_t > SegLinkVec_t
std::vector< PrdLink_t > PrdLinkVec_t
ElementLink< xAOD::MuonSegmentContainer > SegLink_t
xAOD::UncalibratedMeasurementContainer PrdCont_t
xAOD::ContainerDecorator< PrdCont_t, std::uint8_t > MarkerHandle_t
SG::WriteDecorHandleKey< xAOD::UncalibratedMeasurementContainer > WriteDecorKey_t
std::string decorKeyFromKey(const std::string &key, const std::string &deflt)
Extract the decoration part of key.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
UncalibratedMeasurementContainer_v1 UncalibratedMeasurementContainer
Define the version of the uncalibrated measurement container.
MuonSegment_v1 MuonSegment
Reference the current persistent version: