AnalysisTree
Toggle main menu visibility
Loading...
Searching...
No Matches
infra
Cuts.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_CUTS_H
5
#define ANALYSISTREE_CUTS_H
6
7
#include <set>
8
#include <stdexcept>
9
#include <string>
10
#include <utility>
11
#include <vector>
12
13
#include "Constants.hpp"
14
#include "SimpleCut.hpp"
18
namespace
AnalysisTree
{
19
20
class
Configuration
;
21
25
class
Cuts {
26
27
public
:
28
Cuts() =
default
;
29
Cuts(
const
Cuts& cut) =
default
;
30
Cuts(Cuts&& cut) =
default
;
31
Cuts& operator=(Cuts&&) =
default
;
32
Cuts& operator=(
const
Cuts& cut) =
default
;
33
virtual
~Cuts() =
default
;
34
35
Cuts(std::string name, std::vector<SimpleCut> cuts) : name_(std::move(name)),
36
cuts_(std::move(cuts)) {
37
for
(
const
auto
& v : cuts_) {
38
const
auto
& br = v.GetBranches();
39
branch_names_.insert(br.begin(), br.end());
40
}
41
};
42
43
Cuts(std::string name, std::initializer_list<SimpleCut> cuts) : name_(std::move(name)),
44
cuts_(cuts.begin(), cuts.end()) {
45
for
(
const
auto
& v : cuts_) {
46
const
auto
& br = v.GetBranches();
47
branch_names_.insert(br.begin(), br.end());
48
}
49
}
50
51
void
AddCut(
const
SimpleCut
& cut);
52
53
void
AddCuts(
const
std::vector<SimpleCut>& cuts);
54
61
template
<
class
T>
62
bool
Apply
(
const
T&
object
)
const
{
63
if
(!is_init_) {
64
throw
std::runtime_error(
"Cuts::Apply - cut is not initialized!!"
);
65
}
66
for
(
const
auto
& cut : cuts_) {
67
if
(!cut.
Apply
(
object
))
68
return
false
;
69
}
70
return
true
;
71
}
72
73
bool
Apply
(
const
BranchChannel
& ob)
const
;
74
75
bool
Apply
(std::vector<const BranchChannel*>& bch, std::vector<size_t>&
id
)
const
;
76
[[deprecated]]
bool
Apply
(
const
BranchChannel
& a,
size_t
a_id,
const
BranchChannel
& b,
size_t
b_id)
const
;
77
78
void
Init(
const
Configuration
& conf);
79
void
Print()
const
;
80
81
ANALYSISTREE_ATTR_NODISCARD
const
std::set<std::string>& GetBranches()
const
{
return
branch_names_; }
82
ANALYSISTREE_ATTR_DEPRECATED()
83
ANALYSISTREE_ATTR_NODISCARD const std::
string
&
84
GetBranchName()
const
{
85
assert(branch_names_.size() == 1);
86
return
*branch_names_.begin();
87
}
88
89
ANALYSISTREE_ATTR_NODISCARD std::set<size_t> GetBranchIds()
const
{
return
branch_ids_; }
90
ANALYSISTREE_ATTR_NODISCARD
const
std::string& GetName()
const
{
return
name_; }
91
92
void
SetName(
const
std::string& name) { name_ = name; }
93
94
std::vector<SimpleCut>& GetCuts() {
return
cuts_; }
95
96
friend
bool
operator==(
const
Cuts& that,
const
Cuts& other);
97
static
bool
Equal(
const
Cuts* that,
const
Cuts* other);
98
99
protected
:
100
std::string name_;
101
std::set<std::string> branch_names_{};
102
std::set<size_t> branch_ids_{};
103
std::vector<SimpleCut> cuts_{};
104
105
bool
is_init_{
false
};
106
107
ClassDef(Cuts, 1);
108
};
109
110
}
// namespace AnalysisTree
111
#endif
//ANALYSISTREE_CUTS_H
AnalysisTree::BranchChannel
Definition
BranchChannel.hpp:19
AnalysisTree::Configuration
A class to store configuration of the whole AnalysisTree object.
Definition
Configuration.hpp:58
AnalysisTree::Cuts::Apply
bool Apply(const T &object) const
Evaluates all SimpleCuts.
Definition
Cuts.hpp:62
AnalysisTree::SimpleCut
SimpleCut keeps predicate (lambda function with vector of arguments) and list of Variables.
Definition
SimpleCut.hpp:22
AnalysisTree
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition
BranchConfig.cpp:10
Generated by
1.17.0