AnalysisTree
Loading...
Searching...
No Matches
AnalysisTask.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_ANALYSISTASK_HPP_
5#define ANALYSISTREE_INFRA_ANALYSISTASK_HPP_
6
7#include "vector"
8
9#include "AnalysisEntry.hpp"
10#include "Matching.hpp"
11#include "Task.hpp"
12#include "Variable.hpp"
13
14namespace AnalysisTree {
15
21class AnalysisTask : public Task {
22 typedef std::vector<std::vector<double>> array2D;
23 typedef std::vector<double> array1D;
24
25 public:
26 AnalysisTask() = default;
27 ~AnalysisTask() override = default;
28
29 std::pair<int, std::vector<int>> AddEntry(const AnalysisEntry& vars);
30
31 void Init() override;
32 void Exec() override;
33 void Finish() override{};
34
35 ANALYSISTREE_ATTR_NODISCARD const array2D& GetValues(int i_var) const { return entries_.at(i_var).GetValues(); }
36 ANALYSISTREE_ATTR_NODISCARD const array1D& GetWeights(int i_var) const { return entries_.at(i_var).GetWeights(); }
37 ANALYSISTREE_ATTR_NODISCARD const std::vector<AnalysisEntry>& GetVarEntries() const { return entries_; }
38 ANALYSISTREE_ATTR_NODISCARD std::vector<AnalysisEntry>& VarEntries() { return entries_; }
39
40 void AddBranchCut(Cuts* cut) {
41 if (cut->GetBranches().size() != 1) {
42 throw std::runtime_error("Branch cuts on only 1 branch are allowed at the moment!");
43 }
44 std::string br_name = *(cut->GetBranches().begin());
45 if (cuts_map_.find(br_name) != cuts_map_.end()) {
46 throw std::runtime_error("Branch cut on " + br_name + " already exists");
47 }
48 cuts_map_[br_name] = cut;
49 }
50
51 protected:
52 std::vector<AnalysisEntry> entries_{};
53 std::map<std::string, Cuts*> cuts_map_{};
54
55 ClassDefOverride(AnalysisTask, 0);
56};
57
58}// namespace AnalysisTree
59
60#endif//ANALYSISTREE_INFRA_ANALYSISTASK_HPP_
AnalysisEntry keeps list of Variables from one or more branches. Before each event AnalysisEntry eval...
Definition AnalysisEntry.hpp:20
AnalysisTask is a Task which keeps list of AnalysisEntry-s It evaluates Variables according to the ru...
Definition AnalysisTask.hpp:21
Cuts holds list of SimpleCuts and provides Apply function which subsequently applies cuts.
Definition Cuts.hpp:25
Definition Task.hpp:25
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10