Line | Branch | Exec | Source |
---|---|---|---|
1 | // test an iguana algorithm validator | ||
2 | |||
3 | #include <filesystem> | ||
4 | #include <hipo4/reader.h> | ||
5 | #include <iguana/algorithms/Validator.h> | ||
6 | |||
7 | 8 | inline int TestValidator( | |
8 | std::string vdor_name, | ||
9 | std::vector<std::string> bank_names, | ||
10 | std::string data_file, | ||
11 | int num_events, | ||
12 | std::string output_dir, | ||
13 | bool verbose) | ||
14 | { | ||
15 | |||
16 | // check arguments | ||
17 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
8 | if(vdor_name == "" || bank_names.empty()) { |
18 | ✗ | fmt::print(stderr, "ERROR: need validator name and banks\n"); | |
19 | ✗ | return 1; | |
20 | } | ||
21 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(data_file == "") { |
22 | ✗ | fmt::print(stderr, "ERROR: need a data file for command 'validator'\n"); | |
23 | ✗ | return 1; | |
24 | } | ||
25 | |||
26 | // open the HIPO file | ||
27 | 8 | hipo::reader reader(data_file.c_str()); | |
28 |
3/6✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | auto banks = reader.getBanks(bank_names); |
29 | |||
30 | // make the output directory | ||
31 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if(output_dir != "") |
32 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | std::filesystem::create_directories(output_dir); |
33 | |||
34 | // define the validator | ||
35 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | auto vdor = iguana::AlgorithmFactory::Create(vdor_name); |
36 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | dynamic_cast<iguana::Validator*>(vdor.get())->SetOutputDirectory(output_dir); |
37 |
4/10✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
24 | vdor->SetOption("log", verbose ? "trace" : "info"); |
38 | |||
39 | // event loop | ||
40 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | vdor->Start(banks); |
41 | int it_ev = 0; | ||
42 |
5/8✓ Branch 0 taken 8008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8008 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8008 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8000 times.
✓ Branch 7 taken 8 times.
|
8008 | while(reader.next(banks) && (num_events == 0 || it_ev++ < num_events)) { |
43 |
1/2✓ Branch 0 taken 8000 times.
✗ Branch 1 not taken.
|
8000 | vdor->Run(banks); |
44 | } | ||
45 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | vdor->Stop(); |
46 | return 0; | ||
47 | 8 | } | |
48 |