9 #ifndef ANAB_MVAREADER_H 10 #define ANAB_MVAREADER_H 22 template <
class T,
size_t N>
31 std::unique_ptr<FVectorReader> ptr(
new FVectorReader(evt, tag, success));
32 if (success) {
return ptr; }
57 std::array<float, N> vout;
58 for (
size_t i = 0; i < N; ++i)
86 o <<
"FVectorReader:" << std::endl << *(a.
fDescription) << std::endl;
102 template <
class T,
size_t N>
111 std::unique_ptr<MVAReader> ptr(
new MVAReader(evt, tag, success));
112 if (success) {
return ptr; }
145 std::vector<float>
const& weights)
const 154 std::function<
float(T
const&)> fweight)
const 177 template <
class T,
size_t N>
181 if (!N) {
throw cet::exception(
"FVectorReader") <<
"Vector size should be > 0." << std::endl; }
183 auto descriptionHandle = evt.
getValidHandle<std::vector<anab::FVecDescription<N>>>(tag);
187 for (
auto const& dscr : *descriptionHandle) {
188 if (dscr.outputInstance() == outputInstanceName) {
195 <<
"Vectors description not found for " << outputInstanceName << std::endl;
208 <<
"Feature vectors and data products sizes inconsistent: " <<
fVectors->size()
214 template <
class T,
size_t N>
223 std::cout <<
"FVectorReader: Vector size should be > 0." << std::endl;
228 if (!evt.
getByLabel(tag, descriptionHandle)) {
return; }
232 for (
auto const& dscr : *descriptionHandle) {
233 if (dscr.outputInstance() == outputInstanceName) {
239 std::cout <<
"FVectorReader: Vectors description not found for " << outputInstanceName
248 std::cout <<
"FVectorReader: Associated data product handle failed: " 254 std::cout <<
"FVectorReader: Feature vectors and data products sizes inconsistent: " 263 #endif //ANAB_MVAREADER const art::Handle< std::vector< T > > & dataHandle() const
Access the data product handle.
std::array< float, N > getVector(size_t key) const
Get copy of the feature vector at index "key".
art::Handle< std::vector< T > > fDataHandle
static std::unique_ptr< FVectorReader > create(const art::Event &evt, const art::InputTag &tag)
int getIndex(const std::string &name) const
Index of column with given name, or -1 if name not found.
std::array< float, N > getOutput(std::vector< art::Ptr< T >> const &items, std::vector< float > const &weights) const
const std::string & outputName(size_t index) const
Meaning/name of the index'th column in the collection of MVA output 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().
MVAReader(const art::Event &evt, const art::InputTag &tag)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< T > const & items() 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
std::vector< FeatureVector< N > > const & outputs() const
Access the vector of the feature vectors.
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 & vectors() const
Access the vector of the feature vectors.
std::vector< FeatureVector< N > > const * fVectors
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)
std::array< float, N > getOutput(std::vector< art::Ptr< T >> const &items, std::function< float(T const &)> fweight) const
Helper functions for MVAReader/Writer and FVecReader/Writer wrappers.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
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)...
std::shared_ptr< art::Exception const > whyFailed() const
friend std::ostream & operator<<(std::ostream &o, FVectorReader const &a)
std::array< float, N > getOutput(size_t key) const
Get copy of the MVA output vector at index "key".
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
cet::coded_exception< error, detail::translate > exception
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...