ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
JunctionAwareVisitor Class Reference

#include <FPGATrackSimGNNRoadMakerTool.h>

Inheritance diagram for JunctionAwareVisitor:
Collaboration diagram for JunctionAwareVisitor:

Public Member Functions

 JunctionAwareVisitor (int &current, std::vector< int > &in_control_vars, std::vector< std::vector< int >> &in_comps, std::unordered_map< Vertex, std::vector< Vertex >> &in_pred_map)
 
template<typename VertexT , typename GraphT >
void discover_vertex (VertexT v, const GraphT &g)
 
template<typename EdgeT , typename GraphT >
void examine_edge (EdgeT e, const GraphT &g)
 

Private Attributes

int & m_current_comp
 
std::vector< int > & m_control_vars
 
std::vector< std::vector< int > > & m_components
 
std::unordered_map< Vertex, std::vector< Vertex > > & m_pred_map
 
int m_initial_comp
 
int m_n_iter = 1
 

Detailed Description

Definition at line 111 of file FPGATrackSimGNNRoadMakerTool.h.

Constructor & Destructor Documentation

◆ JunctionAwareVisitor()

JunctionAwareVisitor::JunctionAwareVisitor ( int &  current,
std::vector< int > &  in_control_vars,
std::vector< std::vector< int >> &  in_comps,
std::unordered_map< Vertex, std::vector< Vertex >> &  in_pred_map 
)

Definition at line 284 of file FPGATrackSimGNNRoadMakerTool.cxx.

285  :
286  m_current_comp(in_current), m_control_vars(in_control_vars), m_components(in_comps),
287  m_pred_map(in_pred_map), m_initial_comp(in_current) {}

Member Function Documentation

◆ discover_vertex()

template<typename VertexT , typename GraphT >
void JunctionAwareVisitor::discover_vertex ( VertexT  v,
const GraphT &  g 
)

Definition at line 290 of file FPGATrackSimGNNRoadMakerTool.cxx.

291 {
292  if (m_control_vars[v] == -1){
293  m_control_vars[v] = boost:: out_degree(v,g) < 2 ? 1 : -2; // -2 labels junctions before they are transversed
294  m_components[v].push_back(m_current_comp);
295  }
296 }

◆ examine_edge()

template<typename EdgeT , typename GraphT >
void JunctionAwareVisitor::examine_edge ( EdgeT  e,
const GraphT &  g 
)

Definition at line 299 of file FPGATrackSimGNNRoadMakerTool.cxx.

300 {
301  auto src_node = source(e,g);
302  auto tar_node = target(e,g);
303  m_pred_map[tar_node].push_back(src_node);
304 
305  std::vector<int> src_comp; // Store the components of the source that need to be tracked
306 
307  for(int comp : m_components[src_node]){
308  if(comp >= m_initial_comp &&
309  std::find(m_components[tar_node].begin(), m_components[tar_node].end(), comp) == m_components[tar_node].end()){
310  src_comp.push_back(comp); // Components of source node not in target
311  }
312  }
313 
314  // If source node has multiple in-edges, add the components from its predecessors
315  if (boost::in_degree(src_node, g) > 1){
316  auto in_edges = boost::in_edges(src_node, g);
317  for (auto it = in_edges.first; it != in_edges.second; ++it){
318  auto edge_src = source(*it, g);
319  for (int comp : m_components[edge_src]){
320  if((comp >= m_initial_comp) && (std::find(src_comp.begin(), src_comp.end(), comp) == src_comp.end()) &&
321  (std::find(m_components[tar_node].begin(), m_components[tar_node].end(), comp) == m_components[tar_node].end())){
322  src_comp.push_back(comp);
323  }
324  }
325  }
326  }
327 
328  // No junction case
329  if (m_control_vars[src_node] == 1){
330  m_components[tar_node].insert(m_components[tar_node].end(), src_comp.begin(), src_comp.end());
331  m_control_vars[tar_node] = boost::out_degree(tar_node, g) < 2 ? 1 : -2;
332  }
333 
334  // First time visiting a junction
335  else if (m_control_vars[src_node] == -2){
336  m_components[tar_node].insert(m_components[tar_node].end(), src_comp.begin(), src_comp.end());
337  m_control_vars[tar_node] = boost::out_degree(tar_node, g) < 2 ? 1 : -2;
338  m_control_vars[src_node] = 2; // 2 labels a junction after the first visit to it
339  m_n_iter = src_comp.size(); // Number of indices to add to each component going out of this junction
340  }
341 
342  // Going through a junction already visited
343  else if (m_control_vars[src_node] == 2){
344  for(int i = 0; i != m_n_iter; ++i){
345  ++m_current_comp;
346  m_components[tar_node].push_back(m_current_comp);
347  m_control_vars[tar_node] = boost::out_degree(tar_node, g) < 2 ? 1 : -2;
348  // Backtrace the node's predecessors to propagate the new label
349  std::unordered_set<Vertex> visited;
350  std::function<void(Vertex)> backtrace = [&](Vertex node){
351  if(visited.count(node)) return;
352  visited.insert(node);
353  const auto& node_comps = m_components[node];
354  if((std::find(node_comps.begin(), node_comps.end(), m_current_comp) == node_comps.end()) &&
355  (src_comp.empty() || std::find(node_comps.begin(), node_comps.end(), src_comp[i]) == node_comps.end())){ // Backpropagate with junction awareness
356  m_components[node].push_back(m_current_comp);
357  }
358  for (const auto& pred : m_pred_map[node]){
359  backtrace(pred);
360  }
361  };
362  backtrace(tar_node);
363  }
364  }
365 }

