ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrigCompositeUtils::NavGraph Class Reference

Structure to hold a transient Directed Acyclic Graph (DAG) structure. NavGraph is populated from, and forms a sub-graph over the full Run 3 trigger navigation graph in a single event. Requirements on specific chains, and the specification of allowable graph entry-points are considered in the construction of the NavGraph sub-graph. Once one of these sub-graphs is fully populated to a given specification, it is searched by the feature-retrieval code to find features. More...

#include <NavGraph.h>

Collaboration diagram for TrigCompositeUtils::NavGraph:

Public Member Functions

 NavGraph ()
 Construct an empty NavGraph. More...
 
void addNode (const Decision *node, const EventContext &ctx, const Decision *comingFrom=nullptr)
 Add a new NavGraphNode which shadows the xAOD Decision object "node" from the full navigation graph. More...
 
std::vector< NavGraphNode * > finalNodes () const
 Get all final nodes. More...
 
std::vector< NavGraphNode * > allNodes ()
 Get all nodes. More...
 
size_t nodes () const
 
size_t edges () const
 
std::vector< const Decision * > thin ()
 Perform thinning. More...
 
void printAllPaths (MsgStream &log, MSG::Level msgLevel=MSG::VERBOSE) const
 Helper function. More...
 

Private Member Functions

void rewireNodeForRemoval (NavGraphNode &toBeDeleted)
 Take all seeds (parents) of the supplied node and connect them to all the node's children. More...
 
void recursivePrintNavPath (const NavGraphNode &nav, size_t level, MsgStream &log, MSG::Level msgLevel) const
 @bried Internal helper function. More...
 

Private Attributes

std::map< const ElementLink< TrigCompositeUtils::DecisionContainer >, NavGraphNodem_nodes
 Map of nodes in the graph. More...
 
std::vector< NavGraphNode * > m_finalNodes
 Entry points into the navigation graph. More...
 
size_t m_edges
 Statistics on the number of edges, connecting the nodes in the graph. More...
 

Detailed Description

Structure to hold a transient Directed Acyclic Graph (DAG) structure. NavGraph is populated from, and forms a sub-graph over the full Run 3 trigger navigation graph in a single event. Requirements on specific chains, and the specification of allowable graph entry-points are considered in the construction of the NavGraph sub-graph. Once one of these sub-graphs is fully populated to a given specification, it is searched by the feature-retrieval code to find features.

Definition at line 98 of file NavGraph.h.

Constructor & Destructor Documentation

◆ NavGraph()

TrigCompositeUtils::NavGraph::NavGraph ( )

Construct an empty NavGraph.

Definition at line 75 of file NavGraph.cxx.

75  : m_nodes(), m_finalNodes(), m_edges(0) {
76  }

Member Function Documentation

◆ addNode()

void TrigCompositeUtils::NavGraph::addNode ( const Decision node,
const EventContext &  ctx,
const Decision comingFrom = nullptr 
)

Add a new NavGraphNode which shadows the xAOD Decision object "node" from the full navigation graph.

Parameters
[in]nodeThe xAOD Decision object which the new node will shadow. Will not cause duplication if node has already been added.
[in]ctxThe event context.
[in]comingFromIf not null, used to indicate which xAOD Decision object was the seed of "node". This is used to form an edge in the graph. Alternately, if comingFrom is null then "node" is taken as a final node (one of the locations from which the graph should be explored) and hence is added to the finalNodes vector.

Definition at line 79 of file NavGraph.cxx.

79  {
80 
82  auto nodePairIt = m_nodes.insert( std::make_pair(nodeEL, NavGraphNode(node)) );
83  NavGraphNode& nodeObj = nodePairIt.first->second;
84 
85  if (comingFrom == nullptr) { // Not coming from anywhere - hence a final node.
86  m_finalNodes.push_back( &nodeObj );
87  } else {
88  const ElementLink<DecisionContainer> comingFromEL = decisionToElementLink(comingFrom, ctx);
89  auto comingFromPairIt = m_nodes.insert( std::make_pair(comingFromEL, NavGraphNode(comingFrom)) );
90  NavGraphNode& comingFromNodeObj = comingFromPairIt.first->second;
91  const bool newEdge = comingFromNodeObj.linksTo( &nodeObj );
92  if (newEdge) {
93  ++m_edges;
94  }
95  }
96  }

◆ allNodes()

std::vector< NavGraphNode * > TrigCompositeUtils::NavGraph::allNodes ( )

Get all nodes.

