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"
9 
10 #include "TROOT.h"
11 #include "TBranch.h"
12 #include "TClass.h"
13 
14 #include <cassert>
15 
16 namespace edm {
17 
19  RootTree const& tree,
20  boost::shared_ptr<InputFile> filePtr,
21  InputType inputType) :
22  tree_(tree),
23  filePtr_(filePtr),
24  nextReader_(),
25  inputType_(inputType) {
26  }
27 
29  }
30 
32  RootDelayedReader::getProduct_(BranchKey const& k, WrapperInterfaceBase const* interface, EDProductGetter const* ep) const {
33  iterator iter = branchIter(k);
34  if (!found(iter)) {
35  if (nextReader_) {
36  return nextReader_->getProduct(k, interface, ep);
37  } else {
38  return WrapperOwningHolder();
39  }
40  }
41  roottree::BranchInfo const& branchInfo = getBranchInfo(iter);
42  TBranch* br = branchInfo.productBranch_;
43  if (br == nullptr) {
44  if (nextReader_) {
45  return nextReader_->getProduct(k, interface, ep);
46  } else {
47  return WrapperOwningHolder();
48  }
49  }
50 
52  TClass* cp = branchInfo.classCache_;
53  if(nullptr == cp) {
54  branchInfo.classCache_ = gROOT->GetClass(branchInfo.branchDescription_.wrappedName().c_str());
55  cp = branchInfo.classCache_;
56  }
57  void* p = cp->New();
58  br->SetAddress(&p);
60  if(tree_.branchType() == InEvent) {
61  // CMS-THREADING For the primary input source calls to this function need to be serialized
63  }
64  setRefCoreStreamer(false);
65  WrapperOwningHolder edp(p, interface);
66  return edp;
67  }
68 }
InputType
Definition: InputType.h:5
WrapperOwningHolder getProduct(BranchKey const &k, WrapperInterfaceBase const *interface, EDProductGetter const *ep)
Definition: DelayedReader.h:22
RootTree const & tree_
void setRefCoreStreamer(bool resetAll=false)
static void reportReadBranch(InputType inputType, std::string const &branchname)
Definition: InputFile.cc:108
BranchInfo const & getBranchInfo(iterator const &iter) const
DelayedReader * nextReader_
BranchDescription const branchDescription_
Definition: RootTree.h:48
BranchType branchType() const
Definition: RootTree.h:151
roottree::BranchMap::const_iterator iterator
int k[5][pyjets_maxn]
virtual WrapperOwningHolder getProduct_(BranchKey const &k, WrapperInterfaceBase const *interface, EDProductGetter const *ep) const override
EntryNumber const & entryNumberForIndex(unsigned int index) const
Definition: RootTree.cc:91
bool found(iterator const &iter) const
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:354
unsigned int transitionIndex() const
TBranch * productBranch_
Definition: RootTree.h:49
RootDelayedReader(RootTree const &tree, boost::shared_ptr< InputFile > filePtr, InputType inputType)
iterator branchIter(BranchKey const &k) const
std::string const & wrappedName() const