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
BareRootProductGetter::Buffer::address_
void * address_
Definition: BareRootProductGetter.h:103
BareRootProductGetter::Buffer::eventEntry_
Long_t eventEntry_
Definition: BareRootProductGetter.h:104
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:101
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:99
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
BareRootProductGetter::idToBuffers_
IdToBuffers idToBuffers_
Definition: BareRootProductGetter.h:114
BareRootProductGetter::transitionIndex_
unsigned int transitionIndex_() const override
Definition: BareRootProductGetter.h:92
BareRootProductGetter::Buffer::Buffer
Buffer(edm::WrapperBase const *iProd, TBranch *iBranch, void *iAddress, TClass *iClass)
Definition: BareRootProductGetter.h:97
BareRootProductGetter::Buffer::class_
edm::propagate_const< TClass * > class_
Definition: BareRootProductGetter.h:105
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:115
WrapperBase.h
BareRootProductGetter::Buffer
Definition: BareRootProductGetter.h:96
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:113
fwlite::BranchMapReader
Definition: BranchMapReader.h:70
EDProductGetter.h
crabWrapper.key
key
Definition: crabWrapper.py:19
class-composition.parent
parent
Definition: class-composition.py:98
edm::ProductID
Definition: ProductID.h:27
BareRootProductGetter::Buffer::branch_
edm::propagate_const< TBranch * > branch_
Definition: BareRootProductGetter.h:102