Returns
Vector of all nodes. Including all final, intermediate, and initial nodes.

Definition at line 103 of file NavGraph.cxx.

103  {
104  std::vector<NavGraphNode*> returnVec;
105  returnVec.reserve(m_nodes.size());
106  for (auto& entry : m_nodes) {
107  NavGraphNode& n = entry.second;
108  returnVec.push_back( &n );
109  }
110  return returnVec;
111  }

◆ edges()

size_t TrigCompositeUtils::NavGraph::edges ( ) const
Returns
Total number of edges in the NavGraph.

Definition at line 119 of file NavGraph.cxx.

119  {
120  return m_edges;
121  }

◆ finalNodes()

std::vector< NavGraphNode * > TrigCompositeUtils::NavGraph::finalNodes ( ) const

Get all final nodes.

Returns
Vector of final nodes. These are the nodes which were added without any "comingFrom". To explore the NavGraph fully, one should explore recursively all paths originating from each of the final nodes.

Definition at line 99 of file NavGraph.cxx.

99  {
100  return m_finalNodes;
101  }

◆ nodes()

size_t TrigCompositeUtils::NavGraph::nodes ( ) const
Returns
Total number of nodes in the NavGraph.

Definition at line 114 of file NavGraph.cxx.

114  {
115  return m_nodes.size();
116  }

◆ printAllPaths()

void TrigCompositeUtils::NavGraph::printAllPaths ( MsgStream &  log,
MSG::Level  msgLevel = MSG::VERBOSE 
) const

Helper function.

Print the internal graph structure to the terminal.

Parameters
[in]logAthena messaging service reference.
[in]msgLevelAthena messaging service verbosity level.

Definition at line 165 of file NavGraph.cxx.

165  {
166  for (const NavGraphNode* finalNode : m_finalNodes) {
167  recursivePrintNavPath(*finalNode, 0, log, msgLevel);
168  }
169  }

◆ recursivePrintNavPath()

void TrigCompositeUtils::NavGraph::recursivePrintNavPath ( const NavGraphNode nav,
size_t  level,
MsgStream &  log,
MSG::Level  msgLevel 
) const
private

@bried Internal helper function.

Recursively print the graph structure from a single given starting node.

Parameters
[in]navThe node to recursively explore.
[in]levelThe current depth of recursion. Used to pad output format.
[in]logAthena messaging service reference.
[in]msgLevelAthena messaging service verbosity level.

Definition at line 172 of file NavGraph.cxx.

172  {
173  const Decision* node = nav.node();
175  std::stringstream ss;
176  for (size_t i = 0; i < level; ++i) {
177  ss << " ";
178  }
179 
180  ss << "|-> " << nodeEL.dataID() << " #" << nodeEL.index() << " Name(" << node->name() << ") Passing(" << node->decisions().size() << ")";
181  if (nav.getKeep()) ss << " [KEEP]";
182  if (node->hasObjectLink(featureString())) {
184  uint32_t clid;
185  uint16_t index;
186  node->typelessGetObjectLink(featureString(), key, clid, index);
187 #ifndef XAOD_STANDALONE // Athena or AthAnalysis
188  ss << " Feature(#" << index << ", " << CLIDRegistry::CLIDToTypeinfo(clid)->name() << ", " << key << ")";
189 #else
190  ss << " Feature(#" << index << ", " << key << ")";
191 #endif
192  }
193  if (node->hasObjectLink(viewString())) ss << " [View]";
194  if (node->hasObjectLink(roiString())) ss << " [RoI]";
195  if (node->hasObjectLink(initialRoIString())) ss << " [InitialRoI]";
196  log << msgLevel << ss.str() << endmsg;
197  for (const NavGraphNode* seed : nav.seeds()) {
198  recursivePrintNavPath(*seed, level + 1, log, msgLevel);
199  }
200  }

◆ rewireNodeForRemoval()

void TrigCompositeUtils::NavGraph::rewireNodeForRemoval ( NavGraphNode toBeDeleted)
private

Take all seeds (parents) of the supplied node and connect them to all the node's children.

Unlink the parents and children from the node. For the case of Parent nodes, P, node to be deleted, N, and Child nodes, C, this function converts from P P P P P P | \ / | \ / N , N , N , N | | / \ / \ C C C C C C to P P P P P P | \ / | |\ /| | , | , | , | | | | | / \ |/ | C C C C C C where N is orphaned from the graph, with no parents or children.

Parameters
[in]toBeDeletedNode to rewire out of the navigation graph prior to its removal.

