ATLAS Offline Software
Loading...
Searching...
No Matches
MeasurementMarkerAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
5
10
11namespace MuonR4{
12
14 using SegLink_t = ElementLink<xAOD::MuonSegmentContainer>;
15 using SegLinkVec_t = std::vector<SegLink_t>;
16
18 using PrdLinkVec_t = std::vector<PrdLink_t>;
19
22
24 using namespace DerivationFramework;
25
27 ATH_CHECK(m_segKey.initialize());
28 ATH_CHECK(m_readMarkKey.initialize());
29 ATH_CHECK(m_prdLinkKey.initialize());
30 ATH_CHECK(m_measKeys.initialize());
31 if (m_measKeys.empty()) {
32 ATH_MSG_FATAL("Please configure the measurement containers to decorate.");
33 return StatusCode::FAILURE;
34 }
35 const std::string decor = SG::decorKeyFromKey(m_readMarkKey.key());
36 for (const auto& key : m_measKeys) {
37 m_writeMarkKeys.emplace_back(key, decor);
38 if (m_segLink.value().size()) {
39 m_writeSegLinkKeys.emplace_back(key, m_segLink);
40 }
41 }
42 ATH_CHECK(m_writeMarkKeys.initialize());
43 ATH_CHECK(m_writeSegLinkKeys.initialize());
44 return StatusCode::SUCCESS;
45 }
46 StatusCode MeasurementMarkerAlg::execute(const EventContext& ctx) const{
47 const xAOD::MuonSegmentContainer* segments{nullptr};
48 ATH_CHECK(SG::get(segments, m_segKey, ctx));
52
53 std::unordered_map<const SG::AuxVectorData*, MarkerHandle_t> writeDecorMap{};
54 std::unordered_map<const SG::AuxVectorData*, LinkHandle_t> linkDecorMap{};
55 for (const WriteDecorKey_t& decorKey : m_writeMarkKeys) {
56 const xAOD::UncalibratedMeasurementContainer* measCont{nullptr};
57 ATH_CHECK(SG::get(measCont, decorKey.contHandleKey(), ctx));
58 writeDecorMap.emplace(std::make_pair(measCont, makeHandle(ctx, decorKey, false)));
59 }
60
61 for (const WriteDecorKey_t& key : m_writeSegLinkKeys) {
62 const xAOD::UncalibratedMeasurementContainer* measCont{nullptr};
63 ATH_CHECK(SG::get(measCont, key.contHandleKey(), ctx));
64 linkDecorMap.emplace(std::make_pair(measCont, makeHandle(ctx, key, SegLinkVec_t{})));
65 }
66
67 for (const xAOD::MuonSegment* seg : *segments) {
68 if (!readDecor(*seg)){
69 continue;
70 }
71 SegLink_t segLink{segments, seg->index()};
72 for (const PrdLink_t& link : prdLinks(*seg)) {
73 const auto* prd = (*link);
74 writeDecorMap.at(prd->container())(*prd) = readDecor(*seg);
75 if (m_segLink.value().empty()) {
76 continue;
77 }
78 linkDecorMap.at(prd->container())(*prd).push_back(segLink);
79 }
80 }
81 return StatusCode::SUCCESS;
82 }
83}
#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.
Handle class for adding a decoration to an object.
THE reconstruction tool.
SG::WriteDecorHandle< ContType, dType > makeHandle(const EventContext &ctx, const SG::WriteDecorHandleKey< ContType > &key, const dType &defValue=dType{})
This header ties the generic definitions in this package.
std::vector< PrdLink_t > PrdLinkVec_t
Abrivation of a collection of Prd links.
SG::WriteDecorHandle< PrdCont_t, bool > MarkerHandle_t
SG::WriteDecorHandle< PrdCont_t, SegLinkVec_t > LinkHandle_t
ElementLink< MuonR4::SegmentContainer > SegLink_t
Abrivation of the link to the reco segment container.
SG::WriteDecorHandleKey< xAOD::UncalibratedMeasurementContainer > WriteDecorKey_t
std::vector< SegLink_t > SegLinkVec_t
ElementLink< PrdCont_t > PrdLink_t
Abrivation to call the link to an element inside an uncalibrated measurement container.
xAOD::UncalibratedMeasurementContainer PrdCont_t
Abrivation to call an uncalibrated measurement container.
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: