AnalysisTree
Loading...
Searching...
No Matches
AnalysisEntry.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_INFRA_ANALYSISENTRY_HPP_
5#define ANALYSISTREE_INFRA_ANALYSISENTRY_HPP_
6
7#include <utility>
8
9#include "Branch.hpp"
10#include "Cuts.hpp"
11#include "Matching.hpp"
12#include "Variable.hpp"
13
14namespace AnalysisTree {
15
21
22 typedef std::vector<std::vector<double>> array2D;
23 typedef std::vector<double> array1D;
24
25 public:
26 AnalysisEntry() = default;
27 virtual ~AnalysisEntry();
28
29 explicit AnalysisEntry(std::vector<Variable> vars, Cuts* cuts = nullptr, Variable vars4weight = {}) : vars_(std::move(vars)),
30 var4weight_(std::move(vars4weight)),
31 cuts_(cuts) {
32 var4weight_.IfEmptyVariableConvertToOnes(vars_.at(0));
33 FillBranchNames();
34 };
35
36 void Init(const Configuration& conf, const std::map<std::string, Matching*>& matches);
37 void FillValues();
38
39 size_t AddVariable(const Variable& var);
40
41 ANALYSISTREE_ATTR_NODISCARD const array2D& GetValues() const { return values_; }
42 ANALYSISTREE_ATTR_NODISCARD const array1D& GetWeights() const { return weights_; }
43 ANALYSISTREE_ATTR_NODISCARD const std::set<std::string>& GetBranchNames() const { return branch_names_; }
44 // ANALYSISTREE_ATTR_NODISCARD const std::vector<Branch>& GetBranches() const { return branches_; }
45 ANALYSISTREE_ATTR_NODISCARD size_t GetNumberOfBranches() const { return branch_names_.size(); }
46 ANALYSISTREE_ATTR_NODISCARD const Cuts* GetCuts() const { return cuts_; }
47 ANALYSISTREE_ATTR_NODISCARD const std::vector<Variable>& GetVariables() const { return vars_; }
48 ANALYSISTREE_ATTR_NODISCARD std::vector<Variable>& Variables() { return vars_; }
49 ANALYSISTREE_ATTR_NODISCARD const Variable& GetVariableForWeight() const { return var4weight_; }
50 ANALYSISTREE_ATTR_NODISCARD Variable& VariableForWeight() { return var4weight_; }
51
52 void AddBranch(const Branch& branch, Cuts* cuts = nullptr);
53 void SetMatching(Matching* matching) { matching_ = matching; }
54 void SetIsInvertedMatching(bool is_inverted_matching) { is_inverted_matching_ = is_inverted_matching; }
55 void FillBranchNames();
56
57 private:
58 void FillFromEveHeaders();
59 void FillFromOneChannalizedBranch();
60 void FillFromTwoChannalizedBranches();
61 ANALYSISTREE_ATTR_NODISCARD bool ApplyCutOnBranch(const Branch& br, Cuts* cuts, int i_channel) const;
62 ANALYSISTREE_ATTR_NODISCARD bool ApplyCutOnBranches(std::vector<const Branch*>& br, std::vector<Cuts*>& cuts, std::vector<int>& ch) const;
63 [[deprecated]] ANALYSISTREE_ATTR_NODISCARD bool ApplyCutOnBranches(const Branch& br1, Cuts* cuts1, int ch1, const Branch& br2, Cuts* cuts2, int ch2) const;
64 static double FillVariable(const Variable& var, std::vector<const Branch*>& br, std::vector<int>& id);
65 [[deprecated]] static double FillVariable(const Variable& var, const Branch& br1, int ch1, const Branch& br2, int ch2);
66
67 std::vector<Variable> vars_{};
68 Variable var4weight_{};
69 Cuts* cuts_{nullptr};
70
71 std::set<std::string> branch_names_{};
72 std::vector<std::pair<const Branch*, Cuts*>> branches_{};
73
74 std::vector<int> eve_header_indices_{};
75 std::vector<int> non_eve_header_indices_{};
76
77 Matching* matching_{nullptr};
78 bool is_inverted_matching_{false};
79
80 array2D values_{};
81 array1D weights_{};
82
83 ClassDef(AnalysisEntry, 1);
84};
85
86}// namespace AnalysisTree
87#endif//ANALYSISTREE_INFRA_ANALYSISENTRY_HPP_
AnalysisEntry keeps list of Variables from one or more branches. Before each event AnalysisEntry eval...
Definition AnalysisEntry.hpp:20
Definition Branch.hpp:23
A class to store configuration of the whole AnalysisTree object.
Definition Configuration.hpp:58
Cuts holds list of SimpleCuts and provides Apply function which subsequently applies cuts.
Definition Cuts.hpp:25
Definition Matching.hpp:17
Variable is a wrapper object for Field. In contrary to Field Variable is not bound to the data....
Definition Variable.hpp:23
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10