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
 

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 (RootDelayedReader const &)=delete
 
 RootDelayedReader (RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
 
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 (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::unique_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< SharedResourcesAcquirerresourceAcquirer_
 
RootTree const & tree_
 
edm::propagate_const< TClass * > wrapperBaseTClass_
 

Detailed Description

Definition at line 33 of file RootDelayedReader.h.

Member Typedef Documentation

◆ BranchInfo

Definition at line 35 of file RootDelayedReader.h.

◆ BranchMap

Definition at line 36 of file RootDelayedReader.h.

◆ EntryNumber

Definition at line 37 of file RootDelayedReader.h.

Constructor & Destructor Documentation

◆ RootDelayedReader() [1/2]

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

Definition at line 23 of file RootDelayedReader.cc.

24  : tree_(tree),
25  filePtr_(filePtr),
26  nextReader_(),
28  : static_cast<SharedResourcesAcquirer*>(nullptr)),
29  inputType_(inputType),
30  wrapperBaseTClass_(TClass::GetClass("edm::WrapperBase")) {
31  if (inputType == InputType::Primary) {
33  resourceAcquirer_ = std::make_unique<SharedResourcesAcquirer>(std::move(resources.first));
34  mutex_ = resources.second;
35  }
36  }

References edm::SharedResourcesRegistry::createAcquirerForSourceDelayedReader(), edm::SharedResourcesRegistry::instance(), eostools::move(), mutex_, edm::Primary, resourceAcquirer_, and mps_fire::resources.

◆ ~RootDelayedReader()

edm::RootDelayedReader::~RootDelayedReader ( )
override

Definition at line 38 of file RootDelayedReader.cc.

38 {}

◆ RootDelayedReader() [2/2]

edm::RootDelayedReader::RootDelayedReader ( RootDelayedReader const &  )
delete

Member Function Documentation

◆ branches()

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

Definition at line 67 of file RootDelayedReader.h.

67 { return tree_.branches(); }

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

Referenced by getBranchInfo().

◆ getBranchInfo()

BranchInfo const* edm::RootDelayedReader::getBranchInfo ( BranchID const &  k) const
inlineprivate

Definition at line 68 of file RootDelayedReader.h.

68 { return branches().find(k); }

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

Referenced by getProduct_().

◆ getProduct_()

std::unique_ptr< WrapperBase > edm::RootDelayedReader::getProduct_ ( BranchID const &  k,
EDProductGetter const *  ep 
)
overrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 44 of file RootDelayedReader.cc.

44  {
45  if (lastException_) {
46  std::rethrow_exception(lastException_);
47  }
48  auto branchInfo = getBranchInfo(k);
49  if (not branchInfo) {
50  if (nextReader_) {
51  return nextReader_->getProduct(k, ep);
52  } else {
53  return std::unique_ptr<WrapperBase>();
54  }
55  }
56  TBranch* br = branchInfo->productBranch_;
57  if (br == nullptr) {
58  if (nextReader_) {
59  return nextReader_->getProduct(k, ep);
60  } else {
61  return std::unique_ptr<WrapperBase>();
62  }
63  }
64 
66  //make code exception safe
67  std::shared_ptr<void> refCoreStreamerGuard(nullptr, [](void*) {
68  setRefCoreStreamer(false);
69  ;
70  });
71  TClass* cp = branchInfo->classCache_;
72  if (nullptr == cp) {
73  branchInfo->classCache_ = TClass::GetClass(branchInfo->branchDescription_.wrappedName().c_str());
74  cp = branchInfo->classCache_;
75  branchInfo->offsetToWrapperBase_ = cp->GetBaseClassOffset(wrapperBaseTClass_);
76  }
77  void* p = cp->New();
78  std::unique_ptr<WrapperBase> edp = getWrapperBasePtr(p, branchInfo->offsetToWrapperBase_);
79  br->SetAddress(&p);
80  try {
81  //Run and Lumi only have 1 entry number, which is index 0
82  tree_.getEntry(br, tree_.entryNumberForIndex(tree_.branchType() == InEvent ? ep->transitionIndex() : 0));
83  } catch (edm::Exception& exception) {
84  exception.addContext("Rethrowing an exception that happened on a different thread.");
85  lastException_ = std::current_exception();
86  } catch (...) {
87  lastException_ = std::current_exception();
88  }
89  if (lastException_) {
90  std::rethrow_exception(lastException_);
91  }
92  if (tree_.branchType() == InEvent) {
93  // CMS-THREADING For the primary input source calls to this function need to be serialized
95  }
96  return edp;
97  }

References beamvalidation::br, edm::RootTree::branchType(), CommonMethods::cp(), edm::RootTree::entryNumberForIndex(), SiStripBadComponentsDQMServiceTemplate_cfg::ep, cppFunctionSkipper::exception, getBranchInfo(), edm::RootTree::getEntry(), edm::getWrapperBasePtr(), edm::InEvent, inputType_, dqmdumpme::k, lastException_, nextReader_, AlCaHLTBitMon_ParallelJobs::p, edm::InputFile::reportReadBranch(), edm::setRefCoreStreamer(), AlCaHLTBitMon_QueryRunRegistry::string, tree_, and wrapperBaseTClass_.

◆ mergeReaders_()

void edm::RootDelayedReader::mergeReaders_ ( DelayedReader other)
inlineoverrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 63 of file RootDelayedReader.h.

63 { nextReader_ = other; }

References nextReader_, and trackingPlots::other.

◆ operator=()

RootDelayedReader& edm::RootDelayedReader::operator= ( RootDelayedReader const &  )
delete

◆ postEventReadFromSourceSignal()

signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* edm::RootDelayedReader::postEventReadFromSourceSignal ( ) const
inlinefinalvirtual

Implements edm::DelayedReader.

Definition at line 49 of file RootDelayedReader.h.

50  {
52  }

References postEventReadFromSourceSignal_.

◆ preEventReadFromSourceSignal()

signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* edm::RootDelayedReader::preEventReadFromSourceSignal ( ) const
inlinefinalvirtual

Implements edm::DelayedReader.

Definition at line 45 of file RootDelayedReader.h.

46  {
48  }

References preEventReadFromSourceSignal_.

◆ reset_()

void edm::RootDelayedReader::reset_ ( )
inlineoverrideprivatevirtual

Implements edm::DelayedReader.

Definition at line 64 of file RootDelayedReader.h.

64 { nextReader_ = nullptr; }

References nextReader_.

◆ setSignals()

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.

56  {
57  preEventReadFromSourceSignal_ = preEventReadSource;
58  postEventReadFromSourceSignal_ = postEventReadSource;
59  }

References postEventReadFromSourceSignal_, and preEventReadFromSourceSignal_.

◆ sharedResources_()

std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > edm::RootDelayedReader::sharedResources_ ( ) const
overrideprivatevirtual

Reimplemented from edm::DelayedReader.

Definition at line 40 of file RootDelayedReader.cc.

40  {
41  return std::make_pair(resourceAcquirer_.get(), mutex_.get());
42  }

References mutex_, and resourceAcquirer_.

Member Data Documentation

◆ filePtr_

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

Definition at line 72 of file RootDelayedReader.h.

◆ inputType_

InputType edm::RootDelayedReader::inputType_
private

Definition at line 77 of file RootDelayedReader.h.

Referenced by getProduct_().

◆ lastException_

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

Definition at line 89 of file RootDelayedReader.h.

Referenced by getProduct_().

◆ mutex_

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

Definition at line 76 of file RootDelayedReader.h.

Referenced by RootDelayedReader(), and sharedResources_().

◆ nextReader_

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

Definition at line 73 of file RootDelayedReader.h.

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

◆ postEventReadFromSourceSignal_

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().

◆ preEventReadFromSourceSignal_

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().

◆ resourceAcquirer_

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

Definition at line 75 of file RootDelayedReader.h.

Referenced by RootDelayedReader(), and sharedResources_().

◆ tree_

RootTree const& edm::RootDelayedReader::tree_
private

Definition at line 71 of file RootDelayedReader.h.

Referenced by branches(), and getProduct_().

◆ wrapperBaseTClass_

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

Definition at line 78 of file RootDelayedReader.h.

Referenced by getProduct_().

edm::RootDelayedReader::getBranchInfo
BranchInfo const * getBranchInfo(BranchID const &k) const
Definition: RootDelayedReader.h:68
edm::RootDelayedReader::mutex_
std::shared_ptr< std::recursive_mutex > mutex_
Definition: RootDelayedReader.h:76
edm::getWrapperBasePtr
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
Definition: getWrapperBasePtr.h:8
edm::RootTree::branches
BranchMap const & branches() const
Definition: RootTree.cc:177
edm::roottree::BranchMap::find
BranchInfo const * find(BranchID const &iKey) const
Definition: RootTree.h:76
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
tree
Definition: tree.py:1
edm::RootDelayedReader::resourceAcquirer_
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
Definition: RootDelayedReader.h:75
edm::RootDelayedReader::inputType_
InputType inputType_
Definition: RootDelayedReader.h:77
edm::SharedResourcesRegistry::createAcquirerForSourceDelayedReader
std::pair< SharedResourcesAcquirer, std::shared_ptr< std::recursive_mutex > > createAcquirerForSourceDelayedReader()
Definition: SharedResourcesRegistry.cc:64
edm::InputFile::reportReadBranch
static void reportReadBranch(InputType inputType, std::string const &branchname)
Definition: InputFile.cc:111
edm::Exception
Definition: EDMException.h:77
edm::RootDelayedReader::filePtr_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootDelayedReader.h:72
edm::RootDelayedReader::postEventReadFromSourceSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal_
Definition: RootDelayedReader.h:82
edm::RootDelayedReader::wrapperBaseTClass_
edm::propagate_const< TClass * > wrapperBaseTClass_
Definition: RootDelayedReader.h:78
edm::RootTree::entryNumberForIndex
EntryNumber const & entryNumberForIndex(unsigned int index) const
Definition: RootTree.cc:100
trackingPlots.other
other
Definition: trackingPlots.py:1467
edm::InEvent
Definition: BranchType.h:11
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::SharedResourcesRegistry::instance
static SharedResourcesRegistry * instance()
Definition: SharedResourcesRegistry.cc:25
SharedResourcesAcquirer
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
edm::RootTree::getEntry
void getEntry(TBranch *branch, EntryNumber entry) const
Definition: RootTree.cc:365
edm::RootDelayedReader::tree_
RootTree const & tree_
Definition: RootDelayedReader.h:71
beamvalidation.br
br
Definition: beamvalidation.py:398
edm::RootDelayedReader::preEventReadFromSourceSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_
Definition: RootDelayedReader.h:80
edm::RootDelayedReader::nextReader_
edm::propagate_const< DelayedReader * > nextReader_
Definition: RootDelayedReader.h:73
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::InputType::Primary
mps_fire.resources
resources
Definition: mps_fire.py:263
edm::setRefCoreStreamer
void setRefCoreStreamer(bool resetAll=false)
Definition: RefCoreStreamer.cc:83
edm::RootTree::branchType
BranchType branchType() const
Definition: RootTree.h:196
edm::RootDelayedReader::lastException_
std::exception_ptr lastException_
Definition: RootDelayedReader.h:89
CommonMethods.cp
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
Definition: CommonMethods.py:192
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::RootDelayedReader::branches
BranchMap const & branches() const
Definition: RootDelayedReader.h:67