#ifndef ROOT_TTree # include #endif #ifndef __UTILITY__ # include #endif #ifndef __STRING__ # include #endif #ifndef __VECTOR__ # include #endif class MixTree : public TTree { private: TTree* fTree; typedef std::pair branch_info_type; typedef std::vector branch_info_list; branch_info_list fList; public: MixTree(TTree* tree) : fTree(tree) {} const Char_t* GetName() const { return fTree->GetName(); } Int_t GetEntry(Long64_t entry=0, Int_t getall=0); void SetBranchAddress(const char *bname,void *add); }; //____________________________________________________________________ Int_t MixTree::GetEntry(Long64_t entry, Int_t getall) { // SetBranchStatus("*", 0); branch_info_list keep; for (branch_info_list::iterator i = fList.begin(); i != fList.end(); ++i) { std::string* name = (*i).first; void* add = (*i).second; TBranch* b = fTree->GetBranch(name->c_str()); if (!b) continue; void* olda = b->GetAddress(); keep.push_back(branch_info_type(name, olda)); fTree->SetBranchAddress(name->c_str(), add); } Int_t ret = fTree->GetEntry(entry, getall); for (branch_info_list::iterator i = keep.begin(); i != keep.end(); ++i) { std::string* name = (*i).first; void* add = (*i).second; TBranch* b = fTree->GetBranch(name->c_str()); if (!b) continue; fTree->SetBranchAddress(name->c_str(), add); } // SetBranchStatus("*", 1); return ret; } //____________________________________________________________________ void MixTree::SetBranchAddress(const char *bname,void *add) { std::string* name = new std::string(bname); fList.push_back(branch_info_type(name, add)); } // // EOF //