Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MC/config/common/ini/GeneratorPerformance.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Performance generator test using hybrid configuration with Pythia8
# underlying event generator
[GeneratorHybrid]
configFile = ${O2DPG_MC_CONFIG_ROOT}/MC/config/common/external/generator/perfConf.json
55 changes: 55 additions & 0 deletions MC/config/common/ini/tests/GeneratorPerformance.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
int Hybrid()
{
std::string path{"o2sim_Kine.root"};
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;
}
// Get the MCTrack branch
std::vector<o2::MCTrack> *tracks{};
tree->SetBranchAddress("MCTrack", &tracks);
// Check if processes with ID 42 are available
const int processID = 42; // Performance test particle custom process ID
int nEvents = tree->GetEntries();
short int count_perf = 0;
bool flag = false;
for (int i = 0; i < nEvents; i++)
{
tree->GetEntry(i);
int nTracks = tracks->size();
count_perf = 0;
for (auto &track : *tracks)
{
const auto &process = track.getProcess();
if (process == processID)
{
flag = true;
// No need to continue checking other tracks in the event
break;
}
}
if (flag == true)
{
count_perf++;
flag = false;
}
}
if (count_perf == 0)
{
std::cerr << "No performance test particles found in the events\n";
return 1;
} else if (count_perf > nEvents) {
std::cerr << "More performance test flagged events than generated events\n";
return 1;
}
file.Close();
return 0;
}
8 changes: 7 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Whenever an `ini` file is detedcted to be tested, a test macro is required to be
```bash
<name-of-ini-file>.C
```
Note, that `run_tests.sh` will automatically detect all generators used in an `ini`. For at least one generator defined in the `ini` file there must be a test. Each test is defined as a function in the `<name-of-ini-file>.C` macro. Assuming you want to test `External` and `Pythia8` generator, the macro should look like
Note, that `run_tests.sh` will automatically detect all generators used in an `ini`. For at least one generator defined in the `ini` file there must be a test. Each test is defined as a function in the `<name-of-ini-file>.C` macro. Assuming you want to test `External`, `Pythia8` and `Hybrid` generators, the macro should look like
```cpp
int Pythia8()
{
Expand All @@ -37,6 +37,12 @@ int External()
// do your test
return ret;
}

int Hybrid()
{
// do your test
return ret;
}
```
The return type must be an integer, `0` in case of success and `!=0` in case of failure.

Expand Down
2 changes: 1 addition & 1 deletion test/run_generator_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export ROOT_INCLUDE_PATH LD_LIBRARY_PATH
# Entrypoint for O2DPG related tests #
######################################

CHECK_GENERATORS="Pythia8 External"
CHECK_GENERATORS="Pythia8 External Hybrid"

# The test parent dir to be cretaed in current directory
TEST_PARENT_DIR="o2dpg_tests/generators"
Expand Down