test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::RootDelayedReader Class Reference

#include <RootDelayedReader.h>

Inheritance diagram for edm::RootDelayedReader:
edm::DelayedReader

Public Types

typedef roottree::BranchInfo BranchInfo
 
typedef roottree::BranchMap BranchMap
 
typedef roottree::EntryNumber EntryNumber
 
typedef
roottree::BranchMap::const_iterator 
iterator
 

Public Member Functions

RootDelayedReaderoperator= (RootDelayedReader const &)=delete
 
 RootDelayedReader (RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
 
 RootDelayedReader (RootDelayedReader const &)=delete
 
virtual ~RootDelayedReader ()
 
- Public Member Functions inherited from edm::DelayedReader
virtual std::unique_ptr
< WrapperBase
getProduct (BranchKey const &k, EDProductGetter const *ep)
 
void mergeReaders (DelayedReader *other)
 
void reset ()
 
SharedResourcesAcquirersharedResources () const
 
virtual ~DelayedReader ()
 

Private Member Functions

BranchMap const & branches () const
 
iterator branchIter (BranchKey const &k) const
 
bool found (iterator const &iter) const
 
BranchInfo const & getBranchInfo (iterator const &iter) const
 
virtual std::unique_ptr
< WrapperBase
getProduct_ (BranchKey const &k, EDProductGetter const *ep) override
 
virtual void mergeReaders_ (DelayedReader *other) override
 
virtual void reset_ () override
 
SharedResourcesAcquirersharedResources_ () const override
 

Private Attributes

edm::propagate_const
< std::shared_ptr< InputFile > > 
filePtr_
 
InputType inputType_
 
std::unique_ptr< ExceptionlastException_
 
edm::propagate_const
< DelayedReader * > 
nextReader_
 
std::unique_ptr
< SharedResourcesAcquirer
resourceAcquirer_
 
RootTree const & tree_
 
edm::propagate_const< TClass * > wrapperBaseTClass_
 

Detailed Description

Definition at line 31 of file RootDelayedReader.h.

Member Typedef Documentation

Definition at line 33 of file RootDelayedReader.h.

Definition at line 34 of file RootDelayedReader.h.

Definition at line 36 of file RootDelayedReader.h.

typedef roottree::BranchMap::const_iterator edm::RootDelayedReader::iterator

Definition at line 35 of file RootDelayedReader.h.

Constructor & Destructor Documentation

edm::RootDelayedReader::RootDelayedReader ( RootTree const &  tree,
std::shared_ptr< InputFile filePtr,
InputType  inputType 
)

Definition at line 23 of file RootDelayedReader.cc.

References edm::Primary.

26  :
27  tree_(tree),
28  filePtr_(filePtr),
29  nextReader_(),
30  resourceAcquirer_(inputType == InputType::Primary ? new SharedResourcesAcquirer(SharedResourcesRegistry::instance()->createAcquirerForSourceDelayedReader()) : static_cast<SharedResourcesAcquirer*>(nullptr)),
31  inputType_(inputType),
32  wrapperBaseTClass_(TClass::GetClass("edm::WrapperBase")) {
33  }
RootTree const & tree_
static SharedResourcesRegistry * instance()
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
edm::propagate_const< TClass * > wrapperBaseTClass_
edm::propagate_const< DelayedReader * > nextReader_
edm::RootDelayedReader::~RootDelayedReader ( )
virtual

Definition at line 35 of file RootDelayedReader.cc.

35  {
36  }
edm::RootDelayedReader::RootDelayedReader ( RootDelayedReader const &  )
delete

Member Function Documentation

BranchMap const& edm::RootDelayedReader::branches ( ) const
inlineprivate

Definition at line 53 of file RootDelayedReader.h.

References edm::RootTree::branches(), and tree_.

Referenced by branchIter(), and found().

53 {return tree_.branches();}
RootTree const & tree_
BranchMap const & branches() const
Definition: RootTree.cc:172
iterator edm::RootDelayedReader::branchIter ( BranchKey const &  k) const
inlineprivate

Definition at line 54 of file RootDelayedReader.h.

References branches().

Referenced by getProduct_().

54 {return branches().find(k);}
BranchMap const & branches() const
bool edm::RootDelayedReader::found ( iterator const &  iter) const
inlineprivate
BranchInfo const& edm::RootDelayedReader::getBranchInfo ( iterator const &  iter) const
inlineprivate

Definition at line 56 of file RootDelayedReader.h.

Referenced by getProduct_().

56 {return iter->second; }
std::unique_ptr< WrapperBase > edm::RootDelayedReader::getProduct_ ( BranchKey const &  k,
EDProductGetter const *  ep 
)
overrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 44 of file RootDelayedReader.cc.

References beamvalidation::br, edm::roottree::BranchInfo::branchDescription_, branchIter(), edm::RootTree::branchType(), edm::roottree::BranchInfo::classCache_, CommonMethods::cp(), edm::RootTree::entryNumberForIndex(), cppFunctionSkipper::exception, found(), getBranchInfo(), edm::RootTree::getEntry(), edm::getWrapperBasePtr(), edm::InEvent, inputType_, lastException_, nextReader_, edm::roottree::BranchInfo::offsetToWrapperBase_, AlCaHLTBitMon_ParallelJobs::p, edm::roottree::BranchInfo::productBranch_, edm::InputFile::reportReadBranch(), edm::setRefCoreStreamer(), AlCaHLTBitMon_QueryRunRegistry::string, edm::EDProductGetter::transitionIndex(), tree_, edm::BranchDescription::wrappedName(), and wrapperBaseTClass_.

44  {
45  if (lastException_) {
46  throw *lastException_;
47  }
48  iterator iter = branchIter(k);
49  if (!found(iter)) {
50  if (nextReader_) {
51  return nextReader_->getProduct(k, ep);
52  } else {
53  return std::unique_ptr<WrapperBase>();
54  }
55  }
56  roottree::BranchInfo const& branchInfo = getBranchInfo(iter);
57  TBranch* br = branchInfo.productBranch_;
58  if (br == nullptr) {
59  if (nextReader_) {
60  return nextReader_->getProduct(k, ep);
61  } else {
62  return std::unique_ptr<WrapperBase>();
63  }
64  }
65 
67  //make code exception safe
68  std::shared_ptr<void> refCoreStreamerGuard(nullptr,[](void*){ setRefCoreStreamer(false);
69  ;});
70  TClass* cp = branchInfo.classCache_;
71  if(nullptr == cp) {
72  branchInfo.classCache_ = TClass::GetClass(branchInfo.branchDescription_.wrappedName().c_str());
73  cp = branchInfo.classCache_;
74  branchInfo.offsetToWrapperBase_ = cp->GetBaseClassOffset(wrapperBaseTClass_);
75  }
76  void* p = cp->New();
77  std::unique_ptr<WrapperBase> edp = getWrapperBasePtr(p, branchInfo.offsetToWrapperBase_);
78  br->SetAddress(&p);
79  try{
80  tree_.getEntry(br, tree_.entryNumberForIndex(ep->transitionIndex()));
81  } catch(const edm::Exception& exception) {
82  lastException_ = std::make_unique<Exception>(exception);
83  lastException_->addContext("Rethrowing an exception that happened on a different thread.");
84  throw exception;
85  }
86  if(tree_.branchType() == InEvent) {
87  // CMS-THREADING For the primary input source calls to this function need to be serialized
89  }
90  return edp;
91  }
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:119
BranchType branchType() const
Definition: RootTree.h:154
roottree::BranchMap::const_iterator iterator
std::unique_ptr< Exception > lastException_
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
edm::propagate_const< TClass * > wrapperBaseTClass_
iterator branchIter(BranchKey const &k) const
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
edm::propagate_const< DelayedReader * > nextReader_
virtual void edm::RootDelayedReader::mergeReaders_ ( DelayedReader other)
inlineoverrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 49 of file RootDelayedReader.h.

References nextReader_.

49 {nextReader_ = other;}
edm::propagate_const< DelayedReader * > nextReader_
RootDelayedReader& edm::RootDelayedReader::operator= ( RootDelayedReader const &  )
delete
virtual void edm::RootDelayedReader::reset_ ( )
inlineoverrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 50 of file RootDelayedReader.h.

References nextReader_.

50 {nextReader_ = nullptr;}
edm::propagate_const< DelayedReader * > nextReader_
SharedResourcesAcquirer * edm::RootDelayedReader::sharedResources_ ( ) const
overrideprivatevirtual

Reimplemented from edm::DelayedReader.

Definition at line 39 of file RootDelayedReader.cc.

References resourceAcquirer_.

39  {
40  return resourceAcquirer_.get();
41  }
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_

Member Data Documentation

edm::propagate_const<std::shared_ptr<InputFile> > edm::RootDelayedReader::filePtr_
private

Definition at line 60 of file RootDelayedReader.h.

InputType edm::RootDelayedReader::inputType_
private

Definition at line 63 of file RootDelayedReader.h.

Referenced by getProduct_().

std::unique_ptr<Exception> edm::RootDelayedReader::lastException_
mutableprivate

Definition at line 68 of file RootDelayedReader.h.

Referenced by getProduct_().

edm::propagate_const<DelayedReader*> edm::RootDelayedReader::nextReader_
private

Definition at line 61 of file RootDelayedReader.h.

Referenced by getProduct_(), mergeReaders_(), and reset_().

std::unique_ptr<SharedResourcesAcquirer> edm::RootDelayedReader::resourceAcquirer_
private

Definition at line 62 of file RootDelayedReader.h.

Referenced by sharedResources_().

RootTree const& edm::RootDelayedReader::tree_
private

Definition at line 59 of file RootDelayedReader.h.

Referenced by branches(), and getProduct_().

edm::propagate_const<TClass*> edm::RootDelayedReader::wrapperBaseTClass_
private

Definition at line 64 of file RootDelayedReader.h.

Referenced by getProduct_().