artdaq  v2_03_02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
reconfigure_t.cc
1 #include "art/Framework/Art/artapp.h"
2 #include "artdaq-core/Data/Fragment.hh"
3 #include "artdaq/DAQdata/GenericFragmentSimulator.hh"
4 #include "artdaq/DAQrate/EventStore.hh"
5 #include "artdaq/Application/MPI2/MPISentry.hh"
6 #include "cetlib/exception.h"
7 #include "fhiclcpp/ParameterSet.h"
8 #include "fhiclcpp/make_ParameterSet.h"
9 
10 #include <cstddef>
11 #include <iostream>
12 #include <string>
13 #include <vector>
14 
15 using artdaq::EventStore;
16 using artdaq::FragmentPtrs;
18 using fhicl::ParameterSet;
19 using std::size_t;
20 
21 
22 int main(int argc, char* argv[])
23 {
24  artdaq::MPISentry mpiSentry(&argc, &argv);
25  int rc = -1;
26  try
27  {
28  size_t const NUM_FRAGS_PER_EVENT = 5;
29  EventStore::run_id_t const RUN_ID = 2112;
30  size_t const NUM_EVENTS = 100;
31  // We may want to add ParameterSet parsing to this code, but right
32  // now this will do...
33  ParameterSet sim_config;
34  sim_config.put("fragments_per_event", NUM_FRAGS_PER_EVENT);
35  sim_config.put("run_number", RUN_ID);
36  sim_config.put("print_event_store_stats", true);
37  sim_config.put("event_store_wait_time", 10.0);
38  // Eventually, this test should make a mixed-up streams of
39  // Fragments; this has too clean a pattern to be an interesting
40  // test of the EventStore's ability to deal with multiple events
41  // simulatenously.
42  GenericFragmentSimulator sim(sim_config);
43  std::unique_ptr<EventStore> events(new EventStore(sim_config, NUM_FRAGS_PER_EVENT, RUN_ID, argc, argv, &artapp));
44  FragmentPtrs frags;
45  size_t event_count = 0;
46  while (frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
47  {
48  LOG_DEBUG("main") << "Number of fragments: " << frags.size() << '\n';
49  assert(frags.size() == NUM_FRAGS_PER_EVENT);
50  for (auto&& frag : frags)
51  {
52  assert(frag != nullptr);
53  events->insert(std::move(frag));
54  }
55  }
56 
57  int readerReturnValue;
58  bool endSucceeded = events->endOfData(readerReturnValue);
59  if (endSucceeded)
60  {
61  rc = readerReturnValue;
62 
63  EventStore::run_id_t const RUN_ID2 = 2113;
64  size_t const NUM_EVENTS2 = 200;
65  auto temp = sim_config.to_string() + " physics.analyzers.frags.num_events_expected: " + std::to_string(NUM_EVENTS2);
66  fhicl::ParameterSet sim_config2;
67  fhicl::make_ParameterSet(temp, sim_config2);
68  GenericFragmentSimulator sim2(sim_config2);
69  events.reset(new EventStore(sim_config2, NUM_FRAGS_PER_EVENT, RUN_ID2, argc, argv, &artapp));
70  event_count = 0;
71  while (frags.clear() , event_count++ < NUM_EVENTS && sim2.getNext(frags))
72  {
73  LOG_DEBUG("main") << "Number of fragments: " << frags.size() << '\n';
74  assert(frags.size() == NUM_FRAGS_PER_EVENT);
75  for (auto&& frag : frags)
76  {
77  assert(frag != nullptr);
78  events->insert(std::move(frag));
79  }
80  }
81 
82  int readerReturnValue;
83  bool endSucceeded2 = events->endOfData(readerReturnValue);
84  if (endSucceeded2)
85  {
86  rc = readerReturnValue;
87  }
88  else
89  {
90  rc = 16;
91  }
92  }
93  else
94  {
95  rc = 15;
96  }
97  }
98  catch (cet::exception& x)
99  {
100  std::cerr << argv[0] << " failure\n" << x << std::endl;
101  rc = 1;
102  }
103  catch (std::string& x)
104  {
105  std::cerr << argv[0] << " failure\n" << x << std::endl;
106  rc = 2;
107  }
108  catch (char const* x)
109  {
110  std::cerr << argv[0] << " failure\n" << x << std::endl;
111  rc = 3;
112  }
113  return rc;
114 }
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
Definition: MPISentry.hh:15
GenericFragmentSimulator creates simulated Generic events, with data distributed according to a &quot;hist...
The EventStore class collects Fragment objects, until it receives a complete event, at which point the event is handed over to the art thread.
Definition: EventStore.hh:49