CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RootDelayedReader.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 
4 #include "RootDelayedReader.h"
5 #include "InputFile.h"
8 
9 #include "TROOT.h"
10 #include "TBranch.h"
11 #include "TClass.h"
12 
13 namespace edm {
14 
16  RootTree const& tree,
17  boost::shared_ptr<InputFile> filePtr) :
18  tree_(tree),
19  filePtr_(filePtr),
20  nextReader_() {
21  }
22 
24  }
25 
27  RootDelayedReader::getProduct_(BranchKey const& k, WrapperInterfaceBase const* interface, EDProductGetter const* ep) const {
28  iterator iter = branchIter(k);
29  if (!found(iter)) {
30  if (nextReader_) {
31  return nextReader_->getProduct(k, interface, ep);
32  } else {
33  return WrapperOwningHolder();
34  }
35  }
36  roottree::BranchInfo const& branchInfo = getBranchInfo(iter);
37  TBranch* br = branchInfo.productBranch_;
38  if (br == 0) {
39  if (nextReader_) {
40  return nextReader_->getProduct(k, interface, ep);
41  } else {
42  return WrapperOwningHolder();
43  }
44  }
46  TClass* cp = branchInfo.classCache_;
47  if(0 == cp) {
48  branchInfo.classCache_ = gROOT->GetClass(branchInfo.branchDescription_.wrappedName().c_str());
49  cp = branchInfo.classCache_;
50  }
51  void* p = cp->New();
52  br->SetAddress(&p);
53  tree_.getEntry(br, entryNumber());
54  if(tree_.branchType() == InEvent) {
55  InputFile::reportReadBranch(std::string(br->GetName()));
56  }
57  setRefCoreStreamer(false);
58  WrapperOwningHolder edp(p, interface);
59  return edp;
60  }
61 }
std::string const & wrappedName() const
ConstBranchDescription branchDescription_
Definition: RootTree.h:45
WrapperOwningHolder getProduct(BranchKey const &k, WrapperInterfaceBase const *interface, EDProductGetter const *ep)
Definition: DelayedReader.h:22
RootTree const & tree_
void setRefCoreStreamer(bool resetAll=false)
BranchInfo const & getBranchInfo(iterator const &iter) const
DelayedReader * nextReader_
virtual WrapperOwningHolder getProduct_(BranchKey const &k, WrapperInterfaceBase const *interface, EDProductGetter const *ep) const
tuple br
Definition: scaleCards.py:54
BranchType branchType() const
Definition: RootTree.h:122
roottree::BranchMap::const_iterator iterator
int k[5][pyjets_maxn]
bool found(iterator const &iter) const
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:182
static void reportReadBranch(std::string const &branchname)
Definition: InputFile.cc:106
RootDelayedReader(RootTree const &tree, boost::shared_ptr< InputFile > filePtr)
TBranch * productBranch_
Definition: RootTree.h:46
EntryNumber const & entryNumber() const
iterator branchIter(BranchKey const &k) const