Member Data Documentation

◆ m_components

std::vector<std::vector<int> >& JunctionAwareVisitor::m_components
private

Definition at line 126 of file FPGATrackSimGNNRoadMakerTool.h.

◆ m_control_vars

std::vector<int>& JunctionAwareVisitor::m_control_vars
private

Definition at line 125 of file FPGATrackSimGNNRoadMakerTool.h.

◆ m_current_comp

int& JunctionAwareVisitor::m_current_comp
private

Definition at line 124 of file FPGATrackSimGNNRoadMakerTool.h.

◆ m_initial_comp

int JunctionAwareVisitor::m_initial_comp
private

Definition at line 128 of file FPGATrackSimGNNRoadMakerTool.h.

◆ m_n_iter

int JunctionAwareVisitor::m_n_iter = 1
private

Definition at line 129 of file FPGATrackSimGNNRoadMakerTool.h.

◆ m_pred_map

std::unordered_map<Vertex, std::vector<Vertex> >& JunctionAwareVisitor::m_pred_map
private

Definition at line 127 of file FPGATrackSimGNNRoadMakerTool.h.


The documentation for this class was generated from the following files:
plotting.yearwise_luminosity_vs_mu.comp
comp
Definition: yearwise_luminosity_vs_mu.py:23
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
JunctionAwareVisitor::m_current_comp
int & m_current_comp
Definition: FPGATrackSimGNNRoadMakerTool.h:124
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:138
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:407
JunctionAwareVisitor::m_initial_comp
int m_initial_comp
Definition: FPGATrackSimGNNRoadMakerTool.h:128
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
JunctionAwareVisitor::m_control_vars
std::vector< int > & m_control_vars
Definition: FPGATrackSimGNNRoadMakerTool.h:125
JunctionAwareVisitor::m_components
std::vector< std::vector< int > > & m_components
Definition: FPGATrackSimGNNRoadMakerTool.h:126
PyPoolBrowser.node
node
Definition: PyPoolBrowser.py:131
JunctionAwareVisitor::m_n_iter
int m_n_iter
Definition: FPGATrackSimGNNRoadMakerTool.h:129
Vertex
boost::graph_traits< boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS > >::vertex_descriptor Vertex
Definition: FPGATrackSimGNNRoadMakerTool.h:35
JunctionAwareVisitor::m_pred_map
std::unordered_map< Vertex, std::vector< Vertex > > & m_pred_map
Definition: FPGATrackSimGNNRoadMakerTool.h:127
python.PyAthena.v
v
Definition: PyAthena.py:154
copySelective.target
string target
Definition: copySelective.py:36
copySelective.source
string source
Definition: copySelective.py:31
check_log.backtrace
backtrace
Definition: check_log.py:58
node
Definition: node.h:24