SelectBranches.hpp

Go to the documentation of this file.
00001 #ifndef CAFE_SELECTBRANCHES_HPP_
00002 #define CAFE_SELECTBRANCHES_HPP_
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 class TBranch;
00008 class TTree;
00009 
00010 namespace cafe {
00011 
00012     class Event;
00013     class SelectBranches;
00014 
00015   /*
00016     Helper class to maintain a list of branch names and corresponding
00017      TBranch pointers.
00018     
00019      All names should be of the form 'BRANCH.MEMBER' or 
00020      just 'BRANCH'.
00021     
00022      Examples:
00023      BranchNames names("EMscone.fX", "EMscone.fY");
00024     
00025     \ingroup group_cafe
00026     */
00027     class BranchNames {
00028     public:
00029         BranchNames();
00030         BranchNames(const std::string& name);
00031         BranchNames(const std::string& name1, const std::string& name2);
00032         BranchNames(const std::string& name1, const std::string& name2, const std::string& name3);
00033         BranchNames(const std::string& name1, const std::string& name2, const std::string& name3, const std::string& name4);
00034         BranchNames(const std::vector<std::string>& names);
00035 
00036         BranchNames(const BranchNames& other);
00037         BranchNames& operator=(const BranchNames& other);
00038 
00039     private:
00040         friend class SelectBranches;
00041         void disable(TTree *tree, int cookie) const;
00042         void enable() const;
00043         
00044         std::vector<std::string>      _branchNames;
00045         mutable std::vector<TBranch*> _branches;
00046         mutable std::vector<bool>     _oldStatus;
00047         mutable int                   _cookie;
00048     };
00049 
00050   /*
00051     Helper class to temporarily disable branches.
00052     
00053      An instance of this class should be instantiated
00054      around a code block where certain TMBTree branches
00055      should not be read. The destructor will automatically
00056      enable all disabled branches again.
00057     
00058      Example:
00059     
00060      BranchNames names("EMscone.fX", "EMscone.fY");
00061     
00062      SelectBranches enable(event, names);
00063         
00064     \ingroup group_cafe
00065   */
00066     class SelectBranches {
00067     public:
00068         SelectBranches(cafe::Event& event, const BranchNames& names);
00069         ~SelectBranches();
00070     private:
00071         // not implemented
00072         SelectBranches(const SelectBranches& );
00073         SelectBranches operator=(const SelectBranches& );
00074 
00075         const BranchNames& _names;
00076     };
00077     
00078 
00079 }
00080 
00081 #endif // CAFE_SELECTBRANCHES_HPP_

Generated on Thu Apr 3 04:14:23 2008 for CAF by doxygen 1.3.4