ATLAS Offline Software
Loading...
Searching...
No Matches
MlMsTrackSeeder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#include "MlMsTrackSeeder.h"
5
11
12#include <map>
13#include <utility>
14#include <vector>
15
16namespace MuonR4 {
17
18namespace {
19
20struct MlComponent {
21 std::vector<const xAOD::MuonSegment*> segments;
22 std::vector<const xAOD::MuonSegment*> anchors;
23};
24
25} // namespace
26
29 ATH_CHECK(m_segmentKey.initialize());
30 ATH_CHECK(m_candidateDecorKey.initialize());
31 return StatusCode::SUCCESS;
32}
33
35 const EventContext& ctx,
36 std::vector<MsTrackSeed>& outSeeds) const {
37 const xAOD::MuonSegmentContainer* segments{nullptr};
38 ATH_CHECK(SG::get(segments, m_segmentKey, ctx));
39
40 // The decoration payload is [componentId, isSeedAnchor].
42 componentAcc{m_candidateDecorKey, ctx};
43 if (!componentAcc.isAvailable()) {
44 ATH_MSG_DEBUG("No ML candidate decoration found");
45 return StatusCode::SUCCESS;
46 }
47
48 std::map<unsigned int, MlComponent> components;
49
50 for (const xAOD::MuonSegment* segment : *segments) {
51 if (!segment) continue;
52 const std::vector<unsigned int>& payload = componentAcc(*segment);
53 if (payload.size() != 2 || payload[0] == 0) continue;
54 MlComponent& component = components[payload[0]];
55 component.segments.push_back(segment);
56 if (payload[1] != 0) component.anchors.push_back(segment);
57 }
58
59 std::size_t acceptedComponents = 0;
60 std::size_t constructedSeeds = 0;
61 for (const auto& [componentId, component] : components) {
62 if (component.segments.size() < m_minSegmentsPerCandidate.value() ||
63 component.anchors.empty()) {
64 continue;
65 }
66 ++acceptedComponents;
67
68 for (const xAOD::MuonSegment* anchor : component.anchors) {
69 const MsTrackSeed::Location location =
73 MsTrackSeed seed{location, ExpandedSector{anchor->position().phi()}};
74 for (const xAOD::MuonSegment* segment : component.segments) {
75 seed.addSegment(segment);
76 }
77 seed.setPosition(anchor->position());
78 outSeeds.push_back(std::move(seed));
79 ++constructedSeeds;
80 }
81 ATH_MSG_VERBOSE("Constructed " << component.anchors.size()
82 << " seed(s) from ML component " << componentId
83 << " with " << component.segments.size()
84 << " segments");
85 }
86
87 ATH_MSG_DEBUG("Constructed " << constructedSeeds << " seed(s) from "
88 << acceptedComponents << "/" << components.size()
89 << " decorated ML component(s)");
90 return StatusCode::SUCCESS;
91}
92
93Acts::Result<Acts::BoundTrackParameters>
95 const EventContext& ctx,
96 const MsTrackSeed& seed) const {
97 return m_seedParameterEstimator->estimateStartParameters(ctx, seed);
98}
99
100} // namespace MuonR4
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
StatusCode initialize() override final
StatusCode findTrackSeeds(const EventContext &ctx, std::vector< MsTrackSeed > &outSeeds) const override final
Retrieves the segment container from StoreGate and constructs TrackSeeds from them.
Gaudi::Property< unsigned int > m_minSegmentsPerCandidate
Acts::Result< Acts::BoundTrackParameters > estimateStartParameters(const EventContext &ctx, const MsTrackSeed &seed) const override final
Estimate the start track parameters for a given track seed.
ToolHandle< ITrackSeedingTool > m_seedParameterEstimator
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_candidateDecorKey
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Location
Enum defining whether the seed is made in the endcap / barrel.
Definition MsTrackSeed.h:25
Handle class for reading a decoration on an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
This header ties the generic definitions in this package.
bool isBarrel(const ChIndex index)
Returns true if the chamber index points to a barrel chamber.
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".
MuonSegment_v1 MuonSegment
Reference the current persistent version: