CMS 3D CMS Logo

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