ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lwtDev::LightweightGraph Class Reference

#include <LightweightGraph.h>

Collaboration diagram for lwtDev::LightweightGraph:

Public Types

typedef std::map< std::string, ValueMapNodeMap
 
typedef std::map< std::string, VectorMapSeqNodeMap
 

Public Member Functions

 LightweightGraph (const GraphConfig &config, const std::string &default_output="")
 
 ~LightweightGraph ()
 
 LightweightGraph (LightweightGraph &)=delete
 
LightweightGraphoperator= (LightweightGraph &)=delete
 
ValueMap compute (const NodeMap &, const SeqNodeMap &={}) const
 
ValueMap compute (const NodeMap &, const SeqNodeMap &, const std::string &output) const
 
VectorMap scan (const NodeMap &, const SeqNodeMap &={}) const
 
VectorMap scan (const NodeMap &, const SeqNodeMap &, const std::string &output) const
 

Private Types

typedef InputPreprocessor IP
 
typedef InputVectorPreprocessor IVP
 
typedef std::vector< std::pair< std::string, IP * > > Preprocs
 
typedef std::vector< std::pair< std::string, IVP * > > VecPreprocs
 

Private Member Functions

ValueMap compute (const NodeMap &, const SeqNodeMap &, size_t) const
 
VectorMap scan (const NodeMap &, const SeqNodeMap &, size_t) const
 

Private Attributes

Graphm_graph
 
Preprocs m_preprocs
 
VecPreprocs m_vec_preprocs
 
std::vector< std::pair< size_t, std::vector< std::string > > > m_outputs
 
std::map< std::string, size_t > m_output_indices
 
size_t m_default_output
 

Detailed Description

Definition at line 64 of file LightweightGraph.h.

Member Typedef Documentation

◆ IP

Definition at line 98 of file LightweightGraph.h.

◆ IVP

Definition at line 99 of file LightweightGraph.h.

◆ NodeMap

typedef std::map<std::string, ValueMap> lwtDev::LightweightGraph::NodeMap

Definition at line 68 of file LightweightGraph.h.

◆ Preprocs

typedef std::vector<std::pair<std::string, IP*> > lwtDev::LightweightGraph::Preprocs
private

Definition at line 100 of file LightweightGraph.h.

◆ SeqNodeMap

typedef std::map<std::string, VectorMap> lwtDev::LightweightGraph::SeqNodeMap

Definition at line 69 of file LightweightGraph.h.

◆ VecPreprocs

typedef std::vector<std::pair<std::string, IVP*> > lwtDev::LightweightGraph::VecPreprocs
private

Definition at line 101 of file LightweightGraph.h.

Constructor & Destructor Documentation

◆ LightweightGraph() [1/2]

lwtDev::LightweightGraph::LightweightGraph ( const GraphConfig config,
const std::string &  default_output = "" 
)

Definition at line 68 of file LightweightGraph.cxx.

69  :
70  m_graph(new Graph(config.nodes, config.layers))
71  {
72  for (const auto& node: config.inputs) {
73  m_preprocs.emplace_back(
74  node.name, new InputPreprocessor(node.variables));
75  }
76  for (const auto& node: config.input_sequences) {
77  m_vec_preprocs.emplace_back(
78  node.name, new InputVectorPreprocessor(node.variables));
79  }
80  size_t output_n = 0;
81  for (const auto& node: config.outputs) {
82  m_outputs.emplace_back(node.second.node_index, node.second.labels);
83  m_output_indices.emplace(node.first, output_n);
84  output_n++;
85  }
86  if (default_output.size() > 0) {
87  if (!m_output_indices.count(default_output)) {
88  throw NNConfigurationException("no output node" + default_output);
89  }
90  m_default_output = m_output_indices.at(default_output);
91  } else if (output_n == 1) {
92  m_default_output = 0;
93  } else {
94  throw NNConfigurationException("you must specify a default output");
95  }
96  }

◆ ~LightweightGraph()

lwtDev::LightweightGraph::~LightweightGraph ( )

Definition at line 98 of file LightweightGraph.cxx.

98  {
99  delete m_graph;
100  for (auto& preproc: m_preprocs) {
101  delete preproc.second;
102  preproc.second = 0;
103  }
104  for (auto& preproc: m_vec_preprocs) {
105  delete preproc.second;
106  preproc.second = 0;
107  }
108  }

◆ LightweightGraph() [2/2]

lwtDev::LightweightGraph::LightweightGraph ( LightweightGraph )
delete

Member Function Documentation

◆ compute() [1/3]

ValueMap lwtDev::LightweightGraph::compute ( const NodeMap nodes,
const SeqNodeMap seq,
const std::string &  output 
) const

Definition at line 114 of file LightweightGraph.cxx.

116  {
117  if (!m_output_indices.count(output)) {
118  throw NNEvaluationException("no output node " + output);
119  }
120  return compute(nodes, seq, m_output_indices.at(output));
121  }

◆ compute() [2/3]

ValueMap lwtDev::LightweightGraph::compute ( const NodeMap nodes,
const SeqNodeMap seq,
size_t  idx 
) const
private

Definition at line 122 of file LightweightGraph.cxx.

124  {
125  LazySource source(nodes, seq, m_preprocs, m_vec_preprocs);
126  VectorXd result = m_graph->compute(source, m_outputs.at(idx).first);
127  const std::vector<std::string>& labels = m_outputs.at(idx).second;
128  std::map<std::string, double> output;
129  for (size_t iii = 0; iii < labels.size(); iii++) {
130  output[labels.at(iii)] = result(iii);
131  }
132  return output;
133  }

