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 
11 
13 
14 #include "TBranch.h"
15 #include "TClass.h"
16 
17 #include <cassert>
18 
19 namespace edm {
20 
22  RootTree const& tree,
23  std::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  wrapperBaseTClass_(TClass::GetClass("edm::WrapperBase")) {
31  }
32 
34  }
35 
38  return resourceAcquirer_.get();
39  }
40 
41  std::unique_ptr<WrapperBase>
44  if (!found(iter)) {
45  if (nextReader_) {
46  return nextReader_->getProduct(k, ep);
47  } else {
48  return std::unique_ptr<WrapperBase>();
49  }
50  }
51  roottree::BranchInfo const& branchInfo = getBranchInfo(iter);
52  TBranch* br = branchInfo.productBranch_;
53  if (br == nullptr) {
54  if (nextReader_) {
55  return nextReader_->getProduct(k, ep);
56  } else {
57  return std::unique_ptr<WrapperBase>();
58  }
59  }
60 
62  TClass* cp = branchInfo.classCache_;
63  if(nullptr == cp) {
64  branchInfo.classCache_ = TClass::GetClass(branchInfo.branchDescription_.wrappedName().c_str());
65  cp = branchInfo.classCache_;
66  branchInfo.offsetToWrapperBase_ = cp->GetBaseClassOffset(wrapperBaseTClass_);
67  }
68  void* p = cp->New();
69  std::unique_ptr<WrapperBase> edp = getWrapperBasePtr(p, branchInfo.offsetToWrapperBase_);
70  br->SetAddress(&p);
72  if(tree_.branchType() == InEvent) {
73  // CMS-THREADING For the primary input source calls to this function need to be serialized
75  }
76  setRefCoreStreamer(false);
77  return edp;
78  }
79 }
InputType
Definition: InputType.h:5
static PFTauRenderPlugin instance
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
virtual std::unique_ptr< WrapperBase > getProduct_(BranchKey const &k, EDProductGetter const *ep) const override
DelayedReader * nextReader_
BranchDescription const branchDescription_
Definition: RootTree.h:49
virtual std::unique_ptr< WrapperBase > getProduct(BranchKey const &k, EDProductGetter const *ep)
BranchType branchType() const
Definition: RootTree.h:153
RootDelayedReader(RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
roottree::BranchMap::const_iterator iterator
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:50
iterator branchIter(BranchKey const &k) const
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
std::string const & wrappedName() const