ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentEdgeClassifierTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONINFERENCE_SEGMENTEDGECLASSIFIERTOOL_H
5#define MUONINFERENCE_SEGMENTEDGECLASSIFIERTOOL_H
6
9#include "MuonMLEvent.h"
10#include "Gaudi/Property.h"
11
12#include <atomic>
13#include <cstdint>
14#include <mutex>
15#include <string>
16#include <vector>
17
18namespace MuonML {
19
28 int chamberIndex{0};
29 int layers{0};
30 int sector{0};
31 int nSegments{0};
32 };
33
62 virtual public ISegmentEdgeClassifierTool {
63 public:
64 using BucketInferenceToolBase::BucketInferenceToolBase;
65
67 StatusCode initialize() override;
68
71 StatusCode runGraphInference(const EventContext& ctx,
72 GraphRawData& graphData) const override;
73
76 StatusCode buildGraph(const EventContext& ctx,
77 const xAOD::MuonSegmentContainer& segments,
78 SegmentEdgeGraph& graph) const override;
79
82 StatusCode classifyEdges(const EventContext& ctx,
83 const SegmentEdgeGraph& graph,
84 std::vector<SegmentEdgeScore>& scores) const override;
85
86 private:
87 StatusCode dumpDebugEvent(const EventContext& ctx,
88 const SegmentEdgeGraph& graph,
89 const std::vector<SegmentEdgeScore>& scores) const;
90
91 Gaudi::Property<float> m_maxDeltaThetaDeg{this, "MaxDeltaThetaDeg", 35.f};
92 Gaudi::Property<int> m_maxDeltaSector{this, "MaxDeltaSector", 1};
93 Gaudi::Property<int> m_sectorModulo{this, "SectorModulo", 16,
94 "Number of muon sectors used when applying wrap-around sector distance"};
95 Gaudi::Property<unsigned int> m_maxSegmentsPerBucket{this, "MaxSegmentsPerBucket", 0,
96 "Keep at most this many quality-ranked segments per (sector, chamber, eta) bucket before inference; 0 keeps all"};
97 Gaudi::Property<unsigned int> m_maxEdgesPerNodeBeforeInference{this, "MaxEdgesPerNodeBeforeInference", 0,
98 "Keep at most this many geometrical neighbour pairs per node before ONNX inference; 0 keeps all"};
99 Gaudi::Property<unsigned int> m_maxEdgesPerTargetChamberBeforeInference{
100 this, "MaxEdgesPerTargetChamberBeforeInference", 0,
101 "Keep at most this many pre-ONNX neighbours from one target chamber per node; 0 keeps all"};
102 Gaudi::Property<bool> m_dropSameChamberEdgesBeforeInference{this, "DropSameChamberEdgesBeforeInference", true,
103 "Drop same-chamber segment pairs before ONNX inference"};
104 Gaudi::Property<bool> m_dropIsolatedNodesBeforeInference{this, "DropIsolatedNodesBeforeInference", true,
105 "Remove nodes without a retained pre-ONNX edge before creating ONNX tensors"};
106 Gaudi::Property<std::string> m_inputNodeName{this, "InputNodeName", "x"};
107 Gaudi::Property<std::string> m_inputEdgeIndexName{this, "InputEdgeIndexName", "edge_index"};
108 Gaudi::Property<std::string> m_inputEdgeAttrName{this, "InputEdgeAttrName", "edge_attr"};
109 Gaudi::Property<std::string> m_outputName{this, "OutputName", "logits"};
110 Gaudi::Property<std::string> m_debugDumpFile{this, "DebugDumpFile", ""};
111 Gaudi::Property<unsigned int> m_debugDumpMaxEvents{this, "DebugDumpMaxEvents", 0};
112 float m_cosMin{0.f};
113
115 std::vector<std::string> m_nodeFeatureNames{};
116 std::vector<SegmentNodeFeatureId> m_nodeFeatureIds{};
117 mutable std::mutex m_debugDumpMutex;
118 mutable std::atomic<unsigned int> m_debugDumpEvents{0};
119 };
120}
121#endif
Generic feature definitions and utilities shared across ML inference tools.
Interface for segment-edge GNN classification.
Runs a segment-level GNN on reconstructed muon segments to classify segment-pair edges as "good" or "...
Gaudi::Property< unsigned int > m_debugDumpMaxEvents
Gaudi::Property< unsigned int > m_maxEdgesPerNodeBeforeInference
Gaudi::Property< unsigned int > m_maxEdgesPerTargetChamberBeforeInference
Gaudi::Property< std::string > m_outputName
std::atomic< unsigned int > m_debugDumpEvents
Gaudi::Property< std::string > m_inputEdgeAttrName
StatusCode runGraphInference(const EventContext &ctx, GraphRawData &graphData) const override
Not supported by this tool; returns FAILURE.
Gaudi::Property< unsigned int > m_maxSegmentsPerBucket
StatusCode classifyEdges(const EventContext &ctx, const SegmentEdgeGraph &graph, std::vector< SegmentEdgeScore > &scores) const override
Run ONNX inference on graph and populate scores with logit and probability for each edge; called afte...
Gaudi::Property< std::string > m_debugDumpFile
StatusCode buildGraph(const EventContext &ctx, const xAOD::MuonSegmentContainer &segments, SegmentEdgeGraph &graph) const override
Build a GNN graph from segments, computing node and edge features and storing the graph structure in ...
std::vector< std::string > m_nodeFeatureNames
Node feature order expected by the model metadata (resolved at initialize).
Gaudi::Property< std::string > m_inputEdgeIndexName
Gaudi::Property< bool > m_dropSameChamberEdgesBeforeInference
Gaudi::Property< std::string > m_inputNodeName
std::vector< SegmentNodeFeatureId > m_nodeFeatureIds
StatusCode initialize() override
Retrieve the ONNX model and resolve node feature ordering from metadata.
Gaudi::Property< bool > m_dropIsolatedNodesBeforeInference
StatusCode dumpDebugEvent(const EventContext &ctx, const SegmentEdgeGraph &graph, const std::vector< SegmentEdgeScore > &scores) const
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
Segment features derived from or stored in bucket metadata.
int chamberIndex
Muon chamber index of the segment.
int sector
Sector number (typically 0–15).
int layers
Total number of active layers in the segment.
int nSegments
Count of segments in the same chamber/sector/eta group.
Helper struct to ship the Graph from the space point buckets to ONNX.
Definition GraphData.h:25