00001 /*---------------------------------------------------------------------- 00002 ----------------------------------------------------------------------*/ 00003 00004 #include "RootDelayedReader.h" 00005 #include "DataFormats/Common/interface/RefCoreStreamer.h" 00006 #include "DataFormats/Provenance/interface/BranchDescription.h" 00007 #include "TROOT.h" 00008 #include "TClass.h" 00009 #include "TBranch.h" 00010 00011 namespace edm { 00012 00013 RootDelayedReader::RootDelayedReader(EntryNumber const& entry, 00014 boost::shared_ptr<BranchMap const> bMap, 00015 boost::shared_ptr<TFile const> filePtr) 00016 : entryNumber_(entry), branches_(bMap), filePtr_(filePtr), nextReader_() {} 00017 00018 RootDelayedReader::~RootDelayedReader() {} 00019 00020 std::auto_ptr<EDProduct> 00021 RootDelayedReader::getProduct_(BranchKey const& k, EDProductGetter const* ep) const { 00022 setRefCoreStreamer(ep); 00023 iterator iter = branchIter(k); 00024 if (!found(iter)) { 00025 assert(nextReader_); 00026 return nextReader_->getProduct(k, ep); 00027 } 00028 input::BranchInfo const& branchInfo = getBranchInfo(iter); 00029 TBranch *br = branchInfo.productBranch_; 00030 if (br == 0) { 00031 assert(nextReader_); 00032 return nextReader_->getProduct(k, ep); 00033 } 00034 TClass *cp = gROOT->GetClass(branchInfo.branchDescription_.wrappedName().c_str()); 00035 std::auto_ptr<EDProduct> p(static_cast<EDProduct *>(cp->New())); 00036 EDProduct *pp = p.get(); 00037 br->SetAddress(&pp); 00038 input::getEntry(br, entryNumber_); 00039 return p; 00040 } 00041 }