Skip to content

Follow-up from "defining a function to set up the branches in a concise way"

Flow flow(cmd, steering, input | output); // where `cmd` just is `__func__` in most cases, and `input` and `output` are bitfields
auto tIn = flow.GetInputTree(inputs);
auto hIn = flow.GetInputHist<TH1D>(inputs);
auto fOut = flow.GetOutputFile(output);
auto tOut = flow.GetOutputTree(output);
auto recEvent = flow.GetBranchReadOnly<RecEvent>("recEvent");
auto recDijet = flow.GetBranchWriteOnly<RecDijet>("recDijet");
  • https://en.cppreference.com/w/cpp/utility/source_location instead of __func__
  • tOut->Write() could go in the destructor
  • input | output is not necessary \to rather set internal flags when calling GetInputTree() and GetOutputTree (raise exception if GetBranchReadOnly() is called while no input tree has been set)
  • use std::any to store a pointer to a pointer (and define a map<string, any> to record all branch addresses)
  • GetBranch*() should return a pointer
Edited by Patrick Louis S Connor