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"
16 using artdaq::FragmentPtrs;
18 using fhicl::ParameterSet;
22 int main(
int argc,
char* argv[])
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;
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);
43 std::unique_ptr<EventStore> events(
new EventStore(sim_config, NUM_FRAGS_PER_EVENT, RUN_ID, argc, argv, &artapp));
45 size_t event_count = 0;
46 while (frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
48 LOG_DEBUG(
"main") <<
"Number of fragments: " << frags.size() <<
'\n';
49 assert(frags.size() == NUM_FRAGS_PER_EVENT);
50 for (
auto&& frag : frags)
52 assert(frag !=
nullptr);
53 events->insert(std::move(frag));
57 int readerReturnValue;
58 bool endSucceeded = events->endOfData(readerReturnValue);
61 rc = readerReturnValue;
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);
69 events.reset(
new EventStore(sim_config2, NUM_FRAGS_PER_EVENT, RUN_ID2, argc, argv, &artapp));
71 while (frags.clear() , event_count++ < NUM_EVENTS && sim2.getNext(frags))
73 LOG_DEBUG(
"main") <<
"Number of fragments: " << frags.size() <<
'\n';
74 assert(frags.size() == NUM_FRAGS_PER_EVENT);
75 for (
auto&& frag : frags)
77 assert(frag !=
nullptr);
78 events->insert(std::move(frag));
82 int readerReturnValue;
83 bool endSucceeded2 = events->endOfData(readerReturnValue);
86 rc = readerReturnValue;
98 catch (cet::exception& x)
100 std::cerr << argv[0] <<
" failure\n" << x << std::endl;
103 catch (std::string& x)
105 std::cerr << argv[0] <<
" failure\n" << x << std::endl;
108 catch (
char const* x)
110 std::cerr << argv[0] <<
" failure\n" << x << std::endl;
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
GenericFragmentSimulator creates simulated Generic events, with data distributed according to a "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.