1 #define TRACE_NAME "reconfigure_t"
3 #include "art/Framework/Art/artapp.h"
4 #include "artdaq-core/Data/Fragment.hh"
5 #include "artdaq/DAQdata/GenericFragmentSimulator.hh"
6 #include "artdaq/DAQrate/SharedMemoryEventManager.hh"
7 #include "cetlib_except/exception.h"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "fhiclcpp/make_ParameterSet.h"
10 #include "artdaq/Application/LoadParameterSet.hh"
18 using artdaq::FragmentPtrs;
20 using fhicl::ParameterSet;
24 int main(
int argc,
char* argv[])
26 artdaq::configureMessageFacility(
"reconfigure_t");
27 auto pset = LoadParameterSet(argc, argv);
31 size_t const NUM_FRAGS_PER_EVENT = 5;
32 SharedMemoryEventManager::run_id_t
const RUN_ID = 2112;
33 size_t const NUM_EVENTS = 100;
36 pset.put(
"expected_fragments_per_event", NUM_FRAGS_PER_EVENT);
37 pset.put(
"run_number", RUN_ID);
38 pset.put(
"print_event_store_stats",
true);
39 pset.put(
"max_event_size_bytes", 0x100000);
40 pset.put(
"buffer_count",10);
42 auto temp = pset.to_string() +
" source.waiting_time: 10";
43 pset = fhicl::ParameterSet();
44 fhicl::make_ParameterSet(temp, pset);
51 events->startRun(100);
53 size_t event_count = 0;
54 while (frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
56 LOG_DEBUG(
"main") <<
"Number of fragments: " << frags.size() <<
'\n';
57 assert(frags.size() == NUM_FRAGS_PER_EVENT);
58 for (
auto&& frag : frags)
60 assert(frag !=
nullptr);
61 artdaq::FragmentPtr tempFrag;
62 auto sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
65 TLOG(TLVL_ERROR) <<
"Fragment was not added after 1s. Check art thread status!" ;
71 std::cout <<
"Ending first run..." << std::endl;
72 bool endSucceeded = events->endOfData();
77 size_t const NUM_EVENTS2 = 200;
78 auto temp_config = pset.to_string() +
" source.waiting_time: 10 physics.analyzers.frags.num_events_expected: " + std::to_string(NUM_EVENTS2);
79 fhicl::ParameterSet sim_config2;
80 fhicl::make_ParameterSet(temp_config, sim_config2);
82 events->ReconfigureArt(sim_config2);
84 while (frags.clear() , event_count++ < NUM_EVENTS2 && sim2.getNext(frags))
86 LOG_DEBUG(
"main") <<
"Number of fragments: " << frags.size() <<
'\n';
87 assert(frags.size() == NUM_FRAGS_PER_EVENT);
88 for (
auto&& frag : frags)
90 assert(frag !=
nullptr);
91 artdaq::FragmentPtr tempFrag;
92 auto sts = events->AddFragment(std::move(frag), 1000000, tempFrag);
95 TLOG(TLVL_ERROR) <<
"Fragment was not added after 1s. Check art thread status!" ;
101 bool endSucceeded2 = events->endOfData();
116 catch (cet::exception& x)
118 std::cerr << argv[0] <<
" failure\n" << x << std::endl;
121 catch (std::string& x)
123 std::cerr << argv[0] <<
" failure\n" << x << std::endl;
126 catch (
char const* x)
128 std::cerr << argv[0] <<
" failure\n" << x << std::endl;
The SharedMemoryEventManager is a SharedMemoryManger which tracks events as they are built...
GenericFragmentSimulator creates simulated Generic events, with data distributed according to a "hist...