Skip to content

Commit c6adb1b

Browse files
authored
ExtToHybrid parallel example (#2403)
1 parent e4a7c3d commit c6adb1b

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"mode": "parallel",
3+
"generators": [
4+
{
5+
"name": "pythia8pp",
6+
"config": ""
7+
},
8+
{
9+
"name": "pythia8pp",
10+
"config": ""
11+
},
12+
{
13+
"name": "pythia8pp",
14+
"config": ""
15+
},
16+
{
17+
"name": "pythia8pp",
18+
"config": ""
19+
},
20+
{
21+
"name": "pythia8pp",
22+
"config": ""
23+
},
24+
{
25+
"name": "pythia8pp",
26+
"config": ""
27+
},
28+
{
29+
"name": "pythia8pp",
30+
"config": ""
31+
},
32+
{
33+
"name": "pythia8pp",
34+
"config": ""
35+
}
36+
],
37+
"fractions": [
38+
1,
39+
1,
40+
1,
41+
1,
42+
1,
43+
1,
44+
1,
45+
1
46+
]
47+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[GeneratorHybrid]
2+
configFile = ${O2DPG_MC_CONFIG_ROOT}/MC/config/examples/hybrid/exampleparallel.json
3+
switchExtToHybrid = true
4+
num_workers = 8
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
int Hybrid()
2+
{
3+
std::string path{"o2sim_Kine.root"};
4+
// Check that file exists, can be opened and has the correct tree
5+
TFile file(path.c_str(), "READ");
6+
if (file.IsZombie())
7+
{
8+
std::cerr << "Cannot open ROOT file " << path << "\n";
9+
return 1;
10+
}
11+
auto tree = (TTree *)file.Get("o2sim");
12+
if (!tree)
13+
{
14+
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
15+
return 1;
16+
}
17+
std::vector<o2::MCTrack> *tracks{};
18+
tree->SetBranchAddress("MCTrack", &tracks);
19+
20+
// Check if all events are filled
21+
auto nEvents = tree->GetEntries();
22+
for (Long64_t i = 0; i < nEvents; ++i)
23+
{
24+
tree->GetEntry(i);
25+
if (tracks->empty())
26+
{
27+
std::cerr << "Empty entry found at event " << i << "\n";
28+
return 1;
29+
}
30+
}
31+
// Check if there are 100 events, as simulated in the o2dpg-test
32+
if (nEvents != 100)
33+
{
34+
std::cerr << "Expected 100 events, got " << nEvents << "\n";
35+
return 1;
36+
}
37+
return 0;
38+
}

0 commit comments

Comments
 (0)