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,
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");
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);
43 seq.
SetOption(algo_name,
"log", verbose ?
"trace" :
"info");
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);
User-level class for running a sequence of algorithms.
void SetOption(std::string const &algo_name, std::string const &key, const OPTION_TYPE val)
void Stop() override
Finalize this algorithm after all events are processed.
void Run(hipo::banklist &banks) const override
Run this algorithm for an event.
void Add(std::string const &class_name, std::string const &instance_name="")
void Start(hipo::banklist &banks) override
Initialize this algorithm before any events are processed, with the intent to process banks
void SetName(std::string_view name)
void PrintSequence(Logger::Level level=Logger::info) const
GlobalParam< std::string > GlobalConcurrencyModel
The concurrency model, for running certain algorithms in a thread-safe way.