9 #ifndef ANAB_MVAREADER_H 10 #define ANAB_MVAREADER_H 22 template <
class T,
size_t N>
32 std::unique_ptr<FVectorReader> ptr(
new FVectorReader(evt, tag, success));
33 if (success) {
return ptr; }
34 else {
return nullptr; }
56 std::array<float, N> vout;
57 for (
size_t i = 0; i <
N; ++i) vout[i] = (*
fVectors)[
key][i];
96 std::vector< FeatureVector<N> >
const *
fVectors;
103 template <
class T,
size_t N>
113 std::unique_ptr<MVAReader> ptr(
new MVAReader(evt, tag, success));
114 if (success) {
return ptr; }
115 else {
return nullptr; }
144 std::vector<float>
const & weights)
const 169 template <
class T,
size_t N>
175 auto descriptionHandle = evt.
getValidHandle< std::vector< anab::FVecDescription<N> > >(tag);
179 for (
auto const & dscr : *descriptionHandle)
181 if (dscr.outputInstance() == outputInstanceName)
202 template <
class T,
size_t N>
208 if (!
N) { std::cout <<
"FVectorReader: Vector size should be > 0." <<
std::endl;
return; }
211 if (!evt.
getByLabel( tag, descriptionHandle )) {
return; }
215 for (
auto const & dscr : *descriptionHandle)
217 if (dscr.outputInstance() == outputInstanceName)
222 if (!
fDescription) { std::cout <<
"FVectorReader: Vectors description not found for " << outputInstanceName <<
std::endl;
return; }
233 std::cout <<
"FVectorReader: Feature vectors and data products sizes inconsistent: " <<
fVectors->size() <<
"!=" <<
fDataHandle->size() <<
std::endl;
return;
240 #endif //ANAB_MVAREADER
const art::Handle< std::vector< T > > & dataHandle() const
Access the data product handle.
art::Handle< std::vector< T > > fDataHandle
std::array< float, N > getVector(size_t key) const
Get copy of the feature vector at index "key".
static std::unique_ptr< FVectorReader > create(const art::Event &evt, const art::InputTag &tag)
std::array< float, N > getOutput(std::vector< art::Ptr< T > > const &items, std::function< float(T const &)> fweight) const
int getIndex(const std::string &name) const
Index of column with given name, or -1 if name not found.
const std::string & outputName(size_t index) const
Meaning/name of the index'th column in the collection of MVA output vectors.
std::vector< FeatureVector< N > > const & vectors() const
Access the vector of the feature vectors.
T const & item(size_t key) const
Access data product at index "key".
std::string getProductName(std::type_info const &ti) const
FVecDescription< N > const * fDescription
std::array< float, N > getOutput(art::Ptr< T > const &item) const
Get copy of the MVA output vector idicated with art::Ptr::key().
std::vector< FeatureVector< N > > const * fVectors
MVAReader(const art::Event &evt, const art::InputTag &tag)
std::vector< T > const & items() const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::array< float, N > getVector(art::Ptr< T > const &item) const
Get copy of the feature vector idicated with art::Ptr::key().
Helper functions for MVAReader and MVAWriter wrappers.
key_type key() const noexcept
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
const std::string & columnName(size_t index) const
Meaning/name of the index'th column in the collection of feature vectors.
std::vector< FeatureVector< N > > const & outputs() const
Access the vector of the feature vectors.
size_t size() const
Get the number of contained items (no. of data product objects equal to no. of feature vectors)...
size_t length() const
Get the length of a single feature vector.
FVectorReader(const art::Event &evt, const art::InputTag &tag)
Helper functions for MVAReader/Writer and FVecReader/Writer wrappers.
std::shared_ptr< art::Exception const > whyFailed() const
friend std::ostream & operator<<(std::ostream &o, FVectorReader const &a)
std::array< float, N > getOutput(std::vector< art::Ptr< T > > const &items) const
Get MVA results accumulated over the vector of items (eg. over hits associated to a cluster)...
void function(int client, int *resource, int parblock, int *test, int p)
std::array< float, N > getOutput(size_t key) const
Get copy of the MVA output vector at index "key".
std::array< float, N > getOutput(std::vector< art::Ptr< T > > const &items, std::vector< float > const &weights) const
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
MVAReader(const art::Event &evt, const art::InputTag &tag, bool &success)
Not-throwing constructor.
const std::string & dataTag() const
Get the input tag (string representation) of data product used to calculate feature vectors...