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; }
66 if (index <
N) {
return fData[
index]; }
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]; } }
81 void set(std::vector<float>
const &
values)
83 if (
values.size() ==
N) {
for (
size_t i = 0; i <
N; ++i) { fData[i] =
values[i]; } }
86 void set(std::vector<double>
const &
values)
88 if (
values.size() ==
N) {
for (
size_t i = 0; i <
N; ++i) { fData[i] =
values[i]; } }
114 std::vector< std::string >
const & outputNames = std::vector< std::string >(
N,
"")) :
116 fOutputInstance(outputInstance)
118 setOutputNames(outputNames);
122 std::vector< std::string >
const & outputNames = std::vector< std::string >(
N,
"")) :
124 fOutputInstance(outputInstance)
126 setOutputNames(outputNames);
143 if (fDataTag.empty()) { fDataTag = tag; }
149 if (index <
N) {
return fOutputNames[
index]; }
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:
FeatureVector(std::vector< double > const &values)
float fData[N]
Vector values.
const std::string & outputInstance() const
const std::string & outputName(size_t index) const
MVADescription(std::string const &outputInstance, std::vector< std::string > const &outputNames=std::vector< std::string >(N,""))
FeatureVector(std::vector< float > const &values)
std::string fOutputNames[N]
Feature vector entries names/meaning.
float at(size_t index) const
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)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
FeatureVector & operator=(float init)
Assignment operators, from the same types as constructors.