CMS 3D CMS Logo

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
 
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::unique_ptr< WrapperBasegetProduct (BranchKey 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
 
iterator branchIter (BranchKey const &k) const
 
bool found (iterator const &iter) const
 
BranchInfo const & getBranchInfo (iterator const &iter) const
 
std::unique_ptr< WrapperBasegetProduct_ (BranchKey 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_ = nullptr
 
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_ = nullptr
 
std::unique_ptr< SharedResourcesAcquirerresourceAcquirer_
 
RootTree const & tree_
 
edm::propagate_const< TClass * > wrapperBaseTClass_
 

Detailed Description

Definition at line 32 of file RootDelayedReader.h.

Member Typedef Documentation

Definition at line 34 of file RootDelayedReader.h.

Definition at line 35 of file RootDelayedReader.h.

Definition at line 37 of file RootDelayedReader.h.

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

Definition at line 36 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.

26  :
27  tree_(tree),
28  filePtr_(filePtr),
29  nextReader_(),
30  resourceAcquirer_(inputType == InputType::Primary ? new SharedResourcesAcquirer() : static_cast<SharedResourcesAcquirer*>(nullptr)),
31  inputType_(inputType),
32  wrapperBaseTClass_(TClass::GetClass("edm::WrapperBase")) {
33  if(inputType == InputType::Primary) {
35  resourceAcquirer_=std::make_unique<SharedResourcesAcquirer>(std::move(resources.first));
36  mutex_ = resources.second;
37  }
38  }
RootTree const & tree_
std::shared_ptr< std::recursive_mutex > mutex_
static SharedResourcesRegistry * instance()
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
edm::propagate_const< TClass * > wrapperBaseTClass_
Definition: tree.py:1
edm::propagate_const< DelayedReader * > nextReader_
std::pair< SharedResourcesAcquirer, std::shared_ptr< std::recursive_mutex > > createAcquirerForSourceDelayedReader()
def move(src, dest)
Definition: eostools.py:510
edm::RootDelayedReader::~RootDelayedReader ( )
override

Definition at line 40 of file RootDelayedReader.cc.

40  {
41  }
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 branchIter(), and found().

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

Definition at line 68 of file RootDelayedReader.h.

References branches().

Referenced by getProduct_().

68 {return branches().find(k);}
int k[5][pyjets_maxn]
BranchMap const & branches() const
bool edm::RootDelayedReader::found ( iterator const &  iter) const
inlineprivate

Definition at line 69 of file RootDelayedReader.h.

References branches().

Referenced by getProduct_().

69 {return iter != branches().end();}
BranchMap const & branches() const
BranchInfo const& edm::RootDelayedReader::getBranchInfo ( iterator const &  iter) const
inlineprivate

Definition at line 70 of file RootDelayedReader.h.

Referenced by getProduct_().

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

Implements edm::DelayedReader.

Definition at line 49 of file RootDelayedReader.cc.

References cms::Exception::addContext(), beamvalidation::br, branchIter(), edm::RootTree::branchType(), SimDataFormats::CaloAnalysis::cp, edm::RootTree::entryNumberForIndex(), cppFunctionSkipper::exception, found(), 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_.

Referenced by setSignals().

49  {
50  if (lastException_) {
51  std::rethrow_exception(lastException_);
52  }
53  iterator iter = branchIter(k);
54  if (!found(iter)) {
55  if (nextReader_) {
56  return nextReader_->getProduct(k, ep);
57  } else {
58  return std::unique_ptr<WrapperBase>();
59  }
60  }
61  roottree::BranchInfo const& branchInfo = getBranchInfo(iter);
62  TBranch* br = branchInfo.productBranch_;
63  if (br == nullptr) {
64  if (nextReader_) {
65  return nextReader_->getProduct(k, ep);
66  } else {
67  return std::unique_ptr<WrapperBase>();
68  }
69  }
70 
72  //make code exception safe
73  std::shared_ptr<void> refCoreStreamerGuard(nullptr,[](void*){ setRefCoreStreamer(false);
74  ;});
75  TClass* cp = branchInfo.classCache_;
76  if(nullptr == cp) {
77  branchInfo.classCache_ = TClass::GetClass(branchInfo.branchDescription_.wrappedName().c_str());
78  cp = branchInfo.classCache_;
79  branchInfo.offsetToWrapperBase_ = cp->GetBaseClassOffset(wrapperBaseTClass_);
80  }
81  void* p = cp->New();
82  std::unique_ptr<WrapperBase> edp = getWrapperBasePtr(p, branchInfo.offsetToWrapperBase_);
83  br->SetAddress(&p);
84  try{
85  tree_.getEntry(br, tree_.entryNumberForIndex(ep->transitionIndex()));
86  } catch(edm::Exception& exception) {
87  exception.addContext("Rethrowing an exception that happened on a different thread.");
88  lastException_ = std::current_exception();
89  } catch(...) {
90  lastException_ = std::current_exception();
91  }
92  if(lastException_) {
93  std::rethrow_exception(lastException_);
94  }
95  if(tree_.branchType() == InEvent) {
96  // CMS-THREADING For the primary input source calls to this function need to be serialized
98  }
99  return edp;
100  }
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:128
std::exception_ptr lastException_
BranchType branchType() const
Definition: RootTree.h:164
roottree::BranchMap::const_iterator iterator
int k[5][pyjets_maxn]
EntryNumber const & entryNumberForIndex(unsigned int index) const
Definition: RootTree.cc:93
bool found(iterator const &iter) const
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:357
void addContext(std::string const &context)
Definition: Exception.cc:227
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_
void edm::RootDelayedReader::mergeReaders_ ( DelayedReader other)
inlineoverrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 63 of file RootDelayedReader.h.

References nextReader_, and trackingPlots::other.

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 51 of file RootDelayedReader.h.

References postEventReadFromSourceSignal_.

51  {
53  }
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 48 of file RootDelayedReader.h.

References preEventReadFromSourceSignal_.

48  {
50  }
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_, and sharedResources_().

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 55 of file RootDelayedReader.h.

References getProduct_(), gen::k, 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 44 of file RootDelayedReader.cc.

References mutex_, and resourceAcquirer_.

Referenced by reset_().

44  {
45  return std::make_pair(resourceAcquirer_.get(), mutex_.get());
46  }
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 74 of file RootDelayedReader.h.

InputType edm::RootDelayedReader::inputType_
private

Definition at line 78 of file RootDelayedReader.h.

Referenced by getProduct_().

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

Definition at line 87 of file RootDelayedReader.h.

Referenced by getProduct_().

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

Definition at line 77 of file RootDelayedReader.h.

Referenced by RootDelayedReader(), and sharedResources_().

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

Definition at line 75 of file RootDelayedReader.h.

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

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

Definition at line 82 of file RootDelayedReader.h.

Referenced by postEventReadFromSourceSignal(), and setSignals().

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

Definition at line 81 of file RootDelayedReader.h.

Referenced by preEventReadFromSourceSignal(), and setSignals().

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

Definition at line 76 of file RootDelayedReader.h.

Referenced by RootDelayedReader(), and sharedResources_().

RootTree const& edm::RootDelayedReader::tree_
private

Definition at line 73 of file RootDelayedReader.h.

Referenced by branches(), and getProduct_().

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

Definition at line 79 of file RootDelayedReader.h.

Referenced by getProduct_().