ATLAS Offline Software
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 
13 namespace TrigCompositeUtils {
14 
20  class NavGraphNode {
21  public:
26  NavGraphNode(const Decision* me);
27 
31  ~NavGraphNode() = default;
32 
36  NavGraphNode(const NavGraphNode& obj) = delete;
37 
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;
101 
102  };
103 
111  class NavGraph {
112 
113  public:
114 
118  NavGraph();
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;
215  };
216 
217 }
218 
219 #endif // TrigCompositeUtils_NavGraph_h
TrigCompositeUtils::NavGraphNode::~NavGraphNode
~NavGraphNode()=default
Destruct a NavGraphNode, default.
TrigCompositeUtils::NavGraphNode::linksTo
bool linksTo(NavGraphNode *to)
Form an edge in the graph from this node to another one.
Definition: NavGraph.cxx:30
TrigCompositeUtils::NavGraphNode::NavGraphNode
NavGraphNode(const NavGraphNode &obj)=delete
Prevent copies of a NavGraphNode.
TrigCompositeUtils::NavGraph::recursivePrintNavPath
void recursivePrintNavPath(const NavGraphNode &nav, size_t level, MsgStream &log, MSG::Level msgLevel) const
@bried Internal helper function.
Definition: NavGraph.cxx:173
TrigCompositeUtils::NavGraph::~NavGraph
~NavGraph()=default
Destruct a NavGraph, default.
TrigCompositeUtils::NavGraph::finalNodes
const std::vector< NavGraphNode * > & finalNodes() const
Get all final nodes.
Definition: NavGraph.cxx:100
TrigCompositeUtils::NavGraphNode::seeds
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:47
TrigCompositeUtils::NavGraph::m_edges
size_t m_edges
Statistics on the number of edges, connecting the nodes in the graph.
Definition: NavGraph.h:214
TrigCompositeUtils::NavGraph::allNodes
std::vector< NavGraphNode * > allNodes()
Get all nodes.
Definition: NavGraph.cxx:104
TrigCompositeUtils::NavGraph::addNode
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:78
TrigCompositeUtils::NavGraph::printAllPaths
void printAllPaths(MsgStream &log, MSG::Level msgLevel=MSG::VERBOSE) const
Helper function.
Definition: NavGraph.cxx:166
TrigCompositeUtils::NavGraphNode::dropLinks
void dropLinks(NavGraphNode *node)
Forget about any graph edges to the supplied node.
Definition: NavGraph.cxx:36
TrigCompositeUtils::NavGraph::m_nodes
std::vector< std::unique_ptr< NavGraphNode > > m_nodes
Vector of unique pointers to nodes in the graph.
Definition: NavGraph.h:212
TrigCompositeUtils::NavGraph::edges
size_t edges() const
Definition: NavGraph.cxx:120
TrigCompositeUtils::NavGraphNode::NavGraphNode
NavGraphNode(const Decision *me)
Construct a NavGraphNode shadowing a node in the full xAOD navigation graph.
Definition: NavGraph.cxx:15
TrigCompositeUtils::NavGraphNode::children
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:51
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TrigCompositeUtils::NavGraphNode::m_keepFlag
bool m_keepFlag
Keep this node when slimming the NavGraph.
Definition: NavGraph.h:100
TrigCompositeUtils::NavGraph::nodes
size_t nodes() const
Definition: NavGraph.cxx:115
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
TrigCompositeUtils::NavGraph
Structure to hold a transient Directed Acyclic Graph (DAG) structure. NavGraph is populated from,...
Definition: NavGraph.h:111
TrigCompositeUtils::NavGraphNode::m_decisionObject
const Decision * m_decisionObject
The Decision object node which I shadow.
Definition: NavGraph.h:97
TrigCompositeUtils::NavGraph::NavGraph
NavGraph()
Construct an empty NavGraph.
Definition: NavGraph.cxx:74
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DeMoUpdate.toAdd
bool toAdd
Definition: DeMoUpdate.py:1304
TrigCompositeUtils::NavGraphNode::resetKeep
void resetKeep()
Reset the keep flag to false upon finishing thinning.
Definition: NavGraph.cxx:61
TrigCompositeAuxContainer.h
TrigCompositeContainer.h
TrigCompositeUtils::NavGraphNode::NavGraphNode
NavGraphNode(NavGraphNode &&obj)=delete
Prevent move of a NavGraphNode.
TrigCompositeUtils::NavGraph::rewireNodeForRemoval
void rewireNodeForRemoval(NavGraphNode &toBeDeleted)
Take all seeds (parents) of the supplied node and connect them to all the node's children.
Definition: NavGraph.cxx:140
TrigCompositeUtils::NavGraphNode::node
const Decision * node() const
Return a const pointer to the Decision object node which this NavGraphNode is shadowing.
Definition: NavGraph.cxx:42
TrigCompositeUtils::NavGraph::NavGraph
NavGraph(NavGraph &&obj)=delete
Prevent move of a NavGraphNode.
TrigCompositeUtils::NavGraph::m_nodePositionMap
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
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:39
TrigCompositeUtils::NavGraph::m_finalNodes
std::vector< NavGraphNode * > m_finalNodes
Entry points into the navigation graph.
Definition: NavGraph.h:213
TrigCompositeUtils::NavGraphNode::getKeep
bool getKeep() const
Definition: NavGraph.cxx:66
TrigCompositeUtils::NavGraphNode
Transient utility class to represent a node in a graph (m_decisionObject), and a vector of edges (m_f...
Definition: NavGraph.h:20
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigCompositeUtils::NavGraphNode::keep
void keep()
Flag this node as one to keep when the thin() operation is performed.
Definition: NavGraph.cxx:56
TrigCompositeUtils::NavGraphNode::m_filteredSeeds
std::vector< NavGraphNode * > m_filteredSeeds
My seeds (edges in the graph), filtered on per-chain requirements.
Definition: NavGraph.h:98
TrigCompositeUtils::NavGraphNode::addIfNotDuplicate
static bool addIfNotDuplicate(std::vector< NavGraphNode * > &container, NavGraphNode *toAdd)
Internal helper function.
Definition: NavGraph.cxx:20
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigCompositeUtils::NavGraphNode::m_filteredChildren
std::vector< NavGraphNode * > m_filteredChildren
Two-way linking information, used when thinning the graph.
Definition: NavGraph.h:99
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
python.PyAthena.obj
obj
Definition: PyAthena.py:132
TrigCompositeUtils::NavGraph::NavGraph
NavGraph(const NavGraph &obj)=delete
Prevent copy of a NavGraphNode.
TrigCompositeUtils::NavGraph::thin
std::vector< const Decision * > thin()
Perform thinning.
Definition: NavGraph.cxx:124
node
Definition: memory_hooks-stdcmalloc.h:74
AuxElement.h
Base class for elements of a container that can have aux data.