Event_t.cc
Go to the documentation of this file.
1 // vim: set sw=2 expandtab :
2 #define BOOST_TEST_MODULE (Event_t)
3 
4 // =====================================================================
5 // Event_t tests the art::Event transactional object. It does this by
6 // creating products that originate from a "source", and by producing
7 // one product in the "current" process.
8 //
9 // A large amount of boilerplate is required to construct an
10 // art::Event object. Required items include:
11 //
12 // - A well-formed ProcessHistory
13 // - Properly-constructed product-lookup tables
14 //
15 // =====================================================================
16 
17 #include "boost/test/unit_test.hpp"
18 
44 #include "fhiclcpp/ParameterSet.h"
45 
46 #include <algorithm>
47 #include <fstream>
48 #include <iterator>
49 #include <map>
50 #include <memory>
51 #include <string>
52 #include <typeinfo>
53 #include <utility>
54 #include <vector>
55 
56 using namespace art;
57 using namespace std;
58 using namespace string_literals;
59 
62 
63 namespace {
64 
66  make_id()
67  {
68  return art::EventID{2112, 47, 25};
69  }
70 
71  constexpr art::Timestamp
72  make_timestamp()
73  {
74  return art::Timestamp{1};
75  }
76 
78  module_class_name()
79  {
80  return "IntProducer";
81  }
82 
83  auto
84  product_with_value(int const v)
85  {
86  return std::make_unique<arttest::IntProduct>(v);
87  }
88 
89  ModuleLabelSelector const modMultiSelector{"modMulti"};
90 } // namespace
91 
92 // This is a gross hack, to allow us to test the event
93 namespace art {
94 
95  std::ostream&
96  boost_test_print_type(std::ostream& os, Timestamp const timestamp)
97  {
98  return os << timestamp.value();
99  }
100 
101  class EDProducer {
102  public:
103  static void
105  {
107  }
108  };
109 
110 } // namespace art
111 
113 public:
115 
116  ModuleDescription currentModuleDescription_{};
117  // The moduleConfigurations_ data member is a map that with the
118  // following semantics:
119  // process_name <-> (module_name <-> module_configuration)
120  std::map<std::string, std::map<std::string, ParameterSet>>
121  moduleConfigurations_{};
122  std::map<std::string, ModuleDescription> moduleDescriptions_{};
123 
124  // The descriptions_ data member is used only to create the product
125  // lookup tables.
126  ProductDescriptions descriptions_{};
127  ProductTables producedProducts_{ProductTables::invalid()};
128  ProductTable presentProducts_{};
129  std::map<std::string, TypeLabelLookup_t> earlyLookup_{};
130  TypeLabelLookup_t currentLookup_{};
131 
132 private:
133  // The 'Present' non-type parameter refers to if the product is
134  // present from the source (true) or if the product is produced
135  // (false).
136  template <typename T, bool Present>
137  ModuleDescription const& registerProduct(
138  std::string const& tag,
139  std::string const& moduleLabel,
140  std::string const& processName,
141  std::string const& productInstanceName = {});
142 };
143 
145 {
146  constexpr bool presentFromSource{true};
147  constexpr bool produced{false};
148 
149  // Register products for "EARLY" process
150  registerProduct<product_t, presentFromSource>(
151  "nolabel_tag", "modOne", "EARLY");
152  registerProduct<product_t, presentFromSource>(
153  "int1_tag", "modMulti", "EARLY", "int1");
154  registerProduct<product_t, presentFromSource>(
155  "int2_tag", "modMulti", "EARLY", "int2");
156  registerProduct<product_t, presentFromSource>(
157  "int3_tag", "modMulti", "EARLY");
158 
159  // Register products for "LATE" process
160  registerProduct<product_t, presentFromSource>(
161  "int1_tag_late", "modMulti", "LATE", "int1");
162 
163  // Fill the lookups for "source-like" products
164  {
165  presentProducts_ = ProductTables{descriptions_}.get(InEvent);
166  descriptions_.clear();
167  }
168 
169  // Register single IntProduct for the "CURRENT" process
170  currentModuleDescription_ = registerProduct<product_t, produced>(
171  "current_tag", "modMulti", "CURRENT", "int1");
172 
173  // Create the lookup that we will use for the current-process module
174  {
175  producedProducts_ = ProductTables{descriptions_};
176  descriptions_.clear();
177  }
178 }
179 
180 template <class T, bool Present>
181 ModuleDescription const&
183  std::string const& moduleLabel,
184  std::string const& processName,
185  std::string const& productInstanceName)
186 {
187  ParameterSet moduleParams;
188  moduleParams.put("module_type", module_class_name());
189  moduleParams.put("module_label", moduleLabel);
190 
191  moduleConfigurations_[processName][moduleLabel] = moduleParams;
192 
193  ParameterSet processParams;
194  processParams.put("process_name", processName);
195  processParams.put(moduleLabel, moduleParams);
196 
198  processName, processParams.id(), getReleaseVersion()};
199 
200  ModuleDescription const localModuleDescription{moduleParams.id(),
201  module_class_name(),
202  moduleLabel,
204  process,
205  Present};
206 
207  TypeID const product_type{typeid(T)};
208 
209  moduleDescriptions_[tag] = localModuleDescription;
210  TypeLabel typeLabel{
211  product_type, productInstanceName, SupportsView<T>::value, false};
212  if (Present) {
213  typeLabel = TypeLabel{
214  product_type, productInstanceName, SupportsView<T>::value, moduleLabel};
215  }
217  InEvent, typeLabel, moduleLabel, moduleParams.id(), process};
218  if (Present) {
219  earlyLookup_[tag].emplace(typeLabel, pd);
220  } else {
221  currentLookup_.emplace(typeLabel, pd);
222  }
223  descriptions_.push_back(pd);
224  return moduleDescriptions_[tag];
225 }
226 
228 public:
230 
231  template <class T>
232  ProductID addSourceProduct(std::unique_ptr<T>&& product,
233  std::string const& tag,
234  std::string const& instanceName = {});
235 
236  ProductTablesFixture& ptf();
237  std::unique_ptr<RunPrincipal> runPrincipal_{};
238  std::unique_ptr<SubRunPrincipal> subRunPrincipal_{};
239  std::unique_ptr<EventPrincipal> principal_{nullptr};
240  ModuleContext currentModuleContext_{ModuleContext::invalid()};
241  std::unique_ptr<Event> currentEvent_{nullptr};
242 };
243 
245 {
246  // Construct process history for event. This takes several lines of
247  // code but other than the process names none of it is used or
248  // interesting.
249  ProcessHistory processHistory;
250  for (auto const& process : ptf().moduleConfigurations_) {
251  auto const& process_name = process.first;
252  // Skip current process since it is not yet part of the history.
253  if (process_name == "CURRENT") {
254  continue;
255  }
256 
257  // Construct the ParameterSet for each process
258  auto const& module_configurations = process.second;
259  ParameterSet processParameterSet;
260  processParameterSet.put("process_name", process_name);
261  for (auto const& modConfig : module_configurations) {
262  processParameterSet.put(modConfig.first, modConfig.second);
263  }
264 
265  ProcessConfiguration const processConfiguration{
266  process.first, processParameterSet.id(), getReleaseVersion()};
267  processHistory.push_back(processConfiguration);
268  }
269 
270  auto const processHistoryID = processHistory.id();
271  ProcessHistoryRegistry::emplace(processHistoryID, processHistory);
272 
273  // When any new product is added to the event principal at
274  // movePutProductsToPrincipal, the "CURRENT" process will go into the
275  // ProcessHistory because the process name comes from the
276  // currentModuleDescription stored in the principal. On the other hand, when
277  // addSourceProduct is called, another event is created with a fake
278  // moduleDescription containing the old process name and that is used to
279  // create the group in the principal used to look up the object.
280 
281  constexpr auto time = make_timestamp();
282  EventID const id{make_id()};
283  ProcessConfiguration const& pc =
284  ptf().currentModuleDescription_.processConfiguration();
285 
286  RunAuxiliary const runAux{id.run(), time, time};
287  runPrincipal_ = std::make_unique<RunPrincipal>(runAux, pc, nullptr);
288 
289  SubRunAuxiliary const subRunAux{runPrincipal_->run(), 1u, time, time};
290  subRunPrincipal_ = std::make_unique<SubRunPrincipal>(subRunAux, pc, nullptr);
291  subRunPrincipal_->setRunPrincipal(runPrincipal_.get());
292 
293  EventAuxiliary const eventAux{id, time, true};
294  auto history = std::make_unique<History>();
295  const_cast<ProcessHistoryID&>(history->processHistoryID()) = processHistoryID;
296  principal_ = std::make_unique<EventPrincipal>(
297  eventAux, pc, &ptf().presentProducts_, std::move(history));
298  principal_->setSubRunPrincipal(subRunPrincipal_.get());
299  principal_->createGroupsForProducedProducts(ptf().producedProducts_);
300  principal_->enableLookupOfProducedProducts(ptf().producedProducts_);
301 
302  currentModuleContext_ = ModuleContext{ptf().currentModuleDescription_};
303  currentEvent_ = std::make_unique<Event>(*principal_, currentModuleContext_);
304 }
305 
306 // Add the given product, of type T, to the current event, as if it
307 // came from the module/source specified by the given tag.
308 template <class T>
309 ProductID
310 EventTestFixture::addSourceProduct(std::unique_ptr<T>&& product,
311  std::string const& tag,
312  std::string const& instanceName)
313 {
314  auto description = ptf().moduleDescriptions_.find(tag);
315  if (description == ptf().moduleDescriptions_.end())
317  << "Failed to find a module description for tag: " << tag << '\n';
318 
319  auto lookup = ptf().earlyLookup_.find(tag);
320  if (lookup == ptf().earlyLookup_.end())
322  << "Failed to find a product lookup for tag: " << tag << '\n';
323 
324  ModuleContext const tempMC{description->second};
325  Event temporaryEvent{*principal_, tempMC};
326  ProductID const id{temporaryEvent.put(std::move(product), instanceName)};
327 
328  EDProducer::commitEvent(*principal_, temporaryEvent);
329  return id;
330 }
331 
334 {
335  static ProductTablesFixture ptf_s;
336  return ptf_s;
337 }
338 
339 BOOST_FIXTURE_TEST_SUITE(Event_t, EventTestFixture)
340 
341 BOOST_AUTO_TEST_CASE(badProductID)
342 {
343  auto const pid = ProductID::invalid();
344  InputTag tag{};
345  if (auto pd = currentEvent_->getProductDescription(pid)) {
346  tag = pd->inputTag();
347  }
348  BOOST_TEST(tag.empty());
349 }
350 
352 {
353  BOOST_TEST_REQUIRE(currentEvent_.get());
354  BOOST_TEST(currentEvent_->id() == make_id());
355  BOOST_TEST(currentEvent_->time() == make_timestamp());
356 }
357 
358 BOOST_AUTO_TEST_CASE(getBySelectorFromEmpty)
359 {
360  ModuleLabelSelector const byModuleLabel{"mod1"};
361  Handle<int> nonesuch;
362  BOOST_TEST(not nonesuch);
363  BOOST_TEST(!nonesuch.isValid());
364  BOOST_TEST(!currentEvent_->get(byModuleLabel, nonesuch));
365  BOOST_TEST(!nonesuch.isValid());
366  BOOST_TEST(nonesuch.failedToGet());
367  BOOST_CHECK_THROW(*nonesuch, cet::exception);
368 }
369 
370 BOOST_AUTO_TEST_CASE(dereferenceDfltHandle)
371 {
372  Handle<int> nonesuch;
373  BOOST_CHECK_THROW(*nonesuch, cet::exception);
374  BOOST_CHECK_THROW(nonesuch.product(), cet::exception);
375 }
376 
377 BOOST_AUTO_TEST_CASE(putAnIntProduct)
378 {
379  currentEvent_->put(product_with_value(3), "int1");
380  EDProducer::commitEvent(*principal_, *currentEvent_);
381 }
382 
383 BOOST_AUTO_TEST_CASE(putAndGetAnIntProduct)
384 {
385  currentEvent_->put(product_with_value(4), "int1");
386  EDProducer::commitEvent(*principal_, *currentEvent_);
387 
388  ProcessNameSelector const should_match{"CURRENT"};
389  ProcessNameSelector const should_not_match{"NONESUCH"};
390  // The ProcessNameSelector does not understand the "current_process"
391  // string. See notes in the Selector header file.
392  ProcessNameSelector const should_also_not_match{"current_process"};
394  BOOST_TEST_REQUIRE(currentEvent_->get(should_match, h));
395  BOOST_TEST(h);
396  BOOST_TEST(h.isValid());
397  h.clear();
398  BOOST_CHECK_THROW(*h, cet::exception);
399  BOOST_TEST_REQUIRE(!currentEvent_->get(should_not_match, h));
400  BOOST_TEST(!h.isValid());
401  BOOST_CHECK_THROW(*h, cet::exception);
402  BOOST_TEST_REQUIRE(!currentEvent_->get(should_also_not_match, h));
403  BOOST_TEST(!h.isValid());
404  BOOST_CHECK_THROW(*h, cet::exception);
405 }
406 
407 BOOST_AUTO_TEST_CASE(getByProductID)
408 {
409  using handle_t = Handle<product_t>;
410 
411  ProductID wanted;
412  {
413  auto const id1 =
414  addSourceProduct(product_with_value(1), "int1_tag", "int1");
415  BOOST_TEST(id1 != ProductID{});
416  wanted = id1;
417 
418  auto const id2 =
419  addSourceProduct(product_with_value(2), "int2_tag", "int2");
420  BOOST_TEST(id2 != ProductID{});
421  BOOST_TEST(id2 != id1);
422  }
424  currentEvent_->get(wanted, h);
425  BOOST_TEST(h.isValid());
426  BOOST_TEST(h.id() == wanted);
427  BOOST_TEST(h->value == 1);
428 
429  ProductID const notpresent{};
430  BOOST_TEST_REQUIRE(!currentEvent_->get(notpresent, h));
431  BOOST_TEST(!h.isValid());
432  BOOST_TEST(h.failedToGet());
433  BOOST_CHECK_THROW(*h, cet::exception);
434 }
435 
437 {
438  // Put a product into an Event, and make sure that if we don't
439  // movePutProductsToPrincipal, there is no product in the EventPrincipal
440  // afterwards.
441  BOOST_TEST(principal_->size() == 6u);
442  currentEvent_->put(product_with_value(3), "int1");
443  BOOST_TEST(principal_->size() == 6u);
444 }
445 
446 BOOST_AUTO_TEST_CASE(getProductTokens)
447 {
448  addSourceProduct(product_with_value(1), "int1_tag", "int1");
449  addSourceProduct(product_with_value(2), "int2_tag", "int2");
450  addSourceProduct(product_with_value(3), "int3_tag");
451  addSourceProduct(product_with_value(4), "nolabel_tag");
452 
453  auto const tags = currentEvent_->getInputTags<product_t>();
454  auto const tokens = currentEvent_->getProductTokens<product_t>();
455  BOOST_TEST(size(tags) == size(tokens));
456 
457  // Verify that the same products are retrieved whether tags or
458  // tokens are used.
459  for (std::size_t i{}; i < tags.size(); ++i) {
460  auto h1 = currentEvent_->getHandle<product_t>(tags[i]);
461  auto h2 = currentEvent_->getHandle(tokens[i]);
462  BOOST_TEST(static_cast<bool>(h1) == static_cast<bool>(h2));
463  }
464 }
465 
466 BOOST_AUTO_TEST_CASE(getByInstanceName)
467 {
468  using handle_t = Handle<product_t>;
469  using handle_vec = std::vector<handle_t>;
470 
471  addSourceProduct(product_with_value(1), "int1_tag", "int1");
472  addSourceProduct(product_with_value(2), "int2_tag", "int2");
473  addSourceProduct(product_with_value(3), "int3_tag");
474  addSourceProduct(product_with_value(4), "nolabel_tag");
475 
476  Selector const sel{ProductInstanceNameSelector{"int2"} &&
477  ModuleLabelSelector{"modMulti"}};
478  auto h = currentEvent_->getHandle<product_t>(sel);
480  BOOST_TEST(h->value == 2);
481 
482  Selector const sel2{ProductInstanceNameSelector{"int2"} ||
484  auto handles = currentEvent_->getMany<product_t>(sel2);
485  BOOST_TEST(handles.size() == std::size_t{2});
486 
487  std::string const instance;
488  Selector sel1{ProductInstanceNameSelector{instance}};
489  sel1 = Selector{sel1 && ModuleLabelSelector{"modMulti"}};
490 
491  BOOST_TEST_REQUIRE(currentEvent_->get(sel1, h));
492  BOOST_TEST(h->value == 3);
493  handles.clear();
494 
495  // There should be five registered products with the 'modMulti'
496  // module label.
497  auto tags = currentEvent_->getInputTags<product_t>(modMultiSelector);
498  BOOST_TEST(tags.size() == 5u);
499  // Now remove the unavailable products
500  auto new_end =
501  std::remove_if(begin(tags), end(tags), [this](auto const& tag) {
502  return !currentEvent_->getHandle<product_t>(tag);
503  });
504  tags.erase(new_end, end(tags));
505 
506  // Only three of the registered products are available.
507  handles = currentEvent_->getMany<product_t>(modMultiSelector);
508  BOOST_TEST(handles.size() == 3u);
509 
510  // Make sure the resolved products agree with those specified in the
511  // 'tags' variable above. The products are resolved in the same
512  // order as the input-tag list.
513  for (std::size_t i{}; i < 3u; ++i) {
514  BOOST_TEST(handles[i].provenance()->inputTag() == tags[i]);
515  }
516 
517  handles = currentEvent_->getMany<product_t>(ModuleLabelSelector{"nomatch"});
518  BOOST_TEST_REQUIRE(handles.empty());
519 
520  auto const nomatches = currentEvent_->getMany<int>(modMultiSelector);
521  BOOST_TEST_REQUIRE(nomatches.empty());
522 }
523 
524 BOOST_AUTO_TEST_CASE(getBySelector)
525 {
526  using handle_t = Handle<product_t>;
527  using handle_vec = std::vector<handle_t>;
528 
529  addSourceProduct(product_with_value(1), "int1_tag", "int1");
530  addSourceProduct(product_with_value(2), "int2_tag", "int2");
531  addSourceProduct(product_with_value(3), "int3_tag");
532  addSourceProduct(product_with_value(4), "nolabel_tag");
533  addSourceProduct(product_with_value(100), "int1_tag_late", "int1");
534 
535  currentEvent_->put(product_with_value(200), "int1");
536  EDProducer::commitEvent(*principal_, *currentEvent_);
537 
538  Selector const sel{ProductInstanceNameSelector{"int2"} && modMultiSelector &&
539  ProcessNameSelector{"EARLY"}};
540  handle_t h;
541  BOOST_TEST_REQUIRE(currentEvent_->get(sel, h));
542  BOOST_TEST(h->value == 2);
543 
544  Selector const sel1{ProductInstanceNameSelector{"nomatch"} &&
545  modMultiSelector && ProcessNameSelector{"EARLY"}};
546  BOOST_TEST_REQUIRE(!currentEvent_->get(sel1, h));
547  BOOST_TEST_REQUIRE(!h.isValid());
548  BOOST_REQUIRE_THROW(*h, cet::exception);
549 
550  Selector const sel2{ProductInstanceNameSelector{"int2"} &&
551  ModuleLabelSelector{"nomatch"} &&
552  ProcessNameSelector{"EARLY"}};
553  BOOST_TEST_REQUIRE(!currentEvent_->get(sel2, h));
554  BOOST_TEST_REQUIRE(!h.isValid());
555  BOOST_REQUIRE_THROW(*h, cet::exception);
556 
557  Selector const sel3{ProductInstanceNameSelector{"int2"} && modMultiSelector &&
558  ProcessNameSelector{"nomatch"}};
559  BOOST_TEST_REQUIRE(!currentEvent_->get(sel3, h));
560  BOOST_TEST_REQUIRE(!h.isValid());
561  BOOST_REQUIRE_THROW(*h, cet::exception);
562 
563  Selector const sel4{modMultiSelector && ProcessNameSelector{"EARLY"}};
564  // multiple selections throw
565  BOOST_REQUIRE_THROW(currentEvent_->get(sel4, h), cet::exception);
566 
567  Selector const sel5{modMultiSelector && ProcessNameSelector{"LATE"}};
568  BOOST_TEST_REQUIRE(currentEvent_->get(sel5, h));
569  BOOST_TEST(h->value == 100);
570 
571  Selector const sel6{modMultiSelector && ProcessNameSelector{"CURRENT"}};
572  BOOST_TEST_REQUIRE(currentEvent_->get(sel6, h));
573  BOOST_TEST(h->value == 200);
574 
575  Selector const sel7{modMultiSelector};
576  BOOST_TEST_REQUIRE(currentEvent_->get(sel7, h));
577  BOOST_TEST(h->value == 200);
578 
579  auto handles = currentEvent_->getMany<product_t>(modMultiSelector);
580  BOOST_TEST(size(handles) == 5u);
581  int sum = 0;
582  for (int k = 0; k < 5; ++k) {
583  sum += handles[k]->value;
584  }
585  BOOST_TEST(sum == 306);
586 }
587 
589 {
590  using handle_t = Handle<product_t>;
591  using handle_vec = std::vector<handle_t>;
592 
593  addSourceProduct(product_with_value(1), "int1_tag", "int1");
594  addSourceProduct(product_with_value(2), "int2_tag", "int2");
595  addSourceProduct(product_with_value(3), "int3_tag");
596  addSourceProduct(product_with_value(4), "nolabel_tag");
597  addSourceProduct(product_with_value(100), "int1_tag_late", "int1");
598 
599  currentEvent_->put(product_with_value(200), "int1");
600 
601  EDProducer::commitEvent(*principal_, *currentEvent_);
602 
603  handle_t h;
604  BOOST_TEST_REQUIRE(currentEvent_->getByLabel("modMulti", h));
605  BOOST_TEST(h->value == 3);
606  BOOST_TEST_REQUIRE(currentEvent_->getByLabel("modMulti", "int1", h));
607  BOOST_TEST(h->value == 200);
609  currentEvent_->getByLabel("modMulti", "int1", "CURRENT", h));
610  BOOST_TEST(h->value == 200);
612  currentEvent_->getByLabel("modMulti", "int1", "current_process", h));
613  BOOST_TEST(h->value == 200);
614  BOOST_TEST(!currentEvent_->getByLabel("modMulti", "nomatch", h));
615  BOOST_TEST(!h.isValid());
616  BOOST_CHECK_THROW(*h, cet::exception);
617 
618  InputTag const inputTag{"modMulti", "int1"};
619  BOOST_TEST_REQUIRE(currentEvent_->getByLabel(inputTag, h));
620  BOOST_TEST(h->value == 200);
621 
622  GroupQueryResult bh{principal_->getByLabel(currentModuleContext_,
623  WrappedTypeID::make<product_t>(),
624  "modMulti",
625  "int1",
626  ProcessTag{"LATE", "CURRENT"})};
627  h = handle_t{bh};
628  BOOST_TEST(h->value == 100);
629 
630  GroupQueryResult bh2{
631  principal_->getByLabel(currentModuleContext_,
632  WrappedTypeID::make<product_t>(),
633  "modMulti",
634  "int1",
635  ProcessTag{"nomatch", "CURRENT"})};
636  BOOST_TEST(!bh2.succeeded());
637 }
638 
639 BOOST_AUTO_TEST_CASE(getByLabelSpecialProcessNames)
640 {
641  addSourceProduct(product_with_value(2), "int2_tag", "int2");
642  currentEvent_->put(product_with_value(200), "int1");
643 
644  // Try to retrieve something that does not exist in the current process.
645  InputTag const badEarlyTag{"modMulti", "int2", "current_process"};
646  BOOST_REQUIRE_THROW(currentEvent_->getValidHandle<product_t>(badEarlyTag),
648 
649  // Verify that it can be read using the 'input_source' process name
651  InputTag const goodEarlyTag{"modMulti", "int2", "input_source"};
652  BOOST_TEST_REQUIRE(currentEvent_->getByLabel(goodEarlyTag, h));
653  BOOST_TEST(h->value == 2);
654 
655  // Verify that "int1" cannot be looked up using the "input_source"
656  // process name.
657  InputTag const badCurrentTag{"modMulti", "int1", "input_source"};
658  BOOST_CHECK_THROW(currentEvent_->getValidHandle<product_t>(badCurrentTag),
660 }
661 
662 BOOST_AUTO_TEST_CASE(getManyByType)
663 {
664  addSourceProduct(product_with_value(1), "int1_tag", "int1");
665  addSourceProduct(product_with_value(2), "int2_tag", "int2");
666  addSourceProduct(product_with_value(3), "int3_tag");
667  addSourceProduct(product_with_value(4), "nolabel_tag");
668 
669  addSourceProduct(product_with_value(100), "int1_tag_late", "int1");
670 
671  currentEvent_->put(product_with_value(200), "int1");
672  EDProducer::commitEvent(*principal_, *currentEvent_);
673 
674  // Verify that the returned tags match thos provided through the
675  // handles below.
676  auto const tags = currentEvent_->getInputTags<product_t>();
677  BOOST_TEST(tags.size() == 6u);
678 
679  auto const handles = currentEvent_->getMany<product_t>();
680  BOOST_TEST(handles.size() == 6u);
681  int sum = 0;
682  for (int k = 0; k < 6; ++k) {
683  auto const& h = handles[k];
684  BOOST_TEST(tags[k] == h.provenance()->productDescription().inputTag());
685  sum += h->value;
686  }
687  BOOST_TEST(sum == 310);
688 }
689 
690 BOOST_AUTO_TEST_CASE(printHistory)
691 {
692  auto const& history = currentEvent_->processHistory();
693  std::ofstream out{"history.log"};
694 
696  history,
697  std::ostream_iterator<ProcessHistory::const_iterator::value_type>(out,
698  "\n"));
699 }
700 
701 BOOST_AUTO_TEST_SUITE_END()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
ProductTablesFixture & ptf()
Definition: Event_t.cc:333
std::string string
Definition: nybbler.cc:12
BOOST_AUTO_TEST_CASE(badProductID)
Definition: Event_t.cc:341
ModuleDescription const & registerProduct(std::string const &tag, std::string const &moduleLabel, std::string const &processName, std::string const &productInstanceName={})
Definition: Event_t.cc:182
const std::string instance
STL namespace.
auto & get(BranchType const bt)
Definition: ProductTables.h:49
std::vector< BranchDescription > ProductDescriptions
BOOST_TEST_REQUIRE(static_cast< bool >(inFile))
constexpr TimeValue_t value() const
Definition: Timestamp.h:23
ProcessHistoryID id() const
void movePutProductsToPrincipal(Principal &principal)
bool isValid() const noexcept
Definition: Handle.h:191
std::map< TypeLabel, BranchDescription > TypeLabelLookup_t
Definition: type_aliases.h:20
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
def process(f, kind)
Definition: search.py:254
const double e
T const * product() const
Definition: Handle.h:163
def move(depos, offset)
Definition: depos.py:107
std::string const & getReleaseVersion()
std::ostream & boost_test_print_type(std::ostream &os, Timestamp const timestamp)
Definition: Event_t.cc:96
RunNumber_t run() const noexcept
ParameterSetID id() const
static ProductTables invalid()
RunNumber_t run() const noexcept
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
auto copy_all(FwdCont &, FwdIter)
static void commitEvent(EventPrincipal &ep, Event &e)
Definition: Event_t.cc:104
void clear()
Definition: Handle.h:236
static constexpr ProductID invalid() noexcept
Definition: ProductID.h:26
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
void push_back(const_reference t)
static auto emplace(value_type const &value)
ProductID id() const
Definition: Handle.h:212
ProductID addSourceProduct(std::unique_ptr< T > &&product, std::string const &tag, std::string const &instanceName={})
Definition: Event_t.cc:310
static ModuleContext invalid()
Definition: ModuleContext.h:22
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool failedToGet() const
Definition: Handle.h:198