9 #ifndef ANAB_FEATUREVECTORS_H
10 #define ANAB_FEATUREVECTORS_H
12 #include "cetlib_except/exception.h"
56 o <<
"FeatureVector values:";
57 for (
size_t i = 0; i <
N; ++i) { o <<
" " << a.
fData[i]; }
62 size_t size()
const {
return N; }
64 float at(
size_t index)
const
66 if (index <
N) {
return fData[index]; }
67 else {
throw cet::exception(
"FeatureVector") <<
"Index out of range: " << index << std::endl; }
78 void set(
float init) {
for (
size_t i = 0; i <
N; ++i) {
fData[i] = init; } }
79 void set(std::array<float, N>
const &
values) {
for (
size_t i = 0; i <
N; ++i) {
fData[i] = values[i]; } }
80 void set(std::array<double, N>
const &
values) {
for (
size_t i = 0; i <
N; ++i) {
fData[i] = values[i]; } }
83 if (values.size() ==
N) {
for (
size_t i = 0; i <
N; ++i) {
fData[i] = values[i]; } }
84 else {
throw cet::exception(
"FeatureVector") <<
"Expected length: " <<
N <<
", provided: " << values.size() << std::endl; }
88 if (values.size() ==
N) {
for (
size_t i = 0; i <
N; ++i) {
fData[i] = values[i]; } }
89 else {
throw cet::exception(
"FeatureVector") <<
"Expected length: " <<
N <<
", provided: " << values.size() << std::endl; }
114 std::vector< std::string >
const & outputNames = std::vector< std::string >(
N,
"")) :
122 std::vector< std::string >
const & outputNames = std::vector< std::string >(
N,
"")) :
131 o <<
"MVADescription: prepared for " << a.
fDataTag <<
", instance name " << a.
fOutputInstance <<
", " <<
N <<
" outputs:" << std::endl;
132 for (
size_t i = 0; i <
N; ++i) { o <<
" " << a.
fOutputNames[i] << std::endl; }
144 else {
throw cet::exception(
"MVADescription") <<
"Data tag already assigned: " <<
fDataTag << std::endl; }
150 else {
throw cet::exception(
"MVADescription") <<
"Index out of range: " << index << std::endl; }
154 if (outputNames.size() <=
N) {
for (
size_t i = 0; i < outputNames.size(); ++i) {
fOutputNames[i] = outputNames[i]; } }
155 else {
throw cet::exception(
"FeatureVector") <<
"Expected max length of outputNames: " <<
N <<
", provided: " << outputNames.size() << std::endl; }
160 for (
size_t i = 0; i <
N; ++i) {
if (
fOutputNames[i] == name) {
return i; } }
171 #endif //ANAB_FEATUREVECTORS
void setDataTag(const std::string &tag)
static short Class_Version()
friend std::ostream & operator<<(std::ostream &o, FeatureVector const &a)
const std::string & dataTag() const
void setOutputNames(std::vector< std::string > const &outputNames)
std::string fOutputInstance
Instance name of the feature vector collection.
static short Class_Version()
int getIndex(const std::string &name) const
FeatureVector(float init)
FeatureVector(float const *values)
If you really have to use C arrays:
void set(std::array< double, N > const &values)
FeatureVector(std::vector< double > const &values)
float fData[N]
Vector values.
const std::string & outputInstance() const
void set(std::vector< double > const &values)
const std::string & outputName(size_t index) const
void set(std::array< float, N > const &values)
MVADescription(std::string const &outputInstance, std::vector< std::string > const &outputNames=std::vector< std::string >(N,""))
void set(std::vector< float > const &values)
FeatureVector(std::vector< float > const &values)
std::string fOutputNames[N]
Feature vector entries names/meaning.
float at(size_t index) const
process_name largeant stream1 can override from command line with o or output physics producers generator N
FeatureVector(std::array< double, N > const &values)
FeatureVector(std::array< float, N > const &values)
MVADescription(std::string const &dataTag, std::string const &outputInstance, std::vector< std::string > const &outputNames=std::vector< std::string >(N,""))
float operator[](size_t index) const
FeatureVector(double const *values)
std::string fDataTag
Tag of the reco data products (art::InputTag format)
friend std::ostream & operator<<(std::ostream &o, MVADescription const &a)
FeatureVector & operator=(float init)
Assignment operators, from the same types as constructors.