69 const std::shared_ptr<GLogger>& log,
70 const std::shared_ptr<const gdynamicdigitization::dRoutinesMap>& dynamicRoutinesMap,
71 const std::shared_ptr<GOptions>& gopts) {
73 std::atomic<int> next{1};
76 std::vector<jthread_alias> pool;
77 pool.reserve(nthreads);
79 for (
int tid = 0; tid < nthreads; ++tid) {
80 pool.emplace_back([&, tid]
82 log->info(0,
"worker ", tid,
" started");
90 for (
auto& [name,
gstreamer] : *gstreamer_map) {
92 log->error(1,
"Failed to open connection for GStreamer ", name,
" in thread ", tid);
98 int evn = next.fetch_add(1, std::memory_order_relaxed);
99 if (evn > nevents)
break;
103 auto eventData = std::make_shared<GEventDataCollection>(gopts, std::move(gevent_header));
104 eventData->setAncestors({
105 {11, 1, 0, 1000.0, 0.0, 0.0, 1000.0, 0.0, 0.0, 0.0},
106 {22, 2, 1, 500.0, 10.0, 0.0, 490.0, 1.0, 2.0, 3.0}
110 for (
unsigned i = 1; i < 11; i++) {
112 auto true_data = dynamicRoutinesMap->at(
plugin_name)->collectTrueInformation(hit, i);
113 auto digi_data = dynamicRoutinesMap->at(
plugin_name)->digitizeHit(hit, i);
115 eventData->addDetectorDigitizedData(
"ctof", std::move(digi_data));
116 eventData->addDetectorTrueInfoData(
"ctof", std::move(true_data));
119 log->info(0,
"worker ", tid,
" event ", evn,
" has ",
120 eventData->getDataCollectionMap().at(
"ctof")->getDigitizedData().size(),
124 for (
const auto& [name,
gstreamer] : *gstreamer_map) {
132 for (
const auto& [name,
gstreamer] : *gstreamer_map) {
134 log->error(1,
"Failed to close connection for GStreamer ", name,
" in thread ", tid);
138 log->info(0,
"worker ", tid,
" processed ", localCount,
" events");
156int main(
int argc,
char* argv[]) {
163 constexpr int nevents = 200;
164 constexpr int nthreads = 4;
168 if (dynamicRoutinesMap->at(
plugin_name)->loadConstants(1,
"default") ==
false) {
169 log->error(1,
"Failed to load constants for dynamic routine",
plugin_name,
170 "for run number 1 with variation 'default'.");
176 (void) preloaded_gstreamer_map;
void run_simulation_in_threads(int nevents, int nthreads, const std::shared_ptr< GLogger > &log, const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > &dynamicRoutinesMap, const std::shared_ptr< GOptions > &gopts)
Run a synthetic multithreaded event loop and publish the results through configured streamers.