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 
48  // ---------- const member functions ---------------------
49  edm::WrapperBase const* getIt(edm::ProductID const&) const override;
50 
51  // getThinnedProduct assumes getIt was already called and failed to find
52  // the product. The input key is the index of the desired element in the
53  // container identified by ProductID (which cannot be found).
54  // If the return value is not null, then the desired element was
55  // found in a thinned container. If the desired element is not
56  // found, then an optional without a value is returned.
57  std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const&,
58  unsigned int key) const override;
59 
60  // getThinnedProducts assumes getIt was already called and failed to find
61  // the product. The input keys are the indexes into the container identified
62  // by ProductID (which cannot be found). On input the WrapperBase pointers
63  // must all be set to nullptr (except when the function calls itself
64  // recursively where non-null pointers mark already found elements).
65  // Thinned containers derived from the product are searched to see
66  // if they contain the desired elements. For each that is
67  // found, the corresponding WrapperBase pointer is set and the key
68  // is modified to be the key into the container where the element
69  // was found. The WrapperBase pointers might or might not all point
70  // to the same thinned container.
72  std::vector<edm::WrapperBase const*>& foundContainers,
73  std::vector<unsigned int>& keys) const override;
74 
75  // This overload is allowed to be called also without getIt()
76  // being called first, but the thinned ProductID must come from an
77  // existing RefCore. The input key is the index of the desired
78  // element in the container identified by the parent ProductID.
79  // If the return value is not null, then the desired element was found
80  // in a thinned container. If the desired element is not found, then
81  // an optional without a value is returned.
83  unsigned int key,
84  edm::ProductID const& thinned) const override;
85 
86 private:
87  // ---------- static member functions --------------------
88 
89  // ---------- member functions ---------------------------
90  unsigned int transitionIndex_() const override { return 0u; }
91 
92  edm::WrapperBase const* getIt(edm::BranchID const&, Long_t eventEntry) const;
93 
94  struct Buffer {
95  Buffer(edm::WrapperBase const* iProd, TBranch* iBranch, void* iAddress, TClass* iClass)
96  : product_(iProd), branch_(iBranch), address_(iAddress), eventEntry_(-1), class_(iClass) {}
97  Buffer() : product_(), branch_(), address_(), eventEntry_(-1), class_(nullptr) {}
98 
99  std::shared_ptr<edm::WrapperBase const> product_;
101  void* address_; //the address to pass to Root since as of 5.13 they cache that info
102  Long_t eventEntry_; //the event Entry used with the last GetEntry call
104  };
105 
106  BareRootProductGetter(BareRootProductGetter const&) = delete; // stop default
107 
108  BareRootProductGetter const& operator=(BareRootProductGetter const&) = delete; // stop default
109 
110  Buffer* createNewBuffer(edm::BranchID const&) const;
111  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID, Long_t eventEntry) const;
112 
113  // ---------- member data --------------------------------
114 
115  typedef std::map<edm::BranchID, Buffer> IdToBuffers;
118 };
119 #endif
BareRootProductGetter::Buffer::address_
void * address_
Definition: BareRootProductGetter.h:101
BareRootProductGetter::Buffer::eventEntry_
Long_t eventEntry_
Definition: BareRootProductGetter.h:102
BareRootProductGetter::~BareRootProductGetter
~BareRootProductGetter() override
Definition: BareRootProductGetter.cc:51
BareRootProductGetter::getThinnedProducts
void getThinnedProducts(edm::ProductID const &, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
Definition: BareRootProductGetter.cc:173
BareRootProductGetter::BareRootProductGetter
BareRootProductGetter()
Definition: BareRootProductGetter.cc:45
propagate_const.h
edm
HLT enums.
Definition: AlignableModifier.h:19
BareRootProductGetter::getThinnedKeyFrom
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const override
Definition: BareRootProductGetter.cc:187
BareRootProductGetter::Buffer::product_
std::shared_ptr< edm::WrapperBase const > product_
Definition: BareRootProductGetter.h:99
BareRootProductGetter::getThinnedProduct
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &, unsigned int key) const override
Definition: BareRootProductGetter.cc:161
edm::ThinnedAssociation
Definition: ThinnedAssociation.h:15
BareRootProductGetter::Buffer::Buffer
Buffer()
Definition: BareRootProductGetter.h:97
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
BareRootProductGetter::idToBuffers_
IdToBuffers idToBuffers_
Definition: BareRootProductGetter.h:116
BareRootProductGetter::transitionIndex_
unsigned int transitionIndex_() const override
Definition: BareRootProductGetter.h:90
BareRootProductGetter::Buffer::Buffer
Buffer(edm::WrapperBase const *iProd, TBranch *iBranch, void *iAddress, TClass *iClass)
Definition: BareRootProductGetter.h:95
BareRootProductGetter::Buffer::class_
edm::propagate_const< TClass * > class_
Definition: BareRootProductGetter.h:103
BranchMapReader.h
edm::EDProductGetter
Definition: EDProductGetter.h:41
edm::propagate_const< TBranch * >
edm::BranchID
Definition: BranchID.h:14
BareRootProductGetter::getThinnedAssociation
edm::ThinnedAssociation const * getThinnedAssociation(edm::BranchID const &branchID, Long_t eventEntry) const
Definition: BareRootProductGetter.cc:268
BareRootProductGetter::branchMap_
fwlite::BranchMapReader branchMap_
Definition: BareRootProductGetter.h:117
WrapperBase.h
BareRootProductGetter::Buffer
Definition: BareRootProductGetter.h:94
BareRootProductGetter::getIt
edm::WrapperBase const * getIt(edm::ProductID const &) const override
Definition: BareRootProductGetter.cc:71
BareRootProductGetter
Definition: BareRootProductGetter.h:43
BareRootProductGetter::createNewBuffer
Buffer * createNewBuffer(edm::BranchID const &) const
Definition: BareRootProductGetter.cc:221
edm::WrapperBase
Definition: WrapperBase.h:23
edm::OptionalThinnedKey
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
Definition: EDProductGetter.h:39
BareRootProductGetter::operator=
BareRootProductGetter const & operator=(BareRootProductGetter const &)=delete
BareRootProductGetter::IdToBuffers
std::map< edm::BranchID, Buffer > IdToBuffers
Definition: BareRootProductGetter.h:115
fwlite::BranchMapReader
Definition: BranchMapReader.h:70
EDProductGetter.h
crabWrapper.key
key
Definition: crabWrapper.py:19
class-composition.parent
parent
Definition: class-composition.py:88
edm::ProductID
Definition: ProductID.h:27
BareRootProductGetter::Buffer::branch_
edm::propagate_const< TBranch * > branch_
Definition: BareRootProductGetter.h:100