LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
anab::FeatureVector< N > Class Template Reference

#include "MVAOutput.h"

Public Member Functions

 FeatureVector ()
 
 FeatureVector (float init)
 
 FeatureVector (std::array< float, N > const &values)
 
 FeatureVector (std::array< double, N > const &values)
 
 FeatureVector (std::vector< float > const &values)
 
 FeatureVector (std::vector< double > const &values)
 
 FeatureVector (float const *values)
 If you really have to use C arrays: More...
 
 FeatureVector (double const *values)
 
FeatureVectoroperator= (float init)
 Assignment operators, from the same types as constructors. More...
 
FeatureVectoroperator= (std::array< float, N > const &values)
 
FeatureVectoroperator= (std::array< double, N > const &values)
 
FeatureVectoroperator= (std::vector< float > const &values)
 
FeatureVectoroperator= (std::vector< double > const &values)
 
size_t size () const
 
float at (size_t index) const
 
float operator[] (size_t index) const
 

Static Public Member Functions

static short Class_Version ()
 

Private Member Functions

void set (float init)
 
void set (std::array< float, N > const &values)
 
void set (std::array< double, N > const &values)
 
void set (std::vector< float > const &values)
 
void set (std::vector< double > const &values)
 

Private Attributes

float fData [N]
 Vector values. More...
 

Friends

std::ostream & operator<< (std::ostream &o, FeatureVector const &a)
 

Detailed Description

template<size_t N>
class anab::FeatureVector< N >

Feature vector of size N. Values are saved as 32bit fp's, this is usually enough for the classification purposes and the precision one can expect from MVA algorithms.

Definition at line 24 of file MVAOutput.h.

Constructor & Destructor Documentation

template<size_t N>
anab::FeatureVector< N >::FeatureVector ( )
inline

Definition at line 26 of file MVAOutput.h.

26 {}
template<size_t N>
anab::FeatureVector< N >::FeatureVector ( float  init)
inline

Definition at line 35 of file MVAOutput.h.

35 { set(init); }
template<size_t N>
anab::FeatureVector< N >::FeatureVector ( std::array< float, N > const &  values)
inline

Definition at line 36 of file MVAOutput.h.

References util::values().

36 { set(values); }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
anab::FeatureVector< N >::FeatureVector ( std::array< double, N > const &  values)
inline

Definition at line 37 of file MVAOutput.h.

References util::values().

37 { set(values); }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
anab::FeatureVector< N >::FeatureVector ( std::vector< float > const &  values)
inline

Definition at line 38 of file MVAOutput.h.

References util::values().

38 { set(values); }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
anab::FeatureVector< N >::FeatureVector ( std::vector< double > const &  values)
inline

Definition at line 39 of file MVAOutput.h.

References util::values().

39 { set(values); }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
anab::FeatureVector< N >::FeatureVector ( float const *  values)
inline

If you really have to use C arrays:

Definition at line 42 of file MVAOutput.h.

43  {
44  for (size_t i = 0; i < N; ++i) {
45  fData[i] = values[i];
46  }
47  }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
float fData[N]
Vector values.
Definition: MVAOutput.h:32
template<size_t N>
anab::FeatureVector< N >::FeatureVector ( double const *  values)
inline

Definition at line 48 of file MVAOutput.h.

49  {
50  for (size_t i = 0; i < N; ++i) {
51  fData[i] = values[i];
52  }
53  }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
float fData[N]
Vector values.
Definition: MVAOutput.h:32

Member Function Documentation

template<size_t N>
float anab::FeatureVector< N >::at ( size_t  index) const
inline

Definition at line 94 of file MVAOutput.h.

Referenced by NuGraphAnalyzer::analyze(), and NuGraphInference::produce().

95  {
96  if (index < N) { return fData[index]; }
97  else {
98  throw cet::exception("FeatureVector") << "Index out of range: " << index << std::endl;
99  }
100  }
float fData[N]
Vector values.
Definition: MVAOutput.h:32
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<size_t N>
static short anab::FeatureVector< N >::Class_Version ( )
inlinestatic

Definition at line 29 of file MVAOutput.h.

29 { return 10; }
template<size_t N>
FeatureVector& anab::FeatureVector< N >::operator= ( float  init)
inline

Assignment operators, from the same types as constructors.

Definition at line 56 of file MVAOutput.h.

