test
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 
12 
13 #include "TROOT.h"
14 #include "TBranch.h"
15 #include "TClass.h"
16 
17 #include <cassert>
18 
19 namespace edm {
20 
22  RootTree const& tree,
23  boost::shared_ptr<InputFile> filePtr,
24  InputType inputType) :
25  tree_(tree),
26  filePtr_(filePtr),
27  nextReader_(),
28  resourceAcquirer_(inputType == InputType::Primary ? new SharedResourcesAcquirer(SharedResourcesRegistry::instance()->createAcquirerForSourceDelayedReader()) : static_cast<SharedResourcesAcquirer*>(nullptr)),
29  inputType_(inputType) {
30  }
31 
33  }
34 
37  return resourceAcquirer_.get();
38  }
39 
41  RootDelayedReader::getProduct_(BranchKey const& k, WrapperInterfaceBase const* interface, EDProductGetter const* ep) const {
43  if (!found(iter)) {
44  if (nextReader_) {
45  return nextReader_->getProduct(k, interface, ep);
46  } else {
47  return WrapperOwningHolder();
48  }
49  }
50  roottree::BranchInfo const& branchInfo = getBranchInfo(iter);
51  TBranch* br = branchInfo.productBranch_;
52  if (br == nullptr) {
53  if (nextReader_) {
54  return nextReader_->getProduct(k, interface, ep);
55  } else {
56  return WrapperOwningHolder();
57  }
58  }
59 
61  TClass* cp = branchInfo.classCache_;
62  if(nullptr == cp) {
63  branchInfo.classCache_ = gROOT->GetClass(branchInfo.branchDescription_.wrappedName().c_str());
64  cp = branchInfo.classCache_;
65  }
66  void* p = cp->New();
67  br->SetAddress(&p);
69  if(tree_.branchType() == InEvent) {
70  // CMS-THREADING For the primary input source calls to this function need to be serialized
72  }
73  setRefCoreStreamer(false);
74  WrapperOwningHolder edp(p, interface);
75  return edp;
76  }
77 }
InputType
Definition: InputType.h:5
static PFTauRenderPlugin instance
WrapperOwningHolder getProduct(BranchKey const &k, WrapperInterfaceBase const *interface, EDProductGetter const *ep)
RootTree const & tree_
void setRefCoreStreamer(bool resetAll=false)
BranchInfo const & getBranchInfo(iterator const &iter) const
static void reportReadBranch(InputType inputType, std::string const &branchname)
Definition: InputFile.cc:112
#define nullptr
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:92
bool found(iterator const &iter) const
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:355
SharedResourcesAcquirer * sharedResources_() const override
unsigned int transitionIndex() const
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
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