CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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
 

Public Member Functions

RootDelayedReaderoperator= (RootDelayedReader const &)=delete
 
signalslot::Signal< void(StreamContext
const &, ModuleCallingContext
const &)> const * 
postEventReadFromSourceSignal () const final
 
signalslot::Signal< void(StreamContext
const &, ModuleCallingContext
const &)> const * 
preEventReadFromSourceSignal () const final
 
 RootDelayedReader (RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
 
 RootDelayedReader (RootDelayedReader const &)=delete
 
void setSignals (signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
 
 ~RootDelayedReader () override
 
- Public Member Functions inherited from edm::DelayedReader
std::shared_ptr< WrapperBasegetProduct (BranchID const &k, EDProductGetter const *ep, ModuleCallingContext const *mcc=nullptr)
 
void mergeReaders (DelayedReader *other)
 
void reset ()
 
std::pair
< SharedResourcesAcquirer
*, std::recursive_mutex * > 
sharedResources () const
 
virtual ~DelayedReader ()
 

Private Member Functions

BranchMap const & branches () const
 
BranchInfo const * getBranchInfo (BranchID const &k) const
 
std::shared_ptr< WrapperBasegetProduct_ (BranchID const &k, EDProductGetter const *ep) override
 
void mergeReaders_ (DelayedReader *other) override
 
void reset_ () override
 
std::pair
< SharedResourcesAcquirer
*, std::recursive_mutex * > 
sharedResources_ () const override
 

Private Attributes

edm::propagate_const
< std::shared_ptr< InputFile > > 
filePtr_
 
InputType inputType_
 
std::exception_ptr lastException_
 
std::shared_ptr
< std::recursive_mutex > 
mutex_
 
edm::propagate_const
< DelayedReader * > 
nextReader_
 
signalslot::Signal< void(StreamContext
const &, ModuleCallingContext
const &)> const * 
postEventReadFromSourceSignal_
 
signalslot::Signal< void(StreamContext
const &, ModuleCallingContext
const &)> const * 
preEventReadFromSourceSignal_
 
std::unique_ptr
< SharedResourcesAcquirer
resourceAcquirer_
 
RootTree const & tree_
 
edm::propagate_const< TClass * > wrapperBaseTClass_
 

Detailed Description

Definition at line 33 of file RootDelayedReader.h.

Member Typedef Documentation

Definition at line 35 of file RootDelayedReader.h.

Definition at line 36 of file RootDelayedReader.h.

Definition at line 37 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::SharedResourcesRegistry::createAcquirerForSourceDelayedReader(), edm::SharedResourcesRegistry::instance(), eostools::move(), mutex_, edm::Primary, resourceAcquirer_, and mps_fire::resources.

24  : tree_(tree),
25  filePtr_(filePtr),
26  nextReader_(),
27  inputType_(inputType),
28  wrapperBaseTClass_(TClass::GetClass("edm::WrapperBase")) {
29  if (inputType == InputType::Primary) {
31  resourceAcquirer_ = std::make_unique<SharedResourcesAcquirer>(std::move(resources.first));
32  mutex_ = resources.second;
33  }
34  }
RootTree const & tree_
tuple resources
Definition: mps_fire.py:263
std::shared_ptr< std::recursive_mutex > mutex_
static SharedResourcesRegistry * instance()
def move
Definition: eostools.py:511
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
edm::propagate_const< TClass * > wrapperBaseTClass_
edm::propagate_const< DelayedReader * > nextReader_
std::pair< SharedResourcesAcquirer, std::shared_ptr< std::recursive_mutex > > createAcquirerForSourceDelayedReader()
edm::RootDelayedReader::~RootDelayedReader ( )
override

Definition at line 36 of file RootDelayedReader.cc.

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

Member Function Documentation

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

Definition at line 67 of file RootDelayedReader.h.

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

Referenced by getBranchInfo().

67 { return tree_.branches(); }
RootTree const & tree_
BranchMap const & branches() const
Definition: RootTree.cc:194
BranchInfo const* edm::RootDelayedReader::getBranchInfo ( BranchID const &  k) const
inlineprivate

Definition at line 68 of file RootDelayedReader.h.

References branches(), and edm::roottree::BranchMap::find().

Referenced by getProduct_().

68 { return branches().find(k); }
BranchInfo const * find(BranchID const &iKey) const
Definition: RootTree.h:59
BranchMap const & branches() const
std::shared_ptr< WrapperBase > edm::RootDelayedReader::getProduct_ ( BranchID const &  k,
EDProductGetter const *  ep 
)
overrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 42 of file RootDelayedReader.cc.

References cms::Exception::addContext(), beamvalidation::br, edm::RootTree::branchType(), CommonMethods::cp(), alignCSCRings::e, edm::RootTree::entryNumberForIndex(), getBranchInfo(), edm::RootTree::getEntry(), edm::getWrapperBasePtr(), edm::InEvent, inputType_, lastException_, nextReader_, AlCaHLTBitMon_ParallelJobs::p, edm::InputFile::reportReadBranch(), edm::setRefCoreStreamer(), AlCaHLTBitMon_QueryRunRegistry::string, edm::EDProductGetter::transitionIndex(), tree_, and wrapperBaseTClass_.

42  {
43  if (lastException_) {
44  try {
45  std::rethrow_exception(lastException_);
46  } catch (cms::Exception& e) {
47  e.addContext("Rethrowing an exception that happened on a different read request.");
48  throw;
49  }
50  }
51  auto branchInfo = getBranchInfo(k);
52  if (not branchInfo) {
53  if (nextReader_) {
54  return nextReader_->getProduct(k, ep);
55  } else {
56  return std::shared_ptr<WrapperBase>();
57  }
58  }
59  TBranch* br = branchInfo->productBranch_;
60  if (br == nullptr) {
61  if (nextReader_) {
62  return nextReader_->getProduct(k, ep);
63  } else {
64  return std::shared_ptr<WrapperBase>();
65  }
66  }
67 
69  //make code exception safe
70  std::shared_ptr<void> refCoreStreamerGuard(nullptr, [](void*) {
71  setRefCoreStreamer(false);
72  ;
73  });
74  TClass* cp = branchInfo->classCache_;
75  if (nullptr == cp) {
76  branchInfo->classCache_ = TClass::GetClass(branchInfo->branchDescription_.wrappedName().c_str());
77  cp = branchInfo->classCache_;
78  branchInfo->offsetToWrapperBase_ = cp->GetBaseClassOffset(wrapperBaseTClass_);
79  }
80  void* p = cp->New();
81  std::unique_ptr<WrapperBase> edp = getWrapperBasePtr(p, branchInfo->offsetToWrapperBase_);
82  br->SetAddress(&p);
83  try {
84  //Run, Lumi, and ProcessBlock only have 1 entry number, which is index 0
85  tree_.getEntry(br, tree_.entryNumberForIndex(tree_.branchType() == InEvent ? ep->transitionIndex() : 0));
86  } catch (...) {
87  lastException_ = std::current_exception();
88  std::rethrow_exception(lastException_);
89  }
90  if (tree_.branchType() == InEvent) {
91  // CMS-THREADING For the primary input source calls to this function need to be serialized
93  }
94  return edp;
95  }
BranchInfo const * getBranchInfo(BranchID const &k) const
RootTree const & tree_
void setRefCoreStreamer(bool resetAll=false)
static void reportReadBranch(InputType inputType, std::string const &branchname)
Definition: InputFile.cc:111
std::exception_ptr lastException_
BranchType branchType() const
Definition: RootTree.h:184
EntryNumber const & entryNumberForIndex(unsigned int index) const
Definition: RootTree.cc:113
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:382
void addContext(std::string const &context)
Definition: Exception.cc:165
edm::propagate_const< TClass * > wrapperBaseTClass_
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
edm::propagate_const< DelayedReader * > nextReader_
void edm::RootDelayedReader::mergeReaders_ ( DelayedReader other)
inlineoverrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 63 of file RootDelayedReader.h.

References nextReader_.

63 { nextReader_ = other; }
edm::propagate_const< DelayedReader * > nextReader_
RootDelayedReader& edm::RootDelayedReader::operator= ( RootDelayedReader const &  )
delete
signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* edm::RootDelayedReader::postEventReadFromSourceSignal ( ) const
inlinefinalvirtual

Implements edm::DelayedReader.

Definition at line 49 of file RootDelayedReader.h.

References postEventReadFromSourceSignal_.

50  {
52  }
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal_
signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* edm::RootDelayedReader::preEventReadFromSourceSignal ( ) const
inlinefinalvirtual

Implements edm::DelayedReader.

Definition at line 45 of file RootDelayedReader.h.

References preEventReadFromSourceSignal_.

46  {
48  }
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_
void edm::RootDelayedReader::reset_ ( )
inlineoverrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 64 of file RootDelayedReader.h.

References nextReader_.

64 { nextReader_ = nullptr; }
edm::propagate_const< DelayedReader * > nextReader_
void edm::RootDelayedReader::setSignals ( signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *  preEventReadSource,
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *  postEventReadSource 
)
inline

Definition at line 54 of file RootDelayedReader.h.

References postEventReadFromSourceSignal_, and preEventReadFromSourceSignal_.

56  {
57  preEventReadFromSourceSignal_ = preEventReadSource;
58  postEventReadFromSourceSignal_ = postEventReadSource;
59  }
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > edm::RootDelayedReader::sharedResources_ ( ) const
overrideprivatevirtual

Reimplemented from edm::DelayedReader.

Definition at line 38 of file RootDelayedReader.cc.

References mutex_, and resourceAcquirer_.

38  {
39  return std::make_pair(resourceAcquirer_.get(), mutex_.get());
40  }
std::shared_ptr< std::recursive_mutex > mutex_
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_

Member Data Documentation

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

Definition at line 72 of file RootDelayedReader.h.

InputType edm::RootDelayedReader::inputType_
private

Definition at line 77 of file RootDelayedReader.h.

Referenced by getProduct_().

std::exception_ptr edm::RootDelayedReader::lastException_
mutableprivate

Definition at line 89 of file RootDelayedReader.h.

Referenced by getProduct_().

std::shared_ptr<std::recursive_mutex> edm::RootDelayedReader::mutex_
private

Definition at line 76 of file RootDelayedReader.h.

Referenced by RootDelayedReader(), and sharedResources_().

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

Definition at line 73 of file RootDelayedReader.h.

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

signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* edm::RootDelayedReader::postEventReadFromSourceSignal_
private
Initial value:
=
nullptr

Definition at line 82 of file RootDelayedReader.h.

Referenced by postEventReadFromSourceSignal(), and setSignals().

signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* edm::RootDelayedReader::preEventReadFromSourceSignal_
private
Initial value:
=
nullptr

Definition at line 80 of file RootDelayedReader.h.

Referenced by preEventReadFromSourceSignal(), and setSignals().

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

Definition at line 75 of file RootDelayedReader.h.

Referenced by RootDelayedReader(), and sharedResources_().

RootTree const& edm::RootDelayedReader::tree_
private

Definition at line 71 of file RootDelayedReader.h.

Referenced by branches(), and getProduct_().

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

Definition at line 78 of file RootDelayedReader.h.

Referenced by getProduct_().