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 
14 #include "RootTree.h"
15 
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <exception>
20 
21 class TClass;
22 namespace edm {
23  class InputFile;
24  class RootTree;
26  class Exception;
27 
28  //------------------------------------------------------------
29  // Class RootDelayedReader: pretends to support file reading.
30  //
31 
33  public:
36  typedef roottree::BranchMap::const_iterator iterator;
39  RootTree const& tree,
40  std::shared_ptr<InputFile> filePtr,
41  InputType inputType);
42 
43  ~RootDelayedReader() override;
44 
45  RootDelayedReader(RootDelayedReader const&) = delete; // Disallow copying and moving
46  RootDelayedReader& operator=(RootDelayedReader const&) = delete; // Disallow copying and moving
47 
50  }
53  }
54 
55  void setSignals(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_(BranchKey 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  iterator branchIter(BranchKey const& k) const {return branches().find(k);}
69  bool found(iterator const& iter) const {return iter != branches().end();}
70  BranchInfo const& getBranchInfo(iterator const& iter) const {return iter->second; }
71  // NOTE: filePtr_ appears to be unused, but is needed to prevent
72  // the file containing the branch from being reclaimed.
73  RootTree const& tree_;
76  std::unique_ptr<SharedResourcesAcquirer> resourceAcquirer_; // We do not use propagate_const because the acquirer is itself mutable.
77  std::shared_ptr<std::recursive_mutex> mutex_;
80 
83 
84  //If a fatal exception happens we need to make a copy so we can
85  // rethrow that exception on other threads. This avoids TTree
86  // non-exception safety problems on later calls to TTree.
87  mutable std::exception_ptr lastException_;
88  }; // class RootDelayedReader
89  //------------------------------------------------------------
90 }
91 #endif
void mergeReaders_(DelayedReader *other) override
InputType
Definition: InputType.h:5
RootTree const & tree_
roottree::BranchMap BranchMap
BranchInfo const & getBranchInfo(iterator const &iter) const
std::shared_ptr< std::recursive_mutex > mutex_
std::map< BranchKey const, BranchInfo > BranchMap
Definition: RootTree.h:63
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > sharedResources_() const override
std::unique_ptr< WrapperBase > getProduct_(BranchKey const &k, EDProductGetter const *ep) override
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal() const final
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)
RootDelayedReader(RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal() const final
IndexIntoFile::EntryNumber_t EntryNumber
Definition: RootTree.h:49
roottree::BranchMap::const_iterator iterator
RootDelayedReader & operator=(RootDelayedReader const &)=delete
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_
int k[5][pyjets_maxn]
bool found(iterator const &iter) const
roottree::BranchInfo BranchInfo
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
edm::propagate_const< TClass * > wrapperBaseTClass_
HLT enums.
roottree::EntryNumber EntryNumber
BranchMap const & branches() const
Definition: RootTree.cc:178
iterator branchIter(BranchKey const &k) const
Definition: tree.py:1
edm::propagate_const< DelayedReader * > nextReader_
BranchMap const & branches() const