AnalysisTree
Loading...
Searching...
No Matches
Matching.hpp
1/* Copyright (C) 2019-2021 GSI, Universität Tübingen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Viktor Klochkov, Ilya Selyuzhenkov */
4#ifndef ANALYSISTREE_MATCHING_H
5#define ANALYSISTREE_MATCHING_H
6
7#include "Constants.hpp"
8#include <map>
9#include <utility>
10
11namespace AnalysisTree {
12
17class Matching {
18
19 typedef std::map<Integer_t, Integer_t> MapType;
20
21 public:
22 Matching() = default;
23 Matching(size_t id1, size_t id2) : branch1_id_(id1), branch2_id_(id2){};
24 Matching(size_t id1, size_t id2, MapType match, MapType match_inverted) : branch1_id_(id1),
25 branch2_id_(id2),
26 match_(std::move(match)),
27 match_inverted_(std::move(match_inverted)){};
28
29 virtual ~Matching() = default;
30
31 void AddMatch(Integer_t id1, Integer_t id2) {
32 match_.insert(std::make_pair(id1, id2));
33 match_inverted_.insert(std::make_pair(id2, id1));
34 }
35
36 ANALYSISTREE_ATTR_NODISCARD Integer_t GetMatchDirect(Integer_t id) const;
37 ANALYSISTREE_ATTR_NODISCARD Integer_t GetMatchInverted(Integer_t id) const;
38 ANALYSISTREE_ATTR_NODISCARD Integer_t GetMatch(Integer_t id, bool is_inverted = false) const {
39 return is_inverted ? GetMatchInverted(id) : GetMatchDirect(id);
40 }
41
42 ANALYSISTREE_ATTR_NODISCARD const MapType& GetMatches(bool is_inv = false) const {
43 return is_inv ? match_inverted_ : match_;
44 }
45
46 void Clear() {
47 match_.clear();
48 match_inverted_.clear();
49 }
50
51 ANALYSISTREE_ATTR_NODISCARD size_t GetBranch1Id() const { return branch1_id_; }
52 ANALYSISTREE_ATTR_NODISCARD size_t GetBranch2Id() const { return branch2_id_; }
53
54 void SetMatches(MapType match, MapType match_inv) {
55 match_ = std::move(match);
56 match_inverted_ = std::move(match_inv);
57 }
58
59 protected:
60 size_t branch1_id_{0};
61 size_t branch2_id_{0};
62
63 MapType match_{};
64 MapType match_inverted_{};//TODO is there a better way? Boost.Bimap?
65
66 ClassDef(Matching, 2)
67};
68
69}// namespace AnalysisTree
70#endif//ANALYSISTREE_MATCHING_H
Definition Matching.hpp:17
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10