00001 #include "art/Framework/Art/artapp.h"
00002 #include "artdaq-core/Data/Fragment.hh"
00003 #include "artdaq/DAQdata/GenericFragmentSimulator.hh"
00004 #include "artdaq/DAQrate/EventStore.hh"
00005 #include "artdaq/Application/MPI2/MPISentry.hh"
00006 #include "cetlib/exception.h"
00007 #include "fhiclcpp/ParameterSet.h"
00008
00009 #include <cstddef>
00010 #include <iostream>
00011 #include <string>
00012 #include <vector>
00013
00014 using artdaq::EventStore;
00015 using artdaq::FragmentPtrs;
00016 using artdaq::GenericFragmentSimulator;
00017 using fhicl::ParameterSet;
00018 using std::size_t;
00019
00020
00021 int main(int argc, char* argv[])
00022 {
00023 artdaq::MPISentry mpiSentry(&argc, &argv);
00024 int rc = -1;
00025 try
00026 {
00027 size_t const NUM_FRAGS_PER_EVENT = 5;
00028 EventStore::run_id_t const RUN_ID = 2112;
00029 size_t const NUM_EVENTS = 100;
00030
00031
00032 ParameterSet sim_config;
00033 sim_config.put("fragments_per_event", NUM_FRAGS_PER_EVENT);
00034 sim_config.put("run_number", RUN_ID);
00035 sim_config.put("print_event_store_stats", true);
00036 sim_config.put("event_queue_wait_time", 10.0);
00037
00038
00039
00040
00041 GenericFragmentSimulator sim(sim_config);
00042 EventStore events(sim_config, NUM_FRAGS_PER_EVENT, RUN_ID, argc, argv, &artapp);
00043 FragmentPtrs frags;
00044 size_t event_count = 0;
00045 while (frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
00046 {
00047 LOG_DEBUG("main") << "Number of fragments: " << frags.size() << '\n';
00048 assert(frags.size() == NUM_FRAGS_PER_EVENT);
00049 for (auto&& frag : frags)
00050 {
00051 assert(frag != nullptr);
00052 events.insert(std::move(frag));
00053 }
00054 }
00055
00056 int readerReturnValue;
00057 bool endSucceeded = events.endOfData(readerReturnValue);
00058 if (endSucceeded)
00059 {
00060 rc = readerReturnValue;
00061 }
00062 else
00063 {
00064 rc = 15;
00065 }
00066 }
00067 catch (cet::exception& x)
00068 {
00069 std::cerr << argv[0] << " failure\n" << x << std::endl;
00070 rc = 1;
00071 }
00072 catch (std::string& x)
00073 {
00074 std::cerr << argv[0] << " failure\n" << x << std::endl;
00075 rc = 2;
00076 }
00077 catch (char const* x)
00078 {
00079 std::cerr << argv[0] << " failure\n" << x << std::endl;
00080 rc = 3;
00081 }
00082 return rc;
00083 }