CMS 3D CMS Logo

BareRootProductGetterBase.h
Go to the documentation of this file.
1 #ifndef FWCore_FWLite_BareRootProductGetterBase_h
2 #define FWCore_FWLite_BareRootProductGetterBase_h
3 // -*- C++ -*-
4 //
5 // Package: FWLite
6 // Class : BareRootProductGetterBase
7 //
20 //
21 // Original Author: Chris Jones
22 // Created: Tue May 23 11:03:27 EDT 2006
23 //
24 
25 // user include files
30 
31 // system include files
32 #include "Rtypes.h"
33 #include <map>
34 #include <memory>
35 #include <vector>
36 
37 // forward declarations
38 class TBranch;
39 class TClass;
40 
41 namespace edm {
42  class BranchID;
43  class ProductID;
44  class ThinnedAssociation;
45 } // namespace edm
46 
48 public:
50  ~BareRootProductGetterBase() override;
51  BareRootProductGetterBase(BareRootProductGetterBase const&) = delete; // stop default
52  BareRootProductGetterBase const& operator=(BareRootProductGetterBase const&) = delete; // stop default
53 
54  // ---------- const member functions ---------------------
55  edm::WrapperBase const* getIt(edm::ProductID const&) const override;
56 
57  // getThinnedProduct assumes getIt was already called and failed to find
58  // the product. The input key is the index of the desired element in the
59  // container identified by ProductID (which cannot be found).
60  // If the return value is not null, then the desired element was
61  // found in a thinned container. If the desired element is not
62  // found, then an optional without a value is returned.
63  std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const&,
64  unsigned int key) const override;
65 
66  // getThinnedProducts assumes getIt was already called and failed to find
67  // the product. The input keys are the indexes into the container identified
68  // by ProductID (which cannot be found). On input the WrapperBase pointers
69  // must all be set to nullptr (except when the function calls itself
70  // recursively where non-null pointers mark already found elements).
71  // Thinned containers derived from the product are searched to see
72  // if they contain the desired elements. For each that is
73  // found, the corresponding WrapperBase pointer is set and the key
74  // is modified to be the key into the container where the element
75  // was found. The WrapperBase pointers might or might not all point
76  // to the same thinned container.
78  std::vector<edm::WrapperBase const*>& foundContainers,
79  std::vector<unsigned int>& keys) const override;
80 
81  // This overload is allowed to be called also without getIt()
82  // being called first, but the thinned ProductID must come from an
83  // existing RefCore. The input key is the index of the desired
84  // element in the container identified by the parent ProductID.
85  // If the return value is not null, then the desired element was found
86  // in a thinned container. If the desired element is not found, then
87  // an optional without a value is returned.
89  unsigned int key,
90  edm::ProductID const& thinned) const override;
91 
92 private:
93  // ---------- static member functions --------------------
94 
95  // ---------- member functions ---------------------------
96  unsigned int transitionIndex_() const override { return 0u; }
97 
98  edm::WrapperBase const* getIt(edm::BranchID const&, Long_t eventEntry) const;
99  // This customization point was created for FireworksWeb
100  virtual TFile* currentFile() const = 0;
101 
102  struct Buffer {
103  Buffer(edm::WrapperBase const* iProd, TBranch* iBranch, void* iAddress, TClass* iClass)
104  : product_(iProd), branch_(iBranch), address_(iAddress), eventEntry_(-1), class_(iClass) {}
105  Buffer() : product_(), branch_(), address_(), eventEntry_(-1), class_(nullptr) {}
106 
107  std::shared_ptr<edm::WrapperBase const> product_;
109  void* address_; //the address to pass to Root since as of 5.13 they cache that info
110  Long_t eventEntry_; //the event Entry used with the last GetEntry call
112  };
113 
114  Buffer* createNewBuffer(edm::BranchID const&) const;
115  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID, Long_t eventEntry) const;
116 
117  // ---------- member data --------------------------------
118 
119  typedef std::map<edm::BranchID, Buffer> IdToBuffers;
122 };
123 #endif
std::shared_ptr< edm::WrapperBase const > product_
~BareRootProductGetterBase() override
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &, unsigned int key) const override
fwlite::BranchMapReader branchMap_
void getThinnedProducts(edm::ProductID const &, std::vector< edm::WrapperBase const *> &foundContainers, std::vector< unsigned int > &keys) const override
edm::ThinnedAssociation const * getThinnedAssociation(edm::BranchID const &branchID, Long_t eventEntry) const
virtual TFile * currentFile() const =0
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const override
unsigned int transitionIndex_() const override
BareRootProductGetterBase const & operator=(BareRootProductGetterBase const &)=delete
edm::propagate_const< TBranch * > branch_
key
prepare the HTCondor submission files and eventually submit them
edm::propagate_const< TClass * > class_
Buffer(edm::WrapperBase const *iProd, TBranch *iBranch, void *iAddress, TClass *iClass)
HLT enums.
edm::WrapperBase const * getIt(edm::ProductID const &) const override
std::map< edm::BranchID, Buffer > IdToBuffers
Buffer * createNewBuffer(edm::BranchID const &) const