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 found
55  // in a thinned container and key is modified to be the index into
56  // that thinned container. If the desired element is not found, then
57  // nullptr is returned.
58  edm::WrapperBase const* getThinnedProduct(edm::ProductID const&, 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.
71  void getThinnedProducts(edm::ProductID const&,
72  std::vector<edm::WrapperBase const*>& foundContainers,
73  std::vector<unsigned int>& keys) const override;
74 
75 private:
76  // ---------- static member functions --------------------
77 
78  // ---------- member functions ---------------------------
79  unsigned int transitionIndex_() const override { return 0u; }
80 
81  edm::WrapperBase const* getIt(edm::BranchID const&, Long_t eventEntry) const;
82 
83  struct Buffer {
84  Buffer(edm::WrapperBase const* iProd, TBranch* iBranch, void* iAddress, TClass* iClass)
85  : product_(iProd), branch_(iBranch), address_(iAddress), eventEntry_(-1), class_(iClass) {}
86  Buffer() : product_(), branch_(), address_(), eventEntry_(-1), class_(nullptr) {}
87 
88  std::shared_ptr<edm::WrapperBase const> product_;
90  void* address_; //the address to pass to Root since as of 5.13 they cache that info
91  Long_t eventEntry_; //the event Entry used with the last GetEntry call
93  };
94 
95  BareRootProductGetter(BareRootProductGetter const&) = delete; // stop default
96 
97  BareRootProductGetter const& operator=(BareRootProductGetter const&) = delete; // stop default
98 
99  Buffer* createNewBuffer(edm::BranchID const&) const;
100  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID, Long_t eventEntry) const;
101 
102  // ---------- member data --------------------------------
103 
104  typedef std::map<edm::BranchID, Buffer> IdToBuffers;
105  mutable IdToBuffers idToBuffers_;
107 };
108 #endif
edm::propagate_const< TClass * > class_
#define nullptr
std::map< edm::BranchID, Buffer > IdToBuffers
T const * getThinnedProduct(RefCore const &ref, unsigned int &thinnedKey, EDProductGetter const *prodGetter)
Definition: RefCoreGet.h:116
unsigned int transitionIndex_() const override
Buffer(edm::WrapperBase const *iProd, TBranch *iBranch, void *iAddress, TClass *iClass)
edm::propagate_const< TBranch * > branch_
HLT enums.
fwlite::BranchMapReader branchMap_
std::shared_ptr< edm::WrapperBase const > product_