Go to the documentation of this file.00001
00002
00003
00004 #include "RootDelayedReader.h"
00005 #include "InputFile.h"
00006 #include "DataFormats/Common/interface/WrapperOwningHolder.h"
00007 #include "DataFormats/Common/interface/RefCoreStreamer.h"
00008
00009 #include "TROOT.h"
00010 #include "TBranch.h"
00011 #include "TClass.h"
00012
00013 namespace edm {
00014
00015 RootDelayedReader::RootDelayedReader(
00016 RootTree const& tree,
00017 boost::shared_ptr<InputFile> filePtr) :
00018 tree_(tree),
00019 filePtr_(filePtr),
00020 nextReader_() {
00021 }
00022
00023 RootDelayedReader::~RootDelayedReader() {
00024 }
00025
00026 WrapperOwningHolder
00027 RootDelayedReader::getProduct_(BranchKey const& k, WrapperInterfaceBase const* interface, EDProductGetter const* ep) const {
00028 iterator iter = branchIter(k);
00029 if (!found(iter)) {
00030 if (nextReader_) {
00031 return nextReader_->getProduct(k, interface, ep);
00032 } else {
00033 return WrapperOwningHolder();
00034 }
00035 }
00036 roottree::BranchInfo const& branchInfo = getBranchInfo(iter);
00037 TBranch* br = branchInfo.productBranch_;
00038 if (br == 0) {
00039 if (nextReader_) {
00040 return nextReader_->getProduct(k, interface, ep);
00041 } else {
00042 return WrapperOwningHolder();
00043 }
00044 }
00045 setRefCoreStreamer(ep);
00046 TClass* cp = branchInfo.classCache_;
00047 if(0 == cp) {
00048 branchInfo.classCache_ = gROOT->GetClass(branchInfo.branchDescription_.wrappedName().c_str());
00049 cp = branchInfo.classCache_;
00050 }
00051 void* p = cp->New();
00052 br->SetAddress(&p);
00053 tree_.getEntry(br, entryNumber());
00054 if(tree_.branchType() == InEvent) {
00055 InputFile::reportReadBranch(std::string(br->GetName()));
00056 }
00057 setRefCoreStreamer(false);
00058 WrapperOwningHolder edp(p, interface);
00059 return edp;
00060 }
00061 }