CMS 3D CMS Logo

PutOrMergeTestSource.cc
Go to the documentation of this file.
1 //
2 // PutOrMergeTestSource.cc
3 // CMSSW
4 //
5 // Created by Chris Jones on 3/23/21.
6 //
7 
12 
16 
17 #include "DataFormats/TestObjects/interface/Thing.h"
18 #include "DataFormats/TestObjects/interface/ThingWithMerge.h"
19 #include "DataFormats/TestObjects/interface/ThingWithIsEqual.h"
20 
21 #include <cassert>
22 using namespace edm;
23 
24 namespace edmtest {
26  public:
28 
30  void registerProducts() final;
31 
32  private:
33  ItemTypeInfo getNextItemType() final;
34  std::shared_ptr<RunAuxiliary> readRunAuxiliary_() final;
35  std::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() final;
36  std::shared_ptr<FileBlock> readFile_() final;
37  void readRun_(RunPrincipal& runPrincipal) final;
38  void readEvent_(EventPrincipal& eventPrincipal) final;
39 
40  int stage_;
46  };
47 } // namespace edmtest
48 
49 using namespace edmtest;
50 
51 PutOrMergeTestSource::PutOrMergeTestSource(ParameterSet const& iPS, InputSourceDescription const& iISD)
52  : InputSource(iPS, iISD),
53  stage_(0),
54  dummyPSet_([]() {
56  dummy.registerIt();
57  return dummy;
58  }()),
59  thingDesc_(InRun,
60  "thingWithMergeProducer",
61  "PROD",
62  "edmtest::Thing",
63  "edmtestThing",
64  "endRun",
65  "PutOrMergeTestSource",
66  dummyPSet_.id(),
67  edm::TypeWithDict(typeid(edmtest::Thing)),
68  false,
69  true),
70  thingWithMergeDesc_(InRun,
71  "thingWithMergeProducer",
72  "PROD",
73  "edmtest::ThingWithMerge",
74  "edmtestThingWithMerge",
75  "endRun",
76  "PutOrMergeTestSource",
77  dummyPSet_.id(),
78  edm::TypeWithDict(typeid(edmtest::ThingWithMerge)),
79  false,
80  true),
81  thingWithEqualDesc_(InRun,
82  "thingWithMergeProducer",
83  "PROD",
84  "edmtest::ThingWithIsEqual",
85  "edmtestThingWithIsEqual",
86  "endRun",
87  "PutOrMergeTestSource",
88  dummyPSet_.id(),
89  edm::TypeWithDict(typeid(edmtest::ThingWithIsEqual)),
90  false,
91  true) {
92  edm::ParameterSet dummyPset;
93  dummyPset.registerIt();
94 
96  history.emplace_back("PROD", dummyPset.id(), "RELVERSION", "PASSID");
97  processHistoryRegistry().registerProcessHistory(history);
98  historyID_ = history.id();
99 }
100 
102  edm::ParameterSet dummyPset;
103  dummyPset.registerIt();
104 
110 }
111 
112 InputSource::ItemTypeInfo PutOrMergeTestSource::getNextItemType() {
113  switch (stage_) {
114  case 0: {
115  return ItemType::IsFile;
116  }
117  case 1: {
118  return ItemType::IsRun;
119  }
120  case 2: {
121  return ItemType::IsRun;
122  }
123  default:
124  return ItemType::IsStop;
125  }
126  return ItemType::IsInvalid;
127 }
128 
129 std::shared_ptr<RunAuxiliary> PutOrMergeTestSource::readRunAuxiliary_() {
130  auto id = std::make_shared<RunAuxiliary>(1, Timestamp::beginOfTime(), Timestamp::endOfTime());
131  id->setProcessHistoryID(historyID_);
132  return id;
133 }
134 std::shared_ptr<LuminosityBlockAuxiliary> PutOrMergeTestSource::readLuminosityBlockAuxiliary_() { return {}; }
135 std::shared_ptr<FileBlock> PutOrMergeTestSource::readFile_() {
136  ++stage_;
137  return std::make_shared<FileBlock>();
138 }
140  runAuxiliary()->setProcessHistoryID(historyID_);
142  ++stage_;
143  runPrincipal.putOrMerge(thingDesc_, std::make_unique<Wrapper<edmtest::Thing>>(WrapperBase::Emplace{}, 100001));
144  runPrincipal.putOrMerge(thingWithMergeDesc_,
145  std::make_unique<Wrapper<edmtest::ThingWithMerge>>(WrapperBase::Emplace{}, 100002));
146  runPrincipal.putOrMerge(thingWithEqualDesc_,
147  std::make_unique<Wrapper<edmtest::ThingWithIsEqual>>(WrapperBase::Emplace{}, 100003));
148 }
149 void PutOrMergeTestSource::readEvent_(EventPrincipal& eventPrincipal) { assert(false); }
150 
std::shared_ptr< RunAuxiliary > readRunAuxiliary_() final
void registerProducts() final
Register any produced products.
void setIsProvenanceSetOnRead(bool value=true) noexcept
void putOrMerge(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp) const
Definition: RunPrincipal.cc:44
std::shared_ptr< RunAuxiliary > runAuxiliary() const
Called by the framework to merge or insert run in principal cache.
Definition: InputSource.h:261
ProductRegistry & productRegistryUpdate()
Definition: InputSource.h:359
void readEvent_(EventPrincipal &eventPrincipal) final
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() final
void readRun_(RunPrincipal &runPrincipal) final
assert(be >=bs)
ParameterSetID id() const
ParameterSet const & registerIt()
#define DEFINE_FWK_INPUT_SOURCE(type)
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:168
std::shared_ptr< FileBlock > readFile_() final
HLT enums.
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=nullptr)
Definition: RunPrincipal.cc:25
void copyProduct(BranchDescription const &productdesc)