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::shared_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
BranchInfo const * getBranchInfo(BranchID const &k) const
void mergeReaders_(DelayedReader *other) override
InputType
Definition: InputType.h:5
#define CMS_SA_ALLOW
RootTree const & tree_
roottree::BranchMap BranchMap
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > sharedResources_() const override
std::shared_ptr< std::recursive_mutex > mutex_
BranchInfo const * find(BranchID const &iKey) const
Definition: RootTree.h:59
std::exception_ptr lastException_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal_
void setSignals(signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
std::shared_ptr< WrapperBase > getProduct_(BranchID const &k, EDProductGetter const *ep) override
RootDelayedReader(RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal() const final
RootDelayedReader & operator=(RootDelayedReader const &)=delete
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal() const final
BranchMap const & branches() const
roottree::BranchInfo BranchInfo
IndexIntoFile::EntryNumber_t EntryNumber
Definition: RootTree.h:42
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
edm::propagate_const< TClass * > wrapperBaseTClass_
BranchMap const & branches() const
Definition: RootTree.cc:194
HLT enums.
roottree::EntryNumber EntryNumber
Definition: tree.py:1
edm::propagate_const< DelayedReader * > nextReader_