00001 #ifndef IOPool_Input_BranchMapperWithReader 00002 #define IOPool_Input_BranchMapperWithReader 00003 00004 /*---------------------------------------------------------------------- 00005 00006 BranchMapperWithReader: The mapping from per event product ID's to BranchID's. 00007 00008 ----------------------------------------------------------------------*/ 00009 #include "DataFormats/Provenance/interface/BranchMapper.h" 00010 00011 #include <vector> 00012 #include "TBranch.h" 00013 00014 class TBranch; 00015 namespace edm { 00016 template <typename T> 00017 class BranchMapperWithReader : public BranchMapper { 00018 public: 00019 BranchMapperWithReader(TBranch * branch, input::EntryNumber entryNumber); 00020 00021 virtual ~BranchMapperWithReader() {} 00022 00023 private: 00024 virtual void readProvenance_() const; 00025 00026 TBranch * branchPtr_; 00027 input::EntryNumber entryNumber_; 00028 std::vector<T> infoVector_; 00029 mutable std::vector<T> * pInfoVector_; 00030 }; 00031 00032 template <typename T> 00033 BranchMapperWithReader<T>::BranchMapperWithReader(TBranch * branch, input::EntryNumber entryNumber) : 00034 BranchMapper(true), 00035 branchPtr_(branch), entryNumber_(entryNumber), 00036 infoVector_(), pInfoVector_(&infoVector_) 00037 { } 00038 00039 template <typename T> 00040 inline 00041 void 00042 BranchMapperWithReader<T>::readProvenance_() const { 00043 branchPtr_->SetAddress(&pInfoVector_); 00044 input::getEntry(branchPtr_, entryNumber_); 00045 BranchMapperWithReader<T> * me = const_cast<BranchMapperWithReader<T> *>(this); 00046 for (typename std::vector<T>::const_iterator it = infoVector_.begin(), itEnd = infoVector_.end(); 00047 it != itEnd; ++it) { 00048 me->insert(it->makeEntryInfo()); 00049 } 00050 } 00051 00052 } 00053 #endif