CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
25 
26 // system include files
27 #include "Rtypes.h"
28 #include <map>
29 #include <memory>
30 #include <vector>
31 
32 // forward declarations
33 class TBranch;
34 class TClass;
35 
36 namespace edm {
37  class BranchID;
38  class ProductID;
39  class ThinnedAssociation;
40 }
41 
43 
44  public:
46  virtual ~BareRootProductGetter();
47 
48  // ---------- const member functions ---------------------
49  virtual 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.
59  unsigned int& key) const override;
60 
61  // getThinnedProducts assumes getIt was already called and failed to find
62  // the product. The input keys are the indexes into the container identified
63  // by ProductID (which cannot be found). On input the WrapperBase pointers
64  // must all be set to nullptr (except when the function calls itself
65  // recursively where non-null pointers mark already found elements).
66  // Thinned containers derived from the product are searched to see
67  // if they contain the desired elements. For each that is
68  // found, the corresponding WrapperBase pointer is set and the key
69  // is modified to be the key into the container where the element
70  // was found. The WrapperBase pointers might or might not all point
71  // to the same thinned container.
72  virtual void getThinnedProducts(edm::ProductID const&,
73  std::vector<edm::WrapperBase const*>& foundContainers,
74  std::vector<unsigned int>& keys) const override;
75 
76  private:
77 
78  // ---------- static member functions --------------------
79 
80  // ---------- member functions ---------------------------
81  virtual unsigned int transitionIndex_() const override {
82  return 0u;
83  }
84 
85  edm::WrapperBase const* getIt(edm::BranchID const&, Long_t eventEntry) const;
86 
87  struct Buffer {
88  Buffer(edm::WrapperBase const* iProd, TBranch* iBranch, void* iAddress,
89  TClass* iClass) :
90  product_(iProd), branch_(iBranch), address_(iAddress), eventEntry_(-1),
91  class_(iClass) {}
93 
94  std::shared_ptr<edm::WrapperBase const> product_;
95  TBranch* branch_;
96  void* address_; //the address to pass to Root since as of 5.13 they cache that info
97  Long_t eventEntry_; //the event Entry used with the last GetEntry call
98  TClass* class_;
99  };
100 
101  BareRootProductGetter(BareRootProductGetter const&); // stop default
102 
103  BareRootProductGetter const& operator=(BareRootProductGetter const&); // stop default
104 
105  Buffer* createNewBuffer(edm::BranchID const&) const;
106  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID, Long_t eventEntry) const;
107 
108  // ---------- member data --------------------------------
109 
110  typedef std::map<edm::BranchID, Buffer> IdToBuffers;
113 };
114 #endif
virtual edm::WrapperBase const * getThinnedProduct(edm::ProductID const &, unsigned int &key) const override
virtual void getThinnedProducts(edm::ProductID const &, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
#define nullptr
std::map< edm::BranchID, Buffer > IdToBuffers
virtual edm::WrapperBase const * getIt(edm::ProductID const &) const override
edm::ThinnedAssociation const * getThinnedAssociation(edm::BranchID const &branchID, Long_t eventEntry) const
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
Buffer(edm::WrapperBase const *iProd, TBranch *iBranch, void *iAddress, TClass *iClass)
virtual unsigned int transitionIndex_() const override
Buffer * createNewBuffer(edm::BranchID const &) const
BareRootProductGetter const & operator=(BareRootProductGetter const &)
fwlite::BranchMapReader branchMap_
std::shared_ptr< edm::WrapperBase const > product_