28 std::string DataBranch) : branch1_(std::move(Branch1)), branch2_(std::move(Branch2)), data_branch_(std::move(DataBranch)) {}
30 [[nodiscard]] std::string GetFirstBranchName()
const {
return branch1_; }
31 [[nodiscard]] std::string GetSecondBranchName()
const {
return branch2_; }
32 [[nodiscard]] std::string GetDataBranchName()
const {
return data_branch_; }
37 std::string data_branch_;
61 using MatchingIndex = std::map<std::array<std::string, 2>, std::string>;
64 explicit Configuration(std::string name) : name_(std::move(name)){};
71 branches_.emplace(branch.GetId(), branch);
74 void RemoveBranchConfig(
const std::string& branchname);
76 [[nodiscard]] std::vector<std::string> GetMatchesOfBranch(
const std::string& branchname)
const;
82 ANALYSISTREE_ATTR_NODISCARD
BranchConfig& GetBranchConfig(
const std::string& name);
83 ANALYSISTREE_ATTR_NODISCARD
const BranchConfig& GetBranchConfig(
const std::string& name)
const;
84 ANALYSISTREE_ATTR_NODISCARD
const BranchConfig& GetBranchConfig(
size_t i)
const {
85 auto it = branches_.find(i);
86 if (it == branches_.end()) {
87 throw std::runtime_error(
"Branch with id = " + std::to_string(i) +
" not found");
91 ANALYSISTREE_ATTR_NODISCARD
const std::map<size_t, BranchConfig>& GetBranchConfigs()
const {
return branches_; }
92 ANALYSISTREE_ATTR_NODISCARD
const std::vector<MatchingConfig>& GetMatchingConfigs()
const {
return matches_; }
93 ANALYSISTREE_ATTR_NODISCARD
unsigned int GetNumberOfBranches()
const {
return branches_.size(); }
95 ANALYSISTREE_ATTR_NODISCARD
const std::string& GetMatchName(
const std::string& br1,
const std::string& br2)
const;
96 ANALYSISTREE_ATTR_NODISCARD std::pair<std::string, bool> GetMatchInfo(
const std::string& br1,
const std::string& br2)
const;
97 ANALYSISTREE_ATTR_NODISCARD
const MatchingIndex& GetMatches()
const {
return matches_index_; }
99 void Print(Option_t* =
"")
const;
101 void PrintBranchIds()
const;
103 static MatchingIndex MakeMatchingIndex(
const std::vector<MatchingConfig>& matches) {
104 MatchingIndex result;
105 for (
auto& match : matches) {
106 std::array<std::string, 2> map_key{match.GetFirstBranchName(), match.GetSecondBranchName()};
107 auto emplace_result = result.emplace(map_key, match.GetDataBranchName());
108 if (!emplace_result.second) {
109 throw std::runtime_error(
"Two matches with same first and second branch added");
115 static std::vector<MatchingConfig> MakeMatchConfigsFromIndex(
const MatchingIndex& matching_index) {
116 std::vector<MatchingConfig> result;
117 for (
auto& matching_index_element : matching_index) {
118 result.emplace_back(matching_index_element.first[0],
119 matching_index_element.first[1],
120 matching_index_element.second);
125 [[nodiscard]] std::vector<std::string> GetListOfBranches()
const;
133 for (
auto& other_branch : other.branches_) {
134 const auto other_id = other_branch.second.GetId();
135 const auto other_name = other_branch.second.GetName();
136 for (
auto& local_branch : branches_) {
137 if (other_id == local_branch.second.GetId()) {
138 throw std::runtime_error(
"Configurations contain branches with the same id-s");
140 if (other_name == local_branch.second.GetName()) {
141 throw std::runtime_error(
"Configurations contain branches with the same names");
145 branches_.emplace(other_branch);
151 std::map<size_t, BranchConfig> branches_{};
152 std::vector<MatchingConfig> matches_{};
154 MatchingIndex matches_index_{};
156 void AddMatch(
const std::string& br1,
const std::string& br2,
const std::string& data_branch);
158 ClassDef(Configuration, 4)
void Merge(const Configuration &other)
Merge two configurations without reindexing of the branches THIS FUNCTION IS USED IN THE Infra v1.
Definition Configuration.hpp:132