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.
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;
107 };
108 #endif
BareRootProductGetter::Buffer::address_
void * address_
Definition: BareRootProductGetter.h:90
BareRootProductGetter::Buffer::eventEntry_
Long_t eventEntry_
Definition: BareRootProductGetter.h:91
BareRootProductGetter::~BareRootProductGetter
~BareRootProductGetter() override
Definition: BareRootProductGetter.cc:50
BareRootProductGetter::getThinnedProducts
void getThinnedProducts(edm::ProductID const &, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
Definition: BareRootProductGetter.cc:207
BareRootProductGetter::BareRootProductGetter
BareRootProductGetter()
Definition: BareRootProductGetter.cc:44
propagate_const.h
edm
HLT enums.
Definition: AlignableModifier.h:19
BareRootProductGetter::Buffer::product_
std::shared_ptr< edm::WrapperBase const > product_
Definition: BareRootProductGetter.h:88
edm::ThinnedAssociation
Definition: ThinnedAssociation.h:14
BareRootProductGetter::Buffer::Buffer
Buffer()
Definition: BareRootProductGetter.h:86
BareRootProductGetter::getThinnedProduct
edm::WrapperBase const * getThinnedProduct(edm::ProductID const &, unsigned int &key) const override
Definition: BareRootProductGetter.cc:160
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
BareRootProductGetter::idToBuffers_
IdToBuffers idToBuffers_
Definition: BareRootProductGetter.h:105
BareRootProductGetter::transitionIndex_
unsigned int transitionIndex_() const override
Definition: BareRootProductGetter.h:79
BareRootProductGetter::Buffer::Buffer
Buffer(edm::WrapperBase const *iProd, TBranch *iBranch, void *iAddress, TClass *iClass)
Definition: BareRootProductGetter.h:84
BareRootProductGetter::Buffer::class_
edm::propagate_const< TClass * > class_
Definition: BareRootProductGetter.h:92
BranchMapReader.h
edm::EDProductGetter
Definition: EDProductGetter.h:32
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:325
BareRootProductGetter::branchMap_
fwlite::BranchMapReader branchMap_
Definition: BareRootProductGetter.h:106
WrapperBase.h
BareRootProductGetter::Buffer
Definition: BareRootProductGetter.h:83
BareRootProductGetter::getIt
edm::WrapperBase const * getIt(edm::ProductID const &) const override
Definition: BareRootProductGetter.cc:70
BareRootProductGetter
Definition: BareRootProductGetter.h:43
BareRootProductGetter::createNewBuffer
Buffer * createNewBuffer(edm::BranchID const &) const
Definition: BareRootProductGetter.cc:278
edm::WrapperBase
Definition: WrapperBase.h:23
BareRootProductGetter::operator=
BareRootProductGetter const & operator=(BareRootProductGetter const &)=delete
BareRootProductGetter::IdToBuffers
std::map< edm::BranchID, Buffer > IdToBuffers
Definition: BareRootProductGetter.h:104
fwlite::BranchMapReader
Definition: BranchMapReader.h:70
EDProductGetter.h
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::ProductID
Definition: ProductID.h:27
BareRootProductGetter::Buffer::branch_
edm::propagate_const< TBranch * > branch_
Definition: BareRootProductGetter.h:89