From a0cf2fd8b0904dfe0f455400fbab5b0b510a32f1 Mon Sep 17 00:00:00 2001 From: Marco Giacalone Date: Wed, 8 Jul 2026 22:10:29 +0200 Subject: [PATCH] ExtToHybrid parallel example --- .../examples/hybrid/exampleparallel.json | 47 +++++++++++++++++++ .../ini/GeneratorExtToHybridParallel.ini | 4 ++ .../ini/tests/GeneratorExtToHybridParallel.C | 38 +++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 MC/config/examples/hybrid/exampleparallel.json create mode 100644 MC/config/examples/ini/GeneratorExtToHybridParallel.ini create mode 100644 MC/config/examples/ini/tests/GeneratorExtToHybridParallel.C diff --git a/MC/config/examples/hybrid/exampleparallel.json b/MC/config/examples/hybrid/exampleparallel.json new file mode 100644 index 000000000..77416d23d --- /dev/null +++ b/MC/config/examples/hybrid/exampleparallel.json @@ -0,0 +1,47 @@ +{ + "mode": "parallel", + "generators": [ + { + "name": "pythia8pp", + "config": "" + }, + { + "name": "pythia8pp", + "config": "" + }, + { + "name": "pythia8pp", + "config": "" + }, + { + "name": "pythia8pp", + "config": "" + }, + { + "name": "pythia8pp", + "config": "" + }, + { + "name": "pythia8pp", + "config": "" + }, + { + "name": "pythia8pp", + "config": "" + }, + { + "name": "pythia8pp", + "config": "" + } + ], + "fractions": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] +} \ No newline at end of file diff --git a/MC/config/examples/ini/GeneratorExtToHybridParallel.ini b/MC/config/examples/ini/GeneratorExtToHybridParallel.ini new file mode 100644 index 000000000..7745d9095 --- /dev/null +++ b/MC/config/examples/ini/GeneratorExtToHybridParallel.ini @@ -0,0 +1,4 @@ +[GeneratorHybrid] +configFile = ${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/hybrid/exampleparallel.json +switchExtToHybrid = true +num_workers = 8 diff --git a/MC/config/examples/ini/tests/GeneratorExtToHybridParallel.C b/MC/config/examples/ini/tests/GeneratorExtToHybridParallel.C new file mode 100644 index 000000000..2694d57e4 --- /dev/null +++ b/MC/config/examples/ini/tests/GeneratorExtToHybridParallel.C @@ -0,0 +1,38 @@ +int Hybrid() +{ + std::string path{"o2sim_Kine.root"}; + // Check that file exists, can be opened and has the correct tree + TFile file(path.c_str(), "READ"); + if (file.IsZombie()) + { + std::cerr << "Cannot open ROOT file " << path << "\n"; + return 1; + } + auto tree = (TTree *)file.Get("o2sim"); + if (!tree) + { + std::cerr << "Cannot find tree o2sim in file " << path << "\n"; + return 1; + } + std::vector *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + // Check if all events are filled + auto nEvents = tree->GetEntries(); + for (Long64_t i = 0; i < nEvents; ++i) + { + tree->GetEntry(i); + if (tracks->empty()) + { + std::cerr << "Empty entry found at event " << i << "\n"; + return 1; + } + } + // Check if there are 100 events, as simulated in the o2dpg-test + if (nEvents != 100) + { + std::cerr << "Expected 100 events, got " << nEvents << "\n"; + return 1; + } + return 0; +}