3#include <hipo4/reader.h>
4#include <iguana/algorithms/AlgorithmSequence.h>
6inline int TestAlgorithm(
9 std::vector<std::string> prerequisite_algos,
10 std::vector<std::string> bank_names,
11 std::string data_file,
13 std::string log_level)
17 if(algo_name ==
"" || bank_names.empty()) {
18 fmt::print(stderr,
"ERROR: need algorithm name and banks\n");
21 if(command ==
"algorithm" && data_file ==
"") {
22 fmt::print(stderr,
"ERROR: need a data file for command 'algorithm'\n");
27 iguana::GlobalConcurrencyModel =
"single";
31 hipo::reader reader_before(data_file.c_str());
32 hipo::reader reader_after(data_file.c_str());
33 auto banks_before = reader_before.getBanks(bank_names);
34 auto banks_after = reader_after.getBanks(bank_names);
38 for(
auto const& prerequisite_algo : prerequisite_algos)
39 seq.
Add(prerequisite_algo);
46 seq.
Start(banks_after);
50 while(reader_after.next(banks_after) && (num_events == 0 || it_ev++ < num_events)) {
52 reader_before.next(banks_before);
54 if(command ==
"algorithm")
56 else if(command ==
"unit") {
57 fmt::print(stderr,
"ERROR: unit tests are not yet implemented (TODO)\n");
61 fmt::print(stderr,
"ERROR: unknown command '{}'\n", command);
Algorithm: An algorithm that can run a sequence of algorithms
void Add(std::string const &algo_class_name, std::string const &algo_instance_name="")
void SetName(std::string_view name)
void PrintSequence(Logger::Level level=Logger::info) const
void SetLogLevel(std::string const &algo_instance_name, std::string const &lev)
Set an algorithm log level.
virtual bool Run(hipo::banklist &banks) const final
Run Function: Process an event's hipo::banklist
virtual void Stop() final
Stop Function: Finalize this algorithm after all events are processed.
virtual void Start(hipo::banklist &banks) final
Start Function: Initialize this algorithm before any events are processed, with the intent to process...