Iguana
1.2.1
Implementation Guardian of Analysis Algorithms
Toggle main menu visibility
Loading...
Searching...
No Matches
TestValidator.h
1
#pragma once
2
// test an iguana algorithm validator
3
4
#include <filesystem>
5
#include <hipo4/reader.h>
6
#include <iguana/algorithms/Validator.h>
7
8
inline
int
TestValidator(
9
std::string vdor_name,
10
std::vector<std::string> bank_names,
11
std::string data_file,
12
int
data_tag,
13
int
num_events,
14
std::string output_dir,
15
std::string log_level)
16
{
17
18
// check arguments
19
if
(vdor_name ==
""
|| bank_names.empty()) {
20
fmt::print(stderr,
"ERROR: need validator name and banks\n"
);
21
return
1;
22
}
23
if
(data_file ==
""
) {
24
fmt::print(stderr,
"ERROR: need a data file for command 'validator'\n"
);
25
return
1;
26
}
27
28
// open the HIPO file
29
hipo::reader reader(data_file.c_str(), {data_tag});
30
auto
banks = reader.getBanks(bank_names);
31
32
// make the output directory
33
if
(output_dir !=
""
)
34
std::filesystem::create_directories(output_dir);
35
36
// define the validator
37
auto
vdor =
iguana::AlgorithmFactory::Create
(vdor_name);
38
dynamic_cast<
iguana::Validator
*
>
(vdor.get())->
SetOutputDirectory
(output_dir);
39
vdor->SetLogLevel(log_level);
40
41
// event loop
42
vdor->Start(banks);
43
int
it_ev = 0;
44
while
(reader.next(banks) && (num_events == 0 || it_ev++ < num_events)) {
45
vdor->Run(banks);
46
}
47
vdor->Stop();
48
return
0;
49
}
iguana::AlgorithmFactory::Create
static algo_t Create(std::string const &algo_name) noexcept(false)
iguana::Validator
Base class for all algorithm validators to inherit from.
Definition
Validator.h:22
iguana::Validator::SetOutputDirectory
void SetOutputDirectory(std::string_view output_dir)
iguana_v1.2.1
src
iguana
tests
include
TestValidator.h
Generated by
1.18.0