1 #include "art/Framework/Art/artapp.h"
2 #include "artdaq-core/Data/Fragment.hh"
3 #include "artdaq/DAQdata/GenericFragmentSimulator.hh"
4 #include "artdaq/DAQrate/SharedMemoryEventManager.hh"
5 #include "artdaq/Application/MPI2/MPISentry.hh"
6 #include "cetlib/exception.h"
7 #include "fhiclcpp/ParameterSet.h"
8 #include "fhiclcpp/make_ParameterSet.h"
9 #include "artdaq/Application/LoadParameterSet.hh"
17 using artdaq::FragmentPtrs;
19 using fhicl::ParameterSet;
23 int main(
int argc,
char* argv[])
25 artdaq::configureMessageFacility(
"reconfigure_t");
26 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_ERROR(
"reconfigure_t") <<
"Fragment was not added after 1s. Check art thread status!" << TLOG_ENDL;
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_ERROR(
"reconfigure_t") <<
"Fragment was not added after 1s. Check art thread status!" << TLOG_ENDL;
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...
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
GenericFragmentSimulator creates simulated Generic events, with data distributed according to a "hist...