CMS 3D CMS Logo

RootDelayedReader.h
Go to the documentation of this file.
1 #ifndef IOPool_Input_RootDelayedReader_h
2 #define IOPool_Input_RootDelayedReader_h
3 
4 /*----------------------------------------------------------------------
5 
6 RootDelayedReader.h // used by ROOT input sources
7 
8 ----------------------------------------------------------------------*/
9 
15 #include "RootTree.h"
16 
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <exception>
21 
22 class TClass;
23 namespace edm {
24  class InputFile;
25  class RootTree;
27  class Exception;
28 
29  //------------------------------------------------------------
30  // Class RootDelayedReader: pretends to support file reading.
31  //
32 
34  public:
38  RootDelayedReader(RootTree const& tree, std::shared_ptr<InputFile> filePtr, InputType inputType);
39 
40  ~RootDelayedReader() override;
41 
42  RootDelayedReader(RootDelayedReader const&) = delete; // Disallow copying and moving
43  RootDelayedReader& operator=(RootDelayedReader const&) = delete; // Disallow copying and moving
44 
46  const final {
48  }
50  const final {
52  }
53 
54  void setSignals(
55  signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* preEventReadSource,
56  signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* postEventReadSource) {
57  preEventReadFromSourceSignal_ = preEventReadSource;
58  postEventReadFromSourceSignal_ = postEventReadSource;
59  }
60 
61  private:
62  std::unique_ptr<WrapperBase> getProduct_(BranchID const& k, EDProductGetter const* ep) override;
64  void reset_() override { nextReader_ = nullptr; }
65  std::pair<SharedResourcesAcquirer*, std::recursive_mutex*> sharedResources_() const override;
66 
67  BranchMap const& branches() const { return tree_.branches(); }
68  BranchInfo const* getBranchInfo(BranchID const& k) const { return branches().find(k); }
69  // NOTE: filePtr_ appears to be unused, but is needed to prevent
70  // the file containing the branch from being reclaimed.
71  RootTree const& tree_;
74  std::unique_ptr<SharedResourcesAcquirer>
75  resourceAcquirer_; // We do not use propagate_const because the acquirer is itself mutable.
76  std::shared_ptr<std::recursive_mutex> mutex_;
79 
81  nullptr;
83  nullptr;
84 
85  //If a fatal exception happens we need to make a copy so we can
86  // rethrow that exception on other threads. This avoids TTree
87  // non-exception safety problems on later calls to TTree.
88  //All uses of the ROOT file are serialized
89  CMS_SA_ALLOW mutable std::exception_ptr lastException_;
90  }; // class RootDelayedReader
91  //------------------------------------------------------------
92 } // namespace edm
93 #endif
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
propagate_const.h
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
edm::RootDelayedReader
Definition: RootDelayedReader.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
tree
Definition: tree.py:1
edm::RootDelayedReader::resourceAcquirer_
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
Definition: RootDelayedReader.h:75
BranchID.h
RootTree.h
edm::RootDelayedReader::inputType_
InputType inputType_
Definition: RootDelayedReader.h:77
edm::RootDelayedReader::~RootDelayedReader
~RootDelayedReader() override
Definition: RootDelayedReader.cc:38
DelayedReader.h
edm::RootDelayedReader::postEventReadFromSourceSignal
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal() const final
Definition: RootDelayedReader.h:49
edm::RootDelayedReader::RootDelayedReader
RootDelayedReader(RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
Definition: RootDelayedReader.cc:23
watchdog.const
const
Definition: watchdog.py:83
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
edm::RootDelayedReader::setSignals
void setSignals(signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
Definition: RootDelayedReader.h:54
edm::InputType
InputType
Definition: InputType.h:5
edm::RootDelayedReader::BranchMap
roottree::BranchMap BranchMap
Definition: RootDelayedReader.h:36
InputFile
Definition: FedRawDataInputSource.h:206
edm::RootDelayedReader::filePtr_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
Definition: RootDelayedReader.h:72
edm::EDProductGetter
Definition: EDProductGetter.h:41
edm::propagate_const
Definition: propagate_const.h:32
edm::roottree::EntryNumber
IndexIntoFile::EntryNumber_t EntryNumber
Definition: RootTree.h:51
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::RootDelayedReader::BranchInfo
roottree::BranchInfo BranchInfo
Definition: RootDelayedReader.h:35
edm::StreamContext
Definition: StreamContext.h:31
edm::RootDelayedReader::mergeReaders_
void mergeReaders_(DelayedReader *other) override
Definition: RootDelayedReader.h:63
edm::BranchID
Definition: BranchID.h:14
trackingPlots.other
other
Definition: trackingPlots.py:1467
dqmdumpme.k
k
Definition: dqmdumpme.py:60
InputType.h
SharedResourcesAcquirer
edm::RootDelayedReader::operator=
RootDelayedReader & operator=(RootDelayedReader const &)=delete
edm::RootDelayedReader::tree_
RootTree const & tree_
Definition: RootDelayedReader.h:71
Exception
thread_safety_macros.h
edm::RootDelayedReader::reset_
void reset_() override
Definition: RootDelayedReader.h:64
edm::roottree::BranchInfo
Definition: RootTree.h:52
edm::RootDelayedReader::preEventReadFromSourceSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_
Definition: RootDelayedReader.h:80
edm::RootDelayedReader::preEventReadFromSourceSignal
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal() const final
Definition: RootDelayedReader.h:45
edm::RootDelayedReader::nextReader_
edm::propagate_const< DelayedReader * > nextReader_
Definition: RootDelayedReader.h:73
edm::roottree::BranchMap
Definition: RootTree.h:67
edm::RootDelayedReader::EntryNumber
roottree::EntryNumber EntryNumber
Definition: RootDelayedReader.h:37
edm::DelayedReader
Definition: DelayedReader.h:29
edm::RootDelayedReader::getProduct_
std::unique_ptr< WrapperBase > getProduct_(BranchID const &k, EDProductGetter const *ep) override
Definition: RootDelayedReader.cc:44
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
edm::RootTree
Definition: RootTree.h:103
edm::RootDelayedReader::lastException_
std::exception_ptr lastException_
Definition: RootDelayedReader.h:89
edm::signalslot::Signal
Definition: DelayedReader.h:26
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::RootDelayedReader::branches
BranchMap const & branches() const
Definition: RootDelayedReader.h:67
edm::RootDelayedReader::sharedResources_
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > sharedResources_() const override
Definition: RootDelayedReader.cc:40
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29