Skip to content

Commit

Permalink
refactor: no need for unique names if algos are unique
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Dec 11, 2023
1 parent ec2794d commit 7950028
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/algorithms/AlgorithmSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace iguana {
m_log->Error("algorithm '{}' does not exist", class_name);
throw std::runtime_error("AlgorithmFactory cannot create non-existent algorithm");
}
algo->SetName(user_name);
algo->SetName(user_name=="" ? class_name : user_name);
Add(std::move(algo));
}

Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/AlgorithmSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace iguana {
/// Add("iguana::MyAlgorithm", "my_algorithm_name");
/// @endcode
/// @param class_name the name of the algorithm class
/// @param user_name a user-specified unique name for this algorithm
void Add(const std::string class_name, const std::string user_name);
/// @param user_name a user-specified unique name for this algorithm; if not specified, `class_name` will be used
void Add(const std::string class_name, const std::string user_name="");

/// Create and add an algorithm to the sequence.
///
Expand Down
12 changes: 6 additions & 6 deletions src/tests/run_banks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ int main(int argc, char **argv) {

// iguana algorithm sequence
iguana::AlgorithmSequence seq;
seq.Add("clas12::EventBuilderFilter", "pid_filter"); // filter by Event Builder PID
seq.Add("clas12::LorentzTransformer", "new_frame"); // Lorentz transform the momenta
seq.Add("clas12::EventBuilderFilter"); // filter by Event Builder PID
seq.Add("clas12::LorentzTransformer"); // Lorentz transform the momenta

// set log levels
seq.SetOption("pid_filter", "log", "debug");
seq.SetOption("new_frame", "log", "debug");
seq.SetOption("clas12::EventBuilderFilter", "log", "debug");
seq.SetOption("clas12::LorentzTransformer", "log", "debug");

// set algorithm options
seq.SetOption("pid_filter", "pids", std::set<int>{11, 211, -211});
seq.SetOption("new_frame", "frame", "mirror");
seq.SetOption("clas12::EventBuilderFilter", "pids", std::set<int>{11, 211, -211});
seq.SetOption("clas12::LorentzTransformer", "frame", "mirror");

// start the algorithms
seq.Start(banks);
Expand Down

0 comments on commit 7950028

Please sign in to comment.