Definition at line 139 of file NavGraph.cxx.

139  {
140  const std::vector<NavGraphNode*> myParents = toBeDeleted.seeds();
141  const std::vector<NavGraphNode*> myChildren = toBeDeleted.children();
142 
143  // Perform the (potentially) many-to-many re-linking required to remove toBeDeleted from the graph
144  for (NavGraphNode* child : myChildren) {
145  for (NavGraphNode* parent : myParents) {
146  bool newEdge = child->linksTo(parent);
147  if (newEdge) {
148  ++m_edges;
149  }
150  }
151  }
152 
153  // Remove the edges connecting to toBeDeleted from all of its children and all of parents
154  for (NavGraphNode* child : myChildren) {
155  child->dropLinks(&toBeDeleted);
156  --m_edges;
157  }
158  for (NavGraphNode* parent : myParents) {
159  parent->dropLinks(&toBeDeleted);
160  --m_edges;
161  }
162  }

◆ thin()

std::vector< const Decision * > TrigCompositeUtils::NavGraph::thin ( )

Perform thinning.

Removing all nodes which are not explicitly flagged as keep(), after having re-wired them out of the graph.

Returns
A vector of the Decision* behind the NavGraphNodes which were thinned from the NavGraph.

Definition at line 123 of file NavGraph.cxx.

123  {
124  std::vector<const Decision*> returnVec;
125  std::map<const ElementLink<TrigCompositeUtils::DecisionContainer>, NavGraphNode>::iterator it;
126  for (it = m_nodes.begin(); it != m_nodes.end(); /*noop*/) {
127  if (it->second.getKeep()) {
128  it->second.resetKeep();
129  ++it;
130  } else {
131  returnVec.push_back(*(it->first)); // Dereferencing ElementLink to element
132  rewireNodeForRemoval(it->second);
133  it = m_nodes.erase(it);
134  }
135  }
136  return returnVec;
137  }

Member Data Documentation

◆ m_edges

size_t TrigCompositeUtils::NavGraph::m_edges
private

Statistics on the number of edges, connecting the nodes in the graph.

Definition at line 186 of file NavGraph.h.

◆ m_finalNodes

std::vector<NavGraphNode*> TrigCompositeUtils::NavGraph::m_finalNodes
private

Entry points into the navigation graph.

When iterating over the graph, start from all of these places.

Definition at line 185 of file NavGraph.h.

◆ m_nodes

std::map<const ElementLink<TrigCompositeUtils::DecisionContainer>, NavGraphNode> TrigCompositeUtils::NavGraph::m_nodes
private

Map of nodes in the graph.

Indexed on the underlying Decision object's ElementLink.

Definition at line 184 of file NavGraph.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TrigCompositeUtils::NavGraph::recursivePrintNavPath
void recursivePrintNavPath(const NavGraphNode &nav, size_t level, MsgStream &log, MSG::Level msgLevel) const
@bried Internal helper function.
Definition: NavGraph.cxx:172
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TrigCompositeUtils::NavGraph::m_edges
size_t m_edges
Statistics on the number of edges, connecting the nodes in the graph.
Definition: NavGraph.h:186
CLIDRegistry::CLIDToTypeinfo
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
Definition: CLIDRegistry.cxx:136
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigCompositeUtils::initialRoIString
const std::string & initialRoIString()
Definition: TrigCompositeUtilsRoot.cxx:870
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TrigCompositeUtils::decisionToElementLink
ElementLink< DecisionContainer > decisionToElementLink(const Decision *d, const EventContext &ctx)
Takes a raw pointer to a Decision and returns an ElementLink to the Decision.
Definition: TrigCompositeUtilsRoot.cxx:122
test_pyathena.parent
parent
Definition: test_pyathena.py:15
node::node
node()
Definition: memory_hooks-stdcmalloc.h:76
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
node::name
void name(const std::string &n)
Definition: node.h:38
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
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:139
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
DeMoScan.index
string index
Definition: DeMoScan.py:362
TrigCompositeUtils::NavGraph::m_finalNodes
std::vector< NavGraphNode * > m_finalNodes
Entry points into the navigation graph.
Definition: NavGraph.h:185
TrigCompositeUtils::NavGraph::m_nodes
std::map< const ElementLink< TrigCompositeUtils::DecisionContainer >, NavGraphNode > m_nodes
Map of nodes in the graph.
Definition: NavGraph.h:184
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882
node
Definition: memory_hooks-stdcmalloc.h:74
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37