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
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 }
42 
44 
45  public:
47  virtual ~BareRootProductGetter();
48 
49  // ---------- const member functions ---------------------
50  virtual edm::WrapperBase const* getIt(edm::ProductID const&) const override;
51 
52  // getThinnedProduct assumes getIt was already called and failed to find
53  // the product. The input key is the index of the desired element in the
54  // container identified by ProductID (which cannot be found).
55  // If the return value is not null, then the desired element was found
56  // in a thinned container and key is modified to be the index into
57  // that thinned container. If the desired element is not found, then
58  // nullptr is returned.
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.
73  virtual void getThinnedProducts(edm::ProductID const&,
74  std::vector<edm::WrapperBase const*>& foundContainers,
75  std::vector<unsigned int>& keys) const override;
76 
77  private:
78 
79  // ---------- static member functions --------------------
80 
81  // ---------- member functions ---------------------------
82  virtual unsigned int transitionIndex_() const override {
83  return 0u;
84  }
85 
86  edm::WrapperBase const* getIt(edm::BranchID const&, Long_t eventEntry) const;
87 
88  struct Buffer {
89  Buffer(edm::WrapperBase const* iProd, TBranch* iBranch, void* iAddress,
90  TClass* iClass) :
91  product_(iProd), branch_(iBranch), address_(iAddress), eventEntry_(-1),
92  class_(iClass) {}
94 
95  std::shared_ptr<edm::WrapperBase const> product_;
97  void* address_; //the address to pass to Root since as of 5.13 they cache that info
98  Long_t eventEntry_; //the event Entry used with the last GetEntry call
100  };
101 
102  BareRootProductGetter(BareRootProductGetter const&); // stop default
103 
104  BareRootProductGetter const& operator=(BareRootProductGetter const&); // stop default
105 
106  Buffer* createNewBuffer(edm::BranchID const&) const;
107  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID, Long_t eventEntry) const;
108 
109  // ---------- member data --------------------------------
110 
111  typedef std::map<edm::BranchID, Buffer> IdToBuffers;
114 };
115 #endif
virtual edm::WrapperBase const * getThinnedProduct(edm::ProductID const &, unsigned int &key) const override
edm::propagate_const< TClass * > class_
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
edm::propagate_const< TBranch * > branch_
Buffer * createNewBuffer(edm::BranchID const &) const
BareRootProductGetter const & operator=(BareRootProductGetter const &)
fwlite::BranchMapReader branchMap_
std::shared_ptr< edm::WrapperBase const > product_