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

#include <InputPreprocessor.h>

Collaboration diagram for lwtDev::InputVectorPreprocessor:

Public Member Functions

 InputVectorPreprocessor (const std::vector< Input > &inputs)
 
MatrixXd operator() (const VectorMap &) const
 

Private Attributes

VectorXd m_offsets
 
VectorXd m_scales
 
std::vector< std::string > m_names
 

Detailed Description

Definition at line 41 of file InputPreprocessor.h.

Constructor & Destructor Documentation

◆ InputVectorPreprocessor()

lwtDev::InputVectorPreprocessor::InputVectorPreprocessor ( const std::vector< Input > &  inputs)

Definition at line 39 of file InputPreprocessor.cxx.

40  :
41  m_offsets(inputs.size()),
42  m_scales(inputs.size())
43  {
44  size_t in_num = 0;
45  for (const auto& input: inputs) {
46  m_offsets(in_num) = input.offset;
47  m_scales(in_num) = input.scale;
48  m_names.push_back(input.name);
49  in_num++;
50  }
51  // require at least one input at configuration, since we require
52  // at least one for evaluation
53  if (in_num == 0) {
54  throw NNConfigurationException("need at least one input");
55  }
56  }

Member Function Documentation

◆ operator()()

MatrixXd lwtDev::InputVectorPreprocessor::operator() ( const VectorMap in) const

Definition at line 57 of file InputPreprocessor.cxx.

57  {
58  using namespace Eigen;
59  if (in.size() == 0) {
60  throw NNEvaluationException("Empty input map");
61  }
62  size_t n_cols = in.begin()->second.size();
63  MatrixXd inmat(m_names.size(), n_cols);
64  size_t in_num = 0;
65  for (const auto& in_name: m_names) {
66  if (!in.count(in_name)) {
67  throw NNEvaluationException("can't find input: " + in_name);
68  }
69  const auto& invec = in.at(in_name);
70  if (invec.size() != n_cols) {
71  throw NNEvaluationException("Input vector size mismatch");
72  }
73  inmat.row(in_num) = Map<const VectorXd>(invec.data(), invec.size());
74  in_num++;
75  }
76  if (n_cols == 0) {
77  return MatrixXd(m_names.size(), 0);
78  }
79  return m_scales.asDiagonal() * (inmat.colwise() + m_offsets);
80  }

Member Data Documentation

◆ m_names

std::vector<std::string> lwtDev::InputVectorPreprocessor::m_names
private

Definition at line 50 of file InputPreprocessor.h.

◆ m_offsets

VectorXd lwtDev::InputVectorPreprocessor::m_offsets
private

Definition at line 48 of file InputPreprocessor.h.

◆ m_scales

VectorXd lwtDev::InputVectorPreprocessor::m_scales
private

Definition at line 49 of file InputPreprocessor.h.


The documentation for this class was generated from the following files:
lwtDev::InputVectorPreprocessor::m_names
std::vector< std::string > m_names
Definition: InputPreprocessor.h:50
lwtDev::InputVectorPreprocessor::m_scales
VectorXd m_scales
Definition: InputPreprocessor.h:49
lwtDev::InputVectorPreprocessor::m_offsets
VectorXd m_offsets
Definition: InputPreprocessor.h:48
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106