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