1 #define TRACE_NAME "daq_flow_t"
3 #include "art/Framework/Art/artapp.h"
4 #include "artdaq-core/Data/Fragment.hh"
5 #include "artdaq/Application/LoadParameterSet.hh"
6 #include "artdaq/ArtModules/detail/ArtConfig.hh"
7 #include "artdaq/DAQdata/GenericFragmentSimulator.hh"
8 #include "artdaq/DAQrate/SharedMemoryEventManager.hh"
9 #include "cetlib_except/exception.h"
10 #include "fhiclcpp/make_ParameterSet.h"
17 using artdaq::FragmentPtrs;
22 int main(
int argc,
char* argv[])
26 fhicl::TableFragment<artdaq::SharedMemoryEventManager::Config> shmem_config;
27 fhicl::TableFragment<art::Config> art_config;
28 fhicl::TableFragment<artdaq::GenericFragmentSimulator::Config> frag_gen_config;
30 auto pset = LoadParameterSet<Config>(argc, argv,
"daq_flow_t",
"daq_flow_t tests data from a GenericFragmentSimulator through art");
34 size_t const NUM_FRAGS_PER_EVENT = 5;
35 SharedMemoryEventManager::run_id_t
const RUN_ID = 2112;
36 size_t const NUM_EVENTS = 100;
37 pset.put(
"expected_fragments_per_event", NUM_FRAGS_PER_EVENT);
38 pset.put(
"run_number", RUN_ID);
39 pset.put(
"print_event_store_stats",
true);
40 pset.put(
"event_queue_wait_time", 10.0);
41 pset.put(
"max_event_size_bytes", 0x100000);
42 pset.put(
"buffer_count", 10);
43 pset.put(
"send_init_fragments",
false);
45 auto temp = pset.to_string() +
" source.waiting_time: 10";
46 pset = fhicl::ParameterSet();
47 fhicl::make_ParameterSet(temp, pset);
54 events.startRun(RUN_ID);
56 size_t event_count = 0;
57 while (frags.clear(), event_count++ < NUM_EVENTS && sim.getNext(frags))
59 TLOG(TLVL_DEBUG) <<
"Number of fragments: " << frags.size();
60 assert(frags.size() == NUM_FRAGS_PER_EVENT);
61 for (
auto&& frag : frags)
63 assert(frag !=
nullptr);
65 auto start_time = std::chrono::steady_clock::now();
70 artdaq::FragmentPtr tempFrag;
71 sts = events.AddFragment(std::move(frag), 1000000, tempFrag);
72 if (!sts && event_count <= 10 && loop_count > 100)
74 TLOG(TLVL_ERROR) <<
"Fragment was not added after " << artdaq::TimeUtils::GetElapsedTime(start_time) <<
" s. Check art thread status!";
78 frag = std::move(tempFrag);
88 bool endSucceeded = events.endOfData();
98 catch (cet::exception& x)
100 std::cerr << argv[0] <<
" failure\n"
104 catch (std::string& x)
106 std::cerr << argv[0] <<
" failure\n"
110 catch (
char const* x)
112 std::cerr << argv[0] <<
" failure\n"
The SharedMemoryEventManager is a SharedMemoryManger which tracks events as they are built...
GenericFragmentSimulator creates simulated Generic events, with data distributed according to a "hist...