ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
HyPERAnalysisAlgorithms
HyPERAnalysisAlgorithms
GraphBase.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef HYPERANALYSISALGORITHMS_GRAPHBASE_H
6
#define HYPERANALYSISALGORITHMS_GRAPHBASE_H
7
9
10
#include <cstdint>
11
#include <utility>
12
#include <vector>
13
14
namespace
EventReco
{
15
// Define some types used across the graph.
16
using
Features
= std::vector<float>;
17
using
EdgeIndex
= std::pair<int64_t, int64_t>;
18
// @class Node
19
// @brief This class stores a node in the graph.
20
class
Node
{
21
public
:
22
Node
() =
default
;
23
Node
(
const
Features
& attributes, int64_t nodeIndex)
24
:
m_nodeFeatures
(attributes),
m_nodeIndex
(nodeIndex) {};
25
const
Features
&
getFeatures
()
const
{
return
m_nodeFeatures
; };
26
Features
&
getFeatures
() {
return
m_nodeFeatures
; };
27
int64_t
getNodeIndex
()
const
{
return
m_nodeIndex
; };
28
29
private
:
30
Features
m_nodeFeatures
= {};
31
int64_t
m_nodeIndex
= -1;
32
};
33
// @class Edge
34
// @brief This class stores an edge in the graph.
35
class
Edge
{
36
public
:
37
Edge
() =
default
;
38
Edge
(int64_t source, int64_t target,
const
Features
& attributes)
39
:
m_edgeFeatures
(attributes),
40
m_edgeIndex
(
std
::make_pair(source, target)) {};
41
const
Features
&
getFeatures
()
const
{
return
m_edgeFeatures
; };
42
EdgeIndex
getIndices
()
const
{
return
m_edgeIndex
; };
43
44
private
:
45
Features
m_edgeFeatures
= {};
46
EdgeIndex
m_edgeIndex
= {};
47
};
48
// @class Global
49
// @brief This class stores the global features of the graph.
50
class
Global
{
51
public
:
52
Global
() =
default
;
53
Global
(
const
Features
& attributes) :
m_globalFeatures
(attributes) {};
54
const
Features
&
getFeatures
()
const
{
return
m_globalFeatures
; };
55
56
private
:
57
Features
m_globalFeatures
= {};
58
};
59
60
// @class GraphBase
61
// @brief This class is the base class for the graph objects.
62
// It represents a graph on an event by event basis.
63
// It is used to store the graph structure and features of the graph.
64
// Used for evaluation.
65
class
GraphBase
{
66
public
:
67
GraphBase
() =
default
;
68
// Methods to build the graph
69
virtual
void
addNode
(
const
Features
& attributes) = 0;
70
virtual
void
addEdge
(int64_t source, int64_t target,
71
const
Features
& attributes) = 0;
72
virtual
void
addGlobal
(
const
Features
& attributes) = 0;
73
// Methods to get the graph features
74
Features
getNodeFeats
(std::size_t
index
)
const
{
75
return
m_nodes
[
index
].getFeatures();
76
};
77
Features
&
getNodeFeats
(std::size_t
index
) {
78
return
m_nodes
[
index
].getFeatures();
79
};
80
Features
getEdgeFeats
(std::size_t
index
)
const
{
81
return
m_edges
[
index
].getFeatures();
82
};
83
Features
getGlobalFeats
()
const
{
return
m_global
.getFeatures(); };
84
EdgeIndex
getEdgeIndicesVector
(std::size_t
index
)
const
{
85
return
m_edges
[
index
].getIndices();
86
};
87
88
int64_t
nNodes
()
const
{
return
m_nNodes
; };
89
int64_t
nEdges
()
const
{
return
m_nEdges
; };
90
int64_t
nGlobal
()
const
{
return
m_global
.getFeatures().size(); };
91
92
protected
:
93
Global
m_global
;
94
std::vector<Node>
m_nodes
;
95
std::vector<Edge>
m_edges
;
96
int64_t
m_nNodes
= 0;
97
int64_t
m_nEdges
= 0;
98
};
99
}
// namespace EventReco
100
101
#endif
// HYPERANALYSISALGORITHMS_GRAPHBASE_H
EventReco::Edge::Edge
Edge(int64_t source, int64_t target, const Features &attributes)
Definition
GraphBase.h:38
EventReco::Edge::getFeatures
const Features & getFeatures() const
Definition
GraphBase.h:41
EventReco::Edge::m_edgeIndex
EdgeIndex m_edgeIndex
Definition
GraphBase.h:46
EventReco::Edge::getIndices
EdgeIndex getIndices() const
Definition
GraphBase.h:42
EventReco::Edge::Edge
Edge()=default
EventReco::Edge::m_edgeFeatures
Features m_edgeFeatures
Definition
GraphBase.h:45
EventReco::Global
Definition
GraphBase.h:50
EventReco::Global::getFeatures
const Features & getFeatures() const
Definition
GraphBase.h:54
EventReco::Global::Global
Global()=default
EventReco::Global::Global
Global(const Features &attributes)
Definition
GraphBase.h:53
EventReco::Global::m_globalFeatures
Features m_globalFeatures
Definition
GraphBase.h:57
EventReco::GraphBase::getEdgeIndicesVector
EdgeIndex getEdgeIndicesVector(std::size_t index) const
Definition
GraphBase.h:84
EventReco::GraphBase::GraphBase
GraphBase()=default
EventReco::GraphBase::m_nEdges
int64_t m_nEdges
Definition
GraphBase.h:97
EventReco::GraphBase::addGlobal
virtual void addGlobal(const Features &attributes)=0
EventReco::GraphBase::m_nodes
std::vector< Node > m_nodes
Definition
GraphBase.h:94
EventReco::GraphBase::nNodes
int64_t nNodes() const
Definition
GraphBase.h:88
EventReco::GraphBase::addNode
virtual void addNode(const Features &attributes)=0
EventReco::GraphBase::getEdgeFeats
Features getEdgeFeats(std::size_t index) const
Definition
GraphBase.h:80
EventReco::GraphBase::m_edges
std::vector< Edge > m_edges
Definition
GraphBase.h:95
EventReco::GraphBase::getNodeFeats
Features getNodeFeats(std::size_t index) const
Definition
GraphBase.h:74
EventReco::GraphBase::getNodeFeats
Features & getNodeFeats(std::size_t index)
Definition
GraphBase.h:77
EventReco::GraphBase::getGlobalFeats
Features getGlobalFeats() const
Definition
GraphBase.h:83
EventReco::GraphBase::m_nNodes
int64_t m_nNodes
Definition
GraphBase.h:96
EventReco::GraphBase::addEdge
virtual void addEdge(int64_t source, int64_t target, const Features &attributes)=0
EventReco::GraphBase::nGlobal
int64_t nGlobal() const
Definition
GraphBase.h:90
EventReco::GraphBase::m_global
Global m_global
Definition
GraphBase.h:93
EventReco::GraphBase::nEdges
int64_t nEdges() const
Definition
GraphBase.h:89
EventReco::Node::getNodeIndex
int64_t getNodeIndex() const
Definition
GraphBase.h:27
EventReco::Node::getFeatures
const Features & getFeatures() const
Definition
GraphBase.h:25
EventReco::Node::m_nodeFeatures
Features m_nodeFeatures
Definition
GraphBase.h:30
EventReco::Node::m_nodeIndex
int64_t m_nodeIndex
Definition
GraphBase.h:31
EventReco::Node::getFeatures
Features & getFeatures()
Definition
GraphBase.h:26
EventReco::Node::Node
Node()=default
EventReco::Node::Node
Node(const Features &attributes, int64_t nodeIndex)
Definition
GraphBase.h:23
EventReco
Definition
GraphBase.h:14
EventReco::Features
std::vector< float > Features
Definition
GraphBase.h:16
EventReco::EdgeIndex
std::pair< int64_t, int64_t > EdgeIndex
Definition
GraphBase.h:17
index
Definition
index.py:1
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0