ATLAS Offline Software
Loading...
Searching...
No Matches
NavGraph.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TrigCompositeUtils_NavGraph_h
6#define TrigCompositeUtils_NavGraph_h
7
11
12
13namespace TrigCompositeUtils {
14
21 public:
26 NavGraphNode(const Decision* me);
27
31 ~NavGraphNode() = default;
32
36 NavGraphNode(const NavGraphNode& obj) = delete;
37
41 NavGraphNode(NavGraphNode&& obj) = delete;
47 bool linksTo(NavGraphNode* to);
48
54
58 void keep();
59
63 void resetKeep() ;
64
68 bool getKeep() const;
69
73 const Decision* node() const;
74
81 const std::vector<NavGraphNode*>& seeds() const;
82
87 const std::vector<NavGraphNode*>& children() const;
88
89 private:
90
95 static bool addIfNotDuplicate(std::vector<NavGraphNode*>& container, NavGraphNode* toAdd);
96
98 std::vector<NavGraphNode*> m_filteredSeeds;
99 std::vector<NavGraphNode*> m_filteredChildren;
100 bool m_keepFlag{false};
101
102 };
103
111 class NavGraph {
112
113 public:
114
118 NavGraph() = default;
119
123 ~NavGraph() = default;
124
128 NavGraph(const NavGraph& obj) = delete;
129
133 NavGraph(NavGraph&& obj) = delete;
134
142 void addNode(const Decision* node, const Decision* comingFrom = nullptr);
143
149 const std::vector<NavGraphNode*>& finalNodes() const;
150
155 std::vector<NavGraphNode*> allNodes();
156
160 size_t nodes() const;
161
165 size_t edges() const;
166
171 std::vector<const Decision*> thin();
172
178 void printAllPaths(MsgStream& log, MSG::Level msgLevel = MSG::VERBOSE) const;
179
180 private:
181
200 void rewireNodeForRemoval(NavGraphNode& toBeDeleted);
201
209 void recursivePrintNavPath(const NavGraphNode& nav, size_t level, MsgStream& log, MSG::Level msgLevel) const;
210
211 std::map<const Decision*, size_t> m_nodePositionMap;
212 std::vector<std::unique_ptr<NavGraphNode>> m_nodes;
213 std::vector<NavGraphNode*> m_finalNodes;
214 size_t m_edges{0};
215 };
216
217}
218
219#endif // TrigCompositeUtils_NavGraph_h
Base class for elements of a container that can have aux data.
Transient utility class to represent a node in a graph (m_decisionObject), and a vector of edges (m_f...
Definition NavGraph.h:20
NavGraphNode(NavGraphNode &&obj)=delete
Prevent move of a NavGraphNode.
const std::vector< NavGraphNode * > & children() const
Return a vector of const pointers to the Decision object nodes which are the children of this NavGrap...
Definition NavGraph.cxx:50
std::vector< NavGraphNode * > m_filteredSeeds
My seeds (edges in the graph), filtered on per-chain requirements.
Definition NavGraph.h:98
const Decision * m_decisionObject
The Decision object node which I shadow.
Definition NavGraph.h:97
static bool addIfNotDuplicate(std::vector< NavGraphNode * > &container, NavGraphNode *toAdd)
Internal helper function.
Definition NavGraph.cxx:19
bool linksTo(NavGraphNode *to)
Form an edge in the graph from this node to another one.
Definition NavGraph.cxx:29
void dropLinks(NavGraphNode *node)
Forget about any graph edges to the supplied node.
Definition NavGraph.cxx:35
std::vector< NavGraphNode * > m_filteredChildren
Two-way linking information, used when thinning the graph.
Definition NavGraph.h:99
bool m_keepFlag
Keep this node when slimming the NavGraph.
Definition NavGraph.h:100
NavGraphNode(const Decision *me)
Construct a NavGraphNode shadowing a node in the full xAOD navigation graph.
Definition NavGraph.cxx:15
void resetKeep()
Reset the keep flag to false upon finishing thinning.
Definition NavGraph.cxx:60
void keep()
Flag this node as one to keep when the thin() operation is performed.
Definition NavGraph.cxx:55
~NavGraphNode()=default
Destruct a NavGraphNode, default.
const std::vector< NavGraphNode * > & seeds() const
Return a vector of const pointers to the Decision object nodes which this NavGraphNode seeds from.
Definition NavGraph.cxx:46
const Decision * node() const
Return a const pointer to the Decision object node which this NavGraphNode is shadowing.
Definition NavGraph.cxx:41
NavGraphNode(const NavGraphNode &obj)=delete
Prevent copies of a NavGraphNode.
std::vector< NavGraphNode * > allNodes()
Get all nodes.
Definition NavGraph.cxx:103
void addNode(const Decision *node, const Decision *comingFrom=nullptr)
Add a new NavGraphNode which shadows the xAOD Decision object "node" from the full navigation graph.
Definition NavGraph.cxx:73
std::vector< NavGraphNode * > m_finalNodes
Entry points into the navigation graph.
Definition NavGraph.h:213
const std::vector< NavGraphNode * > & finalNodes() const
Get all final nodes.
Definition NavGraph.cxx:99
std::map< const Decision *, size_t > m_nodePositionMap
Map of Decision pointer and index of the node(that contains the Decision) in m_nodes.
Definition NavGraph.h:211
void printAllPaths(MsgStream &log, MSG::Level msgLevel=MSG::VERBOSE) const
Helper function.
Definition NavGraph.cxx:165
void recursivePrintNavPath(const NavGraphNode &nav, size_t level, MsgStream &log, MSG::Level msgLevel) const
@bried Internal helper function.
Definition NavGraph.cxx:172
std::vector< std::unique_ptr< NavGraphNode > > m_nodes
Vector of unique pointers to nodes in the graph.
Definition NavGraph.h:212
NavGraph()=default
Construct an empty NavGraph.
NavGraph(NavGraph &&obj)=delete
Prevent move of a NavGraphNode.
NavGraph(const NavGraph &obj)=delete
Prevent copy of a NavGraphNode.
size_t m_edges
Statistics on the number of edges, connecting the nodes in the graph.
Definition NavGraph.h:214
~NavGraph()=default
Destruct a NavGraph, default.
std::vector< const Decision * > thin()
Perform thinning.
Definition NavGraph.cxx:123
void rewireNodeForRemoval(NavGraphNode &toBeDeleted)
Take all seeds (parents) of the supplied node and connect them to all the node's children.
Definition NavGraph.cxx:139
Definition node.h:24