57  {
58  set(init);
59  return *this;
60  }
template<size_t N>
FeatureVector& anab::FeatureVector< N >::operator= ( std::array< float, N > const &  values)
inline

Definition at line 61 of file MVAOutput.h.

References util::values().

62  {
63  set(values);
64  return *this;
65  }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
FeatureVector& anab::FeatureVector< N >::operator= ( std::array< double, N > const &  values)
inline

Definition at line 66 of file MVAOutput.h.

References util::values().

67  {
68  set(values);
69  return *this;
70  }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
FeatureVector& anab::FeatureVector< N >::operator= ( std::vector< float > const &  values)
inline

Definition at line 71 of file MVAOutput.h.

References util::values().

72  {
73  set(values);
74  return *this;
75  }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
FeatureVector& anab::FeatureVector< N >::operator= ( std::vector< double > const &  values)
inline

Definition at line 76 of file MVAOutput.h.

References util::values().

77  {
78  set(values);
79  return *this;
80  }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<size_t N>
float anab::FeatureVector< N >::operator[] ( size_t  index) const
inline

Definition at line 102 of file MVAOutput.h.

102 { return fData[index]; }
float fData[N]
Vector values.
Definition: MVAOutput.h:32
template<size_t N>
void anab::FeatureVector< N >::set ( float  init)
inlineprivate

Access the contained array. *** WOULD LIKE TO CHANGE TYPE OF DATA MEMBER TO std::array AND THEN ENABLE THIS FUNCTION ***

Definition at line 109 of file MVAOutput.h.

110  {
111  for (size_t i = 0; i < N; ++i) {
112  fData[i] = init;
113  }
114  }
float fData[N]
Vector values.
Definition: MVAOutput.h:32
template<size_t N>
void anab::FeatureVector< N >::set ( std::array< float, N > const &  values)
inlineprivate

Definition at line 115 of file MVAOutput.h.

References util::values().

116  {
117  for (size_t i = 0; i < N; ++i) {
118  fData[i] = values[i];
119  }
120  }
float fData[N]
Vector values.
Definition: MVAOutput.h:32
template<size_t N>
void anab::FeatureVector< N >::set ( std::array< double, N > const &  values)
inlineprivate

Definition at line 121 of file MVAOutput.h.

References util::values().

122  {
123  for (size_t i = 0; i < N; ++i) {
124  fData[i] = values[i];
125  }
126  }
float fData[N]
Vector values.
Definition: MVAOutput.h:32
template<size_t N>
void anab::FeatureVector< N >::set ( std::vector< float > const &  values)
inlineprivate

Definition at line 127 of file MVAOutput.h.

References util::values().

128  {
129  if (values.size() == N) {
130  for (size_t i = 0; i < N; ++i) {
131  fData[i] = values[i];
132  }
133  }
134  else {
135  throw cet::exception("FeatureVector")
136  << "Expected length: " << N << ", provided: " << values.size() << std::endl;
137  }
138  }
float fData[N]
Vector values.
Definition: MVAOutput.h:32
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<size_t N>
void anab::FeatureVector< N >::set ( std::vector< double > const &  values)
inlineprivate

Definition at line 139 of file MVAOutput.h.

References util::values().

140  {
141  if (values.size() == N) {
142  for (size_t i = 0; i < N; ++i) {
143  fData[i] = values[i];
144  }
145  }
146  else {
147  throw cet::exception("FeatureVector")
148  << "Expected length: " << N << ", provided: " << values.size() << std::endl;
149  }
150  }
float fData[N]
Vector values.
Definition: MVAOutput.h:32
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<size_t N>
size_t anab::FeatureVector< N >::size ( ) const
inline

Definition at line 92 of file MVAOutput.h.

92 { return N; }

Friends And Related Function Documentation

template<size_t N>
std::ostream& operator<< ( std::ostream &  o,
FeatureVector< N > const &  a 
)
friend

Definition at line 82 of file MVAOutput.h.

83  {
84  o << "FeatureVector values:";
85  for (size_t i = 0; i < N; ++i) {
86  o << " " << a.fData[i];
87  }
88  o << std::endl;
89  return o;
90  }

Member Data Documentation

template<size_t N>
float anab::FeatureVector< N >::fData[N]
private

Vector values.

Definition at line 32 of file MVAOutput.h.


The documentation for this class was generated from the following file: