#ifndef _BRANCHPROVIDER_HPP #define _BRANCHPROVIDER_HPP #include "ObjectProcessor.hpp" #include "TreeInterface.hpp" #include "PhysicsObject.hpp" #include #include // Class prototypes class TTree; class TBranch; class TLeaf; class BadLeaf; class BranchProvider : public ObjectProcessor, public TreeInterface { public: /**Construct object to provide access to multiple branches of a Tree. Branches are registered by name, which are looked up and added to a map of branchname:branchpointer Classes that then provide objects using multiple branches just inherit from this class. @param name Name of BranchProvider instance */ BranchProvider(const std::string &name); /**Destructor */ ~BranchProvider(); /**Method to add a branch to the map and validate it. BadBranch exception will be raised if tree has no branch with that name. @param branch name of branch to add to map */ void AddBranch(const std::string &branch); /** Method to get a TBranch pointer from the map by name. Raises BadBranch if branch is not in map. @param branch name of branch to return */ TBranch * GetBranch(const std::string &branch) throw(BadBranch); /** Method to get a TLeaf pointer by name from the map Raises BadLeaf if leaf is not on branch @param branch name of branch with leaf @param leaf name of leaf to return */ TLeaf * GetLeaf(const std::string &branch, const std::string &leaf) throw(BadLeaf); /** Method to get a leaf value by name and index. Raises BadLeaf if leaf is not found on branch in map @param branch name of branch with leaf @param leaf name of leaf with value @param n index of value in leaf to return */ double GetLeafValue(const std::string &branch, const std::string &leaf, int n) throw(BadLeaf); /** Method to get array leaf values and return them as a vector of doubles. @param branch name of branch with leaf @param leaf name of leaf with value @param n index of value in leaf to return @param arrsize size of array in leaf */ std::vector GetCompoundLeafValue(const std::string &branch, const std::string &leaf, int n,int arrsize) throw(BadLeaf); protected: /// Name of this object std::string _myname; /// map containing barnch names and TBranch pointers std::map _branchmap; public: // // ROOT class macro // ClassDef(BranchProvider,0) }; #endif