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[])
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();
51 fhicl::make_ParameterSet(temp, pset);
58 events->startRun(100);
60 size_t event_count = 0;
61 while (frags.clear(), event_count++ < NUM_EVENTS && sim.getNext(frags))
63 TLOG(TLVL_DEBUG) <<
"Number of fragments: " << frags.size();
64 assert(frags.size() == NUM_FRAGS_PER_EVENT);
65 for (
auto&& frag : frags)
67 assert(frag !=
nullptr);
69 auto start_time = std::chrono::steady_clock::now();
74 artdaq::FragmentPtr tempFrag;
75 sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
76 if (!sts && event_count <= 10 && loop_count > 100)
78 TLOG(TLVL_ERROR) <<
"Fragment was not added after " << artdaq::TimeUtils::GetElapsedTime(start_time) <<
" s. Check art thread status!";
82 frag = std::move(tempFrag);
92 std::cout <<
"Ending first run..." << std::endl;
93 bool endSucceeded = events->endOfData();
98 size_t const NUM_EVENTS2 = 200;
99 auto temp_config = pset.to_string() +
" source.waiting_time: 10 physics.analyzers.frags.num_events_expected: " + std::to_string(NUM_EVENTS2);
100 fhicl::ParameterSet sim_config2;
101 fhicl::make_ParameterSet(temp_config, sim_config2);
103 events->ReconfigureArt(sim_config2);
105 while (frags.clear(), event_count++ < NUM_EVENTS2 && sim2.getNext(frags))
107 TLOG(TLVL_DEBUG) <<
"Number of fragments: " << frags.size();
108 assert(frags.size() == NUM_FRAGS_PER_EVENT);
109 for (
auto&& frag : frags)
111 assert(frag !=
nullptr);
116 artdaq::FragmentPtr tempFrag;
117 sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
118 if (!sts && event_count <= 10 && loop_count < 100)
120 TLOG(TLVL_ERROR) <<
"Fragment was not added after 1s. Check art thread status!";
123 frag = std::move(tempFrag);
133 bool endSucceeded2 = events->endOfData();
148 catch (cet::exception& x)
150 std::cerr << argv[0] <<
" failure\n"
154 catch (std::string& x)
156 std::cerr << argv[0] <<
" failure\n"
160 catch (
char const* x)
162 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...