1 #define TRACE_NAME "reconfigure_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/ParameterSet.h"
11 #include "fhiclcpp/make_ParameterSet.h"
18 using artdaq::FragmentPtrs;
21 using fhicl::ParameterSet;
24 int main(
int argc,
char* argv[])
27 artdaq::configureMessageFacility(
"reconfigure_t");
30 fhicl::TableFragment<artdaq::SharedMemoryEventManager::Config> shmem_config;
31 fhicl::TableFragment<art::Config> art_config;
32 fhicl::TableFragment<artdaq::GenericFragmentSimulator::Config> frag_gen_config;
34 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.");
38 size_t const NUM_FRAGS_PER_EVENT = 5;
39 SharedMemoryEventManager::run_id_t
const RUN_ID = 2112;
40 size_t const NUM_EVENTS = 100;
43 pset.put(
"expected_fragments_per_event", NUM_FRAGS_PER_EVENT);
44 pset.put(
"run_number", RUN_ID);
45 pset.put(
"print_event_store_stats",
true);
46 pset.put(
"max_event_size_bytes", 0x100000);
47 pset.put(
"buffer_count", 10);
48 pset.put(
"send_init_fragments",
false);
50 auto temp = pset.to_string() +
" source.waiting_time: 10";
51 pset = fhicl::ParameterSet();
52 fhicl::make_ParameterSet(temp, pset);
59 events->startRun(100);
61 size_t event_count = 0;
62 while (frags.clear(), event_count++ < NUM_EVENTS && sim.getNext(frags))
64 TLOG(TLVL_DEBUG) <<
"Number of fragments: " << frags.size();
65 assert(frags.size() == NUM_FRAGS_PER_EVENT);
66 for (
auto&& frag : frags)
68 assert(frag !=
nullptr);
70 auto start_time = std::chrono::steady_clock::now();
75 artdaq::FragmentPtr tempFrag;
76 sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
77 if (!sts && event_count <= 10 && loop_count > 100)
79 TLOG(TLVL_ERROR) <<
"Fragment was not added after " << artdaq::TimeUtils::GetElapsedTime(start_time) <<
" s. Check art thread status!";
83 frag = std::move(tempFrag);
93 std::cout <<
"Ending first run..." << std::endl;
94 bool endSucceeded = events->endOfData();
99 size_t const NUM_EVENTS2 = 200;
100 auto temp_config = pset.to_string() +
" source.waiting_time: 10 physics.analyzers.frags.num_events_expected: " + std::to_string(NUM_EVENTS2);
101 fhicl::ParameterSet sim_config2;
102 fhicl::make_ParameterSet(temp_config, sim_config2);
104 events->ReconfigureArt(sim_config2);
106 while (frags.clear(), event_count++ < NUM_EVENTS2 && sim2.getNext(frags))
108 TLOG(TLVL_DEBUG) <<
"Number of fragments: " << frags.size();
109 assert(frags.size() == NUM_FRAGS_PER_EVENT);
110 for (
auto&& frag : frags)
112 assert(frag !=
nullptr);
117 artdaq::FragmentPtr tempFrag;
118 sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
119 if (!sts && event_count <= 10 && loop_count < 100)
121 TLOG(TLVL_ERROR) <<
"Fragment was not added after 1s. Check art thread status!";
124 frag = std::move(tempFrag);
134 bool endSucceeded2 = events->endOfData();
149 catch (cet::exception& x)
151 std::cerr << *argv <<
" failure\n"
155 catch (std::string& x)
157 std::cerr << *argv <<
" failure\n"
161 catch (
char const* x)
163 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.