◆ compute() [3/3]

ValueMap lwtDev::LightweightGraph::compute ( const NodeMap nodes,
const SeqNodeMap seq = {} 
) const

Definition at line 110 of file LightweightGraph.cxx.

111  {
112  return compute(nodes, seq, m_default_output);
113  }

◆ operator=()

LightweightGraph& lwtDev::LightweightGraph::operator= ( LightweightGraph )
delete

◆ scan() [1/3]

VectorMap lwtDev::LightweightGraph::scan ( const NodeMap nodes,
const SeqNodeMap seq,
const std::string &  output 
) const

Definition at line 139 of file LightweightGraph.cxx.

141  {
142  if (!m_output_indices.count(output)) {
143  throw NNEvaluationException("no output node " + output);
144  }
145  return scan(nodes, seq, m_output_indices.at(output));
146  }

◆ scan() [2/3]

VectorMap lwtDev::LightweightGraph::scan ( const NodeMap nodes,
const SeqNodeMap seq,
size_t  idx 
) const
private

Definition at line 147 of file LightweightGraph.cxx.

149  {
150  LazySource source(nodes, seq, m_preprocs, m_vec_preprocs);
151  MatrixXd result = m_graph->scan(source, m_outputs.at(idx).first);
152  const std::vector<std::string>& labels = m_outputs.at(idx).second;
153  std::map<std::string, std::vector<double> > output;
154  for (size_t iii = 0; iii < labels.size(); iii++) {
155  VectorXd row = result.row(iii);
156  std::vector<double> out_vector(row.data(), row.data() + row.size());
157  output[labels.at(iii)] = out_vector;
158  }
159  return output;
160  }

◆ scan() [3/3]

VectorMap lwtDev::LightweightGraph::scan ( const NodeMap nodes,
const SeqNodeMap seq = {} 
) const

Definition at line 135 of file LightweightGraph.cxx.

136  {
137  return scan(nodes, seq, m_default_output);
138  }

Member Data Documentation

◆ m_default_output

size_t lwtDev::LightweightGraph::m_default_output
private

Definition at line 110 of file LightweightGraph.h.

◆ m_graph

Graph* lwtDev::LightweightGraph::m_graph
private

Definition at line 105 of file LightweightGraph.h.

◆ m_output_indices

std::map<std::string, size_t> lwtDev::LightweightGraph::m_output_indices
private

Definition at line 109 of file LightweightGraph.h.

◆ m_outputs

std::vector<std::pair<size_t, std::vector<std::string> > > lwtDev::LightweightGraph::m_outputs
private

Definition at line 108 of file LightweightGraph.h.

◆ m_preprocs

Preprocs lwtDev::LightweightGraph::m_preprocs
private

Definition at line 106 of file LightweightGraph.h.

◆ m_vec_preprocs

VecPreprocs lwtDev::LightweightGraph::m_vec_preprocs
private

Definition at line 107 of file LightweightGraph.h.


The documentation for this class was generated from the following files:
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
query_example.row
row
Definition: query_example.py:24
get_generator_info.result
result
Definition: get_generator_info.py:21
lwtDev::InputPreprocessor
Definition: InputPreprocessor.h:30
lwtDev::InputVectorPreprocessor
Definition: InputPreprocessor.h:42
lwtDev::LightweightGraph::m_graph
Graph * m_graph
Definition: LightweightGraph.h:105
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
lwtDev::NNConfigurationException
Definition: Reconstruction/tauRecTools/tauRecTools/lwtnn/Exceptions.h:21
lwtDev::LightweightGraph::m_preprocs
Preprocs m_preprocs
Definition: LightweightGraph.h:106
lwtDev::Graph
Definition: Graph.h:120
beamspotnt.labels
list labels
Definition: bin/beamspotnt.py:1447
lwtDev::LightweightGraph::m_outputs
std::vector< std::pair< size_t, std::vector< std::string > > > m_outputs
Definition: LightweightGraph.h:108
lwtDev::LightweightGraph::compute
ValueMap compute(const NodeMap &, const SeqNodeMap &={}) const
Definition: LightweightGraph.cxx:110
merge.output
output
Definition: merge.py:17
node::name
void name(const std::string &n)
Definition: node.h:38
lwtDev::NNEvaluationException
Definition: Reconstruction/tauRecTools/tauRecTools/lwtnn/Exceptions.h:27
lwtDev::LightweightGraph::m_vec_preprocs
VecPreprocs m_vec_preprocs
Definition: LightweightGraph.h:107
lwtDev::LightweightGraph::scan
VectorMap scan(const NodeMap &, const SeqNodeMap &={}) const
Definition: LightweightGraph.cxx:135
lwtDev::Graph::compute
VectorXd compute(const ISource &, size_t node_number) const
Definition: Graph.cxx:315
lwtDev::LightweightGraph::m_output_indices
std::map< std::string, size_t > m_output_indices
Definition: LightweightGraph.h:109
lwtDev::Graph::scan
MatrixXd scan(const ISource &, size_t node_number) const
Definition: Graph.cxx:332
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
node
Definition: memory_hooks-stdcmalloc.h:74
lwtDev::LightweightGraph::m_default_output
size_t m_default_output
Definition: LightweightGraph.h:110