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 #include "fhiclcpp/make_ParameterSet.h"
00009
00010 #include <cstddef>
00011 #include <iostream>
00012 #include <string>
00013 #include <vector>
00014
00015 using artdaq::EventStore;
00016 using artdaq::FragmentPtrs;
00017 using artdaq::GenericFragmentSimulator;
00018 using fhicl::ParameterSet;
00019 using std::size_t;
00020
00021
00022 int main(int argc, char* argv[])
00023 {
00024 artdaq::MPISentry mpiSentry(&argc, &argv);
00025 int rc = -1;
00026 try
00027 {
00028 size_t const NUM_FRAGS_PER_EVENT = 5;
00029 EventStore::run_id_t const RUN_ID = 2112;
00030 size_t const NUM_EVENTS = 100;
00031
00032
00033 ParameterSet sim_config;
00034 sim_config.put("fragments_per_event", NUM_FRAGS_PER_EVENT);
00035 sim_config.put("run_number", RUN_ID);
00036 sim_config.put("print_event_store_stats", true);
00037 sim_config.put("event_store_wait_time", 10.0);
00038
00039
00040
00041
00042 GenericFragmentSimulator sim(sim_config);
00043 std::unique_ptr<EventStore> events(new EventStore(sim_config, NUM_FRAGS_PER_EVENT, RUN_ID, argc, argv, &artapp));
00044 FragmentPtrs frags;
00045 size_t event_count = 0;
00046 while (frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
00047 {
00048 LOG_DEBUG("main") << "Number of fragments: " << frags.size() << '\n';
00049 assert(frags.size() == NUM_FRAGS_PER_EVENT);
00050 for (auto&& frag : frags)
00051 {
00052 assert(frag != nullptr);
00053 events->insert(std::move(frag));
00054 }
00055 }
00056
00057 int readerReturnValue;
00058 bool endSucceeded = events->endOfData(readerReturnValue);
00059 if (endSucceeded)
00060 {
00061 rc = readerReturnValue;
00062
00063 EventStore::run_id_t const RUN_ID2 = 2113;
00064 size_t const NUM_EVENTS2 = 200;
00065 auto temp = sim_config.to_string() + " physics.analyzers.frags.num_events_expected: " + std::to_string(NUM_EVENTS2);
00066 fhicl::ParameterSet sim_config2;
00067 fhicl::make_ParameterSet(temp, sim_config2);
00068 GenericFragmentSimulator sim2(sim_config2);
00069 events.reset(new EventStore(sim_config2, NUM_FRAGS_PER_EVENT, RUN_ID2, argc, argv, &artapp));
00070 event_count = 0;
00071 while (frags.clear() , event_count++ < NUM_EVENTS && sim2.getNext(frags))
00072 {
00073 LOG_DEBUG("main") << "Number of fragments: " << frags.size() << '\n';
00074 assert(frags.size() == NUM_FRAGS_PER_EVENT);
00075 for (auto&& frag : frags)
00076 {
00077 assert(frag != nullptr);
00078 events->insert(std::move(frag));
00079 }
00080 }
00081
00082 int readerReturnValue;
00083 bool endSucceeded2 = events->endOfData(readerReturnValue);
00084 if (endSucceeded2)
00085 {
00086 rc = readerReturnValue;
00087 }
00088 else
00089 {
00090 rc = 16;
00091 }
00092 }
00093 else
00094 {
00095 rc = 15;
00096 }
00097 }
00098 catch (cet::exception& x)
00099 {
00100 std::cerr << argv[0] << " failure\n" << x << std::endl;
00101 rc = 1;
00102 }
00103 catch (std::string& x)
00104 {
00105 std::cerr << argv[0] << " failure\n" << x << std::endl;
00106 rc = 2;
00107 }
00108 catch (char const* x)
00109 {
00110 std::cerr << argv[0] << " failure\n" << x << std::endl;
00111 rc = 3;
00112 }
00113 return rc;
00114 }