CMS 3D CMS Logo

ThingWithMergeProducer.cc
Go to the documentation of this file.
1 
2 //
3 // Puts some simple test objects in the event, run, and lumi
4 // principals. The values put into these objects are just
5 // arbitrary and meaningless. Later we check that what get
6 // out when reading the file after merging is what is expected.
7 //
8 // Original Author: David Dagenhart, Fermilab, February 2008
9 
10 #include "ThingWithMergeProducer.h"
15 #include "DataFormats/TestObjects/interface/Thing.h"
16 #include "DataFormats/TestObjects/interface/ThingWithMerge.h"
17 #include "DataFormats/TestObjects/interface/ThingWithIsEqual.h"
21 
22 namespace edmtest {
24  : changeIsEqualValue_(pset.getUntrackedParameter<bool>("changeIsEqualValue", false)),
25  labelsToGet_(pset.getUntrackedParameter<std::vector<std::string>>("labelsToGet", std::vector<std::string>())),
26  noPut_(pset.getUntrackedParameter<bool>("noPut", false)) {
27  produces<Thing>("event");
28  produces<Thing, edm::Transition::BeginLuminosityBlock>("beginLumi");
29  produces<Thing, edm::Transition::EndLuminosityBlock>("endLumi");
30  produces<Thing, edm::Transition::BeginRun>("beginRun");
31  produces<Thing, edm::Transition::EndRun>("endRun");
32 
33  produces<ThingWithMerge>("event");
34  produces<ThingWithMerge, edm::Transition::BeginLuminosityBlock>("beginLumi");
35  produces<ThingWithMerge, edm::Transition::EndLuminosityBlock>("endLumi");
36  produces<ThingWithMerge, edm::Transition::BeginRun>("beginRun");
37  produces<ThingWithMerge, edm::Transition::EndRun>("endRun");
38 
39  produces<ThingWithIsEqual>("event");
40  produces<ThingWithIsEqual, edm::Transition::BeginLuminosityBlock>("beginLumi");
41  produces<ThingWithIsEqual, edm::Transition::EndLuminosityBlock>("endLumi");
42  produces<ThingWithIsEqual, edm::Transition::BeginRun>("beginRun");
43  produces<ThingWithIsEqual, edm::Transition::EndRun>("endRun");
44 
45  const std::string s_prod("PROD");
46  for (auto const& label : labelsToGet_) {
47  consumes<Thing>(edm::InputTag(label, "event", s_prod));
48  consumes<Thing, edm::InLumi>(edm::InputTag(label, "beginLumi", s_prod));
49  consumes<Thing, edm::InLumi>(edm::InputTag(label, "endLumi", s_prod));
50  consumes<Thing, edm::InRun>(edm::InputTag(label, "beginRun", s_prod));
51  consumes<Thing, edm::InRun>(edm::InputTag(label, "endRun", s_prod));
52  }
53  }
54 
56 
58  // The purpose of this first getByLabel call is to cause the products
59  // that are "put" below to have a parent so we can do tests with the
60  // parentage provenance.
61  for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
63  edm::InputTag tag(*iter, "event", "PROD");
64  e.getByLabel(tag, h);
65  }
66 
67  auto result = std::make_unique<Thing>();
68  result->a = 11;
69  if (!noPut_)
70  e.put(std::move(result), std::string("event"));
71 
72  auto result2 = std::make_unique<ThingWithMerge>();
73  result2->a = 12;
74  if (!noPut_)
75  e.put(std::move(result2), std::string("event"));
76 
77  auto result3 = std::make_unique<ThingWithIsEqual>();
78  result3->a = 13;
80  result3->a = 14;
81  if (!noPut_)
82  e.put(std::move(result3), std::string("event"));
83  }
84 
86  auto result = std::make_unique<Thing>();
87  result->a = 101;
88  if (!noPut_)
89  lb.put(std::move(result), "beginLumi");
90 
91  auto result2 = std::make_unique<ThingWithMerge>();
92  result2->a = 102;
93  if (!noPut_)
94  lb.put(std::move(result2), "beginLumi");
95 
96  auto result3 = std::make_unique<ThingWithIsEqual>();
97  result3->a = 103;
99  result3->a = 104;
100  if (!noPut_)
101  lb.put(std::move(result3), "beginLumi");
102  }
103 
105  auto result = std::make_unique<Thing>();
106  result->a = 1001;
107  if (!noPut_)
108  lb.put(std::move(result), "endLumi");
109 
110  auto result2 = std::make_unique<ThingWithMerge>();
111  result2->a = 1002;
112  if (!noPut_)
113  lb.put(std::move(result2), "endLumi");
114 
115  auto result3 = std::make_unique<ThingWithIsEqual>();
116  result3->a = 1003;
118  result3->a = 1004;
119  if (!noPut_)
120  lb.put(std::move(result3), "endLumi");
121  }
122 
123  // Functions that gets called by framework every run
125  auto result = std::make_unique<Thing>();
126  result->a = 10001;
127  if (!noPut_)
128  r.put(std::move(result), "beginRun");
129 
130  auto result2 = std::make_unique<ThingWithMerge>();
131  result2->a = 10002;
132  if (!noPut_)
133  r.put(std::move(result2), "beginRun");
134 
135  auto result3 = std::make_unique<ThingWithIsEqual>();
136  result3->a = 10003;
138  result3->a = 10004;
139  if (!noPut_)
140  r.put(std::move(result3), "beginRun");
141  }
142 
144  auto result = std::make_unique<Thing>();
145  result->a = 100001;
146  if (!noPut_)
147  r.put(std::move(result), "endRun");
148 
149  auto result2 = std::make_unique<ThingWithMerge>();
150  result2->a = 100002;
151  if (!noPut_)
152  r.put(std::move(result2), "endRun");
153 
154  auto result3 = std::make_unique<ThingWithIsEqual>();
155  result3->a = 100003;
157  result3->a = 100004;
158  if (!noPut_)
159  r.put(std::move(result3), "endRun");
160  }
161 
163  for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
165  edm::InputTag tag(*iter, "beginLumi", "PROD");
166  lb.getByLabel(tag, h);
167  }
168  }
169 
171  for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
173  edm::InputTag tag(*iter, "endLumi", "PROD");
174  lb.getByLabel(tag, h);
175  }
176  }
177 
178  // Functions that gets called by framework every run
180  for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
182  edm::InputTag tag(*iter, "beginRun", "PROD");
183  r.getByLabel(tag, h);
184  }
185  }
186 
188  for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
190  edm::InputTag tag(*iter, "endRun", "PROD");
191  r.getByLabel(tag, h);
192  }
193  }
194 
197  desc.addUntracked<bool>("changeIsEqualValue", false);
198  desc.addUntracked<std::vector<std::string>>("labelsToGet", std::vector<std::string>());
199  desc.addUntracked<bool>("noPut", false);
200  descriptions.add("thingWithMergeProducer", desc);
201  }
202 
203 } // namespace edmtest
void beginRunProduce(edm::Run &r, edm::EventSetup const &c) override
void produce(edm::Event &e, edm::EventSetup const &c) override
std::vector< std::string > labelsToGet_
std::vector< std::string >::const_iterator Iter
void beginLuminosityBlock(edm::LuminosityBlock const &lb, edm::EventSetup const &c) override
void beginLuminosityBlockProduce(edm::LuminosityBlock &lb, edm::EventSetup const &c) override
void beginRun(edm::Run const &r, edm::EventSetup const &c) override
void endRun(edm::Run const &r, edm::EventSetup const &c) override
char const * label
void endRunProduce(edm::Run &r, edm::EventSetup const &c) override
void endLuminosityBlockProduce(edm::LuminosityBlock &lb, edm::EventSetup const &c) override
void put(std::unique_ptr< PROD > product)
Put a new product.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ThingWithMergeProducer(edm::ParameterSet const &ps)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void endLuminosityBlock(edm::LuminosityBlock const &lb, edm::EventSetup const &c) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
def move(src, dest)
Definition: eostools.py:511
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Run.h:45