Skip to content

Commit 8bac688

Browse files
committed
Create BareRootProductGetterBase for FireworksWeb
The BareRootProductGetterBase has nearly all the functionality of earlier BareRootProductGetter, except the logic to get the current file in getIt(), that is now a pure virtual function, overridden and implemented in BareRootProductGetter. FireworksWeb can now inherit from BareRootProductGetterBase and implement only the currentFile().
1 parent f6e0fc4 commit 8bac688

File tree

4 files changed

+388
-383
lines changed

4 files changed

+388
-383
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#ifndef FWCore_FWLite_BareRootProductGetterBase_h
2+
#define FWCore_FWLite_BareRootProductGetterBase_h
3+
// -*- C++ -*-
4+
//
5+
// Package: FWLite
6+
// Class : BareRootProductGetterBase
7+
//
8+
/**\class BareRootProductGetterBase BareRootProductGetterBase.h FWCore/FWLite/interface/BareRootProductGetterBase.h
9+
10+
Description: <one line class summary>
11+
12+
This file was originally FWCore/FWLite/src/BareRootProductGetter.h,
13+
and was copied to the interface/BareRootProductGetterBase.h in order
14+
to refactor it a little bit to make it usable for FireworksWeb.
15+
16+
Usage:
17+
<usage>
18+
19+
*/
20+
//
21+
// Original Author: Chris Jones
22+
// Created: Tue May 23 11:03:27 EDT 2006
23+
//
24+
25+
// user include files
26+
#include "DataFormats/Common/interface/WrapperBase.h"
27+
#include "DataFormats/Common/interface/EDProductGetter.h"
28+
#include "FWCore/FWLite/interface/BranchMapReader.h"
29+
#include "FWCore/Utilities/interface/propagate_const.h"
30+
31+
// system include files
32+
#include "Rtypes.h"
33+
#include <map>
34+
#include <memory>
35+
#include <vector>
36+
37+
// forward declarations
38+
class TBranch;
39+
class TClass;
40+
41+
namespace edm {
42+
class BranchID;
43+
class ProductID;
44+
class ThinnedAssociation;
45+
} // namespace edm
46+
47+
class BareRootProductGetterBase : public edm::EDProductGetter {
48+
public:
49+
BareRootProductGetterBase();
50+
~BareRootProductGetterBase() override;
51+
BareRootProductGetterBase(BareRootProductGetterBase const&) = delete; // stop default
52+
BareRootProductGetterBase const& operator=(BareRootProductGetterBase const&) = delete; // stop default
53+
54+
// ---------- const member functions ---------------------
55+
edm::WrapperBase const* getIt(edm::ProductID const&) const override;
56+
57+
// getThinnedProduct assumes getIt was already called and failed to find
58+
// the product. The input key is the index of the desired element in the
59+
// container identified by ProductID (which cannot be found).
60+
// If the return value is not null, then the desired element was
61+
// found in a thinned container. If the desired element is not
62+
// found, then an optional without a value is returned.
63+
std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const&,
64+
unsigned int key) const override;
65+
66+
// getThinnedProducts assumes getIt was already called and failed to find
67+
// the product. The input keys are the indexes into the container identified
68+
// by ProductID (which cannot be found). On input the WrapperBase pointers
69+
// must all be set to nullptr (except when the function calls itself
70+
// recursively where non-null pointers mark already found elements).
71+
// Thinned containers derived from the product are searched to see
72+
// if they contain the desired elements. For each that is
73+
// found, the corresponding WrapperBase pointer is set and the key
74+
// is modified to be the key into the container where the element
75+
// was found. The WrapperBase pointers might or might not all point
76+
// to the same thinned container.
77+
void getThinnedProducts(edm::ProductID const&,
78+
std::vector<edm::WrapperBase const*>& foundContainers,
79+
std::vector<unsigned int>& keys) const override;
80+
81+
// This overload is allowed to be called also without getIt()
82+
// being called first, but the thinned ProductID must come from an
83+
// existing RefCore. The input key is the index of the desired
84+
// element in the container identified by the parent ProductID.
85+
// If the return value is not null, then the desired element was found
86+
// in a thinned container. If the desired element is not found, then
87+
// an optional without a value is returned.
88+
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const& parent,
89+
unsigned int key,
90+
edm::ProductID const& thinned) const override;
91+
92+
private:
93+
// ---------- static member functions --------------------
94+
95+
// ---------- member functions ---------------------------
96+
unsigned int transitionIndex_() const override { return 0u; }
97+
98+
edm::WrapperBase const* getIt(edm::BranchID const&, Long_t eventEntry) const;
99+
// This customization point was created for FireworksWeb
100+
virtual TFile* currentFile() const = 0;
101+
102+
struct Buffer {
103+
Buffer(edm::WrapperBase const* iProd, TBranch* iBranch, void* iAddress, TClass* iClass)
104+
: product_(iProd), branch_(iBranch), address_(iAddress), eventEntry_(-1), class_(iClass) {}
105+
Buffer() : product_(), branch_(), address_(), eventEntry_(-1), class_(nullptr) {}
106+
107+
std::shared_ptr<edm::WrapperBase const> product_;
108+
edm::propagate_const<TBranch*> branch_;
109+
void* address_; //the address to pass to Root since as of 5.13 they cache that info
110+
Long_t eventEntry_; //the event Entry used with the last GetEntry call
111+
edm::propagate_const<TClass*> class_;
112+
};
113+
114+
Buffer* createNewBuffer(edm::BranchID const&) const;
115+
edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID, Long_t eventEntry) const;
116+
117+
// ---------- member data --------------------------------
118+
119+
typedef std::map<edm::BranchID, Buffer> IdToBuffers;
120+
mutable IdToBuffers idToBuffers_;
121+
mutable fwlite::BranchMapReader branchMap_;
122+
};
123+
#endif

0 commit comments

Comments
 (0)