1 #include "TRACE/tracemf.h"
2 #define TRACE_NAME "reconfigure_t"
3 #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/ParameterSet.h"
11 #include "fhiclcpp/types/TableFragment.h"
18 using artdaq::FragmentPtrs;
23 int main(
int argc,
char* argv[])
26 artdaq::configureMessageFacility(
"reconfigure_t");
29 fhicl::TableFragment<artdaq::SharedMemoryEventManager::Config> shmem_config;
30 fhicl::TableFragment<art::Config> art_config;
31 fhicl::TableFragment<artdaq::GenericFragmentSimulator::Config> frag_gen_config;
33 auto pset = LoadParameterSet<Config>(argc, argv,
"reconfigure_t",
"reconfigure_t tests data from a GenericFragmentSimulator through art, then performs a reconfiguration and tests that the reconfiguration worked correctly.");
37 size_t const NUM_FRAGS_PER_EVENT = 5;
38 SharedMemoryEventManager::run_id_t
const RUN_ID = 2112;
39 size_t const NUM_EVENTS = 100;
42 pset.put(
"expected_fragments_per_event", NUM_FRAGS_PER_EVENT);
43 pset.put(
"run_number", RUN_ID);
44 pset.put(
"print_event_store_stats",
true);
45 pset.put(
"max_event_size_bytes", 0x100000);
46 pset.put(
"buffer_count", 10);
47 pset.put(
"send_init_fragments",
false);
49 auto temp = pset.to_string() +
" source.waiting_time: 10";
50 pset = fhicl::ParameterSet::make(temp);
57 events->startRun(100);
59 size_t event_count = 0;
60 while (frags.clear(), event_count++ < NUM_EVENTS && sim.getNext(frags))
62 TLOG(TLVL_DEBUG) <<
"Number of fragments: " << frags.size();
63 assert(frags.size() == NUM_FRAGS_PER_EVENT);
64 for (
auto&& frag : frags)
66 assert(frag !=
nullptr);
68 auto start_time = std::chrono::steady_clock::now();
73 artdaq::FragmentPtr tempFrag;
74 sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
75 if (!sts && event_count <= 10 && loop_count > 100)
77 TLOG(TLVL_ERROR) <<
"Fragment was not added after " << artdaq::TimeUtils::GetElapsedTime(start_time) <<
" s. Check art thread status!";
81 frag = std::move(tempFrag);
91 std::cout <<
"Ending first run..." << std::endl;
92 bool endSucceeded = events->endOfData();
97 size_t const NUM_EVENTS2 = 200;
98 auto temp_config = pset.to_string() +
" source.waiting_time: 10 physics.analyzers.frags.num_events_expected: " + std::to_string(NUM_EVENTS2);
99 fhicl::ParameterSet sim_config2 = fhicl::ParameterSet::make(temp_config);
101 events->ReconfigureArt(sim_config2);
103 while (frags.clear(), event_count++ < NUM_EVENTS2 && sim2.getNext(frags))
105 TLOG(TLVL_DEBUG) <<
"Number of fragments: " << frags.size();
106 assert(frags.size() == NUM_FRAGS_PER_EVENT);
107 for (
auto&& frag : frags)
109 assert(frag !=
nullptr);
114 artdaq::FragmentPtr tempFrag;
115 sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
116 if (!sts && event_count <= 10 && loop_count < 100)
118 TLOG(TLVL_ERROR) <<
"Fragment was not added after 1s. Check art thread status!";
121 frag = std::move(tempFrag);
131 bool endSucceeded2 = events->endOfData();
146 catch (cet::exception& x)
148 std::cerr << *argv <<
" failure\n"
152 catch (std::string& x)
154 std::cerr << *argv <<
" failure\n"
158 catch (
char const* x)
160 std::cerr << *argv <<
" 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...
Configuration for simple_metric_sender.